BearSSL
Data Fields
br_ec_impl Struct Reference

Type for an EC implementation. More...

Data Fields

uint32_t supported_curves
 Supported curves. More...
 
const unsigned char *(* generator )(int curve, size_t *len)
 Get the conventional generator. More...
 
const unsigned char *(* order )(int curve, size_t *len)
 Get the subgroup order. More...
 
size_t(* xoff )(int curve, size_t *len)
 Get the offset and length for the X coordinate. More...
 
uint32_t(* mul )(unsigned char *G, size_t Glen, const unsigned char *x, size_t xlen, int curve)
 Multiply a curve point by an integer. More...
 
size_t(* mulgen )(unsigned char *R, const unsigned char *x, size_t xlen, int curve)
 Multiply the generator by an integer. More...
 
uint32_t(* muladd )(unsigned char *A, const unsigned char *B, size_t len, const unsigned char *x, size_t xlen, const unsigned char *y, size_t ylen, int curve)
 Multiply two points by two integers and add the results. More...
 

Detailed Description

Type for an EC implementation.

Field Documentation

◆ generator

const unsigned char*(* br_ec_impl::generator) (int curve, size_t *len)

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.

Parameters
curvecurve identifier.
lenreceiver for the encoded generator length (in bytes).
Returns
the encoded generator.

◆ mul

uint32_t(* br_ec_impl::mul) (unsigned char *G, size_t Glen, const unsigned char *x, size_t xlen, int curve)

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.

Parameters
Gpoint to multiply.
Glenlength of the encoded point (in bytes).
xmultiplier (unsigned big-endian).
xlenmultiplier length (in bytes).
curvecurve identifier.
Returns
1 on success, 0 on error.

◆ muladd

uint32_t(* br_ec_impl::muladd) (unsigned char *A, const unsigned char *B, size_t len, const unsigned char *x, size_t xlen, const unsigned char *y, size_t ylen, int curve)

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.

Parameters
Afirst point to multiply.
Bsecond point to multiply (NULL for the generator).
lencommon length of the encoded points (in bytes).
xmultiplier for A (unsigned big-endian).
xlenlength of multiplier for A (in bytes).
ymultiplier for A (unsigned big-endian).
ylenlength of multiplier for A (in bytes).
curvecurve identifier.
Returns
1 on success, 0 on error.

◆ mulgen

size_t(* br_ec_impl::mulgen) (unsigned char *R, const unsigned char *x, size_t xlen, int curve)

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.

Parameters
Routput buffer for the point.
xmultiplier (unsigned big-endian).
xlenmultiplier length (in bytes).
curvecurve identifier.
Returns
encoded result point length (in bytes).

◆ order

const unsigned char*(* br_ec_impl::order) (int curve, size_t *len)

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.

Parameters
curvecurve identifier.
lenreceiver for the encoded order length (in bytes).
Returns
the encoded order.

◆ supported_curves

uint32_t br_ec_impl::supported_curves

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.

◆ xoff

size_t(* br_ec_impl::xoff) (int curve, size_t *len)

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.

Parameters
curvecurve identifier.
lenreceiver for the X coordinate length (in bytes).
Returns
the offset for the X coordinate (in bytes).

The documentation for this struct was generated from the following file: