blob: 073597bc914b335ba02b57e24af2afe7f439b976 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*
* ECDSA
* (C) 2007 Falko Strenzke, FlexSecure GmbH
* Manuel Hartl, FlexSecure GmbH
* (C) 2008-2010 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ECC_PUBLIC_KEY_BASE_H__
#define BOTAN_ECC_PUBLIC_KEY_BASE_H__
#include <botan/ec_dompar.h>
#include <botan/pk_keys.h>
#include <botan/x509_key.h>
#include <botan/pkcs8.h>
#include <memory>
namespace Botan {
/**
* This class represents abstract EC Public Keys. When encoding a key
* via an encoder that can be accessed via the corresponding member
* functions, the key will decide upon its internally stored encoding
* information whether to encode itself with or without domain
* parameters, or using the domain parameter oid. Furthermore, a public
* key without domain parameters can be decoded. In that case, it
* cannot be used for verification until its domain parameters are set
* by calling the corresponding member function.
*/
class BOTAN_DLL EC_PublicKey : public virtual Public_Key
{
public:
/**
* Get the public point of this key.
* @throw Invalid_State is thrown if the
* domain parameters of this point are not set
* @result the public point of this key
*/
const PointGFp& public_point() const { return public_key; }
/**
* Get the domain parameters of this key.
* @throw Invalid_State is thrown if the
* domain parameters of this point are not set
* @result the domain parameters of this key
*/
const EC_Domain_Params& domain() const { return domain_params; }
/**
* Set the domain parameter encoding to be used when encoding this key.
* @param enc the encoding to use
*/
void set_parameter_encoding(EC_Domain_Params_Encoding enc);
/**
* Get the domain parameter encoding to be used when encoding this key.
* @result the encoding to use
*/
EC_Domain_Params_Encoding domain_format() const { return domain_encoding; }
/**
* Get an x509_encoder that can be used to encode this key.
* @result an x509_encoder for this key
*/
X509_Encoder* x509_encoder() const;
/**
* Get an x509_decoder that can be used to decode a stored key into
* this key.
* @result an x509_decoder for this key
*/
X509_Decoder* x509_decoder();
EC_PublicKey() : domain_encoding(EC_DOMPAR_ENC_EXPLICIT) {}
virtual ~EC_PublicKey() {}
protected:
virtual void X509_load_hook();
EC_Domain_Params domain_params;
PointGFp public_key;
EC_Domain_Params_Encoding domain_encoding;
};
/**
* This abstract class represents general EC Private Keys
*/
class BOTAN_DLL EC_PrivateKey : public virtual EC_PublicKey, public virtual Private_Key
{
public:
/**
* Get an PKCS#8 encoder that can be used to encoded this key.
* @result an PKCS#8 encoder for this key
*/
PKCS8_Encoder* pkcs8_encoder() const;
/**
* Get an PKCS#8 decoder that can be used to decoded a stored key into
* this key.
* @result an PKCS#8 decoder for this key
*/
PKCS8_Decoder* pkcs8_decoder(RandomNumberGenerator&);
/**
* Get the private key value of this key object.
* @result the private key value of this key object
*/
const BigInt& private_value() const;
virtual ~EC_PrivateKey() {}
protected:
virtual void PKCS8_load_hook(bool = false);
void generate_private_key(RandomNumberGenerator&);
BigInt private_key;
};
}
#endif
|