Botan 3.11.0
Crypto and TLS for C&
gost_3410.h
Go to the documentation of this file.
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
15BOTAN_DEPRECATED_HEADER("gost_3410.h")
16
17namespace Botan {
18
19/**
20* GOST-34.10 Public Key
21*/
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 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 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 std::optional<size_t> _signature_element_size_for_DER_encoding() const override;
58
60
61 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
62
63 bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::Signature); }
64
65 std::unique_ptr<PK_Ops::Verification> create_verification_op(std::string_view params,
66 std::string_view provider) const override;
67
68 std::unique_ptr<PK_Ops::Verification> create_x509_verification_op(const AlgorithmIdentifier& signature_algorithm,
69 std::string_view provider) const override;
70
71 protected:
73};
74
75/**
76* GOST-34.10 Private Key
77*/
78
81
83 public EC_PrivateKey {
84 public:
85 /**
86 * Load a private key.
87 * @param alg_id the X.509 algorithm identifier
88 * @param key_bits ECPrivateKey bits
89 */
90 GOST_3410_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits) :
91 EC_PrivateKey(alg_id, key_bits) {}
92
93 /**
94 * Create a private key from a given secret @p x
95 * @param domain curve parameters to bu used for this key
96 * @param x the private key
97 */
98 GOST_3410_PrivateKey(const EC_Group& domain, const BigInt& x);
99
100 /**
101 * Create a new private key
102 * @param rng a random number generator
103 * @param domain parameters to used for this key
104 */
106
107 /**
108 * Generate a new private key
109 * @param rng a random number generator
110 * @param domain parameters to used for this key
111 * @param x the private key; if zero, a new random key is generated
112 */
113 BOTAN_DEPRECATED("Use one of the other constructors")
114 GOST_3410_PrivateKey(RandomNumberGenerator& rng, const EC_Group& domain, const BigInt& x);
115
116 std::unique_ptr<Public_Key> public_key() const override;
117
119 return EC_PublicKey::algorithm_identifier(); // NOLINT(bugprone-parent-virtual-call)
120 }
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
128
129} // namespace Botan
130
131#endif
#define BOTAN_DEPRECATED_HEADER(hdr)
Definition api.h:94
#define BOTAN_DIAGNOSTIC_POP
Definition api.h:122
#define BOTAN_DIAGNOSTIC_PUSH
Definition api.h:119
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
Definition api.h:121
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
#define BOTAN_DEPRECATED(msg)
Definition api.h:73
virtual std::string algo_name() const =0
virtual std::unique_ptr< Private_Key > generate_another(RandomNumberGenerator &rng) const =0
virtual std::optional< size_t > _signature_element_size_for_DER_encoding() const
Definition pk_keys.h:137
EC_PrivateKey(const EC_PrivateKey &other)=default
EC_PublicKey(const EC_PublicKey &other)=default
AlgorithmIdentifier algorithm_identifier() const override
Definition ecc_key.cpp:86
std::vector< uint8_t > public_key_bits() const override
Definition ecc_key.cpp:94
AlgorithmIdentifier pkcs8_algorithm_identifier() const override
Definition gost_3410.h:118
GOST_3410_PrivateKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition gost_3410.h:90
Signature_Format _default_x509_signature_format() const override
Definition gost_3410.h:59
bool supports_operation(PublicKeyOperation op) const override
Definition gost_3410.h:63
GOST_3410_PublicKey(const EC_Group &group, const EC_AffinePoint &public_key)
Definition gost_3410.h:29
virtual std::unique_ptr< PK_Ops::Verification > create_verification_op(std::string_view params, std::string_view provider) const
Definition pk_keys.cpp:109
virtual std::unique_ptr< PK_Ops::Verification > create_x509_verification_op(const AlgorithmIdentifier &signature_algorithm, std::string_view provider) const
Definition pk_keys.cpp:114
PublicKeyOperation
Definition pk_keys.h:46
Signature_Format
Definition pk_keys.h:32