Botan 1.10.17
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
18namespace 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*/
30class 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
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 */
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 */
81 protected:
83
87 };
88
89/**
90* This abstract class represents ECC private keys
91*/
92class BOTAN_DLL EC_PrivateKey : public virtual EC_PublicKey,
93 public virtual Private_Key
94 {
95 public:
97 const EC_Group& domain,
98 const BigInt& private_key);
99
101 const MemoryRegion<byte>& key_bits);
102
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:
112
114 };
115
116}
117
118#endif
MemoryVector< byte > pkcs8_private_key() const
Definition ecc_key.cpp:99
const BigInt & private_value() const
Definition ecc_key.cpp:70
EC_PrivateKey(RandomNumberGenerator &rng, const EC_Group &domain, const BigInt &private_key)
Definition ecc_key.cpp:81
const EC_Group & domain() const
Definition ecc_key.h:60
EC_Group_Encoding domain_format() const
Definition ecc_key.h:79
EC_Group domain_params
Definition ecc_key.h:84
MemoryVector< byte > DER_domain() const
Definition ecc_key.h:72
EC_Group_Encoding domain_encoding
Definition ecc_key.h:86
PointGFp public_key
Definition ecc_key.h:85
EC_PublicKey(const EC_Group &dom_par, const PointGFp &pub_point)
Definition ecc_key.cpp:21
const PointGFp & public_point() const
Definition ecc_key.h:45
EC_Group_Encoding
Definition ec_group.h:22
@ EC_DOMPAR_ENC_EXPLICIT
Definition ec_group.h:23