Botan 2.19.5 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
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 {
22 public:
23
24 /**
25 * Construct a public key from a given public point.
26 * @param dom_par the domain parameters associated with this key
27 * @param public_point the public point defining this key
28 */
29 GOST_3410_PublicKey(const EC_Group& dom_par,
30 const PointGFp& public_point) :
31 EC_PublicKey(dom_par, public_point) {}
32
33 /**
34 * Load a public key.
35 * @param alg_id the X.509 algorithm identifier
36 * @param key_bits DER encoded public key bits
37 */
38 GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
39 const std::vector<uint8_t>& key_bits);
40
41 /**
42 * Get this keys algorithm name.
43 * @result this keys algorithm name
44 */
45 std::string algo_name() const override;
46
47 AlgorithmIdentifier algorithm_identifier() const override;
48
49 std::vector<uint8_t> public_key_bits() const override;
50
51 size_t message_parts() const override { return 2; }
52
53 size_t message_part_size() const override
54 { return domain().get_order().bytes(); }
55
56 Signature_Format default_x509_signature_format() const override
57 { return IEEE_1363; }
58
59 std::unique_ptr<PK_Ops::Verification>
60 create_verification_op(const std::string& params,
61 const std::string& provider) const override;
62
63 protected:
64 GOST_3410_PublicKey() = default;
65 };
66
67/**
68* GOST-34.10 Private Key
69*/
70 class BOTAN_PUBLIC_API(2,0) GOST_3410_PrivateKey final :
71 public GOST_3410_PublicKey, public EC_PrivateKey
72 {
73 public:
74 /**
75 * Load a private key.
76 * @param alg_id the X.509 algorithm identifier
77 * @param key_bits ECPrivateKey bits
78 */
79 GOST_3410_PrivateKey(const AlgorithmIdentifier& alg_id,
80 const secure_vector<uint8_t>& key_bits) :
81 EC_PrivateKey(alg_id, key_bits) {}
82
83 /**
84 * Generate a new private key
85 * @param rng a random number generator
86 * @param domain parameters to used for this key
87 * @param x the private key; if zero, a new random key is generated
88 */
89 GOST_3410_PrivateKey(RandomNumberGenerator& rng,
90 const EC_Group& domain,
91 const BigInt& x = 0);
92
93 AlgorithmIdentifier pkcs8_algorithm_identifier() const override
94 { return EC_PublicKey::algorithm_identifier(); }
95
96 std::unique_ptr<PK_Ops::Signature>
97 create_signature_op(RandomNumberGenerator& rng,
98 const std::string& params,
99 const std::string& provider) const override;
100 };
101
102}
103
104#endif
Botan::AlgorithmIdentifier
Definition: asn1_obj.h:430
Botan::BigInt
Definition: bigint.h:25
Botan::EC_Group
Definition: ec_group.h:46
Botan::EC_PrivateKey
Definition: ecc_key.h:125
Botan::EC_PublicKey
Definition: ecc_key.h:29
Botan::EC_PublicKey::algorithm_identifier
AlgorithmIdentifier algorithm_identifier() const override
Definition: ecc_key.cpp:64
Botan::GOST_3410_PrivateKey
Definition: gost_3410.h:72
Botan::GOST_3410_PrivateKey::GOST_3410_PrivateKey
GOST_3410_PrivateKey(const AlgorithmIdentifier &alg_id, const secure_vector< uint8_t > &key_bits)
Definition: gost_3410.h:79
Botan::GOST_3410_PrivateKey::pkcs8_algorithm_identifier
AlgorithmIdentifier pkcs8_algorithm_identifier() const override
Definition: gost_3410.h:93
Botan::GOST_3410_PublicKey
Definition: gost_3410.h:21
Botan::GOST_3410_PublicKey::default_x509_signature_format
Signature_Format default_x509_signature_format() const override
Definition: gost_3410.h:56
Botan::GOST_3410_PublicKey::message_parts
size_t message_parts() const override
Definition: gost_3410.h:51
Botan::GOST_3410_PublicKey::GOST_3410_PublicKey
GOST_3410_PublicKey()=default
Botan::GOST_3410_PublicKey::GOST_3410_PublicKey
GOST_3410_PublicKey(const EC_Group &dom_par, const PointGFp &public_point)
Definition: gost_3410.h:29
Botan::GOST_3410_PublicKey::message_part_size
size_t message_part_size() const override
Definition: gost_3410.h:53
Botan::PointGFp
Definition: point_gfp.h:48
Botan::RandomNumberGenerator
Definition: rng.h:26
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:29
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Botan
Definition: alg_id.cpp:13
Botan::Signature_Format
Signature_Format
Definition: pk_keys.h:23
Botan::IEEE_1363
@ IEEE_1363
Definition: pk_keys.h:23
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65