Mbed OS Reference
Loading...
Searching...
No Matches
mbedtls/include/mbedtls/ecp.h File Reference

This file provides an API for Elliptic Curves over GF(P) (ECP). More...

#include "mbedtls/config.h"
#include "mbedtls/bignum.h"

Go to the source code of this file.

Data Structures

struct  mbedtls_ecp_curve_info
 Curve information, for use by other modules. More...
 
struct  mbedtls_ecp_point
 The ECP point structure, in Jacobian coordinates. More...
 
struct  mbedtls_ecp_group
 The ECP group structure. More...
 
struct  mbedtls_ecp_keypair
 The ECP key-pair structure. More...
 

Macros

#define MBEDTLS_ERR_ECP_BAD_INPUT_DATA   -0x4F80
 Bad input parameters to function. More...
 
#define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL   -0x4F00
 The buffer is too small to write to. More...
 
#define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE   -0x4E80
 The requested feature is not available, for example, the requested curve is not supported. More...
 
#define MBEDTLS_ERR_ECP_VERIFY_FAILED   -0x4E00
 The signature is not valid. More...
 
#define MBEDTLS_ERR_ECP_ALLOC_FAILED   -0x4D80
 Memory allocation failed. More...
 
#define MBEDTLS_ERR_ECP_RANDOM_FAILED   -0x4D00
 Generation of random value, such as ephemeral key, failed. More...
 
#define MBEDTLS_ERR_ECP_INVALID_KEY   -0x4C80
 Invalid private or public key. More...
 
#define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH   -0x4C00
 The buffer contains a valid signature followed by more data. More...
 
#define MBEDTLS_ERR_ECP_HW_ACCEL_FAILED   -0x4B80
 The ECP hardware accelerator failed. More...
 
#define MBEDTLS_ERR_ECP_IN_PROGRESS   -0x4B00
 Operation in progress, call again with the same parameters to continue. More...
 
#define MBEDTLS_ECP_DP_MAX   12
 The number of supported curves, plus one for MBEDTLS_ECP_DP_NONE. More...
 
#define MBEDTLS_ECP_PF_UNCOMPRESSED   0
 Uncompressed point format. More...
 
#define MBEDTLS_ECP_PF_COMPRESSED   1
 Compressed point format. More...
 
#define MBEDTLS_ECP_TLS_NAMED_CURVE   3
 The named_curve of ECCurveType. More...
 
SECTION: Module settings

The configuration options you can set for this module are in this section.

Either change them in config.h, or define them using the compiler command line.

#define MBEDTLS_ECP_MAX_BITS   521
 The maximum size of the groups, that is, of N and P. More...
 
#define MBEDTLS_ECP_MAX_BYTES   ( ( MBEDTLS_ECP_MAX_BITS + 7 ) / 8 )
 
#define MBEDTLS_ECP_MAX_PT_LEN   ( 2 * MBEDTLS_ECP_MAX_BYTES + 1 )
 
#define MBEDTLS_ECP_WINDOW_SIZE   6
 The maximum window size used. More...
 
#define MBEDTLS_ECP_FIXED_POINT_OPTIM   1
 Enable fixed-point speed-up. More...
 

Typedefs

typedef struct mbedtls_ecp_curve_info mbedtls_ecp_curve_info
 Curve information, for use by other modules. More...
 
typedef struct mbedtls_ecp_point mbedtls_ecp_point
 The ECP point structure, in Jacobian coordinates. More...
 
typedef struct mbedtls_ecp_group mbedtls_ecp_group
 The ECP group structure. More...
 
typedef struct mbedtls_ecp_keypair mbedtls_ecp_keypair
 The ECP key-pair structure. More...
 

Enumerations

enum  mbedtls_ecp_group_id {
  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
}
 Domain-parameter identifiers: curve, subgroup, and generator. More...
 

Functions

const mbedtls_ecp_curve_infombedtls_ecp_curve_list (void)
 This function retrieves the information defined in mbedtls_ecp_curve_info() for all supported curves in order of preference. More...
 
const mbedtls_ecp_group_idmbedtls_ecp_grp_id_list (void)
 This function retrieves the list of internal group identifiers of all supported curves in the order of preference. More...
 
const mbedtls_ecp_curve_infombedtls_ecp_curve_info_from_grp_id (mbedtls_ecp_group_id grp_id)
 This function retrieves curve information from an internal group identifier. More...
 
const mbedtls_ecp_curve_infombedtls_ecp_curve_info_from_tls_id (uint16_t tls_id)
 This function retrieves curve information from a TLS NamedCurve value. More...
 
const mbedtls_ecp_curve_infombedtls_ecp_curve_info_from_name (const char *name)
 This function retrieves curve information from a human-readable name. More...
 
void mbedtls_ecp_point_init (mbedtls_ecp_point *pt)
 This function initializes a point as zero. More...
 
void mbedtls_ecp_group_init (mbedtls_ecp_group *grp)
 This function initializes an ECP group context without loading any domain parameters. More...
 
void mbedtls_ecp_keypair_init (mbedtls_ecp_keypair *key)
 This function initializes a key pair as an invalid one. More...
 
void mbedtls_ecp_point_free (mbedtls_ecp_point *pt)
 This function frees the components of a point. More...
 
void mbedtls_ecp_group_free (mbedtls_ecp_group *grp)
 This function frees the components of an ECP group. More...
 
void mbedtls_ecp_keypair_free (mbedtls_ecp_keypair *key)
 This function frees the components of a key pair. More...
 
int mbedtls_ecp_copy (mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
 This function copies the contents of point Q into point P. More...
 
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. More...
 
int mbedtls_ecp_set_zero (mbedtls_ecp_point *pt)
 This function sets a point to the point at infinity. More...
 
int mbedtls_ecp_is_zero (mbedtls_ecp_point *pt)
 This function checks if a point is the point at infinity. More...
 
int mbedtls_ecp_point_cmp (const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
 This function compares two points. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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.4. More...
 
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. More...
 
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, Section 5.4. More...
 
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 4492, Section 5.4. More...
 
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, Section 5.4. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int mbedtls_ecp_write_key (mbedtls_ecp_keypair *key, unsigned char *buf, size_t buflen)
 This function exports an elliptic curve private key. More...
 
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 point, and that the private key in prv is consistent with the public key. More...
 

Detailed Description

This file provides an API for Elliptic Curves over GF(P) (ECP).

The use of ECP in cryptography and TLS is defined in Standards for Efficient Cryptography Group (SECG): SEC1 Elliptic Curve Cryptography and RFC-4492: Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer Security (TLS).

RFC-2409: The Internet Key Exchange (IKE) defines ECP group types.

Definition in file mbedtls/include/mbedtls/ecp.h.