Loading...
Searching...
No Matches
ecp.h
Go to the documentation of this file.
/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
#ifndef MBEDTLS_ECP_H
#define MBEDTLS_ECP_H
#include "mbedtls/private_access.h"
#include "mbedtls/build_info.h"
#include "mbedtls/platform_util.h"
#include "mbedtls/bignum.h"
/*
* ECP error codes
*/
#define MBEDTLS_ERR_ECP_BAD_INPUT_DATA -0x4F80
#define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL -0x4F00
#define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE -0x4E80
#define MBEDTLS_ERR_ECP_VERIFY_FAILED -0x4E00
#define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80
#define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00
#define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80
#define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00
#define MBEDTLS_ERR_ECP_IN_PROGRESS -0x4B00
/* Flags indicating whether to include code that is specific to certain
* types of curves. These flags are for internal library use only. */
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
#define MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED
#endif
#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) || \
defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
#define MBEDTLS_ECP_MONTGOMERY_ENABLED
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Note: when adding a new curve:
* - Add it at the end of this enum, otherwise you'll break the ABI by
* changing the numerical value for existing curves.
* - Increment MBEDTLS_ECP_DP_MAX below if needed.
* - Update the calculation of MBEDTLS_ECP_MAX_BITS below.
* - Add the corresponding MBEDTLS_ECP_DP_xxx_ENABLED macro definition to
* mbedtls_config.h.
* - List the curve as a dependency of MBEDTLS_ECP_C and
* MBEDTLS_ECDSA_C if supported in check_config.h.
* - Add the curve to the appropriate curve type macro
* MBEDTLS_ECP_yyy_ENABLED above.
* - Add the necessary definitions to ecp_curves.c.
* - Add the curve to the ecp_supported_curves array in ecp.c.
* - Add the curve to applicable profiles in x509_crt.c.
* - Add the curve to applicable presets in ssl_tls.c.
*/
typedef enum {
MBEDTLS_ECP_DP_NONE = 0,
MBEDTLS_ECP_DP_SECP192R1,
MBEDTLS_ECP_DP_SECP224R1,
MBEDTLS_ECP_DP_SECP256R1,
MBEDTLS_ECP_DP_SECP384R1,
MBEDTLS_ECP_DP_SECP521R1,
MBEDTLS_ECP_DP_BP256R1,
MBEDTLS_ECP_DP_BP384R1,
MBEDTLS_ECP_DP_BP512R1,
MBEDTLS_ECP_DP_CURVE25519,
MBEDTLS_ECP_DP_SECP192K1,
MBEDTLS_ECP_DP_SECP224K1,
MBEDTLS_ECP_DP_SECP256K1,
MBEDTLS_ECP_DP_CURVE448,
} mbedtls_ecp_group_id;
#define MBEDTLS_ECP_DP_MAX 14
/*
* Curve types
*/
typedef enum {
MBEDTLS_ECP_TYPE_NONE = 0,
MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS, /* y^2 = x^3 + a x + b */
MBEDTLS_ECP_TYPE_MONTGOMERY, /* y^2 = x^3 + a x^2 + x */
} mbedtls_ecp_curve_type;
typedef struct mbedtls_ecp_curve_info {
mbedtls_ecp_group_id grp_id;
uint16_t tls_id;
uint16_t bit_size;
const char *name;
} mbedtls_ecp_curve_info;
typedef struct mbedtls_ecp_point {
mbedtls_mpi MBEDTLS_PRIVATE(X);
mbedtls_mpi MBEDTLS_PRIVATE(Y);
mbedtls_mpi MBEDTLS_PRIVATE(Z);
}
mbedtls_ecp_point;
#if !defined(MBEDTLS_ECP_ALT)
/*
* default Mbed TLS elliptic curve arithmetic implementation
*
* (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an
* alternative implementation for the whole module and it will replace this
* one.)
*/
typedef struct mbedtls_ecp_group {
mbedtls_ecp_group_id id;
mbedtls_mpi P;
mbedtls_mpi A;
mbedtls_mpi B;
mbedtls_ecp_point G;
mbedtls_mpi N;
size_t pbits;
size_t nbits;
/* End of public fields */
unsigned int MBEDTLS_PRIVATE(h);
int(*MBEDTLS_PRIVATE(modp))(mbedtls_mpi *);
int(*MBEDTLS_PRIVATE(t_pre))(mbedtls_ecp_point *, void *);
int(*MBEDTLS_PRIVATE(t_post))(mbedtls_ecp_point *, void *);
void *MBEDTLS_PRIVATE(t_data);
mbedtls_ecp_point *MBEDTLS_PRIVATE(T);
size_t MBEDTLS_PRIVATE(T_size);
}
mbedtls_ecp_group;
#if !defined(MBEDTLS_ECP_WINDOW_SIZE)
/*
* Maximum "window" size used for point multiplication.
* Default: a point where higher memory usage yields diminishing performance
* returns.
* Minimum value: 2. Maximum value: 7.
*
* Result is an array of at most ( 1 << ( MBEDTLS_ECP_WINDOW_SIZE - 1 ) )
* points used for point multiplication. This value is directly tied to EC
* peak memory usage, so decreasing it by one should roughly cut memory usage
* by two (if large curves are in use).
*
* Reduction in size may reduce speed, but larger curves are impacted first.
* Sample performances (in ECDHE handshakes/s, with FIXED_POINT_OPTIM = 1):
* w-size: 6 5 4 3 2
* 521 145 141 135 120 97
* 384 214 209 198 177 146
* 256 320 320 303 262 226
* 224 475 475 453 398 342
* 192 640 640 633 587 476
*/
#define MBEDTLS_ECP_WINDOW_SIZE 4
#endif /* MBEDTLS_ECP_WINDOW_SIZE */
#if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM)
/*
* Trade code size for speed on fixed-point multiplication.
*
* This speeds up repeated multiplication of the generator (that is, the
* multiplication in ECDSA signatures, and half of the multiplications in
* ECDSA verification and ECDHE) by a factor roughly 3 to 4.
*
* For each n-bit Short Weierstrass curve that is enabled, this adds 4n bytes
* of code size if n < 384 and 8n otherwise.
*
* Change this value to 0 to reduce code size.
*/
#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1
#endif /* MBEDTLS_ECP_FIXED_POINT_OPTIM */
#else /* MBEDTLS_ECP_ALT */
#include "ecp_alt.h"
#endif /* MBEDTLS_ECP_ALT */
#if !defined(MBEDTLS_ECP_LIGHT)
/* Dummy definition to help code that has optional ECP support and
* defines an MBEDTLS_ECP_MAX_BYTES-sized array unconditionally. */
#define MBEDTLS_ECP_MAX_BITS 1
/* Note: the curves must be listed in DECREASING size! */
#elif defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
#define MBEDTLS_ECP_MAX_BITS 521
#elif defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
#define MBEDTLS_ECP_MAX_BITS 512
#elif defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
#define MBEDTLS_ECP_MAX_BITS 448
#elif defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
#define MBEDTLS_ECP_MAX_BITS 384
#elif defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
#define MBEDTLS_ECP_MAX_BITS 384
#elif defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
#define MBEDTLS_ECP_MAX_BITS 256
#elif defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
#define MBEDTLS_ECP_MAX_BITS 256
#elif defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
#define MBEDTLS_ECP_MAX_BITS 256
#elif defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
#define MBEDTLS_ECP_MAX_BITS 255
#elif defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
#define MBEDTLS_ECP_MAX_BITS 225 // n is slightly above 2^224
#elif defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
#define MBEDTLS_ECP_MAX_BITS 224
#elif defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
#define MBEDTLS_ECP_MAX_BITS 192
#elif defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
#define MBEDTLS_ECP_MAX_BITS 192
#else /* !MBEDTLS_ECP_LIGHT */
#error "Missing definition of MBEDTLS_ECP_MAX_BITS"
#endif /* !MBEDTLS_ECP_LIGHT */
#define MBEDTLS_ECP_MAX_BYTES ((MBEDTLS_ECP_MAX_BITS + 7) / 8)
#define MBEDTLS_ECP_MAX_PT_LEN (2 * MBEDTLS_ECP_MAX_BYTES + 1)
#if defined(MBEDTLS_ECP_RESTARTABLE)
typedef struct mbedtls_ecp_restart_mul mbedtls_ecp_restart_mul_ctx;
typedef struct mbedtls_ecp_restart_muladd mbedtls_ecp_restart_muladd_ctx;
typedef struct {
unsigned MBEDTLS_PRIVATE(ops_done);
unsigned MBEDTLS_PRIVATE(depth);
mbedtls_ecp_restart_mul_ctx *MBEDTLS_PRIVATE(rsm);
mbedtls_ecp_restart_muladd_ctx *MBEDTLS_PRIVATE(ma);
} mbedtls_ecp_restart_ctx;
/*
* Operation counts for restartable functions
*/
#define MBEDTLS_ECP_OPS_CHK 3
#define MBEDTLS_ECP_OPS_DBL 8
#define MBEDTLS_ECP_OPS_ADD 11
#define MBEDTLS_ECP_OPS_INV 120
int mbedtls_ecp_check_budget(const mbedtls_ecp_group *grp,
mbedtls_ecp_restart_ctx *rs_ctx,
unsigned ops);
/* Utility macro for checking and updating ops budget */
#define MBEDTLS_ECP_BUDGET(ops) \
MBEDTLS_MPI_CHK(mbedtls_ecp_check_budget(grp, rs_ctx, \
(unsigned) (ops)));
#else /* MBEDTLS_ECP_RESTARTABLE */
#define MBEDTLS_ECP_BUDGET(ops) /* no-op; for compatibility */
/* We want to declare restartable versions of existing functions anyway */
typedef void mbedtls_ecp_restart_ctx;
#endif /* MBEDTLS_ECP_RESTARTABLE */
typedef struct mbedtls_ecp_keypair {
mbedtls_ecp_group MBEDTLS_PRIVATE(grp);
mbedtls_mpi MBEDTLS_PRIVATE(d);
mbedtls_ecp_point MBEDTLS_PRIVATE(Q);
}
mbedtls_ecp_keypair;
#define MBEDTLS_ECP_PF_UNCOMPRESSED 0
#define MBEDTLS_ECP_PF_COMPRESSED 1
/*
* Some other constants from RFC 4492
*/
#define MBEDTLS_ECP_TLS_NAMED_CURVE 3
#if defined(MBEDTLS_ECP_RESTARTABLE)
void mbedtls_ecp_set_max_ops(unsigned max_ops);
int mbedtls_ecp_restart_is_enabled(void);
#endif /* MBEDTLS_ECP_RESTARTABLE */
/*
* Get the type of a curve
*/
mbedtls_ecp_curve_type mbedtls_ecp_get_type(const mbedtls_ecp_group *grp);
const mbedtls_ecp_curve_info *mbedtls_ecp_curve_list(void);
const mbedtls_ecp_group_id *mbedtls_ecp_grp_id_list(void);
const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_grp_id(mbedtls_ecp_group_id grp_id);
const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_tls_id(uint16_t tls_id);
const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_name(const char *name);
void mbedtls_ecp_point_init(mbedtls_ecp_point *pt);
void mbedtls_ecp_group_init(mbedtls_ecp_group *grp);
void mbedtls_ecp_keypair_init(mbedtls_ecp_keypair *key);
void mbedtls_ecp_point_free(mbedtls_ecp_point *pt);
void mbedtls_ecp_group_free(mbedtls_ecp_group *grp);
void mbedtls_ecp_keypair_free(mbedtls_ecp_keypair *key);
#if defined(MBEDTLS_ECP_RESTARTABLE)
void mbedtls_ecp_restart_init(mbedtls_ecp_restart_ctx *ctx);
void mbedtls_ecp_restart_free(mbedtls_ecp_restart_ctx *ctx);
#endif /* MBEDTLS_ECP_RESTARTABLE */
int mbedtls_ecp_copy(mbedtls_ecp_point *P, const mbedtls_ecp_point *Q);
int mbedtls_ecp_group_copy(mbedtls_ecp_group *dst,
const mbedtls_ecp_group *src);
int mbedtls_ecp_set_zero(mbedtls_ecp_point *pt);
int mbedtls_ecp_is_zero(mbedtls_ecp_point *pt);
int mbedtls_ecp_point_cmp(const mbedtls_ecp_point *P,
const mbedtls_ecp_point *Q);
int mbedtls_ecp_point_read_string(mbedtls_ecp_point *P, int radix,
const char *x, const char *y);
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);
int mbedtls_ecp_point_read_binary(const mbedtls_ecp_group *grp,
mbedtls_ecp_point *P,
const unsigned char *buf, size_t ilen);
int mbedtls_ecp_tls_read_point(const mbedtls_ecp_group *grp,
mbedtls_ecp_point *pt,
const unsigned char **buf, size_t len);
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);
int mbedtls_ecp_group_load(mbedtls_ecp_group *grp, mbedtls_ecp_group_id id);
int mbedtls_ecp_tls_read_group(mbedtls_ecp_group *grp,
const unsigned char **buf, size_t len);
int mbedtls_ecp_tls_read_group_id(mbedtls_ecp_group_id *grp,
const unsigned char **buf,
size_t len);
int mbedtls_ecp_tls_write_group(const mbedtls_ecp_group *grp,
size_t *olen,
unsigned char *buf, size_t blen);
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);
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);
#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED)
static inline int mbedtls_ecp_group_a_is_minus_3(const mbedtls_ecp_group *grp)
{
return grp->A.MBEDTLS_PRIVATE(p) == NULL;
}
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);
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);
#endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */
int mbedtls_ecp_check_pubkey(const mbedtls_ecp_group *grp,
const mbedtls_ecp_point *pt);
int mbedtls_ecp_check_privkey(const mbedtls_ecp_group *grp,
const mbedtls_mpi *d);
int mbedtls_ecp_gen_privkey(const mbedtls_ecp_group *grp,
mbedtls_mpi *d,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng);
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);
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);
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);
int mbedtls_ecp_set_public_key(mbedtls_ecp_group_id grp_id,
mbedtls_ecp_keypair *key,
const mbedtls_ecp_point *Q);
int mbedtls_ecp_read_key(mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
const unsigned char *buf, size_t buflen);
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
int MBEDTLS_DEPRECATED mbedtls_ecp_write_key(mbedtls_ecp_keypair *key,
unsigned char *buf, size_t buflen);
#endif /* MBEDTLS_DEPRECATED_REMOVED */
int mbedtls_ecp_write_key_ext(const mbedtls_ecp_keypair *key,
size_t *olen, unsigned char *buf, size_t buflen);
int mbedtls_ecp_write_public_key(const mbedtls_ecp_keypair *key,
int format, size_t *olen,
unsigned char *buf, size_t buflen);
int mbedtls_ecp_check_pub_priv(
const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng);
int mbedtls_ecp_keypair_calc_public(
mbedtls_ecp_keypair *key,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng);
mbedtls_ecp_group_id mbedtls_ecp_keypair_get_group_id(
const mbedtls_ecp_keypair *key);
int mbedtls_ecp_export(const mbedtls_ecp_keypair *key, mbedtls_ecp_group *grp,
mbedtls_mpi *d, mbedtls_ecp_point *Q);
#if defined(MBEDTLS_SELF_TEST)
int mbedtls_ecp_self_test(int verbose);
#endif /* MBEDTLS_SELF_TEST */
#ifdef __cplusplus
}
#endif
#endif /* ecp.h */
bignum.h
Multi-precision integer library.
mbedtls_ecp_keypair_free
void mbedtls_ecp_keypair_free(mbedtls_ecp_keypair *key)
This function frees the components of a key pair.
mbedtls_ecp_point_read_binary
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_ecp_muladd
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.
mbedtls_ecp_gen_key
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.
mbedtls_ecp_is_zero
int mbedtls_ecp_is_zero(mbedtls_ecp_point *pt)
This function checks if a point is the point at infinity.
mbedtls_ecp_write_public_key
int mbedtls_ecp_write_public_key(const mbedtls_ecp_keypair *key, int format, size_t *olen, unsigned char *buf, size_t buflen)
This function exports an elliptic curve public key.
mbedtls_ecp_keypair_get_group_id
mbedtls_ecp_group_id mbedtls_ecp_keypair_get_group_id(const mbedtls_ecp_keypair *key)
Query the group that a key pair belongs to.
mbedtls_ecp_tls_write_group
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,...
mbedtls_ecp_group_copy
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.
mbedtls_ecp_get_type
mbedtls_ecp_curve_type mbedtls_ecp_get_type(const mbedtls_ecp_group *grp)
mbedtls_ecp_restart_ctx
void mbedtls_ecp_restart_ctx
Definition ecp.h:416
mbedtls_ecp_export
int mbedtls_ecp_export(const mbedtls_ecp_keypair *key, mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q)
This function exports generic key-pair parameters.
mbedtls_ecp_keypair_calc_public
int mbedtls_ecp_keypair_calc_public(mbedtls_ecp_keypair *key, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Calculate the public key from a private key in a key pair.
mbedtls_ecp_mul
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.
mbedtls_ecp_curve_type
mbedtls_ecp_curve_type
Definition ecp.h:127
MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS
@ MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS
Definition ecp.h:129
MBEDTLS_ECP_TYPE_NONE
@ MBEDTLS_ECP_TYPE_NONE
Definition ecp.h:128
MBEDTLS_ECP_TYPE_MONTGOMERY
@ MBEDTLS_ECP_TYPE_MONTGOMERY
Definition ecp.h:130
mbedtls_ecp_grp_id_list
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...
mbedtls_ecp_group_init
void mbedtls_ecp_group_init(mbedtls_ecp_group *grp)
This function initializes an ECP group context without loading any domain parameters.
mbedtls_ecp_gen_keypair_base
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_ecp_group
struct mbedtls_ecp_group mbedtls_ecp_group
The ECP group structure.
mbedtls_ecp_write_key
int MBEDTLS_DEPRECATED mbedtls_ecp_write_key(mbedtls_ecp_keypair *key, unsigned char *buf, size_t buflen)
This function exports an elliptic curve private key.
mbedtls_ecp_mul_restartable
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.
mbedtls_ecp_point_cmp
int mbedtls_ecp_point_cmp(const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
This function compares two points.
mbedtls_ecp_check_privkey
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_point_read_string
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.
mbedtls_ecp_group_load
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.
mbedtls_ecp_keypair_init
void mbedtls_ecp_keypair_init(mbedtls_ecp_keypair *key)
This function initializes a key pair as an invalid one.
mbedtls_ecp_tls_read_group_id
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...
mbedtls_ecp_curve_info_from_name
const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_name(const char *name)
This function retrieves curve information from a human-readable name.
mbedtls_ecp_point_free
void mbedtls_ecp_point_free(mbedtls_ecp_point *pt)
This function frees the components of a point.
mbedtls_ecp_tls_read_point
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_read_key
int mbedtls_ecp_read_key(mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key, const unsigned char *buf, size_t buflen)
This function reads an elliptic curve private key.
mbedtls_ecp_group_free
void mbedtls_ecp_group_free(mbedtls_ecp_group *grp)
This function frees the components of an ECP group.
mbedtls_ecp_copy
int mbedtls_ecp_copy(mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
This function copies the contents of point Q into point P.
mbedtls_ecp_muladd_restartable
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_gen_privkey
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.
mbedtls_ecp_gen_keypair
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.
mbedtls_ecp_check_pub_priv
int mbedtls_ecp_check_pub_priv(const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function checks that the keypair objects pub and prv have the same group and the same public poi...
mbedtls_ecp_tls_write_point
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....
mbedtls_ecp_write_key_ext
int mbedtls_ecp_write_key_ext(const mbedtls_ecp_keypair *key, size_t *olen, unsigned char *buf, size_t buflen)
This function exports an elliptic curve private key.
mbedtls_ecp_curve_info_from_grp_id
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.
mbedtls_ecp_set_public_key
int mbedtls_ecp_set_public_key(mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key, const mbedtls_ecp_point *Q)
Set the public key in a key pair object.
mbedtls_ecp_set_zero
int mbedtls_ecp_set_zero(mbedtls_ecp_point *pt)
This function sets a point to the point at infinity.
mbedtls_ecp_tls_read_group
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,...
mbedtls_ecp_curve_list
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.
mbedtls_ecp_point_init
void mbedtls_ecp_point_init(mbedtls_ecp_point *pt)
This function initializes a point as zero.
mbedtls_ecp_check_pubkey
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_ecp_group_id
mbedtls_ecp_group_id
Definition ecp.h:102
MBEDTLS_ECP_DP_SECP192K1
@ MBEDTLS_ECP_DP_SECP192K1
Definition ecp.h:113
MBEDTLS_ECP_DP_SECP384R1
@ MBEDTLS_ECP_DP_SECP384R1
Definition ecp.h:107
MBEDTLS_ECP_DP_CURVE448
@ MBEDTLS_ECP_DP_CURVE448
Definition ecp.h:116
MBEDTLS_ECP_DP_CURVE25519
@ MBEDTLS_ECP_DP_CURVE25519
Definition ecp.h:112
MBEDTLS_ECP_DP_NONE
@ MBEDTLS_ECP_DP_NONE
Definition ecp.h:103
MBEDTLS_ECP_DP_SECP256K1
@ MBEDTLS_ECP_DP_SECP256K1
Definition ecp.h:115
MBEDTLS_ECP_DP_BP512R1
@ MBEDTLS_ECP_DP_BP512R1
Definition ecp.h:111
MBEDTLS_ECP_DP_SECP224R1
@ MBEDTLS_ECP_DP_SECP224R1
Definition ecp.h:105
MBEDTLS_ECP_DP_SECP521R1
@ MBEDTLS_ECP_DP_SECP521R1
Definition ecp.h:108
MBEDTLS_ECP_DP_BP384R1
@ MBEDTLS_ECP_DP_BP384R1
Definition ecp.h:110
MBEDTLS_ECP_DP_SECP224K1
@ MBEDTLS_ECP_DP_SECP224K1
Definition ecp.h:114
MBEDTLS_ECP_DP_BP256R1
@ MBEDTLS_ECP_DP_BP256R1
Definition ecp.h:109
MBEDTLS_ECP_DP_SECP192R1
@ MBEDTLS_ECP_DP_SECP192R1
Definition ecp.h:104
MBEDTLS_ECP_DP_SECP256R1
@ MBEDTLS_ECP_DP_SECP256R1
Definition ecp.h:106
mbedtls_ecp_point_write_binary
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.
mbedtls_ecp_curve_info_from_tls_id
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.
mbedtls_ecp_self_test
int mbedtls_ecp_self_test(int verbose)
The ECP checkup routine.
mbedtls_ecp_group_a_is_minus_3
static int mbedtls_ecp_group_a_is_minus_3(const mbedtls_ecp_group *grp)
This function checks if domain parameter A of the curve is -3.
Definition ecp.h:1022
ecp_alt.h
build_info.h
Build-time configuration info.
platform_util.h
Common and shared functions used by multiple modules in the Mbed TLS library.
MBEDTLS_DEPRECATED
#define MBEDTLS_DEPRECATED
Definition platform_util.h:29
private_access.h
Macro wrapper for struct's members.
MBEDTLS_PRIVATE
#define MBEDTLS_PRIVATE(member)
Definition private_access.h:15
mbedtls_ecp_curve_info
Definition ecp.h:140
mbedtls_ecp_curve_info::name
const char * name
Definition ecp.h:144
mbedtls_ecp_curve_info::grp_id
mbedtls_ecp_group_id grp_id
Definition ecp.h:141
mbedtls_ecp_curve_info::bit_size
uint16_t bit_size
Definition ecp.h:143
mbedtls_ecp_curve_info::tls_id
uint16_t tls_id
Definition ecp.h:142
mbedtls_ecp_group
The ECP group structure.
Definition ecp.h:233
mbedtls_ecp_group::pbits
size_t pbits
Definition ecp.h:245
mbedtls_ecp_group::id
mbedtls_ecp_group_id id
Definition ecp.h:234
mbedtls_ecp_group::N
mbedtls_mpi N
Definition ecp.h:244
mbedtls_ecp_group::G
mbedtls_ecp_point G
Definition ecp.h:243
mbedtls_ecp_group::B
mbedtls_mpi B
Definition ecp.h:241
mbedtls_ecp_group::P
mbedtls_mpi P
Definition ecp.h:235
mbedtls_ecp_group::nbits
size_t nbits
Definition ecp.h:246
mbedtls_ecp_group::A
mbedtls_mpi A
Definition ecp.h:236
mbedtls_ecp_keypair
The ECP key-pair structure.
Definition ecp.h:428
mbedtls_ecp_point
The ECP point structure, in Jacobian coordinates.
Definition ecp.h:158
mbedtls_mpi
MPI structure.
Definition bignum.h:207