Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | List of all members
Botan::EC_Group Class Reference

`#include <ec_group.h>`

## Public Member Functions
std::vector< uint8_t > | DER_encode (EC_Group_Encoding form) const
| EC_Group (const CurveGFp &curve, const PointGFp &base_point, const BigInt &order, const BigInt &cofactor)
| EC_Group (const std::vector< uint8_t > &ber_encoding)
| EC_Group (const OID &oid)
| EC_Group (const std::string &pem_or_oid="")
const PointGFp & | get_base_point () const
const BigInt & | get_cofactor () const
const CurveGFp & | get_curve () const
std::string | get_oid () const
const BigInt & | get_order () const
bool | initialized () const
bool | operator== (const EC_Group &other) const
std::string | PEM_encode () const
bool | verify_group (RandomNumberGenerator &rng, bool strong=false) const

## Static Public Member Functions
static std::string | PEM_for_named_group (const std::string &name)

## Detailed Description

Class representing an elliptic curve

Definition at line 31 of file ec_group.h.

## Constructor & Destructor Documentation

Botan::EC_Group::EC_Group | ( | const CurveGFp & | curve,
|  | const PointGFp & | base_point,
|  | const BigInt & | order,
|  | const BigInt & | cofactor
| ) |  |
| inline

Construct Domain paramers from specified parameters

Parameters

  curve | elliptic curve
  base_point | a base point
  order | the order of the base point
  cofactor | the cofactor

Definition at line 42 of file ec_group.h.

Referenced by EC_Group().

45 :
46 m_curve(curve),
47 m_base_point(base_point),
48 m_order(order),
49 m_cofactor(cofactor),
50 m_oid("")
51 {}

Botan::EC_Group::EC_Group | ( | const std::vector< uint8_t > & | ber_encoding | ) |
| explicit

Decode a BER encoded ECC domain parameter set

Parameters

  ber_encoding | the bytes of the BER encoding

Definition at line 48 of file ec_group.cpp.

References Botan::BER_Decoder::decode(), Botan::BER_Decoder::decode_and_check(), Botan::BER_Decoder::decode_octet_string_bigint(), EC_Group(), Botan::BER_Decoder::end_cons(), Botan::BER_Decoder::get_next_object(), Botan::NULL_TAG, Botan::OBJECT_ID, Botan::OCTET_STRING, Botan::OS2ECP(), Botan::SEQUENCE, Botan::BER_Decoder::start_cons(), Botan::BER_Object::type_tag, and Botan::BER_Decoder::verify_end().

49 {
50 BER_Decoder ber(ber_data);
51 BER_Object obj = ber.get_next_object();
52
53 if(obj.type_tag == NULL_TAG)
54 throw Decoding_Error("Cannot handle ImplicitCA ECDSA parameters");
55 else if(obj.type_tag == OBJECT_ID)
56 {
57 OID dom_par_oid;
58 BER_Decoder(ber_data).decode(dom_par_oid);
59 *this = EC_Group(dom_par_oid);
60 }
61 else if(obj.type_tag == SEQUENCE)
62 {
63 BigInt p, a, b;
64 std::vector<uint8_t> sv_base_point;
65
66 BER_Decoder(ber_data)
67 .start_cons(SEQUENCE)
68 .decode_and_check<size_t>(1, "Unknown ECC param version code")
69 .start_cons(SEQUENCE)
70 .decode_and_check(OID("1.2.840.10045.1.1"),
71 "Only prime ECC fields supported")
72 .decode(p)
73 .end_cons()
74 .start_cons(SEQUENCE)
75 .decode_octet_string_bigint(a)
76 .decode_octet_string_bigint(b)
77 .end_cons()
78 .decode(sv_base_point, OCTET_STRING)
79 .decode(m_order)
80 .decode(m_cofactor)
81 .end_cons()
82 .verify_end();
83
84 m_curve = CurveGFp(p, a, b);
85 m_base_point = OS2ECP(sv_base_point, m_curve);
86 }
87 else
88 throw Decoding_Error("Unexpected tag while decoding ECC domain params");
89 }
Botan::OBJECT_ID
Definition: asn1_obj.h:37
Botan::OCTET_STRING
Definition: asn1_obj.h:35
Botan::OS2ECP
PointGFp OS2ECP(const uint8_t data[], size_t data_len, const CurveGFp &curve)
Definition: point_gfp.cpp:544
Botan::SEQUENCE
Definition: asn1_obj.h:39
Botan::EC_Group::EC_Group
EC_Group(const CurveGFp &curve, const PointGFp &base_point, const BigInt &order, const BigInt &cofactor)
Definition: ec_group.h:42
Botan::NULL_TAG
Definition: asn1_obj.h:36

Botan::EC_Group::EC_Group | ( | const OID & | oid | ) |
| explicit

Create an EC domain by OID (or throw if unknown)

Parameters

  oid | the OID of the EC domain to create

Definition at line 19 of file ec_group.cpp.

References Botan::OID::as_string(), EC_Group(), Botan::OIDS::lookup(), and PEM_for_named_group().

20 {
21 const std::string pem = PEM_for_named_group(OIDS::lookup(domain_oid));
22
23 if(pem == "")
24 throw Lookup_Error("No ECC domain data for " + domain_oid.as_string());
25
26 *this = EC_Group(pem);
27 m_oid = domain_oid.as_string();
28 }
Botan::EC_Group::PEM_for_named_group
static std::string PEM_for_named_group(const std::string &name)
Definition: ec_named.cpp:13
Botan::OIDS::lookup
std::string lookup(const OID &oid)
Definition: oids.cpp:18
Botan::EC_Group::EC_Group
EC_Group(const CurveGFp &curve, const PointGFp &base_point, const BigInt &order, const BigInt &cofactor)
Definition: ec_group.h:42

Botan::EC_Group::EC_Group | ( | const std::string & | pem_or_oid = `""` | ) |

Create an EC domain from PEM encoding (as from PEM_encode), or from an OID name (eg "secp256r1", or "1.2.840.10045.3.1.7")

Parameters

  pem_or_oid | PEM-encoded data, or an OID

Definition at line 30 of file ec_group.cpp.

References Botan::PEM_Code::decode_check_label(), EC_Group(), Botan::OIDS::lookup(), and Botan::unlock().

31 {
32 if(str == "")
33 return; // no initialization / uninitialized
34
35 try
36 {
37 std::vector<uint8_t> ber =
38 unlock(PEM_Code::decode_check_label(str, "EC PARAMETERS"));
39
40 *this = EC_Group(ber);
41 }
42 catch(Decoding_Error) // hmm, not PEM?
43 {
44 *this = EC_Group(OIDS::lookup(str));
45 }
46 }
Botan::OIDS::lookup
std::string lookup(const OID &oid)
Definition: oids.cpp:18
Botan::EC_Group::EC_Group
EC_Group(const CurveGFp &curve, const PointGFp &base_point, const BigInt &order, const BigInt &cofactor)
Definition: ec_group.h:42
Botan::unlock
std::vector< T > unlock(const secure_vector< T > &in)
Definition: secmem.h:125
Botan::PEM_Code::decode_check_label
secure_vector< uint8_t > decode_check_label(DataSource &source, const std::string &label_want)
Definition: pem.cpp:54

## Member Function Documentation

std::vector< uint8_t > Botan::EC_Group::DER_encode | ( | EC_Group_Encoding | form | ) | const

Create the DER encoding of this domain

Parameters

  form | of encoding to use

Returns
  bytes encododed as DER

Definition at line 92 of file ec_group.cpp.

References Botan::BigInt::bytes(), Botan::EC2OSP(), Botan::EC_DOMPAR_ENC_EXPLICIT, Botan::EC_DOMPAR_ENC_IMPLICITCA, Botan::EC_DOMPAR_ENC_OID, Botan::DER_Encoder::encode(), Botan::BigInt::encode_1363(), Botan::DER_Encoder::encode_null(), Botan::DER_Encoder::end_cons(), Botan::CurveGFp::get_a(), Botan::CurveGFp::get_b(), Botan::DER_Encoder::get_contents_unlocked(), get_oid(), Botan::CurveGFp::get_p(), Botan::OCTET_STRING, Botan::SEQUENCE, Botan::DER_Encoder::start_cons(), and Botan::PointGFp::UNCOMPRESSED.

Referenced by PEM_encode().

93 {
94 if(form == EC_DOMPAR_ENC_EXPLICIT)
95 {
96 const size_t ecpVers1 = 1;
97 OID curve_type("1.2.840.10045.1.1");
98
99 const size_t p_bytes = m_curve.get_p().bytes();
100
101 return DER_Encoder()
102 .start_cons(SEQUENCE)
103 .encode(ecpVers1)
104 .start_cons(SEQUENCE)
105 .encode(curve_type)
106 .encode(m_curve.get_p())
107 .end_cons()
108 .start_cons(SEQUENCE)
109 .encode(BigInt::encode_1363(m_curve.get_a(), p_bytes),
110 OCTET_STRING)
111 .encode(BigInt::encode_1363(m_curve.get_b(), p_bytes),
112 OCTET_STRING)
113 .end_cons()
114 .encode(EC2OSP(m_base_point, PointGFp::UNCOMPRESSED), OCTET_STRING)
115 .encode(m_order)
116 .encode(m_cofactor)
117 .end_cons()
118 .get_contents_unlocked();
119 }
120 else if(form == EC_DOMPAR_ENC_OID)
121 return DER_Encoder().encode(OID(get_oid())).get_contents_unlocked();
122 else if(form == EC_DOMPAR_ENC_IMPLICITCA)
123 return DER_Encoder().encode_null().get_contents_unlocked();
124 else
125 throw Internal_Error("EC_Group::DER_encode: Unknown encoding");
126 }
Botan::CurveGFp::get_a
const BigInt & get_a() const
Definition: curve_gfp.h:80
Botan::EC_Group::get_oid
std::string get_oid() const
Definition: ec_group.h:115
Botan::PointGFp::UNCOMPRESSED
Definition: point_gfp.h:45
Botan::EC_DOMPAR_ENC_EXPLICIT
Definition: ec_group.h:23
Botan::EC2OSP
secure_vector< uint8_t > EC2OSP(const PointGFp &point, uint8_t format)
Definition: point_gfp.cpp:470
Botan::CurveGFp::get_b
const BigInt & get_b() const
Definition: curve_gfp.h:85
Botan::OCTET_STRING
Definition: asn1_obj.h:35
Botan::EC_DOMPAR_ENC_IMPLICITCA
Definition: ec_group.h:24
Botan::SEQUENCE
Definition: asn1_obj.h:39
Botan::EC_DOMPAR_ENC_OID
Definition: ec_group.h:25
Botan::CurveGFp::get_p
const BigInt & get_p() const
Definition: curve_gfp.h:91
Botan::BigInt::encode_1363
static secure_vector< uint8_t > encode_1363(const BigInt &n, size_t bytes)
Definition: big_code.cpp:82
Botan::BigInt::bytes
size_t bytes() const
Definition: bigint.cpp:176

const PointGFp& Botan::EC_Group::get_base_point | ( |  | ) | const
| inline

Return group base point

Returns
  base point

Definition at line 95 of file ec_group.h.

References m_base_point.

Referenced by Botan::EC_PrivateKey::EC_PrivateKey(), and operator==().

95 { return m_base_point; }

const BigInt& Botan::EC_Group::get_cofactor | ( |  | ) | const
| inline

Return the cofactor

Returns
  the cofactor

Definition at line 107 of file ec_group.h.

References m_cofactor.

Referenced by Botan::EC_PublicKey::check_key(), Botan::ECIES_KA_Operation::derive_secret(), Botan::ECIES_Decryptor::ECIES_Decryptor(), and operator==().

107 { return m_cofactor; }

const CurveGFp& Botan::EC_Group::get_curve | ( |  | ) | const
| inline

Return domain parameter curve

Returns
  domain parameter curve

Definition at line 89 of file ec_group.h.

References m_curve.

Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan::ECIES_Encryptor::ECIES_Encryptor(), Botan::EC_PublicKey::key_length(), and operator==().

89 { return m_curve; }

std::string Botan::EC_Group::get_oid | ( |  | ) | const
| inline

Return the OID of these domain parameters

Returns
  the OID

Definition at line 115 of file ec_group.h.

References m_oid.

Referenced by DER_encode(), and Botan::EC_PublicKey::set_parameter_encoding().

115 { return m_oid; }

const BigInt& Botan::EC_Group::get_order | ( |  | ) | const
| inline

Return the order of the base point

Returns
  order of the base point

Definition at line 101 of file ec_group.h.

References m_order.

Referenced by Botan::EC_PublicKey::check_key(), Botan::ECIES_KA_Operation::derive_secret(), Botan::EC_PrivateKey::EC_PrivateKey(), Botan::ECIES_Decryptor::ECIES_Decryptor(), and operator==().

101 { return m_order; }

bool Botan::EC_Group::initialized | ( |  | ) | const
| inline

Definition at line 109 of file ec_group.h.

References m_base_point.

109 { return !m_base_point.is_zero(); }
Botan::PointGFp::is_zero
bool is_zero() const
Definition: point_gfp.h:177

bool Botan::EC_Group::operator== | ( | const EC_Group & | other | ) | const
| inline

Definition at line 124 of file ec_group.h.

References get_base_point(), get_cofactor(), get_curve(), and get_order().

125 {
126 return ((get_curve() == other.get_curve()) &&
127 (get_base_point() == other.get_base_point()) &&
128 (get_order() == other.get_order()) &&
129 (get_cofactor() == other.get_cofactor()));
130 }
Botan::EC_Group::get_base_point
const PointGFp & get_base_point() const
Definition: ec_group.h:95
Botan::EC_Group::get_curve
const CurveGFp & get_curve() const
Definition: ec_group.h:89
Botan::EC_Group::get_order
const BigInt & get_order() const
Definition: ec_group.h:101
Botan::EC_Group::get_cofactor
const BigInt & get_cofactor() const
Definition: ec_group.h:107

std::string Botan::EC_Group::PEM_encode | ( |  | ) | const

Return the PEM encoding (always in explicit form)

Returns
  string containing PEM data

Definition at line 128 of file ec_group.cpp.

References DER_encode(), Botan::EC_DOMPAR_ENC_EXPLICIT, and Botan::PEM_Code::encode().

129 {
130 const std::vector<uint8_t> der = DER_encode(EC_DOMPAR_ENC_EXPLICIT);
131 return PEM_Code::encode(der, "EC PARAMETERS");
132 }
Botan::EC_DOMPAR_ENC_EXPLICIT
Definition: ec_group.h:23
Botan::PEM_Code::encode
std::string encode(const uint8_t der[], size_t length, const std::string &label, size_t width)
Definition: pem.cpp:43
Botan::EC_Group::DER_encode
std::vector< uint8_t > DER_encode(EC_Group_Encoding form) const
Definition: ec_group.cpp:92

std::string Botan::EC_Group::PEM_for_named_group | ( | const std::string & | name | ) |
| static

Return PEM representation of named EC group

Definition at line 13 of file ec_named.cpp.

Referenced by EC_Group().

14 {
15 if(name == "secp160k1")
16 return
17 "-----BEGIN EC PARAMETERS-----"
18 "MIGYAgEBMCAGByqGSM49AQECFQD////////////////////+//+sczAsBBQAAAAA"
19 "AAAAAAAAAAAAAAAAAAAAAAQUAAAAAAAAAAAAAAAAAAAAAAAAAAcEKQQ7TDgs43qh"
20 "kqQBnnYwNvT13U1+u5OM+TUxj9zta8KChlMXM8PwPE/uAhUBAAAAAAAAAAAAAbj6"
21 "Ft+rmsoWtrMCAQE="
22 "-----END EC PARAMETERS-----";
23
24 if(name == "secp160r1")
25 return
26 "-----BEGIN EC PARAMETERS-----"
27 "MIGYAgEBMCAGByqGSM49AQECFQD/////////////////////f////zAsBBT/////"
28 "////////////////f////AQUHJe+/FS9eotlrPifgdTUrcVl+kUEKQRKlrVojvVz"
29 "KEZkaYlow4u5E8v8giOmKFUxaJR9WdzJEgQjUTd6xfsyAhUBAAAAAAAAAAAAAfTI"
30 "+Seu08p1IlcCAQE="
31 "-----END EC PARAMETERS-----";
32
33 if(name == "secp160r2")
34 return
35 "-----BEGIN EC PARAMETERS-----"
36 "MIGYAgEBMCAGByqGSM49AQECFQD////////////////////+//+sczAsBBT/////"
37 "///////////////+//+scAQUtOE00/tZ64urVydJBGZNWvUDiLoEKQRS3LA0KToR"
38 "fh9P8Rsw9xmdMUTObf6v/vLjMfKW4HH6DfmYLP6n1D8uAhUBAAAAAAAAAAAAADUe"
39 "54aoGPOhoWsCAQE="
40 "-----END EC PARAMETERS-----";
41
42 if(name == "secp192k1")
43 return
44 "-----BEGIN EC PARAMETERS-----"
45 "MIGwAgEBMCQGByqGSM49AQECGQD//////////////////////////v//7jcwNAQY"
46 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
47 "AAMEMQTbT/EOwFfpriawfQKAt/Q0HaXRsergbH2bLy9tnFYop4RBY9AVvoY0QIKq"
48 "iNleL50CGQD///////////////4m8vwXD2lGanTe/Y0CAQE="
49 "-----END EC PARAMETERS-----";
50
51 if(name == "secp192r1")
52 return
53 "-----BEGIN EC PARAMETERS-----"
54 "MIGwAgEBMCQGByqGSM49AQECGQD////////////////////+//////////8wNAQY"
55 "/////////////////////v/////////8BBhkIQUZ5ZyA5w+n6atyJDBJ/rje7MFG"
56 "ubEEMQQYjagOsDCQ9ny/IOtDoYgA9P8K/YL/EBIHGSuV/8jaeGMQEe1rJM3Vc/l3"
57 "oR55SBECGQD///////////////+Z3vg2FGvJsbTSKDECAQE="
58 "-----END EC PARAMETERS-----";
59
60 if(name == "secp224k1")
61 return
62 "-----BEGIN EC PARAMETERS-----"
63 "MIHIAgEBMCgGByqGSM49AQECHQD///////////////////////////////7//+Vt"
64 "MDwEHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEHAAAAAAAAAAAAAAAAAAA"
65 "AAAAAAAAAAAAAAAAAAUEOQShRVszTfCZ3zD8KKFppGfp5HB1qQ9+ZQ62t6Rcfgif"
66 "7X+6NEKCyvvW9+MZ98CwvVniykvbVW1hpQIdAQAAAAAAAAAAAAAAAAAB3OjS7GGE"
67 "yvCpcXafsfcCAQE="
68 "-----END EC PARAMETERS-----";
69
70 if(name == "secp224r1")
71 return
72 "-----BEGIN EC PARAMETERS-----"
73 "MIHIAgEBMCgGByqGSM49AQECHQD/////////////////////AAAAAAAAAAAAAAAB"
74 "MDwEHP////////////////////7///////////////4EHLQFCoUMBLOr9UEyVlBE"
75 "sLfXv9i6Jws5QyNV/7QEOQS3Dgy9a7S/fzITkLlKA8HTVsIRIjQygNYRXB0hvTdj"
76 "iLX3I/tMIt/mzUN1oFoHR2RE1YGZhQB+NAIdAP//////////////////FqLguPA+"
77 "E90pRVxcKj0CAQE="
78 "-----END EC PARAMETERS-----";
79
80 if(name == "secp256k1")
81 return
82 "-----BEGIN EC PARAMETERS-----"
83 "MIHgAgEBMCwGByqGSM49AQECIQD////////////////////////////////////+"
84 "///8LzBEBCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQgAAAAAAAA"
85 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcEQQR5vmZ++dy7rFWgYpXOhwsHApv8"
86 "2y3OKNlZ8oFbFvgXmEg62ncmo8RlXaT7/A4RCKj9F7RIpoVUGZxH0I/7ENS4AiEA"
87 "/////////////////////rqu3OavSKA7v9JejNA2QUECAQE="
88 "-----END EC PARAMETERS-----";
89
90 if(name == "secp256r1")
91 return
92 "-----BEGIN EC PARAMETERS-----"
93 "MIHgAgEBMCwGByqGSM49AQECIQD/////AAAAAQAAAAAAAAAAAAAAAP//////////"
94 "/////zBEBCD/////AAAAAQAAAAAAAAAAAAAAAP///////////////AQgWsY12Ko6"
95 "k+ez671VdpiGvGUdBrDMU7D2O848PifSYEsEQQRrF9Hy4SxCR/i85uVjpEDydwN9"
96 "gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA"
97 "/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQE="
98 "-----END EC PARAMETERS-----";
99
100 if(name == "secp384r1")
101 return
102 "-----BEGIN EC PARAMETERS-----"
103 "MIIBQAIBATA8BgcqhkjOPQEBAjEA////////////////////////////////////"
104 "//////7/////AAAAAAAAAAD/////MGQEMP//////////////////////////////"
105 "///////////+/////wAAAAAAAAAA/////AQwszEvp+I+5+SYjgVr4/gtGRgdnG7+"
106 "gUESAxQIj1ATh1rGVjmNii7RnSqFyO3T7CrvBGEEqofKIr6LBTeOscce8yCtdG4d"
107 "O2KLp5uYWfdB4IJUKjhVAvJdv1UpbDpUXjhydgq3NhfeSpYmLG9dnpi/kpLcKfj0"
108 "Hb0omhR86doxE7XwuMAKYLHOHX6BnXpDHXyQ6g5fAjEA////////////////////"
109 "////////////x2NNgfQ3Ld9YGg2ySLCneuzsGWrMxSlzAgEB"
110 "-----END EC PARAMETERS-----";
111
112 if(name == "secp521r1")
113 return
114 "-----BEGIN EC PARAMETERS-----"
115 "MIIBrAIBATBNBgcqhkjOPQEBAkIB////////////////////////////////////"
116 "//////////////////////////////////////////////////8wgYgEQgH/////"
117 "////////////////////////////////////////////////////////////////"
118 "/////////////////ARCAFGVPrlhjhyaH5KaIaC2hUDuotpyW5mzFfO4tImRjvEJ"
119 "4VYZOVHsfpN7FlLAvTuxvwc1c9+IPSw08e9FH9RrUD8ABIGFBADGhY4GtwQE6c2e"
120 "PstmI5W0QpxkgTkFP7Uh+CivYGtNPbqhS1537+dZKP4dwSei/6jeM0izwYVqQpv5"
121 "fn4xwuW9ZgEYOSlqeJo7wARcil+0LH0b2Zj1RElXm0RoF6+9Fyc+ZiyX7nKZXvQm"
122 "QMVQuQE/rQdhNTxwhqJywkCIvpR2n9FmUAJCAf//////////////////////////"
123 "////////////////+lGGh4O/L5Zrf8wBSPcJpdA7tcm4iZxHrrtvtx6ROGQJAgEB"
124 "-----END EC PARAMETERS-----";
125
126 if(name == "brainpool160r1")
127 return
128 "-----BEGIN EC PARAMETERS-----"
129 "MIGYAgEBMCAGByqGSM49AQECFQDpXkpfc3BZ3GDfx62Vs9gTlRViDzAsBBQ0Dnvi"
130 "ooDrdOK+YbradF2X6PfDAAQUHliahZVCNBITT6otveyVyNhnXlgEKQS+1a8W6j9q"
131 "T2KTjEYx61r3vbzbwxZny0d6Go7DOPlHQWacl2MW2mMhAhUA6V5KX3NwWdxg31mR"
132 "1FApQJ5g/AkCAQE="
133 "-----END EC PARAMETERS-----";
134
135 if(name == "brainpool192r1")
136 return
137 "-----BEGIN EC PARAMETERS-----"
138 "MIGwAgEBMCQGByqGSM49AQECGQDDAvQdkyo2zaejRjCT0Y23j85HbeGoYpcwNAQY"
139 "apEXQHax4OGcOcAx/oaFwcrgQOXGmijvBBhGmijvfCjMo9xyHQRPRJa8yn70FG+/"
140 "JckEMQTAoGR+qrakh1OwM8VssPCQCi9cSFM3X9YUtpCGar1buItfSCjBSQAC5nc/"
141 "ovopm48CGQDDAvQdkyo2zaejRi+enpFrW+jxAprErMECAQE="
142 "-----END EC PARAMETERS-----";
143
144 if(name == "brainpool224r1")
145 return
146 "-----BEGIN EC PARAMETERS-----"
147 "MIHIAgEBMCgGByqGSM49AQECHQDXwTSqJkNmhioYMCV10deHsJ8HV5faifV+yMD/"
148 "MDwEHGil5iypzmwcKZgDpsFTC1FOGCrYsAQqWcrSn0MEHCWA9jzP5EE4hwcTsakj"
149 "aeM+ITXSZtuzcjhsQAsEOQQNkCmtLH5c9DQII7KofcaMnkzjF0webv3uEsB9WKpW"
150 "93LAcm8kxrieTs2sJDVLnpnKo/bTdhQCzQIdANfBNKomQ2aGKhgwJXXQ+5jRFrxL"
151 "bd68o6Wnk58CAQE="
152 "-----END EC PARAMETERS-----";
153
154 if(name == "brainpool256r1")
155 return
156 "-----BEGIN EC PARAMETERS-----"
157 "MIHgAgEBMCwGByqGSM49AQECIQCp+1fboe6pvD5mCpCdg41ybjv2I9UmICggE0gd"
158 "H25TdzBEBCB9Wgl1/CwwV+72dTBBev/n+4BVwSbcXGzpSktE8zC12QQgJtxcbOlK"
159 "S0TzMLXZu9d8v5WEFilc9+HOa8zcGP+MB7YEQQSL0q65y35XyyxLSC/8gbevud4n"
160 "4eO9I8I6RFO9ms4yYlR++DXD2sT9l/hGGhRhHcnCd0UTLe2OVFwdVMcvBGmXAiEA"
161 "qftX26Huqbw+ZgqQnYONcYw5eqO1Yab3kB4OgpdIVqcCAQE="
162 "-----END EC PARAMETERS-----";
163
164 if(name == "brainpool320r1")
165 return
166 "-----BEGIN EC PARAMETERS-----"
167 "MIIBEAIBATA0BgcqhkjOPQEBAikA015HIDa8T7fhPHhe0gHgZfmPz6b29A3vT5K5"
168 "7HiT7Cj81BKx8bMuJzBUBCg+4wtWj7qw+IPM69RtPzu4oqc1E/XredpmGQ6whf+p"
169 "9JLzdal9hg60BChSCIOUnf28QtOtGYZAaIpv4T9BNJVUtJrMMdzNiEU5gW9etKyP"
170 "sfGmBFEEQ71+mvtT2LhSibzEjuW/5vIBN9EKCH6254ceKhClmccQr40NOeIGERT9"
171 "0FVF7BzIq0CTJH93J14HQ//tEXGC6qnHeHeqrGrH01JF0WkujuECKQDTXkcgNrxP"
172 "t+E8eF7SAeBl+Y/PpbaPEqMtSC7H7oZY6YaRVVtExZMRAgEB"
173 "-----END EC PARAMETERS-----";
174
175 if(name == "brainpool384r1")
176 return
177 "-----BEGIN EC PARAMETERS-----"
178 "MIIBQAIBATA8BgcqhkjOPQEBAjEAjLkegqM4bSgPXW9+UOZB3xUvcQntVFa0ErHa"
179 "GX+3ESOs06cpkB0acYdHABMxB+xTMGQEMHvDgsY9jBUMPHIICs4Fr6DCvqKOT7In"
180 "hxORZe+6kfkPiqWBSlA61OsEqMfdIs4oJgQwBKjH3SLOKCaLObVUFvBEfC+3feEH"
181 "3NKmLogOpT7rYtV8tDkCldvJlDq3hpb6UEwRBGEEHRxk8GjPRf+ipjqBt8E/a4hH"
182 "o+d+8U/j23/K/gy9EOjoJuA0NtZGqu+HsuJH1K8eir4ddSD5wqRcseuOlc/VUmK3"
183 "Cyn+7Fhk4ZwFT/mRKSgORkYhd5GBEUKCA0EmPFMVAjEAjLkegqM4bSgPXW9+UOZB"
184 "3xUvcQntVFazHxZubKwEJafPOrava3/DEDuIMgLpBGVlAgEB"
185 "-----END EC PARAMETERS-----";
186
187 if(name == "brainpool512r1")
188 return
189 "-----BEGIN EC PARAMETERS-----"
190 "MIIBogIBATBMBgcqhkjOPQEBAkEAqt2duNvpxIs/1OauM8n8B8swjbOzydIO1mOc"
191 "ynAzCHF9TZsAm8ZoQq7NoSrmo4DmKIH/Ly2CxoUoqmBWWDpI8zCBhARAeDCjMYtg"
192 "O4niMnFFrCNMxZTL3Y09+RYQqDRByuqYY7wt7V1aqCU6oQou8cmLmsi1fxEXpyvy"
193 "x7nnwaxNd/yUygRAPfkWEKg0QcrqmGO8Le1dWqglOqEKLvHJi5rItX8RF6cr8se5"
194 "58GsTXf8lMrcCD5nmEBQt1665d0oCb1jgBb3IwSBgQSBruS92C7ZZFohMi6cTGqT"
195 "he2fcLXZFsG0O2Lu9NAJjv87H3ji0NSNUNFoe5O5fV98bVBHQGpeaIs1Igm8ufgi"
196 "fd44XVZjMuzA6r+pz3gi/fIJ9wAkpXsaoADFW4gfgRGy3N5JSl9IXlvKS9iKJ2Ou"
197 "0corL6jwVAZ4zR4POtgIkgJBAKrdnbjb6cSLP9TmrjPJ/AfLMI2zs8nSDtZjnMpw"
198 "MwhwVT5cQUypJhlBhmEZf6wQRx2x04EIXdrdtYeWgpypAGkCAQE="
199 "-----END EC PARAMETERS-----";
200
201 if(name == "x962_p192v2")
202 return
203 "-----BEGIN EC PARAMETERS-----"
204 "MIGwAgEBMCQGByqGSM49AQECGQD////////////////////+//////////8wNAQY"
205 "/////////////////////v/////////8BBjMItbfuVxrJeScDWNkpOWYDDk6ohZo"
206 "2VMEMQTuorrn4Ul4QvLed2nP6cmJwHKtaW9IA0pldNEdabbsemcruCoIPfLysIR9"
207 "6XCy3hUCGQD///////////////5fsack3IBBhkjY3TECAQE="
208 "-----END EC PARAMETERS-----";
209
210 if(name == "x962_p192v3")
211 return
212 "-----BEGIN EC PARAMETERS-----"
213 "MIGwAgEBMCQGByqGSM49AQECGQD////////////////////+//////////8wNAQY"
214 "/////////////////////v/////////8BBgiEj3COVoFyqdCPa7MyUdgp9RiJWvV"
215 "aRYEMQR9KXeBAMZaHaF4NxZYjc4ri0rujiKPGJY4qQ8iY3M3M0tJ3LZqbcj5l4rK"
216 "dkipQ7ACGQD///////////////96YtAxyD9ClPZA7BMCAQE="
217 "-----END EC PARAMETERS-----";
218
219 if(name == "x962_p239v1")
220 return
221 "-----BEGIN EC PARAMETERS-----"
222 "MIHSAgEBMCkGByqGSM49AQECHn///////////////3///////4AAAAAAAH//////"
223 "/zBABB5///////////////9///////+AAAAAAAB///////wEHmsBbDvc8YlB0NZU"
224 "khR1ynGp2y+yfR03eWGFwpQsCgQ9BA/6ljzcqIFszDO4ZCvt+QXD01hXPT8n+707"
225 "PLmqr33r6OTpCl2ubkBUylMLoEZUs2gYziJrOfzLewLxrgIef///////////////"
226 "f///nl6an12QcfvRUiaIkJ0LAgEB"
227 "-----END EC PARAMETERS-----";
228
229 if(name == "x962_p239v2")
230 return
231 "-----BEGIN EC PARAMETERS-----"
232 "MIHSAgEBMCkGByqGSM49AQECHn///////////////3///////4AAAAAAAH//////"
233 "/zBABB5///////////////9///////+AAAAAAAB///////wEHmF/q2gyV2y7/tUN"
234 "mfAknD/uWLlLoAOMeuhMjIMvLAQ9BDivCdmHJ3BRIMkhu16eJilqPNzy81dXoOr9"
235 "h7gw51sBJeTb6g7HIG2g/AHZsIEyn7VV3m70YCN9/4vkugIef///////////////"
236 "gAAAz6foWUN31BTAOCG8WCBjAgEB"
237 "-----END EC PARAMETERS-----";
238
239 if(name == "x962_p239v3")
240 return
241 "-----BEGIN EC PARAMETERS-----"
242 "MIHSAgEBMCkGByqGSM49AQECHn///////////////3///////4AAAAAAAH//////"
243 "/zBABB5///////////////9///////+AAAAAAAB///////wEHiVXBfoqMGZUsfTL"
244 "A9anUKMMJQEC1JiHF9m6FattPgQ9BGdoro4Yu5LPzwBclJqixtlIU9DmYLv4VLHJ"
245 "UF/pWhYH5omPOQwGvB1VK60ibztvz+SLboGEma8Y4+1s8wIef///////////////"
246 "f///l13rQbOmBXw8QyFGUmVRAgEB"
247 "-----END EC PARAMETERS-----";
248
249 if(name == "gost_256A")
250 return
251 "-----BEGIN EC PARAMETERS-----"
252 "MIHgAgEBMCwGByqGSM49AQECIQD/////////////////////////////////////"
253 "///9lzBEBCD////////////////////////////////////////9lAQgAAAAAAAA"
254 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKYEQQQAAAAAAAAAAAAAAAAAAAAAAAAA"
255 "AAAAAAAAAAAAAAAAAY2R5HHgmJzaJ99QWkU/K3Y1KU8t3yPjsSKsyZyenx4UAiEA"
256 "/////////////////////2xhEHCZWtEARYQbCbdhuJMCAQE="
257 "-----END EC PARAMETERS-----";
258
259 if(name == "frp256v1")
260 return
261 "-----BEGIN EC PARAMETERS-----"
262 "MIHgAgEBMCwGByqGSM49AQECIQDx/ReMCzrVjxASbejOQkNbOWGtvKvIym3o/PNT"
263 "2G6cAzBEBCDx/ReMCzrVjxASbejOQkNbOWGtvKvIym3o/PNT2G6cAAQg7jU/ylQo"
264 "qTANSrp1SkTAD9/sDJrksaGAMHXtlnt7tz8EQQS2s9TDVsE56zEYPUdJ1COVjCfS"
265 "3K+YtwFkyXot2Y9c/2FC4PfIsgSRH5Jx8PPs74wnAcMH6OTJ4YMRWhVUBiz7AiEA"
266 "8f0XjAs61Y8QEm3ozkJDW1PcZ+FA0r+UH/3UWcbWVeECAQE="
267 "-----END EC PARAMETERS-----";
268
269 #if defined(BOTAN_HOUSE_ECC_CURVE_NAME)
270 if(name == BOTAN_HOUSE_ECC_CURVE_NAME)
271 return BOTAN_HOUSE_ECC_CURVE_PEM;
272 #endif
273
274 return "";
275 }

bool Botan::EC_Group::verify_group | ( | RandomNumberGenerator & | rng,
|  | bool | strong = `false`
| ) |  | const

Verify EC_Group domain

Returns
  true if group is valid. false otherwise

Definition at line 134 of file ec_group.cpp.

References Botan::CurveGFp::get_a(), Botan::CurveGFp::get_b(), Botan::CurveGFp::get_p(), Botan::is_prime(), and Botan::PointGFp::on_the_curve().

Referenced by Botan::EC_PublicKey::check_key().

136 {
137 //compute the discriminant
138 Modular_Reducer p(m_curve.get_p());
139 BigInt discriminant = p.multiply(4, m_curve.get_a());
140 discriminant += p.multiply(27, m_curve.get_b());
141 discriminant = p.reduce(discriminant);
142 //check the discriminant
143 if(discriminant == 0)
144 {
145 return false;
146 }
147 //check for valid cofactor
148 if(m_cofactor < 1)
149 {
150 return false;
151 }
152 //check if the base point is on the curve
153 if(!m_base_point.on_the_curve())
154 {
155 return false;
156 }
157 if((m_base_point * m_cofactor).is_zero())
158 {
159 return false;
160 }
161 //check if order is prime
162 if(!is_prime(m_order, rng, 128))
163 {
164 return false;
165 }
166 //check if order of the base point is correct
167 if(!(m_base_point * m_order).is_zero())
168 {
169 return false;
170 }
171 return true;
172 }
Botan::CurveGFp::get_a
const BigInt & get_a() const
Definition: curve_gfp.h:80
Botan::CurveGFp::get_b
const BigInt & get_b() const
Definition: curve_gfp.h:85
Botan::is_prime
bool is_prime(const BigInt &n, RandomNumberGenerator &rng, size_t prob, bool is_random)
Definition: numthry.cpp:441
Botan::CurveGFp::get_p
const BigInt & get_p() const
Definition: curve_gfp.h:91
Botan::PointGFp::on_the_curve
bool on_the_curve() const
Definition: point_gfp.cpp:414

The documentation for this class was generated from the following files:

- src/lib/pubkey/ec_group/ec_group.h
- src/lib/pubkey/ec_group/ec_group.cpp
- src/lib/pubkey/ec_group/ec_named.cpp