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