BearSSL

Data Fields
br_ec_impl Struct Reference

Type for an EC implementation. More...

`#include <bearssl_ec.h>`

## 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

  curve | curve identifier.
  len | receiver 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

  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.

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

  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.

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

  R | output buffer for the point.
  x | multiplier (unsigned big-endian).
  xlen | multiplier length (in bytes).
  curve | curve 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

  curve | curve identifier.
  len | receiver 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

  curve | curve identifier.
  len | receiver 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:

- bearssl_ec.h