RetroArch
Macros | Enumerations | Functions | Variables
ecp.c File Reference
#include "mbedtls/config.h"
#include "mbedtls/ecp.h"
#include "mbedtls/threading.h"
#include <string.h>
#include "mbedtls/platform.h"
#include "mbedtls/ecp_internal.h"
#include "arc4_alt.h"
Include dependency graph for ecp.c:

Macros

#define ECP_SHORTWEIERSTRASS
 
#define ECP_MONTGOMERY
 
#define ECP_NB_CURVES
 
#define INC_MUL_COUNT   mul_count++;
 
#define MOD_MUL(N)
 
#define MOD_SUB(N)
 
#define MOD_ADD(N)
 
#define COMB_MAX_D   ( MBEDTLS_ECP_MAX_BITS + 1 ) / 2
 
#define COMB_MAX_PRE   ( 1 << ( MBEDTLS_ECP_WINDOW_SIZE - 1 ) )
 

Enumerations

enum  ecp_curve_type { ECP_TYPE_NONE = 0, ECP_TYPE_SHORT_WEIERSTRASS, ECP_TYPE_MONTGOMERY }
 

Functions

const mbedtls_ecp_curve_infombedtls_ecp_curve_list (void)
 Get the list of supported curves in order of preferrence (full information) More...
 
const mbedtls_ecp_group_idmbedtls_ecp_grp_id_list (void)
 Get the list of supported curves in order of preferrence (grp_id only) More...
 
const mbedtls_ecp_curve_infombedtls_ecp_curve_info_from_grp_id (mbedtls_ecp_group_id grp_id)
 Get curve information from an internal group identifier. More...
 
const mbedtls_ecp_curve_infombedtls_ecp_curve_info_from_tls_id (uint16_t tls_id)
 Get curve information from a TLS NamedCurve value. More...
 
const mbedtls_ecp_curve_infombedtls_ecp_curve_info_from_name (const char *name)
 Get curve information from a human-readable name. More...
 
static ecp_curve_type ecp_get_type (const mbedtls_ecp_group *grp)
 
void mbedtls_ecp_point_init (mbedtls_ecp_point *pt)
 Initialize a point (as zero) More...
 
void mbedtls_ecp_group_init (mbedtls_ecp_group *grp)
 Initialize a group (to something meaningless) More...
 
void mbedtls_ecp_keypair_init (mbedtls_ecp_keypair *key)
 Initialize a key pair (as an invalid one) More...
 
void mbedtls_ecp_point_free (mbedtls_ecp_point *pt)
 Free the components of a point. More...
 
void mbedtls_ecp_group_free (mbedtls_ecp_group *grp)
 Free the components of an ECP group. More...
 
void mbedtls_ecp_keypair_free (mbedtls_ecp_keypair *key)
 Free the components of a key pair. More...
 
int mbedtls_ecp_copy (mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
 Copy the contents of point Q into P. More...
 
int mbedtls_ecp_group_copy (mbedtls_ecp_group *dst, const mbedtls_ecp_group *src)
 Copy the contents of a group object. More...
 
int mbedtls_ecp_set_zero (mbedtls_ecp_point *pt)
 Set a point to zero. More...
 
int mbedtls_ecp_is_zero (mbedtls_ecp_point *pt)
 Tell if a point is zero. More...
 
int mbedtls_ecp_point_cmp (const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
 Compare two points. More...
 
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. 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)
 Export a point into unsigned binary data. More...
 
int mbedtls_ecp_point_read_binary (const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt, const unsigned char *buf, size_t ilen)
 Import 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 buf_len)
 Import 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)
 Export a point as a TLS ECPoint record. More...
 
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. More...
 
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. More...
 
static int ecp_modp (mbedtls_mpi *N, const mbedtls_ecp_group *grp)
 
static int ecp_normalize_jac (const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt)
 
static int ecp_normalize_jac_many (const mbedtls_ecp_group *grp, mbedtls_ecp_point *T[], size_t t_len)
 
static int ecp_safe_invert_jac (const mbedtls_ecp_group *grp, mbedtls_ecp_point *Q, unsigned char inv)
 
static int ecp_double_jac (const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_ecp_point *P)
 
static int ecp_add_mixed (const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
 
static int ecp_randomize_jac (const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
 
static void ecp_comb_fixed (unsigned char x[], size_t d, unsigned char w, const mbedtls_mpi *m)
 
static int ecp_precompute_comb (const mbedtls_ecp_group *grp, mbedtls_ecp_point T[], const mbedtls_ecp_point *P, unsigned char w, size_t d)
 
static int ecp_select_comb (const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_ecp_point T[], unsigned char t_len, unsigned char i)
 
static int ecp_mul_comb_core (const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_ecp_point T[], unsigned char t_len, const unsigned char x[], size_t d, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
 
static int ecp_mul_comb (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)
 
static int ecp_normalize_mxz (const mbedtls_ecp_group *grp, mbedtls_ecp_point *P)
 
static int ecp_randomize_mxz (const mbedtls_ecp_group *grp, mbedtls_ecp_point *P, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
 
static int ecp_double_add_mxz (const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, mbedtls_ecp_point *S, const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q, const mbedtls_mpi *d)
 
static int ecp_mul_mxz (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 (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) More...
 
static int ecp_check_pubkey_sw (const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt)
 
static int mbedtls_ecp_mul_shortcuts (mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P)
 
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 group in multiple threads) More...
 
static int ecp_check_pubkey_mx (const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt)
 
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. More...
 
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. 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)
 Generate a keypair with 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)
 Generate a 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)
 Generate a keypair. More...
 
int mbedtls_ecp_check_pub_priv (const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv)
 Check a public-private key pair. More...
 
int mbedtls_ecp_self_test (int verbose)
 Checkup routine. More...
 

Variables

static unsigned long add_count
 
static unsigned long dbl_count
 
static unsigned long mul_count
 
static const mbedtls_ecp_curve_info ecp_supported_curves []
 
static mbedtls_ecp_group_id ecp_supported_grp_id [ECP_NB_CURVES]
 

Macro Definition Documentation

◆ COMB_MAX_D

#define COMB_MAX_D   ( MBEDTLS_ECP_MAX_BITS + 1 ) / 2

◆ COMB_MAX_PRE

#define COMB_MAX_PRE   ( 1 << ( MBEDTLS_ECP_WINDOW_SIZE - 1 ) )

◆ ECP_MONTGOMERY

#define ECP_MONTGOMERY

◆ ECP_NB_CURVES

#define ECP_NB_CURVES
Value:
sizeof( ecp_supported_curves ) / \
sizeof( ecp_supported_curves[0] )
static const mbedtls_ecp_curve_info ecp_supported_curves[]
Definition: ecp.c:125

◆ ECP_SHORTWEIERSTRASS

#define ECP_SHORTWEIERSTRASS

◆ INC_MUL_COUNT

#define INC_MUL_COUNT   mul_count++;

◆ MOD_ADD

#define MOD_ADD (   N)
Value:
while( mbedtls_mpi_cmp_mpi( &N, &grp->P ) >= 0 ) \
MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( &N, &N, &grp->P ) )
int mbedtls_mpi_sub_abs(mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B)
Unsigned subtraction: X = |A| - |B|.
Definition: bignum.c:964
int mbedtls_mpi_cmp_mpi(const mbedtls_mpi *X, const mbedtls_mpi *Y)
Compare signed values.
Definition: bignum.c:838

◆ MOD_MUL

#define MOD_MUL (   N)
Value:
do { MBEDTLS_MPI_CHK( ecp_modp( &N, grp ) ); INC_MUL_COUNT } \
while( 0 )
static int ecp_modp(mbedtls_mpi *N, const mbedtls_ecp_group *grp)
Definition: ecp.c:665
#define MBEDTLS_MPI_CHK(f)
Definition: bignum.h:48
#define INC_MUL_COUNT
Definition: ecp.c:707

◆ MOD_SUB

#define MOD_SUB (   N)
Value:
while( N.s < 0 && mbedtls_mpi_cmp_int( &N, 0 ) != 0 ) \
MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &N, &N, &grp->P ) )
int mbedtls_mpi_add_mpi(mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B)
Signed addition: X = A + B.
Definition: bignum.c:1007
int mbedtls_mpi_cmp_int(const mbedtls_mpi *X, mbedtls_mpi_sint z)
Compare signed values.
Definition: bignum.c:871

Enumeration Type Documentation

◆ ecp_curve_type

Enumerator
ECP_TYPE_NONE 
ECP_TYPE_SHORT_WEIERSTRASS 
ECP_TYPE_MONTGOMERY 

Function Documentation

◆ ecp_add_mixed()

static int ecp_add_mixed ( const mbedtls_ecp_group grp,
mbedtls_ecp_point R,
const mbedtls_ecp_point P,
const mbedtls_ecp_point Q 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_check_pubkey_mx()

static int ecp_check_pubkey_mx ( const mbedtls_ecp_group grp,
const mbedtls_ecp_point pt 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_check_pubkey_sw()

static int ecp_check_pubkey_sw ( const mbedtls_ecp_group grp,
const mbedtls_ecp_point pt 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_comb_fixed()

static void ecp_comb_fixed ( unsigned char  x[],
size_t  d,
unsigned char  w,
const mbedtls_mpi m 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_double_add_mxz()

static int ecp_double_add_mxz ( const mbedtls_ecp_group grp,
mbedtls_ecp_point R,
mbedtls_ecp_point S,
const mbedtls_ecp_point P,
const mbedtls_ecp_point Q,
const mbedtls_mpi d 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_double_jac()

static int ecp_double_jac ( const mbedtls_ecp_group grp,
mbedtls_ecp_point R,
const mbedtls_ecp_point P 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_get_type()

static ecp_curve_type ecp_get_type ( const mbedtls_ecp_group grp)
inlinestatic
Here is the caller graph for this function:

◆ ecp_modp()

static int ecp_modp ( mbedtls_mpi N,
const mbedtls_ecp_group grp 
)
static
Here is the call graph for this function:

◆ ecp_mul_comb()

static int ecp_mul_comb ( mbedtls_ecp_group grp,
mbedtls_ecp_point R,
const mbedtls_mpi m,
const mbedtls_ecp_point P,
int(*)(void *, unsigned char *, size_t)  f_rng,
void p_rng 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_mul_comb_core()

static int ecp_mul_comb_core ( const mbedtls_ecp_group grp,
mbedtls_ecp_point R,
const mbedtls_ecp_point  T[],
unsigned char  t_len,
const unsigned char  x[],
size_t  d,
int(*)(void *, unsigned char *, size_t)  f_rng,
void p_rng 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_mul_mxz()

static int ecp_mul_mxz ( mbedtls_ecp_group grp,
mbedtls_ecp_point R,
const mbedtls_mpi m,
const mbedtls_ecp_point P,
int(*)(void *, unsigned char *, size_t)  f_rng,
void p_rng 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_normalize_jac()

static int ecp_normalize_jac ( const mbedtls_ecp_group grp,
mbedtls_ecp_point pt 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_normalize_jac_many()

static int ecp_normalize_jac_many ( const mbedtls_ecp_group grp,
mbedtls_ecp_point T[],
size_t  t_len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_normalize_mxz()

static int ecp_normalize_mxz ( const mbedtls_ecp_group grp,
mbedtls_ecp_point P 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_precompute_comb()

static int ecp_precompute_comb ( const mbedtls_ecp_group grp,
mbedtls_ecp_point  T[],
const mbedtls_ecp_point P,
unsigned char  w,
size_t  d 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_randomize_jac()

static int ecp_randomize_jac ( const mbedtls_ecp_group grp,
mbedtls_ecp_point pt,
int(*)(void *, unsigned char *, size_t)  f_rng,
void p_rng 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_randomize_mxz()

static int ecp_randomize_mxz ( const mbedtls_ecp_group grp,
mbedtls_ecp_point P,
int(*)(void *, unsigned char *, size_t)  f_rng,
void p_rng 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_safe_invert_jac()

static int ecp_safe_invert_jac ( const mbedtls_ecp_group grp,
mbedtls_ecp_point Q,
unsigned char  inv 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecp_select_comb()

static int ecp_select_comb ( const mbedtls_ecp_group grp,
mbedtls_ecp_point R,
const mbedtls_ecp_point  T[],
unsigned char  t_len,
unsigned char  i 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_check_privkey()

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.

Parameters
grpGroup used
dInteger to check
Returns
0 if point is a valid private key, MBEDTLS_ERR_ECP_INVALID_KEY otherwise.
Note
Uses bare components rather than an mbedtls_ecp_keypair structure in order to ease use with other structures such as mbedtls_ecdh_context of mbedtls_ecdsa_context.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_check_pub_priv()

int mbedtls_ecp_check_pub_priv ( const mbedtls_ecp_keypair pub,
const mbedtls_ecp_keypair prv 
)

Check a public-private key pair.

Parameters
pubKeypair structure holding a public key
prvKeypair structure holding a private (plus public) key
Returns
0 if successful (keys are valid and match), or MBEDTLS_ERR_ECP_BAD_INPUT_DATA, or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_ERR_MPI_XXX code.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_check_pubkey()

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.

Parameters
grpCurve/group the point should belong to
ptPoint to check
Returns
0 if point is a valid public key, MBEDTLS_ERR_ECP_INVALID_KEY otherwise.
Note
This function only checks the point is non-zero, has valid coordinates and lies on the curve, but not that it is indeed a multiple of G. This is additional check is more expensive, isn't required by standards, and shouldn't be necessary if the group used has a small cofactor. In particular, it is useless for the NIST groups which all have a cofactor of 1.
Uses bare components rather than an mbedtls_ecp_keypair structure in order to ease use with other structures such as mbedtls_ecdh_context of mbedtls_ecdsa_context.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_copy()

int mbedtls_ecp_copy ( mbedtls_ecp_point P,
const mbedtls_ecp_point Q 
)

Copy the contents of point Q into P.

Parameters
PDestination point
QSource point
Returns
0 if successful, MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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)

Get curve information from an internal group identifier.

Parameters
grp_idA MBEDTLS_ECP_DP_XXX value
Returns
The associated curve information or NULL
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_curve_info_from_name()

const mbedtls_ecp_curve_info* mbedtls_ecp_curve_info_from_name ( const char *  name)

Get curve information from a human-readable name.

Parameters
nameThe name
Returns
The associated curve information or NULL
Here is the call graph for this function:

◆ mbedtls_ecp_curve_info_from_tls_id()

const mbedtls_ecp_curve_info* mbedtls_ecp_curve_info_from_tls_id ( uint16_t  tls_id)

Get curve information from a TLS NamedCurve value.

Parameters
tls_idA MBEDTLS_ECP_DP_XXX value
Returns
The associated curve information or NULL
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_curve_list()

const mbedtls_ecp_curve_info* mbedtls_ecp_curve_list ( void  )

Get the list of supported curves in order of preferrence (full information)

Returns
A statically allocated array, the last entry is 0.
Here is the caller graph for this function:

◆ mbedtls_ecp_gen_key()

int mbedtls_ecp_gen_key ( mbedtls_ecp_group_id  grp_id,
mbedtls_ecp_keypair key,
int(*)(void *, unsigned char *, size_t)  f_rng,
void p_rng 
)

Generate a keypair.

Parameters
grp_idECP group identifier
keyDestination keypair
f_rngRNG function
p_rngRNG parameter
Returns
0 if successful, or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
Here is the call graph for this function:

◆ mbedtls_ecp_gen_keypair()

int mbedtls_ecp_gen_keypair ( mbedtls_ecp_group grp,
mbedtls_mpi d,
mbedtls_ecp_point Q,
int(*)(void *, unsigned char *, size_t)  f_rng,
void p_rng 
)

Generate a keypair.

Parameters
grpECP group
dDestination MPI (secret part)
QDestination point (public part)
f_rngRNG function
p_rngRNG parameter
Returns
0 if successful, or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
Note
Uses bare components rather than an mbedtls_ecp_keypair structure in order to ease use with other structures such as mbedtls_ecdh_context of mbedtls_ecdsa_context.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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(*)(void *, unsigned char *, size_t)  f_rng,
void p_rng 
)

Generate a keypair with configurable base point.

Parameters
grpECP group
GChosen base point
dDestination MPI (secret part)
QDestination point (public part)
f_rngRNG function
p_rngRNG parameter
Returns
0 if successful, or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
Note
Uses bare components rather than an mbedtls_ecp_keypair structure in order to ease use with other structures such as mbedtls_ecdh_context of mbedtls_ecdsa_context.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_group_copy()

int mbedtls_ecp_group_copy ( mbedtls_ecp_group dst,
const mbedtls_ecp_group src 
)

Copy the contents of a group object.

Parameters
dstDestination group
srcSource group
Returns
0 if successful, MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_group_free()

void mbedtls_ecp_group_free ( mbedtls_ecp_group grp)

Free the components of an ECP group.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_group_init()

void mbedtls_ecp_group_init ( mbedtls_ecp_group grp)

Initialize a group (to something meaningless)

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_grp_id_list()

const mbedtls_ecp_group_id* mbedtls_ecp_grp_id_list ( void  )

Get the list of supported curves in order of preferrence (grp_id only)

Returns
A statically allocated array, terminated with MBEDTLS_ECP_DP_NONE.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_is_zero()

int mbedtls_ecp_is_zero ( mbedtls_ecp_point pt)

Tell if a point is zero.

Parameters
ptPoint to test
Returns
1 if point is zero, 0 otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_keypair_free()

void mbedtls_ecp_keypair_free ( mbedtls_ecp_keypair key)

Free the components of a key pair.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_keypair_init()

void mbedtls_ecp_keypair_init ( mbedtls_ecp_keypair key)

Initialize a key pair (as an invalid one)

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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(*)(void *, unsigned char *, size_t)  f_rng,
void p_rng 
)

Multiplication by an integer: R = m * P (Not thread-safe to use same group in multiple threads)

Note
In order to prevent timing attacks, this function executes the exact same sequence of (base field) operations for any valid m. It avoids any if-branch or array index depending on the value of m.
If f_rng is not NULL, it is used to randomize intermediate results in order to prevent potential timing attacks targeting these results. It is recommended to always provide a non-NULL f_rng (the overhead is negligible).
Parameters
grpECP group
RDestination point
mInteger by which to multiply
PPoint to multiply
f_rngRNG function (see notes)
p_rngRNG parameter
Returns
0 if successful, MBEDTLS_ERR_ECP_INVALID_KEY if m is not a valid privkey or P is not a valid pubkey, MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_mul_shortcuts()

static int mbedtls_ecp_mul_shortcuts ( mbedtls_ecp_group grp,
mbedtls_ecp_point R,
const mbedtls_mpi m,
const mbedtls_ecp_point P 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 
)

Multiplication and addition of two points by integers: R = m * P + n * Q (Not thread-safe to use same group in multiple threads)

Note
In contrast to mbedtls_ecp_mul(), this function does not guarantee a constant execution flow and timing.
Parameters
grpECP group
RDestination point
mInteger by which to multiply P
PPoint to multiply by m
nInteger by which to multiply Q
QPoint to be multiplied by n
Returns
0 if successful, MBEDTLS_ERR_ECP_INVALID_KEY if m or n is not a valid privkey or P or Q is not a valid pubkey, MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_point_cmp()

int mbedtls_ecp_point_cmp ( const mbedtls_ecp_point P,
const mbedtls_ecp_point Q 
)

Compare two points.

Note
This assumes the points are normalized. Otherwise, they may compare as "not equal" even if they are.
Parameters
PFirst point to compare
QSecond point to compare
Returns
0 if the points are equal, MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise
Here is the call graph for this function:

◆ mbedtls_ecp_point_free()

void mbedtls_ecp_point_free ( mbedtls_ecp_point pt)

Free the components of a point.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_point_init()

void mbedtls_ecp_point_init ( mbedtls_ecp_point pt)

Initialize a point (as zero)

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 
)

Import a point from unsigned binary data.

Parameters
grpGroup to which the point should belong
PPoint to import
bufInput buffer
ilenActual length of input
Returns
0 if successful, MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid, MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the point format is not implemented.
Note
This function does NOT check that the point actually belongs to the given group, see mbedtls_ecp_check_pubkey() for that.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_point_read_string()

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.

Parameters
PDestination point
radixInput numeric base
xFirst affine coordinate as a null-terminated string
ySecond affine coordinate as a null-terminated string
Returns
0 if successful, or a MBEDTLS_ERR_MPI_XXX error code
Here is the call graph for this function:

◆ 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 
)

Export a point into unsigned binary data.

Parameters
grpGroup to which the point should belong
PPoint to export
formatPoint format, should be a MBEDTLS_ECP_PF_XXX macro
olenLength of the actual output
bufOutput buffer
buflenLength of the output buffer
Returns
0 if successful, or MBEDTLS_ERR_ECP_BAD_INPUT_DATA or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_self_test()

int mbedtls_ecp_self_test ( int  verbose)

Checkup routine.

Returns
0 if successful, or 1 if a test failed
Here is the call graph for this function:

◆ mbedtls_ecp_set_zero()

int mbedtls_ecp_set_zero ( mbedtls_ecp_point pt)

Set a point to zero.

Parameters
ptDestination point
Returns
0 if successful, MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_ecp_tls_read_group()

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.

Parameters
grpDestination group
buf&(Start of input buffer)
lenBuffer length
Note
buf is updated to point right after ECParameters on exit
Returns
0 if successful, MBEDTLS_ERR_MPI_XXX if initialization failed MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 
)

Import a point from a TLS ECPoint record.

Parameters
grpECP group used
ptDestination point
buf$(Start of input buffer)
lenBuffer length
Note
buf is updated to point right after the ECPoint on exit
Returns
0 if successful, MBEDTLS_ERR_MPI_XXX if initialization failed MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 
)

Write the TLS ECParameters record for a group.

Parameters
grpECP group used
olenNumber of bytes actually written
bufBuffer to write to
blenBuffer length
Returns
0 if successful, or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 
)

Export a point as a TLS ECPoint record.

Parameters
grpECP group used
ptPoint to export
formatExport format
olenlength of data written
bufBuffer to write to
blenBuffer length
Returns
0 if successful, or MBEDTLS_ERR_ECP_BAD_INPUT_DATA or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ add_count

unsigned long add_count
static

◆ dbl_count

unsigned long dbl_count
static

◆ ecp_supported_curves

const mbedtls_ecp_curve_info ecp_supported_curves[]
static

◆ ecp_supported_grp_id

mbedtls_ecp_group_id ecp_supported_grp_id[ECP_NB_CURVES]
static

◆ mul_count

unsigned long mul_count
static