31 #define MBEDTLS_ERR_ECP_BAD_INPUT_DATA -0x4F80
32 #define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL -0x4F00
33 #define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE -0x4E80
34 #define MBEDTLS_ERR_ECP_VERIFY_FAILED -0x4E00
35 #define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80
36 #define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00
37 #define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80
38 #define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00
40 #if defined( MBEDTLS_ECP_ALT )
82 #define MBEDTLS_ECP_DP_MAX 12
179 #if !defined(MBEDTLS_ECP_MAX_BITS)
183 #define MBEDTLS_ECP_MAX_BITS 521
186 #define MBEDTLS_ECP_MAX_BYTES ( ( MBEDTLS_ECP_MAX_BITS + 7 ) / 8 )
187 #define MBEDTLS_ECP_MAX_PT_LEN ( 2 * MBEDTLS_ECP_MAX_BYTES + 1 )
189 #if !defined(MBEDTLS_ECP_WINDOW_SIZE)
210 #define MBEDTLS_ECP_WINDOW_SIZE 6
213 #if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM)
225 #define MBEDTLS_ECP_FIXED_POINT_OPTIM 1
233 #define MBEDTLS_ECP_PF_UNCOMPRESSED 0
234 #define MBEDTLS_ECP_PF_COMPRESSED 1
239 #define MBEDTLS_ECP_TLS_NAMED_CURVE 3
247 const mbedtls_ecp_curve_info *mbedtls_ecp_curve_list( void );
382 const char *x,
const char *y );
399 int format,
size_t *olen,
400 unsigned char *buf,
size_t buflen );
421 const unsigned char *buf,
size_t ilen );
438 const unsigned char **buf,
size_t len );
455 int format,
size_t *olen,
456 unsigned char *buf,
size_t blen );
500 unsigned char *buf,
size_t blen );
530 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng );
614 int (*f_rng)(
void *,
unsigned char *,
size_t),
634 int (*f_rng)(
void *,
unsigned char *,
size_t),
649 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng );
663 #if defined(MBEDTLS_SELF_TEST)
669 int mbedtls_ecp_self_test(
int verbose );
int mbedtls_ecp_is_zero(mbedtls_ecp_point *pt)
Tell if a point is zero.
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)
Multiplication and addition of two points by integers: R = m * P + n * Q (Not thread-safe to use same...
int mbedtls_ecp_check_pub_priv(const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv)
Check a public-private key pair.
int mbedtls_ecp_point_read_binary(const mbedtls_ecp_group *grp, mbedtls_ecp_point *P, const unsigned char *buf, size_t ilen)
Import a point from unsigned binary data.
int mbedtls_ecp_group_load(mbedtls_ecp_group *grp, mbedtls_ecp_group_id index)
Set a group using well-known domain parameters.
Elliptic curves over GF(p)
int mbedtls_ecp_set_zero(mbedtls_ecp_point *pt)
Set a point to zero.
int mbedtls_ecp_copy(mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
Copy the contents of point Q into P.
const mbedtls_ecp_group_id * mbedtls_ecp_grp_id_list(void)
Get the list of supported curves in order of preferrence (grp_id only)
int mbedtls_ecp_group_copy(mbedtls_ecp_group *dst, const mbedtls_ecp_group *src)
Copy the contents of a group object.
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)
Generate a keypair.
void mbedtls_ecp_point_free(mbedtls_ecp_point *pt)
Free the components of a point.
void mbedtls_ecp_keypair_init(mbedtls_ecp_keypair *key)
Initialize a key pair (as an invalid one)
Curve information for use by other modules.
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)
Generate a keypair.
int mbedtls_ecp_check_privkey(const mbedtls_ecp_group *grp, const mbedtls_mpi *d)
Check that an mbedtls_mpi is a valid private key for this curve.
const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_grp_id(mbedtls_ecp_group_id grp_id)
Get curve information from an internal group identifier.
int mbedtls_ecp_tls_write_group(const mbedtls_ecp_group *grp, size_t *olen, unsigned char *buf, size_t blen)
Write the TLS ECParameters record for a group.
void mbedtls_ecp_group_free(mbedtls_ecp_group *grp)
Free 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)
Multiplication by an integer: R = m * P (Not thread-safe to use same group in multiple threads) ...
int mbedtls_ecp_check_pubkey(const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt)
Check that a point is a valid public key on this curve.
void mbedtls_ecp_keypair_free(mbedtls_ecp_keypair *key)
Free the components of a key pair.
int mbedtls_ecp_tls_read_group(mbedtls_ecp_group *grp, const unsigned char **buf, size_t len)
Set a group from a TLS ECParameters record.
void mbedtls_ecp_point_init(mbedtls_ecp_point *pt)
Initialize a point (as zero)
mbedtls_ecp_group_id
Domain parameters (curve, subgroup and generator) identifiers.
int mbedtls_ecp_point_read_string(mbedtls_ecp_point *P, int radix, const char *x, const char *y)
Import 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)
Export a point into unsigned binary data.
const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_tls_id(uint16_t tls_id)
Get 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)
Import a point from a TLS ECPoint record.
mbedtls_ecp_group_id grp_id
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)
Generate a keypair with configurable base point.
int mbedtls_ecp_point_cmp(const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
Compare 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)
Export a point as a TLS ECPoint record.
ECP point structure (jacobian coordinates)
const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_name(const char *name)
Get curve information from a human-readable name.
void mbedtls_ecp_group_init(mbedtls_ecp_group *grp)
Initialize a group (to something meaningless)