Botan 3.8.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::function< void(std::span< uint8_t >)> expand_message) const override |
ProjectivePoint | hash_to_curve_ro (std::function< void(std::span< uint8_t >)> expand_message) const override |
ProjectivePoint | mul (const AffinePoint &pt, const Scalar &scalar, RandomNumberGenerator &rng) const override |
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 AffinePoint &a, const AffinePoint &b) const override |
AffinePoint | point_negate (const AffinePoint &pt) const override |
AffinePoint | point_to_affine (const ProjectivePoint &pt) const override |
PrimeOrderCurveImpl () | |
Scalar | random_scalar (RandomNumberGenerator &rng) const override |
Scalar | scalar_add (const Scalar &a, const Scalar &b) const override |
Scalar addition. | |
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 |
Test if two scalars are equal. | |
std::optional< Scalar > | scalar_from_wide_bytes (std::span< const uint8_t > bytes) const override |
Scalar | scalar_invert (const Scalar &ss) const override |
Scalar inversion. | |
Scalar | scalar_invert_vartime (const Scalar &ss) const override |
Scalar inversion (variable time) | |
bool | scalar_is_zero (const Scalar &s) const override |
Test if scalar is zero. | |
Scalar | scalar_mul (const Scalar &a, const Scalar &b) const override |
Scalar multiplication. | |
Scalar | scalar_negate (const Scalar &s) const override |
Scalar negation. | |
Scalar | scalar_one () const override |
Scalar | scalar_square (const Scalar &s) const override |
Scalar squaring. | |
Scalar | scalar_sub (const Scalar &a, const Scalar &b) const override |
Scalar subtraction. | |
void | serialize_point (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 > | for_named_curve (std::string_view name) |
static std::shared_ptr< const PrimeOrderCurve > | from_params (const BigInt &p, const BigInt &a, const BigInt &b, const BigInt &base_x, const BigInt &base_y, const BigInt &order) |
static std::shared_ptr< const PrimeOrderCurve > | instance () |
Static Public Attributes | |
static constexpr size_t | MaximumBitLength = 521 |
static constexpr size_t | MaximumByteLength = (MaximumBitLength + 7) / 8 |
static constexpr size_t | StorageWords = (MaximumByteLength + sizeof(word) - 1) / sizeof(word) |
Number of words used to store MaximumByteLength. | |
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 27 of file pcurves_wrap.h.
|
inherited |
|
inherited |
|
inline |
Definition at line 303 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 207 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 179 of file pcurves_wrap.h.
References Botan::to_affine_x().
|
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 239 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 221 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 36 of file pcurves_wrap.h.
|
staticinherited |
Definition at line 26 of file pcurves.cpp.
References BOTAN_UNUSED.
|
staticinherited |
This function should accept the same subset of curves as the EC_Group constructor that accepts BigInts.
Definition at line 15 of file pcurves.cpp.
References BOTAN_UNUSED.
|
inlineoverridevirtual |
Return the standard generator.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 187 of file pcurves_wrap.h.
|
inlineoverridevirtual |
RFC 9380 hash to curve (NU variant)
This is currently only supported for a few specific curves
expand_message | is a callback which must fill the provided output span with a sequence of uniform bytes, or if this is not possible due to length limitations or some other issue, throw an exception. It is invoked to produce the uniform_bytes value; see RFC 9380 section 5.2 |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 247 of file pcurves_wrap.h.
|
inlineoverridevirtual |
RFC 9380 hash to curve (RO variant)
This is currently only supported for a few specific curves
expand_message | is a callback which must fill the provided output span with a sequence of uniform bytes, or if this is not possible due to length limitations or some other issue, throw an exception. It is invoked to produce the uniform_bytes value; see RFC 9380 section 5.2 |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 255 of file pcurves_wrap.h.
|
inlinestatic |
Definition at line 305 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Generic point multiplication
Multiply an arbitrary point by a scalar
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 42 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 68 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 72 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 102 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 38 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 88 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 47 of file pcurves_wrap.h.
References Botan::to_affine_x().
|
inlineoverridevirtual |
Return the bit length of the group order.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 32 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 201 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 205 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 189 of file pcurves_wrap.h.
References BOTAN_ASSERT, and Botan::to_affine().
|
inlineoverridevirtual |
Return a new random scalar
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 301 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Scalar addition.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 263 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Return the byte length of the scalar element.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 34 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Test if two scalars are equal.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 295 of file pcurves_wrap.h.
|
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 231 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Scalar inversion.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 277 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Scalar inversion (variable time)
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 286 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Test if scalar is zero.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 293 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Scalar multiplication.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 271 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Scalar negation.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 291 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Return the scalar one
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 299 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Scalar squaring.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 275 of file pcurves_wrap.h.
References Botan::square().
|
inlineoverridevirtual |
Scalar subtraction.
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 267 of file pcurves_wrap.h.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 211 of file pcurves_wrap.h.
References BOTAN_ARG_CHECK.
|
inlineoverridevirtual |
Implements Botan::PCurve::PrimeOrderCurve.
Definition at line 216 of file pcurves_wrap.h.
References BOTAN_ARG_CHECK.
|
staticconstexprinherited |
|
staticconstexprinherited |
|
staticconstexprinherited |