Botan
1.11.15
|
00001 /* 00002 * ECDSA 00003 * (C) 2007 Falko Strenzke, FlexSecure GmbH 00004 * Manuel Hartl, FlexSecure GmbH 00005 * (C) 2008-2010 Jack Lloyd 00006 * 00007 * Botan is released under the Simplified BSD License (see license.txt) 00008 */ 00009 00010 #ifndef BOTAN_ECDSA_KEY_H__ 00011 #define BOTAN_ECDSA_KEY_H__ 00012 00013 #include <botan/ecc_key.h> 00014 00015 namespace Botan { 00016 00017 /** 00018 * This class represents ECDSA Public Keys. 00019 */ 00020 class BOTAN_DLL ECDSA_PublicKey : public virtual EC_PublicKey 00021 { 00022 public: 00023 00024 /** 00025 * Construct a public key from a given public point. 00026 * @param dom_par the domain parameters associated with this key 00027 * @param public_point the public point defining this key 00028 */ 00029 ECDSA_PublicKey(const EC_Group& dom_par, 00030 const PointGFp& public_point) : 00031 EC_PublicKey(dom_par, public_point) {} 00032 00033 ECDSA_PublicKey(const AlgorithmIdentifier& alg_id, 00034 const secure_vector<byte>& key_bits) : 00035 EC_PublicKey(alg_id, key_bits) {} 00036 00037 /** 00038 * Get this keys algorithm name. 00039 * @result this keys algorithm name ("ECDSA") 00040 */ 00041 std::string algo_name() const { return "ECDSA"; } 00042 00043 /** 00044 * Get the maximum number of bits allowed to be fed to this key. 00045 * This is the bitlength of the order of the base point. 00046 * @result the maximum number of input bits 00047 */ 00048 size_t max_input_bits() const { return domain().get_order().bits(); } 00049 00050 size_t message_parts() const { return 2; } 00051 00052 size_t message_part_size() const 00053 { return domain().get_order().bytes(); } 00054 00055 protected: 00056 ECDSA_PublicKey() {} 00057 }; 00058 00059 /** 00060 * This class represents ECDSA Private Keys 00061 */ 00062 class BOTAN_DLL ECDSA_PrivateKey : public ECDSA_PublicKey, 00063 public EC_PrivateKey 00064 { 00065 public: 00066 00067 /** 00068 * Load a private key 00069 * @param alg_id the X.509 algorithm identifier 00070 * @param key_bits PKCS #8 structure 00071 */ 00072 ECDSA_PrivateKey(const AlgorithmIdentifier& alg_id, 00073 const secure_vector<byte>& key_bits) : 00074 EC_PrivateKey(alg_id, key_bits) {} 00075 00076 /** 00077 * Generate a new private key 00078 * @param rng a random number generator 00079 * @param domain parameters to used for this key 00080 * @param x the private key (if zero, generate a ney random key) 00081 */ 00082 ECDSA_PrivateKey(RandomNumberGenerator& rng, 00083 const EC_Group& domain, 00084 const BigInt& x = 0) : 00085 EC_PrivateKey(rng, domain, x) {} 00086 00087 bool check_key(RandomNumberGenerator& rng, bool) const; 00088 }; 00089 00090 } 00091 00092 #endif