Struct bearssl::br_ec_impl [] [src]

#[repr(C)]
pub struct br_ec_impl { pub supported_curves: u32, pub generator: Option<unsafe extern "C" fn(_: c_int, _: *mut usize) -> *const c_uchar>, pub order: Option<unsafe extern "C" fn(_: c_int, _: *mut usize) -> *const c_uchar>, pub xoff: Option<unsafe extern "C" fn(_: c_int, _: *mut usize) -> usize>, pub mul: Option<unsafe extern "C" fn(_: *mut c_uchar, _: usize, _: *const c_uchar, _: usize, _: c_int) -> u32>, pub mulgen: Option<unsafe extern "C" fn(_: *mut c_uchar, _: *const c_uchar, _: usize, _: c_int) -> usize>, pub muladd: Option<unsafe extern "C" fn(_: *mut c_uchar, _: *const c_uchar, _: usize, _: *const c_uchar, _: usize, _: *const c_uchar, _: usize, _: c_int) -> u32>, }

\brief Type for an EC implementation.

Fields

\brief Supported curves.

This word is a bitfield: bit x is set if the curve of ID x is supported. E.g. an implementation supporting both NIST P-256 (secp256r1, ID 23) and NIST P-384 (secp384r1, ID 24) will have value 0x01800000 in this field.

\brief Get the conventional generator.

This function returns the conventional generator (encoded curve point) for the specified curve. This function MUST NOT be called if the curve is not supported.

\param curve curve identifier. \param len receiver for the encoded generator length (in bytes). \return the encoded generator.

\brief Get the subgroup order.

This function returns the order of the subgroup generated by the conventional generator, for the specified curve. Unsigned big-endian encoding is used. This function MUST NOT be called if the curve is not supported.

\param curve curve identifier. \param len receiver for the encoded order length (in bytes). \return the encoded order.

\brief Get the offset and length for the X coordinate.

This function returns the offset and length (in bytes) of the X coordinate in an encoded non-zero point.

\param curve curve identifier. \param len receiver for the X coordinate length (in bytes). \return the offset for the X coordinate (in bytes).

\brief Multiply a curve point by an integer.

The source point is provided in array G (of size Glen bytes); the multiplication result is written over it. The multiplier x (of size xlen bytes) uses unsigned big-endian encoding.

Rules:

  • The specified curve MUST be supported.

  • The source point must be a valid point on the relevant curve subgroup (and not the "point at infinity" either). If this is not the case, then this function returns an error (0).

  • The multiplier integer MUST be non-zero and less than the curve subgroup order. If this property does not hold, then the result is indeterminate and an error code is not guaranteed.

Returned value is 1 on success, 0 on error. On error, the contents of G are indeterminate.

\param G point to multiply. \param Glen length of the encoded point (in bytes). \param x multiplier (unsigned big-endian). \param xlen multiplier length (in bytes). \param curve curve identifier. \return 1 on success, 0 on error.

\brief Multiply the generator by an integer.

The multiplier MUST be non-zero and less than the curve subgroup order. Results are indeterminate if this property does not hold.

\param R output buffer for the point. \param x multiplier (unsigned big-endian). \param xlen multiplier length (in bytes). \param curve curve identifier. \return encoded result point length (in bytes).

\brief Multiply two points by two integers and add the results.

The point x*A + y*B is computed and written back in the A array.

Rules:

  • The specified curve MUST be supported.

  • The source points (A and B) must be valid points on the relevant curve subgroup (and not the "point at infinity" either). If this is not the case, then this function returns an error (0).

  • If the B pointer is NULL, then the conventional subgroup generator is used. With some implementations, this may be faster than providing a pointer to the generator.

  • The multiplier integers (x and y) MUST be non-zero and less than the curve subgroup order. If either integer is zero, then an error is reported, but if one of them is not lower than the subgroup order, then the result is indeterminate and an error code is not guaranteed.

  • If the final result is the point at infinity, then an error is returned.

Returned value is 1 on success, 0 on error. On error, the contents of A are indeterminate.

\param A first point to multiply. \param B second point to multiply (NULL for the generator). \param len common length of the encoded points (in bytes). \param x multiplier for A (unsigned big-endian). \param xlen length of multiplier for A (in bytes). \param y multiplier for A (unsigned big-endian). \param ylen length of multiplier for A (in bytes). \param curve curve identifier. \return 1 on success, 0 on error.

Trait Implementations

impl Debug for br_ec_impl
[src]

[src]

Formats the value using the given formatter.

impl Copy for br_ec_impl
[src]

impl Clone for br_ec_impl
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more