44 #define MBEDTLS_ERR_ECP_BAD_INPUT_DATA -0x4F80 45 #define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL -0x4F00 46 #define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE -0x4E80 47 #define MBEDTLS_ERR_ECP_VERIFY_FAILED -0x4E00 48 #define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80 49 #define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00 50 #define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80 51 #define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00 54 #define MBEDTLS_ERR_ECP_HW_ACCEL_FAILED -0x4B80 56 #define MBEDTLS_ERR_ECP_IN_PROGRESS -0x4B00 94 #define MBEDTLS_ECP_DP_MAX 12 126 #if !defined(MBEDTLS_ECP_ALT) 192 #if defined(MBEDTLS_ECP_RESTARTABLE) 199 typedef struct mbedtls_ecp_restart_mul mbedtls_ecp_restart_mul_ctx;
206 typedef struct mbedtls_ecp_restart_muladd mbedtls_ecp_restart_muladd_ctx;
215 mbedtls_ecp_restart_mul_ctx *rsm;
216 mbedtls_ecp_restart_muladd_ctx *ma;
222 #define MBEDTLS_ECP_OPS_CHK 3 223 #define MBEDTLS_ECP_OPS_DBL 8 224 #define MBEDTLS_ECP_OPS_ADD 11 225 #define MBEDTLS_ECP_OPS_INV 120 238 int mbedtls_ecp_check_budget( const mbedtls_ecp_group *grp, 243 #define MBEDTLS_ECP_BUDGET( ops ) \ 244 MBEDTLS_MPI_CHK( mbedtls_ecp_check_budget( grp, rs_ctx, \ 245 (unsigned) (ops) ) ); 249 #define MBEDTLS_ECP_BUDGET( ops ) 264 #if !defined(MBEDTLS_ECP_MAX_BITS) 268 #define MBEDTLS_ECP_MAX_BITS 521 271 #define MBEDTLS_ECP_MAX_BYTES ( ( MBEDTLS_ECP_MAX_BITS + 7 ) / 8 ) 272 #define MBEDTLS_ECP_MAX_PT_LEN ( 2 * MBEDTLS_ECP_MAX_BYTES + 1 ) 274 #if !defined(MBEDTLS_ECP_WINDOW_SIZE) 294 #define MBEDTLS_ECP_WINDOW_SIZE 6 297 #if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM) 309 #define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 337 #define MBEDTLS_ECP_PF_UNCOMPRESSED 0 338 #define MBEDTLS_ECP_PF_COMPRESSED 1 343 #define MBEDTLS_ECP_TLS_NAMED_CURVE 3 345 #if defined(MBEDTLS_ECP_RESTARTABLE) 403 void mbedtls_ecp_set_max_ops(
unsigned max_ops );
411 int mbedtls_ecp_restart_is_enabled(
void );
516 #if defined(MBEDTLS_ECP_RESTARTABLE) 612 const char *x,
const char *y );
635 int format,
size_t *olen,
636 unsigned char *buf,
size_t buflen );
662 const unsigned char *buf,
size_t ilen );
684 const unsigned char **buf,
size_t len );
710 int format,
size_t *olen,
711 unsigned char *buf,
size_t blen );
750 const unsigned char **buf,
size_t len );
771 const unsigned char **buf,
793 unsigned char *buf,
size_t blen );
830 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng );
864 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng,
1009 int (*f_rng)(
void *,
unsigned char *,
size_t),
1042 int (*f_rng)(
void *,
unsigned char *,
size_t),
1070 int (*f_rng)(
void *,
unsigned char *,
size_t),
1087 int (*f_rng)(
void *,
unsigned char *,
size_t),
1110 #if defined(MBEDTLS_SELF_TEST) 1118 int mbedtls_ecp_self_test(
int verbose );
uint16_t tls_id
Definition: ecp.h:102
int(* modp)(mbedtls_mpi *)
Definition: ecp.h:182
int mbedtls_ecp_is_zero(mbedtls_ecp_point *pt)
This function checks if a point is the point at infinity.
mbedtls_mpi N
Definition: ecp.h:176
int mbedtls_ecp_mul_restartable(mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, mbedtls_ecp_restart_ctx *rs_ctx)
This function performs multiplication of a point by an integer: R = m * P in a restartable way.
int(* t_post)(mbedtls_ecp_point *, void *)
Definition: ecp.h:185
mbedtls_mpi Z
Definition: ecp.h:122
int mbedtls_ecp_muladd(mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, const mbedtls_mpi *n, const mbedtls_ecp_point *Q)
This function performs multiplication and addition of two points by integers: R = m * P + n * Q.
int mbedtls_ecp_check_pub_priv(const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv)
This function checks that the keypair objects pub and prv have the same group and the same public poi...
int mbedtls_ecp_point_read_binary(const mbedtls_ecp_group *grp, mbedtls_ecp_point *P, const unsigned char *buf, size_t ilen)
This function imports a point from unsigned binary data.
mbedtls_mpi Y
Definition: ecp.h:121
int mbedtls_ecp_muladd_restartable(mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, const mbedtls_mpi *n, const mbedtls_ecp_point *Q, mbedtls_ecp_restart_ctx *rs_ctx)
This function performs multiplication and addition of two points by integers: R = m * P + n * Q in a ...
mbedtls_ecp_group grp
Definition: ecp.h:328
struct mbedtls_ecp_curve_info mbedtls_ecp_curve_info
The ECP key-pair structure.
Definition: ecp.h:326
int mbedtls_ecp_set_zero(mbedtls_ecp_point *pt)
This function sets a point to the point at infinity.
int mbedtls_ecp_copy(mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
This function copies the contents of point Q into point P.
const mbedtls_ecp_group_id * mbedtls_ecp_grp_id_list(void)
This function retrieves the list of internal group identifiers of all supported curves in the order o...
int mbedtls_ecp_group_copy(mbedtls_ecp_group *dst, const mbedtls_ecp_group *src)
This function copies the contents of group src into group dst.
size_t nbits
Definition: ecp.h:178
struct mbedtls_ecp_group mbedtls_ecp_group
The ECP group structure.
int mbedtls_ecp_gen_keypair(mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates an ECP keypair.
void mbedtls_ecp_point_free(mbedtls_ecp_point *pt)
This function frees the components of a point.
int mbedtls_ecp_gen_privkey(const mbedtls_ecp_group *grp, mbedtls_mpi *d, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates a private key.
void mbedtls_ecp_keypair_init(mbedtls_ecp_keypair *key)
This function initializes a key pair as an invalid one.
size_t pbits
Definition: ecp.h:177
mbedtls_mpi X
Definition: ecp.h:120
Multi-precision integer library.
int mbedtls_ecp_gen_key(mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates an ECP key.
The ECP group structure.
Definition: ecp.h:167
int mbedtls_ecp_check_privkey(const mbedtls_ecp_group *grp, const mbedtls_mpi *d)
This function checks that an mbedtls_mpi is a valid private key for this curve.
mbedtls_ecp_group_id id
Definition: ecp.h:169
const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_grp_id(mbedtls_ecp_group_id grp_id)
This function retrieves curve information from an internal group identifier.
#define P(a, b, c, d, e, f, g, h, x, K)
Definition: sha256.c:193
int mbedtls_ecp_tls_write_group(const mbedtls_ecp_group *grp, size_t *olen, unsigned char *buf, size_t blen)
This function exports an elliptic curve as a TLS ECParameters record as defined in RFC 4492,...
void mbedtls_ecp_group_free(mbedtls_ecp_group *grp)
This function frees the components of an ECP group.
int mbedtls_ecp_mul(mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function performs a scalar multiplication of a point by an integer: R = m * P.
int mbedtls_ecp_check_pubkey(const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt)
This function checks that a point is a valid public key on this curve.
mbedtls_mpi A
Definition: ecp.h:171
mbedtls_mpi P
Definition: ecp.h:170
void mbedtls_ecp_keypair_free(mbedtls_ecp_keypair *key)
This function frees the components of a key pair.
struct mbedtls_ecp_keypair mbedtls_ecp_keypair
The ECP key-pair structure.
int mbedtls_ecp_tls_read_group(mbedtls_ecp_group *grp, const unsigned char **buf, size_t len)
This function sets up an ECP group context from a TLS ECParameters record as defined in RFC 4492,...
void mbedtls_ecp_restart_ctx
Definition: ecp.h:252
mbedtls_ecp_point Q
Definition: ecp.h:330
void * t_data
Definition: ecp.h:186
void mbedtls_ecp_point_init(mbedtls_ecp_point *pt)
This function initializes a point as zero.
mbedtls_ecp_group_id
Definition: ecp.h:71
int mbedtls_ecp_point_read_string(mbedtls_ecp_point *P, int radix, const char *x, const char *y)
This function imports a non-zero point from two ASCII strings.
int mbedtls_ecp_point_write_binary(const mbedtls_ecp_group *grp, const mbedtls_ecp_point *P, int format, size_t *olen, unsigned char *buf, size_t buflen)
This function exports a point into unsigned binary data.
const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_tls_id(uint16_t tls_id)
This function retrieves curve information from a TLS NamedCurve value.
int mbedtls_ecp_tls_read_point(const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt, const unsigned char **buf, size_t len)
This function imports a point from a TLS ECPoint record.
mbedtls_ecp_group_id grp_id
Definition: ecp.h:101
int mbedtls_ecp_tls_read_group_id(mbedtls_ecp_group_id *grp, const unsigned char **buf, size_t len)
This function extracts an elliptic curve group ID from a TLS ECParameters record as defined in RFC 44...
int mbedtls_ecp_gen_keypair_base(mbedtls_ecp_group *grp, const mbedtls_ecp_point *G, mbedtls_mpi *d, mbedtls_ecp_point *Q, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates a keypair with a configurable base point.
mbedtls_mpi d
Definition: ecp.h:329
unsigned int h
Definition: ecp.h:181
int mbedtls_ecp_point_cmp(const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
This function compares two points.
int mbedtls_ecp_tls_write_point(const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt, int format, size_t *olen, unsigned char *buf, size_t blen)
This function exports a point as a TLS ECPoint record defined in RFC 4492, Section 5....
size_t T_size
Definition: ecp.h:188
mbedtls_ecp_point * T
Definition: ecp.h:187
mbedtls_ecp_point G
Definition: ecp.h:175
MPI structure.
Definition: bignum.h:180
struct mbedtls_ecp_point mbedtls_ecp_point
The ECP point structure, in Jacobian coordinates.
#define R(t)
Definition: sha256.c:187
The ECP point structure, in Jacobian coordinates.
Definition: ecp.h:118
const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_name(const char *name)
This function retrieves curve information from a human-readable name.
const mbedtls_ecp_curve_info * mbedtls_ecp_curve_list(void)
This function retrieves the information defined in mbedtls_ecp_curve_info() for all supported curves ...
const char * name
Definition: ecp.h:104
int(* t_pre)(mbedtls_ecp_point *, void *)
Definition: ecp.h:184
int mbedtls_ecp_group_load(mbedtls_ecp_group *grp, mbedtls_ecp_group_id id)
This function sets up an ECP group context from a standardized set of domain parameters.
uint16_t bit_size
Definition: ecp.h:103
mbedtls_mpi B
Definition: ecp.h:173
void mbedtls_ecp_group_init(mbedtls_ecp_group *grp)
This function initializes an ECP group context without loading any domain parameters.