Botan 3.7.1
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 return domain().get_order_bytes();
59 }
60
62
63 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
64
65 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:
75};
76
77/**
78* GOST-34.10 Private Key
79*/
80
83
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 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 */
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 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
128
129} // namespace Botan
130
131#endif
#define BOTAN_DEPRECATED_HEADER(hdr)
Definition api.h:80
#define BOTAN_DIAGNOSTIC_POP
Definition api.h:108
#define BOTAN_DIAGNOSTIC_PUSH
Definition api.h:105
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
Definition api.h:107
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:19
#define BOTAN_DEPRECATED(msg)
Definition api.h:59
virtual std::string algo_name() const =0
virtual std::unique_ptr< Private_Key > generate_another(RandomNumberGenerator &rng) const =0
size_t get_order_bytes() const
Definition ec_group.cpp:510
const EC_Group & domain() const
Definition ecc_key.cpp:63
AlgorithmIdentifier algorithm_identifier() const override
Definition ecc_key.cpp:85
std::vector< uint8_t > public_key_bits() const override
Definition ecc_key.cpp:93
GOST_3410_PrivateKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition gost_3410.h:92
Signature_Format _default_x509_signature_format() const override
Definition gost_3410.h:61
bool supports_operation(PublicKeyOperation op) const override
Definition gost_3410.h:65
std::optional< size_t > _signature_element_size_for_DER_encoding() const override
Definition gost_3410.h:57
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
int(* final)(unsigned char *, CTX *)
PublicKeyOperation
Definition pk_keys.h:45
Signature_Format
Definition pk_keys.h:31