Botan 3.13.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
92 /**
93 * Create a private key from a given secret @p x
94 * @param domain curve parameters to bu used for this key
95 * @param x the private key
96 */
98
99 /**
100 * Create a new private key
101 * @param rng a random number generator
102 * @param domain parameters to used for this key
103 */
105
106 /**
107 * Generate a new private key
108 * @param rng a random number generator
109 * @param domain parameters to used for this key
110 * @param x the private key; if zero, a new random key is generated
111 */
112 BOTAN_DEPRECATED("Use one of the other constructors")
114
115 std::unique_ptr<Public_Key> public_key() const override;
116
120
121 std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng,
122 std::string_view params,
123 std::string_view provider) const override;
124};
125
127
128} // namespace Botan
129
130#endif
#define BOTAN_DEPRECATED_HEADER(hdr)
Definition api.h:100
#define BOTAN_DIAGNOSTIC_POP
Definition api.h:128
#define BOTAN_DIAGNOSTIC_PUSH
Definition api.h:125
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
Definition api.h:127
#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:144
EC_PrivateKey(const EC_PrivateKey &other)=default
const EC_Group & domain() const
Definition ecc_key.cpp:76
EC_PublicKey(const EC_PublicKey &other)=default
AlgorithmIdentifier algorithm_identifier() const override
Definition ecc_key.cpp:98
std::vector< uint8_t > public_key_bits() const override
Definition ecc_key.cpp:106
std::unique_ptr< Public_Key > public_key() const override
AlgorithmIdentifier pkcs8_algorithm_identifier() const override
Definition gost_3410.h:117
GOST_3410_PrivateKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
AlgorithmIdentifier algorithm_identifier() const override
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:116
virtual std::unique_ptr< PK_Ops::Verification > create_x509_verification_op(const AlgorithmIdentifier &signature_algorithm, std::string_view provider) const
Definition pk_keys.cpp:121
PublicKeyOperation
Definition pk_keys.h:46
Signature_Format
Definition pk_keys.h:32