Botan: src/pubkey/ecc_key/ecc_key.h Source File

Botan 1.10.16

ecc_key.h
Go to the documentation of this file.
1 /*
2 * ECDSA
3 * (C) 2007 Falko Strenzke, FlexSecure GmbH
4 * Manuel Hartl, FlexSecure GmbH
5 * (C) 2008-2010 Jack Lloyd
6 *
7 * Distributed under the terms of the Botan license
8 */
9
10 #ifndef BOTAN_ECC_PUBLIC_KEY_BASE_H__
11 #define BOTAN_ECC_PUBLIC_KEY_BASE_H__
12
13 #include <botan/ec_group.h>
14 #include <botan/pk_keys.h>
15 #include <botan/x509_key.h>
16 #include <botan/pkcs8.h>
17
18 namespace Botan {
19
20 /**
21 * This class represents abstract ECC public keys. When encoding a key
22 * via an encoder that can be accessed via the corresponding member
23 * functions, the key will decide upon its internally stored encoding
24 * information whether to encode itself with or without domain
25 * parameters, or using the domain parameter oid. Furthermore, a public
26 * key without domain parameters can be decoded. In that case, it
27 * cannot be used for verification until its domain parameters are set
28 * by calling the corresponding member function.
29 */
30 class BOTAN_DLL EC_PublicKey : public virtual Public_Key
31 {
32 public:
33 EC_PublicKey(const EC_Group& dom_par,
34 const PointGFp& pub_point);
35
36 EC_PublicKey(const AlgorithmIdentifier& alg_id,
37 const MemoryRegion<byte>& key_bits);
38
39 /**
40 * Get the public point of this key.
41 * @throw Invalid_State is thrown if the
42 * domain parameters of this point are not set
43 * @result the public point of this key
44 */
45 const PointGFp& public_point() const { return public_key; }
46
47 AlgorithmIdentifier algorithm_identifier() const;
48
49 MemoryVector<byte> x509_subject_public_key() const;
50
51 bool check_key(RandomNumberGenerator& rng,
52 bool strong) const;
53
54 /**
55 * Get the domain parameters of this key.
56 * @throw Invalid_State is thrown if the
57 * domain parameters of this point are not set
58 * @result the domain parameters of this key
59 */
60 const EC_Group& domain() const { return domain_params; }
61
62 /**
63 * Set the domain parameter encoding to be used when encoding this key.
64 * @param enc the encoding to use
65 */
66 void set_parameter_encoding(EC_Group_Encoding enc);
67
68 /**
69 * Return the DER encoding of this keys domain in whatever format
70 * is preset for this particular key
71 */
72 MemoryVector<byte> DER_domain() const
73 { return domain().DER_encode(domain_format()); }
74
75 /**
76 * Get the domain parameter encoding to be used when encoding this key.
77 * @result the encoding to use
78 */
79 EC_Group_Encoding domain_format() const
80 { return domain_encoding; }
81 protected:
82 EC_PublicKey() : domain_encoding(EC_DOMPAR_ENC_EXPLICIT) {}
83
84 EC_Group domain_params;
85 PointGFp public_key;
86 EC_Group_Encoding domain_encoding;
87 };
88
89 /**
90 * This abstract class represents ECC private keys
91 */
92 class BOTAN_DLL EC_PrivateKey : public virtual EC_PublicKey,
93 public virtual Private_Key
94 {
95 public:
96 EC_PrivateKey(RandomNumberGenerator& rng,
97 const EC_Group& domain,
98 const BigInt& private_key);
99
100 EC_PrivateKey(const AlgorithmIdentifier& alg_id,
101 const MemoryRegion<byte>& key_bits);
102
103 MemoryVector<byte> pkcs8_private_key() const;
104
105 /**
106 * Get the private key value of this key object.
107 * @result the private key value of this key object
108 */
109 const BigInt& private_value() const;
110 protected:
111 EC_PrivateKey() {}
112
113 BigInt private_key;
114 };
115
116 }
117
118 #endif
Botan::EC_PrivateKey::private_key
BigInt private_key
Definition: ecc_key.h:113
Botan::BigInt
Definition: bigint.h:22
Botan::EC_DOMPAR_ENC_EXPLICIT
Definition: ec_group.h:23
Botan::PointGFp
Definition: point_gfp.h:41
Botan::RandomNumberGenerator
Definition: rng.h:20
Botan::Private_Key
Definition: pk_keys.h:86
Botan::EC_PublicKey::public_point
const PointGFp & public_point() const
Definition: ecc_key.h:45
Botan::EC_PublicKey::public_key
PointGFp public_key
Definition: ecc_key.h:85
Botan::EC_PublicKey
Definition: ecc_key.h:30
Botan::EC_PrivateKey
Definition: ecc_key.h:92
Botan::EC_PublicKey::domain
const EC_Group & domain() const
Definition: ecc_key.h:60
Botan::EC_PublicKey::DER_domain
MemoryVector< byte > DER_domain() const
Definition: ecc_key.h:72
Botan::MemoryRegion< byte >
Botan
Definition: algo_base.h:14
Botan::MemoryVector< byte >
Botan::EC_Group
Definition: ec_group.h:31
Botan::Public_Key
Definition: pk_keys.h:21
Botan::EC_PublicKey::EC_PublicKey
EC_PublicKey()
Definition: ecc_key.h:82
Botan::EC_Group_Encoding
EC_Group_Encoding
Definition: ec_group.h:22
Botan::AlgorithmIdentifier
Definition: alg_id.h:20
Botan::EC_PublicKey::domain_encoding
EC_Group_Encoding domain_encoding
Definition: ecc_key.h:86
Botan::EC_PrivateKey::EC_PrivateKey
EC_PrivateKey()
Definition: ecc_key.h:111
Botan::EC_PublicKey::domain_format
EC_Group_Encoding domain_format() const
Definition: ecc_key.h:79
Botan::EC_PublicKey::domain_params
EC_Group domain_params
Definition: ecc_key.h:84