/src/botan/build/include/public/botan/eckcdsa.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * ECKCDSA (ISO/IEC 14888-3:2018) |
3 | | * (C) 2016 René Korthaus, Sirrix AG |
4 | | * |
5 | | * Botan is released under the Simplified BSD License (see license.txt) |
6 | | */ |
7 | | |
8 | | #ifndef BOTAN_ECKCDSA_KEY_H_ |
9 | | #define BOTAN_ECKCDSA_KEY_H_ |
10 | | |
11 | | #include <botan/ecc_key.h> |
12 | | |
13 | | namespace Botan { |
14 | | |
15 | | /** |
16 | | * This class represents ECKCDSA public keys. |
17 | | */ |
18 | | class BOTAN_PUBLIC_API(2, 0) ECKCDSA_PublicKey : public virtual EC_PublicKey { |
19 | | public: |
20 | | /** |
21 | | * Construct a public key from a given public point. |
22 | | * @param dom_par the domain parameters associated with this key |
23 | | * @param public_point the public point defining this key |
24 | | */ |
25 | 0 | ECKCDSA_PublicKey(const EC_Group& dom_par, const EC_Point& public_point) : EC_PublicKey(dom_par, public_point) {} Unexecuted instantiation: Botan::ECKCDSA_PublicKey::ECKCDSA_PublicKey(Botan::EC_Group const&, Botan::EC_Point const&) Unexecuted instantiation: Botan::ECKCDSA_PublicKey::ECKCDSA_PublicKey(Botan::EC_Group const&, Botan::EC_Point const&) |
26 | | |
27 | | /** |
28 | | * Load a public key. |
29 | | * @param alg_id the X.509 algorithm identifier |
30 | | * @param key_bits DER encoded public key bits |
31 | | */ |
32 | | ECKCDSA_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits) : |
33 | 0 | EC_PublicKey(alg_id, key_bits) {} Unexecuted instantiation: Botan::ECKCDSA_PublicKey::ECKCDSA_PublicKey(Botan::AlgorithmIdentifier const&, std::__1::span<unsigned char const, 18446744073709551615ul>) Unexecuted instantiation: Botan::ECKCDSA_PublicKey::ECKCDSA_PublicKey(Botan::AlgorithmIdentifier const&, std::__1::span<unsigned char const, 18446744073709551615ul>) |
34 | | |
35 | | /** |
36 | | * Get this keys algorithm name. |
37 | | */ |
38 | 0 | std::string algo_name() const override { return "ECKCDSA"; } |
39 | | |
40 | 0 | size_t message_parts() const override { return 2; } |
41 | | |
42 | 0 | size_t message_part_size() const override { return domain().get_order().bytes(); } |
43 | | |
44 | | std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final; |
45 | | |
46 | 0 | bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::Signature); } |
47 | | |
48 | | std::unique_ptr<PK_Ops::Verification> create_verification_op(std::string_view params, |
49 | | std::string_view provider) const override; |
50 | | |
51 | | std::unique_ptr<PK_Ops::Verification> create_x509_verification_op(const AlgorithmIdentifier& signature_algorithm, |
52 | | std::string_view provider) const override; |
53 | | |
54 | | protected: |
55 | 0 | ECKCDSA_PublicKey() = default; |
56 | | }; |
57 | | |
58 | | /** |
59 | | * This class represents ECKCDSA private keys. |
60 | | */ |
61 | | |
62 | | BOTAN_DIAGNOSTIC_PUSH |
63 | | BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE |
64 | | |
65 | | class BOTAN_PUBLIC_API(2, 0) ECKCDSA_PrivateKey final : public ECKCDSA_PublicKey, |
66 | | public EC_PrivateKey { |
67 | | public: |
68 | | /** |
69 | | * Load a private key. |
70 | | * @param alg_id the X.509 algorithm identifier |
71 | | * @param key_bits ECPrivateKey bits |
72 | | */ |
73 | | ECKCDSA_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits) : |
74 | 0 | EC_PrivateKey(alg_id, key_bits, true) {} Unexecuted instantiation: Botan::ECKCDSA_PrivateKey::ECKCDSA_PrivateKey(Botan::AlgorithmIdentifier const&, std::__1::span<unsigned char const, 18446744073709551615ul>) Unexecuted instantiation: Botan::ECKCDSA_PrivateKey::ECKCDSA_PrivateKey(Botan::AlgorithmIdentifier const&, std::__1::span<unsigned char const, 18446744073709551615ul>) |
75 | | |
76 | | /** |
77 | | * Create a 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 new random key) |
81 | | */ |
82 | | ECKCDSA_PrivateKey(RandomNumberGenerator& rng, const EC_Group& domain, const BigInt& x = BigInt::zero()) : |
83 | 0 | EC_PrivateKey(rng, domain, x, true) {} |
84 | | |
85 | | bool check_key(RandomNumberGenerator& rng, bool) const override; |
86 | | |
87 | | std::unique_ptr<Public_Key> public_key() const override; |
88 | | |
89 | | std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng, |
90 | | std::string_view params, |
91 | | std::string_view provider) const override; |
92 | | }; |
93 | | |
94 | | BOTAN_DIAGNOSTIC_POP |
95 | | |
96 | | } // namespace Botan |
97 | | |
98 | | #endif |