BearSSL
|
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... | |
Type for an EC implementation.
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.
curve | curve identifier. |
len | receiver for the encoded generator length (in bytes). |
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:
Returned value is 1 on success, 0 on error. On error, the contents of G
are indeterminate.
G | point to multiply. |
Glen | length of the encoded point (in bytes). |
x | multiplier (unsigned big-endian). |
xlen | multiplier length (in bytes). |
curve | curve identifier. |
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:
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).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.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.Returned value is 1 on success, 0 on error. On error, the contents of A
are indeterminate.
A | first point to multiply. |
B | second point to multiply (NULL for the generator). |
len | common length of the encoded points (in bytes). |
x | multiplier for A (unsigned big-endian). |
xlen | length of multiplier for A (in bytes). |
y | multiplier for A (unsigned big-endian). |
ylen | length of multiplier for A (in bytes). |
curve | curve identifier. |
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.
R | output buffer for the point. |
x | multiplier (unsigned big-endian). |
xlen | multiplier length (in bytes). |
curve | curve identifier. |
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.
curve | curve identifier. |
len | receiver for the encoded order length (in bytes). |
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.
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.
curve | curve identifier. |
len | receiver for the X coordinate length (in bytes). |