Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gost_3410.h
Go to the documentation of this file.
1 /*
2 * GOST 34.10-2001
3 * (C) 2007 Falko Strenzke, FlexSecure GmbH
4 * Manuel Hartl, FlexSecure GmbH
5 * (C) 2008-2010 Jack Lloyd
6 *
7 * Botan is released under the Simplified BSD License (see license.txt)
8 */
9
10 #ifndef BOTAN_GOST_3410_KEY_H__
11 #define BOTAN_GOST_3410_KEY_H__
12
13 #include <botan/ecc_key.h>
14
15 namespace Botan {
16
17 /**
18 * GOST-34.10 Public Key
19 */
20 class BOTAN_DLL GOST_3410_PublicKey : public virtual EC_PublicKey
21 {
22 public:
23
24 /**
25 * Construct a public key from a given public point.
26 * @param dom_par the domain parameters associated with this key
27 * @param public_point the public point defining this key
28 */
29 GOST_3410_PublicKey(const EC_Group& dom_par,
30 const PointGFp& public_point) :
31 EC_PublicKey(dom_par, public_point) {}
32
33 /**
34 * Load a public key.
35 * @param alg_id the X.509 algorithm identifier
36 * @param key_bits DER encoded public key bits
37 */
38 GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
39 const std::vector<uint8_t>& key_bits);
40
41 /**
42 * Get this keys algorithm name.
43 * @result this keys algorithm name
44 */
45 std::string algo_name() const override { return "GOST-34.10"; }
46
47 AlgorithmIdentifier algorithm_identifier() const override;
48
49 std::vector<uint8_t> public_key_bits() const override;
50
51 size_t message_parts() const override { return 2; }
52
53 size_t message_part_size() const override
54 { return domain().get_order().bytes(); }
55
56 std::unique_ptr<PK_Ops::Verification>
57 create_verification_op(const std::string& params,
58 const std::string& provider) const override;
59
60 protected:
61 GOST_3410_PublicKey() = default;
62 };
63
64 /**
65 * GOST-34.10 Private Key
66 */
67 class BOTAN_DLL GOST_3410_PrivateKey : public GOST_3410_PublicKey,
68 public EC_PrivateKey
69 {
70 public:
71 /**
72 * Load a private key.
73 * @param alg_id the X.509 algorithm identifier
74 * @param key_bits ECPrivateKey bits
75 */
76 GOST_3410_PrivateKey(const AlgorithmIdentifier& alg_id,
77 const secure_vector<uint8_t>& key_bits) :
78 EC_PrivateKey(alg_id, key_bits) {}
79
80 /**
81 * Generate a new private key
82 * @param rng a random number generator
83 * @param domain parameters to used for this key
84 * @param x the private key; if zero, a new random key is generated
85 */
86 GOST_3410_PrivateKey(RandomNumberGenerator& rng,
87 const EC_Group& domain,
88 const BigInt& x = 0) :
89 EC_PrivateKey(rng, domain, x) {}
90
91 AlgorithmIdentifier pkcs8_algorithm_identifier() const override
92 { return EC_PublicKey::algorithm_identifier(); }
93
94 std::unique_ptr<PK_Ops::Signature>
95 create_signature_op(RandomNumberGenerator& rng,
96 const std::string& params,
97 const std::string& provider) const override;
98 };
99
100 }
101
102 #endif
Botan::BigInt
Definition: bigint.h:23
Botan::PointGFp
Definition: point_gfp.h:41
Botan::RandomNumberGenerator
Definition: rng.h:25
Botan::GOST_3410_PublicKey::message_part_size
size_t message_part_size() const override
Definition: gost_3410.h:53
Botan::GOST_3410_PublicKey::message_parts
size_t message_parts() const override
Definition: gost_3410.h:51
Botan::GOST_3410_PublicKey
Definition: gost_3410.h:20
Botan::EC_PublicKey
Definition: ecc_key.h:29
Botan::GOST_3410_PrivateKey::GOST_3410_PrivateKey
GOST_3410_PrivateKey(RandomNumberGenerator &rng, const EC_Group &domain, const BigInt &x=0)
Definition: gost_3410.h:86
Botan::EC_PrivateKey
Definition: ecc_key.h:110
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan::GOST_3410_PrivateKey::pkcs8_algorithm_identifier
AlgorithmIdentifier pkcs8_algorithm_identifier() const override
Definition: gost_3410.h:91
Botan
Definition: alg_id.cpp:13
Botan::EC_Group
Definition: ec_group.h:31
Botan::GOST_3410_PublicKey::GOST_3410_PublicKey
GOST_3410_PublicKey(const EC_Group &dom_par, const PointGFp &public_point)
Definition: gost_3410.h:29
Botan::EC_PublicKey::algorithm_identifier
AlgorithmIdentifier algorithm_identifier() const override
Definition: ecc_key.cpp:81
Botan::GOST_3410_PublicKey::algo_name
std::string algo_name() const override
Definition: gost_3410.h:45
Botan::AlgorithmIdentifier
Definition: alg_id.h:20
Botan::GOST_3410_PrivateKey::GOST_3410_PrivateKey
GOST_3410_PrivateKey(const AlgorithmIdentifier &alg_id, const secure_vector< uint8_t > &key_bits)
Definition: gost_3410.h:76
Botan::GOST_3410_PrivateKey
Definition: gost_3410.h:67