Mbed TLS v3.6.7
ecp.h
Go to the documentation of this file.
1 
17 /*
18  * Copyright The Mbed TLS Contributors
19  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
20  */
21 
22 #ifndef MBEDTLS_ECP_H
23 #define MBEDTLS_ECP_H
24 #include "mbedtls/private_access.h"
25 
26 #include "mbedtls/build_info.h"
27 #include "mbedtls/platform_util.h"
28 
29 #include "mbedtls/bignum.h"
30 
31 /*
32  * ECP error codes
33  */
35 #define MBEDTLS_ERR_ECP_BAD_INPUT_DATA -0x4F80
37 #define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL -0x4F00
39 #define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE -0x4E80
41 #define MBEDTLS_ERR_ECP_VERIFY_FAILED -0x4E00
43 #define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80
45 #define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00
47 #define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80
49 #define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00
51 #define MBEDTLS_ERR_ECP_IN_PROGRESS -0x4B00
52 
53 /* Flags indicating whether to include code that is specific to certain
54  * types of curves. These flags are for internal library use only. */
55 #if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) || \
56  defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) || \
57  defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \
58  defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) || \
59  defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) || \
60  defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) || \
61  defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) || \
62  defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) || \
63  defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) || \
64  defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \
65  defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
66 #define MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED
67 #endif
68 #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) || \
69  defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
70 #define MBEDTLS_ECP_MONTGOMERY_ENABLED
71 #endif
72 
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76 
86 /* Note: when adding a new curve:
87  * - Add it at the end of this enum, otherwise you'll break the ABI by
88  * changing the numerical value for existing curves.
89  * - Increment MBEDTLS_ECP_DP_MAX below if needed.
90  * - Update the calculation of MBEDTLS_ECP_MAX_BITS below.
91  * - Add the corresponding MBEDTLS_ECP_DP_xxx_ENABLED macro definition to
92  * mbedtls_config.h.
93  * - List the curve as a dependency of MBEDTLS_ECP_C and
94  * MBEDTLS_ECDSA_C if supported in check_config.h.
95  * - Add the curve to the appropriate curve type macro
96  * MBEDTLS_ECP_yyy_ENABLED above.
97  * - Add the necessary definitions to ecp_curves.c.
98  * - Add the curve to the ecp_supported_curves array in ecp.c.
99  * - Add the curve to applicable profiles in x509_crt.c.
100  * - Add the curve to applicable presets in ssl_tls.c.
101  */
102 typedef enum {
118 
122 #define MBEDTLS_ECP_DP_MAX 14
123 
124 /*
125  * Curve types
126  */
127 typedef enum {
129  MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS, /* y^2 = x^3 + a x + b */
130  MBEDTLS_ECP_TYPE_MONTGOMERY, /* y^2 = x^3 + a x^2 + x */
132 
140 typedef struct mbedtls_ecp_curve_info {
142  uint16_t tls_id;
143  uint16_t bit_size;
144  const char *name;
146 
158 typedef struct mbedtls_ecp_point {
162 }
164 
165 #if !defined(MBEDTLS_ECP_ALT)
166 /*
167  * default Mbed TLS elliptic curve arithmetic implementation
168  *
169  * (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an
170  * alternative implementation for the whole module and it will replace this
171  * one.)
172  */
173 
222 typedef struct mbedtls_ecp_group {
234  size_t pbits;
235  size_t nbits;
238  /* End of public fields */
239 
240  unsigned int MBEDTLS_PRIVATE(h);
241  int(*MBEDTLS_PRIVATE(modp))(mbedtls_mpi *);
243  int(*MBEDTLS_PRIVATE(t_pre))(mbedtls_ecp_point *, void *);
244  int(*MBEDTLS_PRIVATE(t_post))(mbedtls_ecp_point *, void *);
245  void *MBEDTLS_PRIVATE(t_data);
247  size_t MBEDTLS_PRIVATE(T_size);
248 }
250 
259 #if !defined(MBEDTLS_ECP_WINDOW_SIZE)
260 /*
261  * Maximum "window" size used for point multiplication.
262  * Default: a point where higher memory usage yields diminishing performance
263  * returns.
264  * Minimum value: 2. Maximum value: 7.
265  *
266  * Result is an array of at most ( 1 << ( MBEDTLS_ECP_WINDOW_SIZE - 1 ) )
267  * points used for point multiplication. This value is directly tied to EC
268  * peak memory usage, so decreasing it by one should roughly cut memory usage
269  * by two (if large curves are in use).
270  *
271  * Reduction in size may reduce speed, but larger curves are impacted first.
272  * Sample performances (in ECDHE handshakes/s, with FIXED_POINT_OPTIM = 1):
273  * w-size: 6 5 4 3 2
274  * 521 145 141 135 120 97
275  * 384 214 209 198 177 146
276  * 256 320 320 303 262 226
277  * 224 475 475 453 398 342
278  * 192 640 640 633 587 476
279  */
280 #define MBEDTLS_ECP_WINDOW_SIZE 4
281 #endif /* MBEDTLS_ECP_WINDOW_SIZE */
282 
283 #if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM)
284 /*
285  * Trade code size for speed on fixed-point multiplication.
286  *
287  * This speeds up repeated multiplication of the generator (that is, the
288  * multiplication in ECDSA signatures, and half of the multiplications in
289  * ECDSA verification and ECDHE) by a factor roughly 3 to 4.
290  *
291  * For each n-bit Short Weierstrass curve that is enabled, this adds 4n bytes
292  * of code size if n < 384 and 8n otherwise.
293  *
294  * Change this value to 0 to reduce code size.
295  */
296 #define MBEDTLS_ECP_FIXED_POINT_OPTIM 1
297 #endif /* MBEDTLS_ECP_FIXED_POINT_OPTIM */
298 
301 #else /* MBEDTLS_ECP_ALT */
302 #include "ecp_alt.h"
303 #endif /* MBEDTLS_ECP_ALT */
304 
308 #if !defined(MBEDTLS_ECP_LIGHT)
309 /* Dummy definition to help code that has optional ECP support and
310  * defines an MBEDTLS_ECP_MAX_BYTES-sized array unconditionally. */
311 #define MBEDTLS_ECP_MAX_BITS 1
312 /* Note: the curves must be listed in DECREASING size! */
313 #elif defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
314 #define MBEDTLS_ECP_MAX_BITS 521
315 #elif defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
316 #define MBEDTLS_ECP_MAX_BITS 512
317 #elif defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
318 #define MBEDTLS_ECP_MAX_BITS 448
319 #elif defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
320 #define MBEDTLS_ECP_MAX_BITS 384
321 #elif defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
322 #define MBEDTLS_ECP_MAX_BITS 384
323 #elif defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
324 #define MBEDTLS_ECP_MAX_BITS 256
325 #elif defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
326 #define MBEDTLS_ECP_MAX_BITS 256
327 #elif defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
328 #define MBEDTLS_ECP_MAX_BITS 256
329 #elif defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
330 #define MBEDTLS_ECP_MAX_BITS 255
331 #elif defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
332 #define MBEDTLS_ECP_MAX_BITS 225 // n is slightly above 2^224
333 #elif defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
334 #define MBEDTLS_ECP_MAX_BITS 224
335 #elif defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
336 #define MBEDTLS_ECP_MAX_BITS 192
337 #elif defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
338 #define MBEDTLS_ECP_MAX_BITS 192
339 #else /* !MBEDTLS_ECP_LIGHT */
340 #error "Missing definition of MBEDTLS_ECP_MAX_BITS"
341 #endif /* !MBEDTLS_ECP_LIGHT */
342 
343 #define MBEDTLS_ECP_MAX_BYTES ((MBEDTLS_ECP_MAX_BITS + 7) / 8)
344 #define MBEDTLS_ECP_MAX_PT_LEN (2 * MBEDTLS_ECP_MAX_BYTES + 1)
345 
346 #if defined(MBEDTLS_ECP_RESTARTABLE)
347 
353 typedef struct mbedtls_ecp_restart_mul mbedtls_ecp_restart_mul_ctx;
354 
360 typedef struct mbedtls_ecp_restart_muladd mbedtls_ecp_restart_muladd_ctx;
361 
365 typedef struct {
366  unsigned MBEDTLS_PRIVATE(ops_done);
367  unsigned MBEDTLS_PRIVATE(depth);
368  mbedtls_ecp_restart_mul_ctx *MBEDTLS_PRIVATE(rsm);
369  mbedtls_ecp_restart_muladd_ctx *MBEDTLS_PRIVATE(ma);
371 
372 /*
373  * Operation counts for restartable functions
374  */
375 #define MBEDTLS_ECP_OPS_CHK 3
376 #define MBEDTLS_ECP_OPS_DBL 8
377 #define MBEDTLS_ECP_OPS_ADD 11
378 #define MBEDTLS_ECP_OPS_INV 120
391 int mbedtls_ecp_check_budget(const mbedtls_ecp_group *grp,
392  mbedtls_ecp_restart_ctx *rs_ctx,
393  unsigned ops);
394 
395 /* Utility macro for checking and updating ops budget */
396 #define MBEDTLS_ECP_BUDGET(ops) \
397  MBEDTLS_MPI_CHK(mbedtls_ecp_check_budget(grp, rs_ctx, \
398  (unsigned) (ops)));
399 
400 #else /* MBEDTLS_ECP_RESTARTABLE */
401 
402 #define MBEDTLS_ECP_BUDGET(ops) /* no-op; for compatibility */
403 
404 /* We want to declare restartable versions of existing functions anyway */
406 
407 #endif /* MBEDTLS_ECP_RESTARTABLE */
408 
417 typedef struct mbedtls_ecp_keypair {
421 }
423 
428 #define MBEDTLS_ECP_PF_UNCOMPRESSED 0
439 #define MBEDTLS_ECP_PF_COMPRESSED 1
440 
441 /*
442  * Some other constants from RFC 4492
443  */
444 #define MBEDTLS_ECP_TLS_NAMED_CURVE 3
446 #if defined(MBEDTLS_ECP_RESTARTABLE)
510 void mbedtls_ecp_set_max_ops(unsigned max_ops);
511 
518 int mbedtls_ecp_restart_is_enabled(void);
519 #endif /* MBEDTLS_ECP_RESTARTABLE */
520 
521 /*
522  * Get the type of a curve
523  */
525 
539 
555 
566 
577 
588 
595 
606 
613 
620 
629 
638 
639 #if defined(MBEDTLS_ECP_RESTARTABLE)
646 void mbedtls_ecp_restart_init(mbedtls_ecp_restart_ctx *ctx);
647 
655 void mbedtls_ecp_restart_free(mbedtls_ecp_restart_ctx *ctx);
656 #endif /* MBEDTLS_ECP_RESTARTABLE */
657 
670 
683  const mbedtls_ecp_group *src);
684 
695 
706 
720  const mbedtls_ecp_point *Q);
721 
735  const char *x, const char *y);
736 
763  const mbedtls_ecp_point *P,
764  int format, size_t *olen,
765  unsigned char *buf, size_t buflen);
766 
794  const unsigned char *buf, size_t ilen);
795 
815  mbedtls_ecp_point *pt,
816  const unsigned char **buf, size_t len);
817 
841  const mbedtls_ecp_point *pt,
842  int format, size_t *olen,
843  unsigned char *buf, size_t blen);
844 
863 
882  const unsigned char **buf, size_t len);
883 
903  const unsigned char **buf,
904  size_t len);
924  size_t *olen,
925  unsigned char *buf, size_t blen);
926 
957  const mbedtls_mpi *m, const mbedtls_ecp_point *P,
958  mbedtls_f_rng_t *f_rng, void *p_rng);
959 
991  const mbedtls_mpi *m, const mbedtls_ecp_point *P,
992  mbedtls_f_rng_t *f_rng, void *p_rng,
993  mbedtls_ecp_restart_ctx *rs_ctx);
994 
995 #if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED)
1012 {
1013  return grp->A.MBEDTLS_PRIVATE(p) == NULL;
1014 }
1015 
1052  const mbedtls_mpi *m, const mbedtls_ecp_point *P,
1053  const mbedtls_mpi *n, const mbedtls_ecp_point *Q);
1054 
1097  const mbedtls_mpi *m, const mbedtls_ecp_point *P,
1098  const mbedtls_mpi *n, const mbedtls_ecp_point *Q,
1099  mbedtls_ecp_restart_ctx *rs_ctx);
1100 #endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */
1101 
1130  const mbedtls_ecp_point *pt);
1131 
1152  const mbedtls_mpi *d);
1153 
1170  mbedtls_mpi *d,
1171  mbedtls_f_rng_t *f_rng,
1172  void *p_rng);
1173 
1202  const mbedtls_ecp_point *G,
1204  mbedtls_f_rng_t *f_rng,
1205  void *p_rng);
1206 
1231  mbedtls_ecp_point *Q,
1232  mbedtls_f_rng_t *f_rng,
1233  void *p_rng);
1234 
1249  mbedtls_f_rng_t *f_rng,
1250  void *p_rng);
1251 
1281  mbedtls_ecp_keypair *key,
1282  const mbedtls_ecp_point *Q);
1283 
1318  const unsigned char *buf, size_t buflen);
1319 
1320 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
1366  unsigned char *buf, size_t buflen);
1367 #endif /* MBEDTLS_DEPRECATED_REMOVED */
1368 
1389  size_t *olen, unsigned char *buf, size_t buflen);
1390 
1418  int format, size_t *olen,
1419  unsigned char *buf, size_t buflen);
1420 
1442  const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv,
1443  mbedtls_f_rng_t *f_rng, void *p_rng);
1444 
1459  mbedtls_ecp_keypair *key,
1460  mbedtls_f_rng_t *f_rng, void *p_rng);
1461 
1472  const mbedtls_ecp_keypair *key);
1473 
1500 
1501 #if defined(MBEDTLS_SELF_TEST)
1502 
1509 int mbedtls_ecp_self_test(int verbose);
1510 
1511 #endif /* MBEDTLS_SELF_TEST */
1512 
1513 #ifdef __cplusplus
1514 }
1515 #endif
1516 
1517 #endif /* ecp.h */
Multi-precision integer library.
int mbedtls_ecp_gen_keypair_base(mbedtls_ecp_group *grp, const mbedtls_ecp_point *G, mbedtls_mpi *d, mbedtls_ecp_point *Q, mbedtls_f_rng_t *f_rng, void *p_rng)
This function generates a keypair with a configurable base point.
void mbedtls_ecp_keypair_free(mbedtls_ecp_keypair *key)
This function frees the components of a key pair.
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.
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.
int mbedtls_ecp_keypair_calc_public(mbedtls_ecp_keypair *key, mbedtls_f_rng_t *f_rng, void *p_rng)
Calculate the public key from a private key in a key pair.
int mbedtls_ecp_is_zero(mbedtls_ecp_point *pt)
This function checks if a point is the point at infinity.
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_group_id mbedtls_ecp_keypair_get_group_id(const mbedtls_ecp_keypair *key)
Query the group that a key pair belongs to.
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,...
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.
int mbedtls_ecp_mul_restartable(mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, mbedtls_f_rng_t *f_rng, 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_curve_type mbedtls_ecp_get_type(const mbedtls_ecp_group *grp)
void mbedtls_ecp_restart_ctx
Definition: ecp.h:405
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_curve_type
Definition: ecp.h:127
@ MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS
Definition: ecp.h:129
@ MBEDTLS_ECP_TYPE_NONE
Definition: ecp.h:128
@ MBEDTLS_ECP_TYPE_MONTGOMERY
Definition: ecp.h:130
void mbedtls_ecp_group_init(mbedtls_ecp_group *grp)
This function initializes an ECP group context without loading any domain parameters.
struct mbedtls_ecp_group mbedtls_ecp_group
The ECP group structure.
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.
struct mbedtls_ecp_keypair mbedtls_ecp_keypair
The ECP key-pair structure.
int mbedtls_ecp_point_cmp(const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
This function compares two points.
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.
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.
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.
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.
int mbedtls_ecp_gen_keypair(mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q, mbedtls_f_rng_t *f_rng, void *p_rng)
This function generates an ECP keypair.
void mbedtls_ecp_keypair_init(mbedtls_ecp_keypair *key)
This function initializes a key pair as an invalid one.
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...
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...
void mbedtls_ecp_point_free(mbedtls_ecp_point *pt)
This function frees the components of a 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.
const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_name(const char *name)
This function retrieves curve information from a human-readable name.
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.
void mbedtls_ecp_group_free(mbedtls_ecp_group *grp)
This function frees the components of an ECP group.
int mbedtls_ecp_copy(mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
This function copies the contents of point Q into point P.
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 ...
int mbedtls_ecp_gen_privkey(const mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_f_rng_t *f_rng, void *p_rng)
This function generates a private key.
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....
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.
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.
int mbedtls_ecp_gen_key(mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key, mbedtls_f_rng_t *f_rng, void *p_rng)
This function generates an ECP 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.
int mbedtls_ecp_check_pub_priv(const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv, mbedtls_f_rng_t *f_rng, void *p_rng)
This function checks that the keypair objects pub and prv have the same group and the same public poi...
int mbedtls_ecp_set_zero(mbedtls_ecp_point *pt)
This function sets a point to the point at infinity.
struct mbedtls_ecp_curve_info mbedtls_ecp_curve_info
struct mbedtls_ecp_point mbedtls_ecp_point
The ECP point structure, in Jacobian coordinates.
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,...
void mbedtls_ecp_point_init(mbedtls_ecp_point *pt)
This function initializes a point as zero.
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.
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.
int mbedtls_ecp_mul(mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, mbedtls_f_rng_t *f_rng, void *p_rng)
This function performs a scalar multiplication of a point by an integer: R = m * P.
mbedtls_ecp_group_id
Definition: ecp.h:102
@ MBEDTLS_ECP_DP_SECP192K1
Definition: ecp.h:113
@ MBEDTLS_ECP_DP_SECP384R1
Definition: ecp.h:107
@ MBEDTLS_ECP_DP_CURVE448
Definition: ecp.h:116
@ MBEDTLS_ECP_DP_CURVE25519
Definition: ecp.h:112
@ MBEDTLS_ECP_DP_NONE
Definition: ecp.h:103
@ MBEDTLS_ECP_DP_SECP256K1
Definition: ecp.h:115
@ MBEDTLS_ECP_DP_BP512R1
Definition: ecp.h:111
@ MBEDTLS_ECP_DP_SECP224R1
Definition: ecp.h:105
@ MBEDTLS_ECP_DP_SECP521R1
Definition: ecp.h:108
@ MBEDTLS_ECP_DP_BP384R1
Definition: ecp.h:110
@ MBEDTLS_ECP_DP_SECP224K1
Definition: ecp.h:114
@ MBEDTLS_ECP_DP_BP256R1
Definition: ecp.h:109
@ MBEDTLS_ECP_DP_SECP192R1
Definition: ecp.h:104
@ MBEDTLS_ECP_DP_SECP256R1
Definition: ecp.h:106
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.
int mbedtls_ecp_self_test(int verbose)
The ECP checkup routine.
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:1011
Build-time configuration info.
Common and shared functions used by multiple modules in the Mbed TLS library.
int mbedtls_f_rng_t(void *p_rng, unsigned char *output, size_t output_size)
The type of custom random generator (RNG) callbacks.
#define MBEDTLS_DEPRECATED
Definition: platform_util.h:37
Macro wrapper for struct's members.
#define MBEDTLS_PRIVATE(member)
const char * name
Definition: ecp.h:144
mbedtls_ecp_group_id grp_id
Definition: ecp.h:141
uint16_t bit_size
Definition: ecp.h:143
uint16_t tls_id
Definition: ecp.h:142
The ECP group structure.
Definition: ecp.h:222
size_t pbits
Definition: ecp.h:234
mbedtls_ecp_group_id id
Definition: ecp.h:223
mbedtls_mpi N
Definition: ecp.h:233
mbedtls_ecp_point G
Definition: ecp.h:232
mbedtls_mpi B
Definition: ecp.h:230
mbedtls_mpi P
Definition: ecp.h:224
size_t nbits
Definition: ecp.h:235
mbedtls_mpi A
Definition: ecp.h:225
The ECP key-pair structure.
Definition: ecp.h:417
The ECP point structure, in Jacobian coordinates.
Definition: ecp.h:158
MPI structure.
Definition: bignum.h:208