Botan  1.11.15
ecdsa.h
Go to the documentation of this file.
1 /*
2 * ECDSA
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_ECDSA_KEY_H__
11 #define BOTAN_ECDSA_KEY_H__
12 
13 #include <botan/ecc_key.h>
14 
15 namespace Botan {
16 
17 /**
18 * This class represents ECDSA Public Keys.
19 */
20 class BOTAN_DLL ECDSA_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  ECDSA_PublicKey(const EC_Group& dom_par,
30  const PointGFp& public_point) :
31  EC_PublicKey(dom_par, public_point) {}
32 
34  const secure_vector<byte>& key_bits) :
35  EC_PublicKey(alg_id, key_bits) {}
36 
37  /**
38  * Get this keys algorithm name.
39  * @result this keys algorithm name ("ECDSA")
40  */
41  std::string algo_name() const { return "ECDSA"; }
42 
43  /**
44  * Get the maximum number of bits allowed to be fed to this key.
45  * This is the bitlength of the order of the base point.
46  * @result the maximum number of input bits
47  */
48  size_t max_input_bits() const { return domain().get_order().bits(); }
49 
50  size_t message_parts() const { return 2; }
51 
52  size_t message_part_size() const
53  { return domain().get_order().bytes(); }
54 
55  protected:
57  };
58 
59 /**
60 * This class represents ECDSA Private Keys
61 */
62 class BOTAN_DLL ECDSA_PrivateKey : public ECDSA_PublicKey,
63  public EC_PrivateKey
64  {
65  public:
66 
67  /**
68  * Load a private key
69  * @param alg_id the X.509 algorithm identifier
70  * @param key_bits PKCS #8 structure
71  */
73  const secure_vector<byte>& key_bits) :
74  EC_PrivateKey(alg_id, key_bits) {}
75 
76  /**
77  * Generate a new private key
78  * @param rng a random number generator
79  * @param domain parameters to used for this key
80  * @param x the private key (if zero, generate a ney random key)
81  */
83  const EC_Group& domain,
84  const BigInt& x = 0) :
85  EC_PrivateKey(rng, domain, x) {}
86 
87  bool check_key(RandomNumberGenerator& rng, bool) const;
88  };
89 
90 }
91 
92 #endif
const BigInt & x
Definition: dsa.cpp:98
ECDSA_PublicKey(const AlgorithmIdentifier &alg_id, const secure_vector< byte > &key_bits)
Definition: ecdsa.h:33
size_t message_part_size() const
Definition: ecdsa.h:52
size_t max_input_bits() const
Definition: ecdsa.h:48
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:93
const PointGFp & public_point
Definition: ecdsa.cpp:112
std::string algo_name() const
Definition: ecdsa.h:41
ECDSA_PrivateKey(const AlgorithmIdentifier &alg_id, const secure_vector< byte > &key_bits)
Definition: ecdsa.h:72
size_t message_parts() const
Definition: ecdsa.h:50
ECDSA_PublicKey(const EC_Group &dom_par, const PointGFp &public_point)
Definition: ecdsa.h:29
ECDSA_PrivateKey(RandomNumberGenerator &rng, const EC_Group &domain, const BigInt &x=0)
Definition: ecdsa.h:82