|
Botan
2.13.0
Crypto and TLS for C++11
|
#include <ec_group.h>
Public Member Functions | |
| bool | a_is_minus_3 () const |
| bool | a_is_zero () const |
| PointGFp | blinded_base_point_multiply (const BigInt &k, RandomNumberGenerator &rng, std::vector< BigInt > &ws) const |
| BigInt | blinded_base_point_multiply_x (const BigInt &k, RandomNumberGenerator &rng, std::vector< BigInt > &ws) const |
| PointGFp | blinded_var_point_multiply (const PointGFp &point, const BigInt &k, RandomNumberGenerator &rng, std::vector< BigInt > &ws) const |
| 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 BigInt &p, const BigInt &a, const BigInt &b, const BigInt &base_x, const BigInt &base_y, const BigInt &order, const BigInt &cofactor, const OID &oid=OID()) | |
| EC_Group (const std::vector< uint8_t > &ber_encoding) | |
| EC_Group (const OID &oid) | |
| EC_Group (const std::string &pem_or_oid) | |
| EC_Group () | |
| EC_Group (const EC_Group &)=default | |
| EC_Group (EC_Group &&)=default | |
| const BigInt & | get_a () const |
| const BigInt & | get_b () const |
| const PointGFp & | get_base_point () const |
| const BigInt & | get_cofactor () const |
| const CurveGFp & | get_curve () const |
| const OID & | get_curve_oid () const |
| const BigInt & | get_g_x () const |
| const BigInt & | get_g_y () const |
| std::string | get_oid () const |
| const BigInt & | get_order () const |
| size_t | get_order_bits () const |
| size_t | get_order_bytes () const |
| const BigInt & | get_p () const |
| size_t | get_p_bits () const |
| size_t | get_p_bytes () const |
| bool | initialized () const |
| BigInt | inverse_mod_order (const BigInt &x) const |
| BigInt | mod_order (const BigInt &x) const |
| BigInt | multiply_mod_order (const BigInt &x, const BigInt &y) const |
| BigInt | multiply_mod_order (const BigInt &x, const BigInt &y, const BigInt &z) const |
| EC_Group & | operator= (const EC_Group &)=default |
| EC_Group & | operator= (EC_Group &&)=default |
| bool | operator== (const EC_Group &other) const |
| PointGFp | OS2ECP (const uint8_t bits[], size_t len) const |
| template<typename Alloc > | |
| PointGFp | OS2ECP (const std::vector< uint8_t, Alloc > &vec) const |
| std::string | PEM_encode () const |
| PointGFp | point (const BigInt &x, const BigInt &y) const |
| PointGFp | point_multiply (const BigInt &x, const PointGFp &pt, const BigInt &y) const |
| size_t | point_size (PointGFp::Compression_Type format) const |
| BigInt | random_scalar (RandomNumberGenerator &rng) const |
| BigInt | square_mod_order (const BigInt &x) const |
| bool | verify_group (RandomNumberGenerator &rng, bool strong=false) const |
| bool | verify_public_element (const PointGFp &y) const |
| PointGFp | zero_point () const |
| ~EC_Group () | |
Static Public Member Functions | |
| static size_t | clear_registered_curve_data () |
| static std::shared_ptr< EC_Group_Data > | EC_group_info (const OID &oid) |
| static const std::set< std::string > & | known_named_groups () |
| static std::string | PEM_for_named_group (const std::string &name) |
Class representing an elliptic curve
The internal representation is stored in a shared_ptr, so copying an EC_Group is inexpensive.
Definition at line 40 of file ec_group.h.
|
inline |
Construct Domain paramers from specified parameters
| curve | elliptic curve |
| base_point | a base point |
| order | the order of the base point |
| cofactor | the cofactor |
Definition at line 52 of file ec_group.h.
| Botan::EC_Group::EC_Group | ( | const BigInt & | p, |
| const BigInt & | a, | ||
| const BigInt & | b, | ||
| const BigInt & | base_x, | ||
| const BigInt & | base_y, | ||
| const BigInt & | order, | ||
| const BigInt & | cofactor, | ||
| const OID & | oid = OID() |
||
| ) |
Construct Domain paramers from specified parameters
| p | the elliptic curve p |
| a | the elliptic curve a param |
| b | the elliptic curve b param |
| base_x | the x coordinate of the base point |
| base_y | the y coordinate of the base point |
| order | the order of the base point |
| cofactor | the cofactor |
| oid | an optional OID used to identify this curve |
Definition at line 399 of file ec_group.cpp.
|
explicit |
Decode a BER encoded ECC domain parameter set
| ber_encoding | the bytes of the BER encoding |
Definition at line 411 of file ec_group.cpp.
|
explicit |
Create an EC domain by OID (or throw if unknown)
| oid | the OID of the EC domain to create |
Definition at line 349 of file ec_group.cpp.
References Botan::OID::to_string().
|
explicit |
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")
| pem_or_oid | PEM-encoded data, or an OID |
Definition at line 356 of file ec_group.cpp.
References Botan::PEM_Code::decode_check_label(), Botan::OID::from_string(), and Botan::OID::has_value().
| Botan::EC_Group::EC_Group | ( | ) |
| Botan::EC_Group::~EC_Group | ( | ) |
Definition at line 344 of file ec_group.cpp.
|
default |
|
default |
| bool Botan::EC_Group::a_is_minus_3 | ( | ) | const |
Return if a == -3 mod p
Definition at line 428 of file ec_group.cpp.
| bool Botan::EC_Group::a_is_zero | ( | ) | const |
Return if a == 0 mod p
Definition at line 433 of file ec_group.cpp.
| PointGFp Botan::EC_Group::blinded_base_point_multiply | ( | const BigInt & | k, |
| RandomNumberGenerator & | rng, | ||
| std::vector< BigInt > & | ws | ||
| ) | const |
Blinded point multiplication, attempts resistance to side channels
| k | the scalar |
| rng | a random number generator |
| ws | a temp workspace |
Definition at line 554 of file ec_group.cpp.
Referenced by Botan::EC_PrivateKey::EC_PrivateKey().
| BigInt Botan::EC_Group::blinded_base_point_multiply_x | ( | const BigInt & | k, |
| RandomNumberGenerator & | rng, | ||
| std::vector< BigInt > & | ws | ||
| ) | const |
Blinded point multiplication, attempts resistance to side channels Returns just the x coordinate of the point
| k | the scalar |
| rng | a random number generator |
| ws | a temp workspace |
Definition at line 561 of file ec_group.cpp.
References Botan::PointGFp::get_affine_x(), and Botan::PointGFp::is_zero().
| PointGFp Botan::EC_Group::blinded_var_point_multiply | ( | const PointGFp & | point, |
| const BigInt & | k, | ||
| RandomNumberGenerator & | rng, | ||
| std::vector< BigInt > & | ws | ||
| ) | const |
Blinded point multiplication, attempts resistance to side channels
| point | input point |
| k | the scalar |
| rng | a random number generator |
| ws | a temp workspace |
Definition at line 577 of file ec_group.cpp.
References get_order(), and Botan::PointGFp_Var_Point_Precompute::mul().
|
static |
Definition at line 248 of file ec_group.cpp.
| std::vector< uint8_t > Botan::EC_Group::DER_encode | ( | EC_Group_Encoding | form | ) | const |
Create the DER encoding of this domain
| form | of encoding to use |
Definition at line 592 of file ec_group.cpp.
References Botan::EC_DOMPAR_ENC_EXPLICIT, Botan::EC_DOMPAR_ENC_IMPLICITCA, Botan::EC_DOMPAR_ENC_OID, Botan::OID::empty(), Botan::PEM_Code::encode(), Botan::DER_Encoder::encode(), Botan::BigInt::encode_1363(), Botan::DER_Encoder::encode_null(), Botan::DER_Encoder::end_cons(), get_a(), get_b(), get_base_point(), get_cofactor(), get_curve_oid(), get_order(), get_p(), get_p_bytes(), Botan::OCTET_STRING, Botan::SEQUENCE, Botan::DER_Encoder::start_cons(), and Botan::PointGFp::UNCOMPRESSED.
Referenced by PEM_encode().
|
static |
Definition at line 13 of file ec_named.cpp.
| const BigInt & Botan::EC_Group::get_a | ( | ) | const |
Return the a parameter of the elliptic curve equation
Definition at line 463 of file ec_group.cpp.
Referenced by DER_encode(), operator==(), Botan::sm2_compute_za(), and verify_group().
| const BigInt & Botan::EC_Group::get_b | ( | ) | const |
Return the b parameter of the elliptic curve equation
Definition at line 468 of file ec_group.cpp.
Referenced by DER_encode(), operator==(), Botan::sm2_compute_za(), and verify_group().
| const PointGFp & Botan::EC_Group::get_base_point | ( | ) | const |
Return group base point
Definition at line 473 of file ec_group.cpp.
Referenced by DER_encode(), Botan::EC_PrivateKey::EC_PrivateKey(), point_multiply(), and verify_group().
| const BigInt & Botan::EC_Group::get_cofactor | ( | ) | const |
Return the cofactor
Definition at line 493 of file ec_group.cpp.
Referenced by DER_encode(), Botan::ECIES_KA_Operation::derive_secret(), Botan::ECIES_Decryptor::ECIES_Decryptor(), verify_group(), and verify_public_element().
| const CurveGFp & Botan::EC_Group::get_curve | ( | ) | const |
Return domain parameter curve
Definition at line 423 of file ec_group.cpp.
Referenced by Botan::EC_PublicKey::EC_PublicKey().
| const OID & Botan::EC_Group::get_curve_oid | ( | ) | const |
Return the OID of these domain parameters
Definition at line 523 of file ec_group.cpp.
Referenced by DER_encode(), Botan::EC_PrivateKey::EC_PrivateKey(), Botan::EC_PublicKey::EC_PublicKey(), and Botan::EC_PublicKey::set_parameter_encoding().
| const BigInt & Botan::EC_Group::get_g_x | ( | ) | const |
Return the x coordinate of the base point
Definition at line 483 of file ec_group.cpp.
Referenced by operator==(), and Botan::sm2_compute_za().
| const BigInt & Botan::EC_Group::get_g_y | ( | ) | const |
Return the y coordinate of the base point
Definition at line 488 of file ec_group.cpp.
Referenced by operator==(), and Botan::sm2_compute_za().
|
inline |
Return the OID of these domain parameters
Definition at line 245 of file ec_group.h.
| const BigInt & Botan::EC_Group::get_order | ( | ) | const |
Return the order of the base point
Definition at line 478 of file ec_group.cpp.
Referenced by blinded_var_point_multiply(), DER_encode(), Botan::ECIES_KA_Operation::derive_secret(), Botan::ECIES_Decryptor::ECIES_Decryptor(), random_scalar(), verify_group(), and verify_public_element().
| size_t Botan::EC_Group::get_order_bits | ( | ) | const |
Return the size of group order in bits (same as get_order().bits())
Definition at line 448 of file ec_group.cpp.
| size_t Botan::EC_Group::get_order_bytes | ( | ) | const |
Return the size of p in bytes (same as get_order().bytes())
Definition at line 453 of file ec_group.cpp.
| const BigInt & Botan::EC_Group::get_p | ( | ) | const |
Return the prime modulus of the field
Definition at line 458 of file ec_group.cpp.
Referenced by DER_encode(), operator==(), and verify_group().
| size_t Botan::EC_Group::get_p_bits | ( | ) | const |
Return the size of p in bits (same as get_p().bits())
Definition at line 438 of file ec_group.cpp.
Referenced by Botan::GOST_3410_PublicKey::algo_name(), Botan::GOST_3410_PrivateKey::GOST_3410_PrivateKey(), Botan::GOST_3410_PublicKey::GOST_3410_PublicKey(), and Botan::EC_PublicKey::key_length().
| size_t Botan::EC_Group::get_p_bytes | ( | ) | const |
Return the size of p in bits (same as get_p().bytes())
Definition at line 443 of file ec_group.cpp.
Referenced by DER_encode(), point_size(), and Botan::sm2_compute_za().
|
inline |
Definition at line 321 of file ec_group.h.
Definition at line 518 of file ec_group.cpp.
Referenced by Botan::EC_PrivateKey::EC_PrivateKey(), and Botan::SM2_PrivateKey::SM2_PrivateKey().
|
static |
Definition at line 498 of file ec_group.cpp.
Definition at line 508 of file ec_group.cpp.
| BigInt Botan::EC_Group::multiply_mod_order | ( | const BigInt & | x, |
| const BigInt & | y, | ||
| const BigInt & | z | ||
| ) | const |
Definition at line 513 of file ec_group.cpp.
| bool Botan::EC_Group::operator== | ( | const EC_Group & | other | ) | const |
| PointGFp Botan::EC_Group::OS2ECP | ( | const uint8_t | bits[], |
| size_t | len | ||
| ) | const |
Definition at line 537 of file ec_group.cpp.
References Botan::OS2ECP().
Referenced by Botan::EC_PrivateKey::EC_PrivateKey(), Botan::EC_PublicKey::EC_PublicKey(), Botan::ECIES_Encryptor::ECIES_Encryptor(), and Botan::TLS::Callbacks::tls_ecdh_agree().
|
inline |
Definition at line 316 of file ec_group.h.
References Botan::OS2ECP().
| std::string Botan::EC_Group::PEM_encode | ( | ) | const |
Return the PEM encoding (always in explicit form)
Definition at line 643 of file ec_group.cpp.
References DER_encode(), Botan::EC_DOMPAR_ENC_EXPLICIT, and Botan::PEM_Code::encode().
Referenced by PEM_for_named_group().
|
static |
Return PEM representation of named EC group Deprecated: Use EC_Group(name).PEM_encode() if this is needed
Definition at line 386 of file ec_group.cpp.
References PEM_encode().
Return a point on this curve with the affine values x, y
Definition at line 542 of file ec_group.cpp.
Referenced by Botan::GOST_3410_PublicKey::GOST_3410_PublicKey().
| PointGFp Botan::EC_Group::point_multiply | ( | const BigInt & | x, |
| const PointGFp & | pt, | ||
| const BigInt & | y | ||
| ) | const |
Multi exponentiate. Not constant time.
Definition at line 548 of file ec_group.cpp.
References get_base_point(), and Botan::PointGFp_Multi_Point_Precompute::multi_exp().
| size_t Botan::EC_Group::point_size | ( | PointGFp::Compression_Type | format | ) | const |
Definition at line 528 of file ec_group.cpp.
References Botan::PointGFp::COMPRESSED, and get_p_bytes().
| BigInt Botan::EC_Group::random_scalar | ( | RandomNumberGenerator & | rng | ) | const |
Return a random scalar ie an integer in [1,order)
Definition at line 572 of file ec_group.cpp.
References get_order(), and Botan::BigInt::random_integer().
Referenced by Botan::EC_PrivateKey::EC_PrivateKey().
Definition at line 503 of file ec_group.cpp.
| bool Botan::EC_Group::verify_group | ( | RandomNumberGenerator & | rng, |
| bool | strong = false |
||
| ) | const |
Verify EC_Group domain
Definition at line 688 of file ec_group.cpp.
References Botan::Modular_Reducer::cube(), get_a(), get_b(), get_base_point(), get_cofactor(), get_order(), get_p(), Botan::is_prime(), Botan::Modular_Reducer::multiply(), Botan::PointGFp::on_the_curve(), Botan::Modular_Reducer::reduce(), and Botan::Modular_Reducer::square().
Referenced by Botan::EC_PublicKey::check_key().
| bool Botan::EC_Group::verify_public_element | ( | const PointGFp & | y | ) | const |
Check if y is a plausible point on the curve
In particular, checks that it is a point on the curve, not infinity, and that it has order matching the group.
Definition at line 665 of file ec_group.cpp.
References get_cofactor(), get_order(), Botan::PointGFp::is_zero(), and Botan::PointGFp::on_the_curve().
Referenced by Botan::EC_PublicKey::check_key().
| PointGFp Botan::EC_Group::zero_point | ( | ) | const |
Return the zero (or infinite) point on this curve
Definition at line 586 of file ec_group.cpp.
1.8.9.1