Botan 3.6.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
15namespace Botan {
16
17/**
18* GOST-34.10 Public Key
19*/
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 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 size_t message_parts() const override { return 2; }
48
49 size_t message_part_size() const override { return domain().get_order_bytes(); }
50
51 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 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:
65};
66
67/**
68* GOST-34.10 Private Key
69*/
70
73
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 EC_PrivateKey(alg_id, key_bits) {}
84
85 /**
86 * Generate a new private key
87 * @param rng a random number generator
88 * @param domain parameters to used for this key
89 * @param x the private key; if zero, a new random key is generated
90 */
91 GOST_3410_PrivateKey(RandomNumberGenerator& rng, const EC_Group& domain, const BigInt& x = BigInt::zero());
92
93 std::unique_ptr<Public_Key> public_key() const override;
94
95 AlgorithmIdentifier pkcs8_algorithm_identifier() const override { return EC_PublicKey::algorithm_identifier(); }
96
97 std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng,
98 std::string_view params,
99 std::string_view provider) const override;
100};
101
103
104} // namespace Botan
105
106#endif
AlgorithmIdentifier pkcs8_algorithm_identifier() const override
Definition gost_3410.h:95
GOST_3410_PrivateKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition gost_3410.h:82
GOST_3410_PublicKey(const EC_Group &dom_par, const EC_Point &public_point)
Definition gost_3410.h:27
Signature_Format default_x509_signature_format() const override
Definition gost_3410.h:51
size_t message_parts() const override
Definition gost_3410.h:47
bool supports_operation(PublicKeyOperation op) const override
Definition gost_3410.h:55
size_t message_part_size() const override
Definition gost_3410.h:49
int(* final)(unsigned char *, CTX *)
#define BOTAN_DIAGNOSTIC_POP
Definition compiler.h:191
#define BOTAN_DIAGNOSTIC_PUSH
Definition compiler.h:188
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
Definition compiler.h:190
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
PublicKeyOperation
Definition pk_keys.h:45
Signature_Format
Definition pk_keys.h:31