/src/botan/build/include/public/botan/gost_3410.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * GOST 34.10-2001 |
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_GOST_3410_KEY_H_ |
11 | | #define BOTAN_GOST_3410_KEY_H_ |
12 | | |
13 | | #include <botan/ecc_key.h> |
14 | | |
15 | | BOTAN_DEPRECATED_HEADER("gost_3410.h") |
16 | | |
17 | | namespace Botan { |
18 | | |
19 | | /** |
20 | | * GOST-34.10 Public Key |
21 | | */ |
22 | | class BOTAN_PUBLIC_API(2, 0) GOST_3410_PublicKey : public virtual EC_PublicKey { |
23 | | public: |
24 | | /** |
25 | | * Construct a public key from a given public point. |
26 | | * @param group the domain parameters associated with this key |
27 | | * @param public_key the public point defining this key |
28 | | */ |
29 | 0 | GOST_3410_PublicKey(const EC_Group& group, const EC_AffinePoint& public_key) : EC_PublicKey(group, public_key) {} |
30 | | |
31 | | #if defined(BOTAN_HAS_LEGACY_EC_POINT) |
32 | | /** |
33 | | * Construct a public key from a given public point. |
34 | | * @param group the domain parameters associated with this key |
35 | | * @param public_point the public point defining this key |
36 | | */ |
37 | 0 | GOST_3410_PublicKey(const EC_Group& group, const EC_Point& public_point) : EC_PublicKey(group, public_point) {} |
38 | | #endif |
39 | | |
40 | | /** |
41 | | * Load a public key. |
42 | | * @param alg_id the X.509 algorithm identifier |
43 | | * @param key_bits DER encoded public key bits |
44 | | */ |
45 | | GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits); |
46 | | |
47 | | /** |
48 | | * Get this keys algorithm name. |
49 | | * @result this keys algorithm name |
50 | | */ |
51 | | std::string algo_name() const override; |
52 | | |
53 | | AlgorithmIdentifier algorithm_identifier() const override; |
54 | | |
55 | | std::vector<uint8_t> public_key_bits() const override; |
56 | | |
57 | 190 | std::optional<size_t> _signature_element_size_for_DER_encoding() const override { |
58 | 190 | return domain().get_order_bytes(); |
59 | 190 | } |
60 | | |
61 | 190 | Signature_Format _default_x509_signature_format() const override { return Signature_Format::Standard; } |
62 | | |
63 | | std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final; |
64 | | |
65 | 0 | bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::Signature); } |
66 | | |
67 | | std::unique_ptr<PK_Ops::Verification> create_verification_op(std::string_view params, |
68 | | std::string_view provider) const override; |
69 | | |
70 | | std::unique_ptr<PK_Ops::Verification> create_x509_verification_op(const AlgorithmIdentifier& signature_algorithm, |
71 | | std::string_view provider) const override; |
72 | | |
73 | | protected: |
74 | 1 | GOST_3410_PublicKey() = default; |
75 | | }; |
76 | | |
77 | | /** |
78 | | * GOST-34.10 Private Key |
79 | | */ |
80 | | |
81 | | BOTAN_DIAGNOSTIC_PUSH |
82 | | BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE |
83 | | |
84 | | class BOTAN_PUBLIC_API(2, 0) GOST_3410_PrivateKey final : public GOST_3410_PublicKey, |
85 | | public EC_PrivateKey { |
86 | | public: |
87 | | /** |
88 | | * Load a private key. |
89 | | * @param alg_id the X.509 algorithm identifier |
90 | | * @param key_bits ECPrivateKey bits |
91 | | */ |
92 | | GOST_3410_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits) : |
93 | 1 | EC_PrivateKey(alg_id, key_bits) {} |
94 | | |
95 | | /** |
96 | | * Create a private key from a given secret @p x |
97 | | * @param domain curve parameters to bu used for this key |
98 | | * @param x the private key |
99 | | */ |
100 | | GOST_3410_PrivateKey(const EC_Group& domain, const BigInt& x); |
101 | | |
102 | | /** |
103 | | * Create a new private key |
104 | | * @param rng a random number generator |
105 | | * @param domain parameters to used for this key |
106 | | */ |
107 | | GOST_3410_PrivateKey(RandomNumberGenerator& rng, EC_Group domain); |
108 | | |
109 | | /** |
110 | | * Generate a new private key |
111 | | * @param rng a random number generator |
112 | | * @param domain parameters to used for this key |
113 | | * @param x the private key; if zero, a new random key is generated |
114 | | */ |
115 | | BOTAN_DEPRECATED("Use one of the other constructors") |
116 | | GOST_3410_PrivateKey(RandomNumberGenerator& rng, const EC_Group& domain, const BigInt& x); |
117 | | |
118 | | std::unique_ptr<Public_Key> public_key() const override; |
119 | | |
120 | 0 | AlgorithmIdentifier pkcs8_algorithm_identifier() const override { return EC_PublicKey::algorithm_identifier(); } |
121 | | |
122 | | std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng, |
123 | | std::string_view params, |
124 | | std::string_view provider) const override; |
125 | | }; |
126 | | |
127 | | BOTAN_DIAGNOSTIC_POP |
128 | | |
129 | | } // namespace Botan |
130 | | |
131 | | #endif |