Botan 3.7.1
Crypto and TLS for C&
|
#include <pcurves_wrap.h>
Classes | |
class | PrecomputedMul2TableC |
Public Types | |
typedef std::shared_ptr< const PrimeOrderCurve > | CurvePtr |
typedef std::array< word, StorageWords > | StorageUnit |
Public Member Functions | |
bool | affine_point_is_identity (const AffinePoint &pt) const override |
Scalar | base_point_mul_x_mod_order (const Scalar &scalar, RandomNumberGenerator &rng) const override |
std::optional< AffinePoint > | deserialize_point (std::span< const uint8_t > bytes) const override |
std::optional< Scalar > | deserialize_scalar (std::span< const uint8_t > bytes) const override |
size_t | field_element_bytes () const override |
AffinePoint | generator () const override |
Return the standard generator. | |
AffinePoint | hash_to_curve_nu (std::string_view hash, std::span< const uint8_t > input, std::span< const uint8_t > domain_sep) const override |
ProjectivePoint | hash_to_curve_ro (std::string_view hash, std::span< const uint8_t > input, std::span< const uint8_t > domain_sep) const override |
ProjectivePoint | mul (const AffinePoint &pt, const Scalar &scalar, RandomNumberGenerator &rng) const override |
std::unique_ptr< const PrecomputedMul2Table > | mul2_setup (const AffinePoint &p, const AffinePoint &q) const override |
Setup a table for 2-ary multiplication. | |
std::unique_ptr< const PrecomputedMul2Table > | mul2_setup_g (const AffinePoint &q) const override |
Setup a table for 2-ary multiplication where the first point is the generator. | |
std::optional< ProjectivePoint > | mul2_vartime (const PrecomputedMul2Table &tableb, const Scalar &x, const Scalar &y) const override |
bool | mul2_vartime_x_mod_order_eq (const PrecomputedMul2Table &tableb, const Scalar &v, const Scalar &x, const Scalar &y) const override |
ProjectivePoint | mul_by_g (const Scalar &scalar, RandomNumberGenerator &rng) const override |
std::optional< ProjectivePoint > | mul_px_qy (const AffinePoint &p, const Scalar &x, const AffinePoint &q, const Scalar &y, RandomNumberGenerator &rng) const override |
secure_vector< uint8_t > | mul_x_only (const AffinePoint &pt, const Scalar &scalar, RandomNumberGenerator &rng) const override |
size_t | order_bits () const override |
Return the bit length of the group order. | |
ProjectivePoint | point_add (const ProjectivePoint &a, const ProjectivePoint &b) const override |
ProjectivePoint | point_add_mixed (const ProjectivePoint &a, const AffinePoint &b) const override |
ProjectivePoint | point_double (const ProjectivePoint &pt) const override |
AffinePoint | point_negate (const AffinePoint &pt) const override |
AffinePoint | point_to_affine (const ProjectivePoint &pt) const override |
ProjectivePoint | point_to_projective (const AffinePoint &pt) const override |
PrimeOrderCurveImpl () | |
Scalar | random_scalar (RandomNumberGenerator &rng) const override |
Scalar | scalar_add (const Scalar &a, const Scalar &b) const override |
size_t | scalar_bytes () const override |
Return the byte length of the scalar element. | |
bool | scalar_equal (const Scalar &a, const Scalar &b) const override |
std::optional< Scalar > | scalar_from_wide_bytes (std::span< const uint8_t > bytes) const override |
Scalar | scalar_invert (const Scalar &ss) const override |
Scalar | scalar_invert_vartime (const Scalar &ss) const override |
bool | scalar_is_zero (const Scalar &s) const override |
Scalar | scalar_mul (const Scalar &a, const Scalar &b) const override |
Scalar | scalar_negate (const Scalar &s) const override |
Scalar | scalar_one () const override |
Scalar | scalar_square (const Scalar &s) const override |
Scalar | scalar_sub (const Scalar &a, const Scalar &b) const override |
Scalar | scalar_zero () const override |
void | serialize_point (std::span< uint8_t > bytes, const AffinePoint &pt) const override |
void | serialize_point_compressed (std::span< uint8_t > bytes, const AffinePoint &pt) const override |
void | serialize_point_x (std::span< uint8_t > bytes, const AffinePoint &pt) const override |
void | serialize_scalar (std::span< uint8_t > bytes, const Scalar &scalar) const override |
Static Public Member Functions | |
static std::shared_ptr< const PrimeOrderCurve > | from_id (PrimeOrderCurveId id) |
static std::shared_ptr< const PrimeOrderCurve > | from_name (std::string_view name) |
static std::shared_ptr< const PrimeOrderCurve > | instance () |
Static Public Attributes | |
static constexpr size_t | BasePointWindowBits = 5 |
static const size_t | MaximumBitLength = 521 |
static const size_t | MaximumByteLength = (MaximumBitLength + 7) / 8 |
static constexpr size_t | Mul2PrecompWindowBits = 3 |
static constexpr size_t | Mul2WindowBits = 2 |
static const size_t | StorageWords = (MaximumByteLength + sizeof(word) - 1) / sizeof(word) |
Number of words used to store MaximumByteLength. | |
static constexpr size_t | VarPointWindowBits = 4 |
This class provides a bridge between the "public" (actually still internal) PrimeOrderCurve type, and the inner templates which are subclasses of EllipticCurve from pcurves_impl.h
Definition at line 26 of file pcurves_wrap.h.
|
inherited |
|
inherited |
|
inline |
Definition at line 336 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 218 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Base point multiplication, returning only the x coordinate modulo the group order
Multiply by the standard generator point g, then extract the x coordinate as an integer, then reduce the x coordinate modulo the group order
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 188 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Deserialize a point
Both compressed and uncompressed encodings are accepted
Note that the deprecated "hybrid" encoding is not supported here
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 261 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Deserialize a scalar in [1,p)
This function requires the input length be exactly scalar_bytes long; it does not accept inputs that are shorter, or with excess leading zero padding bytes.
This function also rejects zero as an input, since in normal usage scalars are integers in Z_p*
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 243 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Return the byte length of a field element
Each point consists of two field elements
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 40 of file pcurves_wrap.h.
|
staticinherited |
Definition at line 101 of file pcurves.cpp.
References Botan::PCurve::PCurveInstance::brainpool256r1(), Botan::PCurve::PrimeOrderCurveId::brainpool256r1, Botan::PCurve::PCurveInstance::brainpool384r1(), Botan::PCurve::PrimeOrderCurveId::brainpool384r1, Botan::PCurve::PCurveInstance::brainpool512r1(), Botan::PCurve::PrimeOrderCurveId::brainpool512r1, Botan::PCurve::PCurveInstance::frp256v1(), Botan::PCurve::PrimeOrderCurveId::frp256v1, Botan::PCurve::PCurveInstance::numsp512d1(), Botan::PCurve::PrimeOrderCurveId::numsp512d1, Botan::PCurve::PCurveInstance::secp192r1(), Botan::PCurve::PrimeOrderCurveId::secp192r1, Botan::PCurve::PCurveInstance::secp224r1(), Botan::PCurve::PrimeOrderCurveId::secp224r1, Botan::PCurve::PCurveInstance::secp256k1(), Botan::PCurve::PrimeOrderCurveId::secp256k1, Botan::PCurve::PCurveInstance::secp256r1(), Botan::PCurve::PrimeOrderCurveId::secp256r1, Botan::PCurve::PCurveInstance::secp384r1(), Botan::PCurve::PrimeOrderCurveId::secp384r1, Botan::PCurve::PCurveInstance::secp521r1(), Botan::PCurve::PrimeOrderCurveId::secp521r1, Botan::PCurve::PCurveInstance::sm2p256v1(), and Botan::PCurve::PrimeOrderCurveId::sm2p256v1.
Referenced by Botan::PCurve::PrimeOrderCurve::from_name().
|
inlinestaticinherited |
Definition at line 44 of file pcurves.h.
References Botan::PCurve::PrimeOrderCurve::from_id(), Botan::PCurve::PrimeOrderCurveId::from_string(), and name.
|
inlineoverridevirtual |
Return the standard generator.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 196 of file pcurves_wrap.h.
|
inlineoverridevirtual |
RFC 9380 hash to curve (NU variant)
This is currently only supported for a few specific curves
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 269 of file pcurves_wrap.h.
|
inlineoverridevirtual |
RFC 9380 hash to curve (RO variant)
This is currently only supported for a few specific curves
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 279 of file pcurves_wrap.h.
|
inlinestatic |
Definition at line 338 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Generic point multiplication
Multiply an arbitrary point by a scalar
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 46 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Setup a table for 2-ary multiplication.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 72 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Setup a table for 2-ary multiplication where the first point is the generator.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 77 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Perform 2-ary multiplication (variable time)
Compute p*x + q*y in variable time
Returns nullopt if the produced point is the point at infinity
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 81 of file pcurves_wrap.h.
References Botan::PCurve::PrimeOrderCurveImpl< C >::PrecomputedMul2TableC::table().
|
inlineoverridevirtual |
Perform 2-ary multiplication (variable time), reducing x modulo order
Compute p*x + q*y in variable time, then extract the x coordinate of the result, and reduce x modulo the group order. Compare that value with v. If equal, returns true. Otherwise returns false, including if the produced point is the point at infinity
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 111 of file pcurves_wrap.h.
References Botan::bigint_ct_is_lt(), and Botan::PCurve::PrimeOrderCurveImpl< C >::PrecomputedMul2TableC::table().
|
inlineoverridevirtual |
Base point multiplication
Multiply by the standard generator point g
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 42 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Perform 2-ary multiplication (constant time)
Compute p*x + q*y
Returns nullopt if the produced point is the point at infinity
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 97 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Generic x-only point multiplication
Multiply an arbitrary point by a scalar, returning only the x coordinate
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 51 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Return the bit length of the group order.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 36 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 208 of file pcurves_wrap.h.
References Botan::b.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 212 of file pcurves_wrap.h.
References Botan::b.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 206 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 216 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 198 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 202 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Return a new random scalar
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 334 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 289 of file pcurves_wrap.h.
References Botan::b.
|
inlineoverridevirtual |
Return the byte length of the scalar element.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 38 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 326 of file pcurves_wrap.h.
References Botan::b.
|
inlineoverridevirtual |
Reduce an integer modulo the group order
The input can be at most twice the bit length of the order; if larger than this nullopt is returned
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 253 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 303 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 312 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 324 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 297 of file pcurves_wrap.h.
References Botan::b.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 322 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Return the scalar one
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 332 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 301 of file pcurves_wrap.h.
References Botan::square().
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 293 of file pcurves_wrap.h.
References Botan::b.
|
inlineoverridevirtual |
Return the scalar zero
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 330 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 222 of file pcurves_wrap.h.
References BOTAN_ARG_CHECK.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 227 of file pcurves_wrap.h.
References BOTAN_ARG_CHECK.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 233 of file pcurves_wrap.h.
References BOTAN_ARG_CHECK.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 238 of file pcurves_wrap.h.
References BOTAN_ARG_CHECK.
|
staticconstexpr |
Definition at line 28 of file pcurves_wrap.h.
|
staticinherited |
|
staticinherited |
|
staticconstexpr |
Definition at line 30 of file pcurves_wrap.h.
|
staticconstexpr |
Definition at line 31 of file pcurves_wrap.h.
|
staticinherited |
|
staticconstexpr |
Definition at line 29 of file pcurves_wrap.h.