/src/botan/build/include/botan/ecdsa.h
Line | Count | Source (jump to first uncovered line) |
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_PUBLIC_API(2,0) 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 | 0 | EC_PublicKey(dom_par, public_point) {} Unexecuted instantiation: Botan::ECDSA_PublicKey::ECDSA_PublicKey(Botan::EC_Group const&, Botan::PointGFp const&) Unexecuted instantiation: Botan::ECDSA_PublicKey::ECDSA_PublicKey(Botan::EC_Group const&, Botan::PointGFp const&) |
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 | 1.69k | EC_PublicKey(alg_id, key_bits) {} Botan::ECDSA_PublicKey::ECDSA_PublicKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&) Line | Count | Source | 40 | 1.69k | EC_PublicKey(alg_id, key_bits) {} |
Unexecuted instantiation: Botan::ECDSA_PublicKey::ECDSA_PublicKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&) |
41 | | |
42 | | /** |
43 | | * Recover a public key from a signature/msg pair |
44 | | * See SEC section 4.6.1 |
45 | | * @param group the elliptic curve group |
46 | | * @param msg the message |
47 | | * @param r the r paramter of the signature |
48 | | * @param s the s paramter of the signature |
49 | | * @param v the recovery ID |
50 | | */ |
51 | | ECDSA_PublicKey(const EC_Group& group, |
52 | | const std::vector<uint8_t>& msg, |
53 | | const BigInt& r, |
54 | | const BigInt& s, |
55 | | uint8_t v); |
56 | | |
57 | | /** |
58 | | * Get this keys algorithm name. |
59 | | * @result this keys algorithm name ("ECDSA") |
60 | | */ |
61 | 668 | std::string algo_name() const override { return "ECDSA"; } |
62 | | |
63 | 914 | size_t message_parts() const override { return 2; } |
64 | | |
65 | | size_t message_part_size() const override |
66 | 457 | { return domain().get_order().bytes(); } |
67 | | |
68 | | uint8_t recovery_param(const std::vector<uint8_t>& msg, |
69 | | const BigInt& r, |
70 | | const BigInt& s) const; |
71 | | |
72 | | std::unique_ptr<PK_Ops::Verification> |
73 | | create_verification_op(const std::string& params, |
74 | | const std::string& provider) const override; |
75 | | protected: |
76 | 840 | ECDSA_PublicKey() = default; |
77 | | }; |
78 | | |
79 | | /** |
80 | | * This class represents ECDSA Private Keys |
81 | | */ |
82 | | class BOTAN_PUBLIC_API(2,0) ECDSA_PrivateKey final : public ECDSA_PublicKey, |
83 | | public EC_PrivateKey |
84 | | { |
85 | | public: |
86 | | |
87 | | /** |
88 | | * Load a private key |
89 | | * @param alg_id the X.509 algorithm identifier |
90 | | * @param key_bits ECPrivateKey bits |
91 | | */ |
92 | | ECDSA_PrivateKey(const AlgorithmIdentifier& alg_id, |
93 | | const secure_vector<uint8_t>& key_bits) : |
94 | 840 | EC_PrivateKey(alg_id, key_bits) {} Botan::ECDSA_PrivateKey::ECDSA_PrivateKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, Botan::secure_allocator<unsigned char> > const&) Line | Count | Source | 94 | 840 | EC_PrivateKey(alg_id, key_bits) {} |
Unexecuted instantiation: Botan::ECDSA_PrivateKey::ECDSA_PrivateKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, Botan::secure_allocator<unsigned char> > const&) |
95 | | |
96 | | /** |
97 | | * Create a private key. |
98 | | * @param rng a random number generator |
99 | | * @param domain parameters to used for this key |
100 | | * @param x the private key (if zero, generate a new random key) |
101 | | */ |
102 | | ECDSA_PrivateKey(RandomNumberGenerator& rng, |
103 | | const EC_Group& domain, |
104 | | const BigInt& x = BigInt::zero()) : |
105 | 0 | EC_PrivateKey(rng, domain, x) {} Unexecuted instantiation: Botan::ECDSA_PrivateKey::ECDSA_PrivateKey(Botan::RandomNumberGenerator&, Botan::EC_Group const&, Botan::BigInt const&) Unexecuted instantiation: Botan::ECDSA_PrivateKey::ECDSA_PrivateKey(Botan::RandomNumberGenerator&, Botan::EC_Group const&, Botan::BigInt const&) |
106 | | |
107 | | bool check_key(RandomNumberGenerator& rng, bool) const override; |
108 | | |
109 | | std::unique_ptr<Public_Key> public_key() const override; |
110 | | |
111 | | std::unique_ptr<PK_Ops::Signature> |
112 | | create_signature_op(RandomNumberGenerator& rng, |
113 | | const std::string& params, |
114 | | const std::string& provider) const override; |
115 | | }; |
116 | | |
117 | | } |
118 | | |
119 | | #endif |