ecp.h File Reference

Elliptic curves over GF(p) More...

`#include "bignum.h"`
Include dependency graph for ecp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | mbedtls_ecp_curve_info
struct | mbedtls_ecp_point
| ECP point structure (jacobian coordinates) More...
struct | mbedtls_ecp_group
| ECP group structure. More...
struct | mbedtls_ecp_keypair
| ECP key pair structure. More...

## Macros

#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_HW_ACCEL_FAILED -0x4B80
#define | MBEDTLS_ECP_DP_MAX 12
#define | MBEDTLS_ECP_PF_UNCOMPRESSED 0
#define | MBEDTLS_ECP_PF_COMPRESSED 1
#define | MBEDTLS_ECP_TLS_NAMED_CURVE 3
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 on the compiler command line.
#define | MBEDTLS_ECP_MAX_BITS 521
#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
#define | MBEDTLS_ECP_FIXED_POINT_OPTIM 1

## 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 }

## Functions

const mbedtls_ecp_curve_info * | mbedtls_ecp_curve_list (void)
| Get the list of supported curves in order of preferrence (full information) More...
const mbedtls_ecp_group_id * | mbedtls_ecp_grp_id_list (void)
| Get the list of supported curves in order of preferrence (grp_id only) More...
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. More...
const mbedtls_ecp_curve_info * | mbedtls_ecp_curve_info_from_tls_id (uint16_t tls_id)
| Get curve information from a TLS NamedCurve value. More...
const mbedtls_ecp_curve_info * | mbedtls_ecp_curve_info_from_name (const char *name)
| Get curve information from a human-readable name. More...
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 *P, 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 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_group_load (mbedtls_ecp_group *grp, mbedtls_ecp_group_id id)
| Set a group using well-known domain parameters. 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...
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...
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...
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...

## Detailed Description

Elliptic curves over GF(p)

Definition in file ecp.h.

## Macro Definition Documentation

## MBEDTLS_ECP_DP_MAX

#define MBEDTLS_ECP_DP_MAX 12

Number of supported curves (plus one for NONE).

(Montgomery curves excluded for now.)

Definition at line 86 of file ecp.h.

## MBEDTLS_ECP_FIXED_POINT_OPTIM

#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1

Enable fixed-point speed-up

Definition at line 229 of file ecp.h.

## MBEDTLS_ECP_MAX_BITS

#define MBEDTLS_ECP_MAX_BITS 521

Maximum size of the groups (that is, of N and P)Maximum bit size of groups

Definition at line 187 of file ecp.h.

## MBEDTLS_ECP_MAX_BYTES

#define MBEDTLS_ECP_MAX_BYTES ( ( MBEDTLS_ECP_MAX_BITS + 7 ) / 8 )

Definition at line 190 of file ecp.h.

## MBEDTLS_ECP_MAX_PT_LEN

#define MBEDTLS_ECP_MAX_PT_LEN ( 2 * MBEDTLS_ECP_MAX_BYTES + 1 )

Definition at line 191 of file ecp.h.

## MBEDTLS_ECP_PF_COMPRESSED

#define MBEDTLS_ECP_PF_COMPRESSED 1

Compressed point format

Definition at line 238 of file ecp.h.

## MBEDTLS_ECP_PF_UNCOMPRESSED

#define MBEDTLS_ECP_PF_UNCOMPRESSED 0

Uncompressed point format

Definition at line 237 of file ecp.h.

## MBEDTLS_ECP_TLS_NAMED_CURVE

#define MBEDTLS_ECP_TLS_NAMED_CURVE 3

ECCurveType's named_curve

Definition at line 243 of file ecp.h.

## MBEDTLS_ECP_WINDOW_SIZE

#define MBEDTLS_ECP_WINDOW_SIZE 6

Maximum window size used

Definition at line 214 of file ecp.h.

## MBEDTLS_ERR_ECP_ALLOC_FAILED

#define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80

Memory allocation failed.

Definition at line 36 of file ecp.h.

## MBEDTLS_ERR_ECP_BAD_INPUT_DATA

#define MBEDTLS_ERR_ECP_BAD_INPUT_DATA -0x4F80

Bad input parameters to function.

Definition at line 32 of file ecp.h.

## MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL

#define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL -0x4F00

The buffer is too small to write to.

Definition at line 33 of file ecp.h.

## MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE

#define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE -0x4E80

Requested curve not available.

Definition at line 34 of file ecp.h.

## MBEDTLS_ERR_ECP_HW_ACCEL_FAILED

#define MBEDTLS_ERR_ECP_HW_ACCEL_FAILED -0x4B80

ECP hardware accelerator failed.

Definition at line 40 of file ecp.h.

## MBEDTLS_ERR_ECP_INVALID_KEY

#define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80

Invalid private or public key.

Definition at line 38 of file ecp.h.

## MBEDTLS_ERR_ECP_RANDOM_FAILED

#define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00

Generation of random value, such as (ephemeral) key, failed.

Definition at line 37 of file ecp.h.

## MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH

#define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00

Signature is valid but shorter than the user-supplied length.

Definition at line 39 of file ecp.h.

## MBEDTLS_ERR_ECP_VERIFY_FAILED

#define MBEDTLS_ERR_ECP_VERIFY_FAILED -0x4E00

The signature is not valid.

Definition at line 35 of file ecp.h.

## Enumeration Type Documentation

## mbedtls_ecp_group_id

enum mbedtls_ecp_group_id

Domain parameters (curve, subgroup and generator) identifiers.

Only curves over prime fields are supported.

Warning
  This library does not support validation of arbitrary domain parameters. Therefore, only well-known domain parameters from trusted sources should be used. See mbedtls_ecp_group_load().

Enumerator
MBEDTLS_ECP_DP_NONE |
MBEDTLS_ECP_DP_SECP192R1 | 192-bits NIST curve
MBEDTLS_ECP_DP_SECP224R1 | 224-bits NIST curve
MBEDTLS_ECP_DP_SECP256R1 | 256-bits NIST curve
MBEDTLS_ECP_DP_SECP384R1 | 384-bits NIST curve
MBEDTLS_ECP_DP_SECP521R1 | 521-bits NIST curve
MBEDTLS_ECP_DP_BP256R1 | 256-bits Brainpool curve
MBEDTLS_ECP_DP_BP384R1 | 384-bits Brainpool curve
MBEDTLS_ECP_DP_BP512R1 | 512-bits Brainpool curve
MBEDTLS_ECP_DP_CURVE25519 | Curve25519
MBEDTLS_ECP_DP_SECP192K1 | 192-bits "Koblitz" curve
MBEDTLS_ECP_DP_SECP224K1 | 224-bits "Koblitz" curve
MBEDTLS_ECP_DP_SECP256K1 | 256-bits "Koblitz" curve

Definition at line 64 of file ecp.h.

## Function Documentation

## 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

  grp | Group used
  d | Integer 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.

## 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

  pub | Keypair structure holding a public key
  prv | Keypair 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.

## 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

  grp | Curve/group the point should belong to
  pt | Point 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.

## 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

  P | Destination point
  Q | Source point

Returns
  0 if successful, MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed

## 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_id | A MBEDTLS_ECP_DP_XXX value

Returns
  The associated curve information or NULL

## 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

  name | The name

Returns
  The associated curve information or NULL

## 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_id | A MBEDTLS_ECP_DP_XXX value

Returns
  The associated curve information or NULL

## 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.

## 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_id | ECP group identifier
  key | Destination keypair
  f_rng | RNG function
  p_rng | RNG parameter

Returns
  0 if successful, or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code

## 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

  grp | ECP group
  d | Destination MPI (secret part)
  Q | Destination point (public part)
  f_rng | RNG function
  p_rng | RNG 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.

## 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

  grp | ECP group
  G | Chosen base point
  d | Destination MPI (secret part)
  Q | Destination point (public part)
  f_rng | RNG function
  p_rng | RNG 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.

## 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

  dst | Destination group
  src | Source group

Returns
  0 if successful, MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed

## mbedtls_ecp_group_free()

void mbedtls_ecp_group_free | ( | mbedtls_ecp_group * | grp | ) |

Free the components of an ECP group.

## mbedtls_ecp_group_init()

void mbedtls_ecp_group_init | ( | mbedtls_ecp_group * | grp | ) |

Initialize a group (to something meaningless)

## mbedtls_ecp_group_load()

int mbedtls_ecp_group_load | ( | mbedtls_ecp_group * | grp,
|  | mbedtls_ecp_group_id | id
| ) |  |

Set a group using well-known domain parameters.

Parameters

  grp | Destination group
  id | Index in the list of well-known domain parameters

Returns
  0 if successful, MBEDTLS_ERR_MPI_XXX if initialization failed MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE for unkownn groups

Note
  Index should be a value of RFC 4492's enum NamedCurve, usually in the form of a MBEDTLS_ECP_DP_XXX macro.

## 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.

## mbedtls_ecp_is_zero()

int mbedtls_ecp_is_zero | ( | mbedtls_ecp_point * | pt | ) |

Tell if a point is zero.

Parameters

  pt | Point to test

Returns
  1 if point is zero, 0 otherwise

## mbedtls_ecp_keypair_free()

void mbedtls_ecp_keypair_free | ( | mbedtls_ecp_keypair * | key | ) |

Free the components of a key pair.

## mbedtls_ecp_keypair_init()

void mbedtls_ecp_keypair_init | ( | mbedtls_ecp_keypair * | key | ) |

Initialize a key pair (as an invalid one)

## 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

  grp | ECP group
  R | Destination point
  m | Integer by which to multiply
  P | Point to multiply
  f_rng | RNG function (see notes)
  p_rng | RNG 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

## 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

  grp | ECP group
  R | Destination point
  m | Integer by which to multiply P
  P | Point to multiply by m
  n | Integer by which to multiply Q
  Q | Point 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

## 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

  P | First point to compare
  Q | Second point to compare

Returns
  0 if the points are equal, MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise

## mbedtls_ecp_point_free()

void mbedtls_ecp_point_free | ( | mbedtls_ecp_point * | pt | ) |

Free the components of a point.

## mbedtls_ecp_point_init()

void mbedtls_ecp_point_init | ( | mbedtls_ecp_point * | pt | ) |

Initialize a point (as zero)

## 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

  grp | Group to which the point should belong
  P | Point to import
  buf | Input buffer
  ilen | Actual 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.

## 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

  P | Destination point
  radix | Input numeric base
  x | First affine coordinate as a null-terminated string
  y | Second affine coordinate as a null-terminated string

Returns
  0 if successful, or a MBEDTLS_ERR_MPI_XXX error code

## 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

  grp | Group to which the point should belong
  P | Point to export
  format | Point format, should be a MBEDTLS_ECP_PF_XXX macro
  olen | Length of the actual output
  buf | Output buffer
  buflen | Length of the output buffer

Returns
  0 if successful, or MBEDTLS_ERR_ECP_BAD_INPUT_DATA or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL

## mbedtls_ecp_self_test()

int mbedtls_ecp_self_test | ( | int | verbose | ) |

Checkup routine.

Returns
  0 if successful, or 1 if a test failed

## mbedtls_ecp_set_zero()

int mbedtls_ecp_set_zero | ( | mbedtls_ecp_point * | pt | ) |

Set a point to zero.

Parameters

  pt | Destination point

Returns
  0 if successful, MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed

## 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

  grp | Destination group
  buf | &(Start of input buffer)
  len | Buffer 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

## 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

  grp | ECP group used
  pt | Destination point
  buf | $(Start of input buffer)
  len | Buffer 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

## 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

  grp | ECP group used
  olen | Number of bytes actually written
  buf | Buffer to write to
  blen | Buffer length

Returns
  0 if successful, or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL

## 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

  grp | ECP group used
  pt | Point to export
  format | Export format
  olen | length of data written
  buf | Buffer to write to
  blen | Buffer length

Returns
  0 if successful, or MBEDTLS_ERR_ECP_BAD_INPUT_DATA or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL