Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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 * Create 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
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 ECDSA_PublicKey(const AlgorithmIdentifier& alg_id,
39 const std::vector<uint8_t>& key_bits) :
40 EC_PublicKey(alg_id, key_bits) {}
41
42 /**
43 * Get this keys algorithm name.
44 * @result this keys algorithm name ("ECDSA")
45 */
46 std::string algo_name() const override { return "ECDSA"; }
47
48 size_t message_parts() const override { return 2; }
49
50 size_t message_part_size() const override
51 { return domain().get_order().bytes(); }
52
53 std::unique_ptr<PK_Ops::Verification>
54 create_verification_op(const std::string& params,
55 const std::string& provider) const override;
56 protected:
57 ECDSA_PublicKey() = default;
58 };
59
60 /**
61 * This class represents ECDSA Private Keys
62 */
63 class BOTAN_DLL ECDSA_PrivateKey : public ECDSA_PublicKey,
64 public EC_PrivateKey
65 {
66 public:
67
68 /**
69 * Load a private key
70 * @param alg_id the X.509 algorithm identifier
71 * @param key_bits ECPrivateKey bits
72 */
73 ECDSA_PrivateKey(const AlgorithmIdentifier& alg_id,
74 const secure_vector<uint8_t>& key_bits) :
75 EC_PrivateKey(alg_id, key_bits) {}
76
77 /**
78 * Create a private key.
79 * @param rng a random number generator
80 * @param domain parameters to used for this key
81 * @param x the private key (if zero, generate a new random key)
82 */
83 ECDSA_PrivateKey(RandomNumberGenerator& rng,
84 const EC_Group& domain,
85 const BigInt& x = 0) :
86 EC_PrivateKey(rng, domain, x) {}
87
88 bool check_key(RandomNumberGenerator& rng, bool) const override;
89
90 std::unique_ptr<PK_Ops::Signature>
91 create_signature_op(RandomNumberGenerator& rng,
92 const std::string& params,
93 const std::string& provider) const override;
94 };
95
96 }
97
98 #endif
Botan::BigInt
Definition: bigint.h:23
Botan::ECDSA_PublicKey::message_parts
size_t message_parts() const override
Definition: ecdsa.h:48
Botan::PointGFp
Definition: point_gfp.h:41
Botan::RandomNumberGenerator
Definition: rng.h:25
Botan::EC_PublicKey
Definition: ecc_key.h:29
Botan::EC_PrivateKey
Definition: ecc_key.h:110
Botan::ECDSA_PublicKey::message_part_size
size_t message_part_size() const override
Definition: ecdsa.h:50
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan::ECDSA_PublicKey
Definition: ecdsa.h:20
Botan
Definition: alg_id.cpp:13
Botan::EC_Group
Definition: ec_group.h:31
Botan::ECDSA_PrivateKey::ECDSA_PrivateKey
ECDSA_PrivateKey(const AlgorithmIdentifier &alg_id, const secure_vector< uint8_t > &key_bits)
Definition: ecdsa.h:73
Botan::AlgorithmIdentifier
Definition: alg_id.h:20
Botan::ECDSA_PublicKey::algo_name
std::string algo_name() const override
Definition: ecdsa.h:46
Botan::ECDSA_PrivateKey
Definition: ecdsa.h:63
Botan::ECDSA_PublicKey::ECDSA_PublicKey
ECDSA_PublicKey(const EC_Group &dom_par, const PointGFp &public_point)
Definition: ecdsa.h:29
Botan::ECDSA_PrivateKey::ECDSA_PrivateKey
ECDSA_PrivateKey(RandomNumberGenerator &rng, const EC_Group &domain, const BigInt &x=0)
Definition: ecdsa.h:83
Botan::ECDSA_PublicKey::ECDSA_PublicKey
ECDSA_PublicKey(const AlgorithmIdentifier &alg_id, const std::vector< uint8_t > &key_bits)
Definition: ecdsa.h:38