Botan  2.8.0
Crypto and TLS for C++11
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 */
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  */
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 */
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  */
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  */
87  const EC_Group& domain,
88  const BigInt& x = 0) :
89  EC_PrivateKey(rng, domain, x) {}
90 
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
size_t message_part_size() const override
Definition: gost_3410.h:53
size_t message_parts() const override
Definition: gost_3410.h:51
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
GOST_3410_PrivateKey(RandomNumberGenerator &rng, const EC_Group &domain, const BigInt &x=0)
Definition: gost_3410.h:86
AlgorithmIdentifier pkcs8_algorithm_identifier() const override
Definition: gost_3410.h:91
Definition: alg_id.cpp:13
GOST_3410_PublicKey(const EC_Group &dom_par, const PointGFp &public_point)
Definition: gost_3410.h:29
AlgorithmIdentifier algorithm_identifier() const override
Definition: ecc_key.cpp:64
std::string algo_name() const override
Definition: gost_3410.h:45
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88
GOST_3410_PrivateKey(const AlgorithmIdentifier &alg_id, const secure_vector< uint8_t > &key_bits)
Definition: gost_3410.h:76