Mbed TLS v2.28.5
ecp.h
Go to the documentation of this file.
1 
17 /*
18  * Copyright The Mbed TLS Contributors
19  * SPDX-License-Identifier: Apache-2.0
20  *
21  * Licensed under the Apache License, Version 2.0 (the "License"); you may
22  * not use this file except in compliance with the License.
23  * You may obtain a copy of the License at
24  *
25  * http://www.apache.org/licenses/LICENSE-2.0
26  *
27  * Unless required by applicable law or agreed to in writing, software
28  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
29  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30  * See the License for the specific language governing permissions and
31  * limitations under the License.
32  */
33 
34 #ifndef MBEDTLS_ECP_H
35 #define MBEDTLS_ECP_H
36 
37 #if !defined(MBEDTLS_CONFIG_FILE)
38 #include "mbedtls/config.h"
39 #else
40 #include MBEDTLS_CONFIG_FILE
41 #endif
42 
43 #include "mbedtls/bignum.h"
44 
45 #if (defined(__ARMCC_VERSION) || defined(_MSC_VER)) && \
46  !defined(inline) && !defined(__cplusplus)
47 #define inline __inline
48 #endif
49 
50 /*
51  * ECP error codes
52  */
54 #define MBEDTLS_ERR_ECP_BAD_INPUT_DATA -0x4F80
55 
56 #define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL -0x4F00
57 
58 #define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE -0x4E80
59 
60 #define MBEDTLS_ERR_ECP_VERIFY_FAILED -0x4E00
61 
62 #define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80
63 
64 #define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00
65 
66 #define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80
67 
68 #define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00
69 
70 /* MBEDTLS_ERR_ECP_HW_ACCEL_FAILED is deprecated and should not be used. */
72 #define MBEDTLS_ERR_ECP_HW_ACCEL_FAILED -0x4B80
73 
75 #define MBEDTLS_ERR_ECP_IN_PROGRESS -0x4B00
76 
77 /* Flags indicating whether to include code that is specific to certain
78  * types of curves. These flags are for internal library use only. */
79 #if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) || \
80  defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) || \
81  defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \
82  defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) || \
83  defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) || \
84  defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) || \
85  defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) || \
86  defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) || \
87  defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) || \
88  defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \
89  defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
90 #define MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED
91 #endif
92 #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) || \
93  defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
94 #define MBEDTLS_ECP_MONTGOMERY_ENABLED
95 #endif
96 
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100 
110 /* Note: when adding a new curve:
111  * - Add it at the end of this enum, otherwise you'll break the ABI by
112  * changing the numerical value for existing curves.
113  * - Increment MBEDTLS_ECP_DP_MAX below if needed.
114  * - Update the calculation of MBEDTLS_ECP_MAX_BITS_MIN below.
115  * - Add the corresponding MBEDTLS_ECP_DP_xxx_ENABLED macro definition to
116  * config.h.
117  * - List the curve as a dependency of MBEDTLS_ECP_C and
118  * MBEDTLS_ECDSA_C if supported in check_config.h.
119  * - Add the curve to the appropriate curve type macro
120  * MBEDTLS_ECP_yyy_ENABLED above.
121  * - Add the necessary definitions to ecp_curves.c.
122  * - Add the curve to the ecp_supported_curves array in ecp.c.
123  * - Add the curve to applicable profiles in x509_crt.c if applicable.
124  */
125 typedef enum {
141 
147 #define MBEDTLS_ECP_DP_MAX 12
148 
149 /*
150  * Curve types
151  */
152 typedef enum {
154  MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS, /* y^2 = x^3 + a x + b */
155  MBEDTLS_ECP_TYPE_MONTGOMERY, /* y^2 = x^3 + a x^2 + x */
157 
161 typedef struct mbedtls_ecp_curve_info {
163  uint16_t tls_id;
164  uint16_t bit_size;
165  const char *name;
167 
179 typedef struct mbedtls_ecp_point {
183 }
185 
186 /* Determine the minimum safe value of MBEDTLS_ECP_MAX_BITS. */
187 #if !defined(MBEDTLS_ECP_C)
188 #define MBEDTLS_ECP_MAX_BITS_MIN 0
189 /* Note: the curves must be listed in DECREASING size! */
190 #elif defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
191 #define MBEDTLS_ECP_MAX_BITS_MIN 521
192 #elif defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
193 #define MBEDTLS_ECP_MAX_BITS_MIN 512
194 #elif defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
195 #define MBEDTLS_ECP_MAX_BITS_MIN 448
196 #elif defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
197 #define MBEDTLS_ECP_MAX_BITS_MIN 384
198 #elif defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
199 #define MBEDTLS_ECP_MAX_BITS_MIN 384
200 #elif defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
201 #define MBEDTLS_ECP_MAX_BITS_MIN 256
202 #elif defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
203 #define MBEDTLS_ECP_MAX_BITS_MIN 256
204 #elif defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
205 #define MBEDTLS_ECP_MAX_BITS_MIN 256
206 #elif defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
207 #define MBEDTLS_ECP_MAX_BITS_MIN 255
208 #elif defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
209 #define MBEDTLS_ECP_MAX_BITS_MIN 225 // n is slightly above 2^224
210 #elif defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
211 #define MBEDTLS_ECP_MAX_BITS_MIN 224
212 #elif defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
213 #define MBEDTLS_ECP_MAX_BITS_MIN 192
214 #elif defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
215 #define MBEDTLS_ECP_MAX_BITS_MIN 192
216 #else
217 #error "MBEDTLS_ECP_C enabled, but no curve?"
218 #endif
219 
220 #if !defined(MBEDTLS_ECP_ALT)
221 /*
222  * default Mbed TLS elliptic curve arithmetic implementation
223  *
224  * (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an
225  * alternative implementation for the whole module and it will replace this
226  * one.)
227  */
228 
282 typedef struct mbedtls_ecp_group {
294  size_t pbits;
295  size_t nbits;
298  unsigned int h;
299  int (*modp)(mbedtls_mpi *);
301  int (*t_pre)(mbedtls_ecp_point *, void *);
302  int (*t_post)(mbedtls_ecp_point *, void *);
303  void *t_data;
305  size_t T_size;
306 }
308 
317 #if defined(MBEDTLS_ECP_MAX_BITS)
318 
319 #if MBEDTLS_ECP_MAX_BITS < MBEDTLS_ECP_MAX_BITS_MIN
320 #error "MBEDTLS_ECP_MAX_BITS is smaller than the largest supported curve"
321 #endif
322 
323 #elif defined(MBEDTLS_ECP_C)
324 
327 #define MBEDTLS_ECP_MAX_BITS MBEDTLS_ECP_MAX_BITS_MIN
328 
329 #else
330 /* MBEDTLS_ECP_MAX_BITS is not relevant without MBEDTLS_ECP_C, but set it
331  * to a nonzero value so that code that unconditionally allocates an array
332  * of a size based on it keeps working if built without ECC support. */
333 #define MBEDTLS_ECP_MAX_BITS 1
334 #endif
335 
336 #define MBEDTLS_ECP_MAX_BYTES ((MBEDTLS_ECP_MAX_BITS + 7) / 8)
337 #define MBEDTLS_ECP_MAX_PT_LEN (2 * MBEDTLS_ECP_MAX_BYTES + 1)
338 
339 #if !defined(MBEDTLS_ECP_WINDOW_SIZE)
340 /*
341  * Maximum "window" size used for point multiplication.
342  * Default: a point where higher memory usage yields diminishing performance
343  * returns.
344  * Minimum value: 2. Maximum value: 7.
345  *
346  * Result is an array of at most ( 1 << ( MBEDTLS_ECP_WINDOW_SIZE - 1 ) )
347  * points used for point multiplication. This value is directly tied to EC
348  * peak memory usage, so decreasing it by one should roughly cut memory usage
349  * by two (if large curves are in use).
350  *
351  * Reduction in size may reduce speed, but larger curves are impacted first.
352  * Sample performances (in ECDHE handshakes/s, with FIXED_POINT_OPTIM = 1):
353  * w-size: 6 5 4 3 2
354  * 521 145 141 135 120 97
355  * 384 214 209 198 177 146
356  * 256 320 320 303 262 226
357  * 224 475 475 453 398 342
358  * 192 640 640 633 587 476
359  */
360 #define MBEDTLS_ECP_WINDOW_SIZE 4
361 #endif /* MBEDTLS_ECP_WINDOW_SIZE */
362 
363 #if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM)
364 /*
365  * Trade memory for speed on fixed-point multiplication.
366  *
367  * This speeds up repeated multiplication of the generator (that is, the
368  * multiplication in ECDSA signatures, and half of the multiplications in
369  * ECDSA verification and ECDHE) by a factor roughly 3 to 4.
370  *
371  * The cost is increasing EC peak memory usage by a factor roughly 2.
372  *
373  * Change this value to 0 to reduce peak memory usage.
374  */
375 #define MBEDTLS_ECP_FIXED_POINT_OPTIM 1
376 #endif /* MBEDTLS_ECP_FIXED_POINT_OPTIM */
377 
380 #else /* MBEDTLS_ECP_ALT */
381 #include "ecp_alt.h"
382 #endif /* MBEDTLS_ECP_ALT */
383 
384 #if defined(MBEDTLS_ECP_RESTARTABLE)
385 
391 typedef struct mbedtls_ecp_restart_mul mbedtls_ecp_restart_mul_ctx;
392 
398 typedef struct mbedtls_ecp_restart_muladd mbedtls_ecp_restart_muladd_ctx;
399 
403 typedef struct {
404  unsigned ops_done;
405  unsigned depth;
406  mbedtls_ecp_restart_mul_ctx *rsm;
407  mbedtls_ecp_restart_muladd_ctx *ma;
409 
410 /*
411  * Operation counts for restartable functions
412  */
413 #define MBEDTLS_ECP_OPS_CHK 3
414 #define MBEDTLS_ECP_OPS_DBL 8
415 #define MBEDTLS_ECP_OPS_ADD 11
416 #define MBEDTLS_ECP_OPS_INV 120
429 int mbedtls_ecp_check_budget(const mbedtls_ecp_group *grp,
430  mbedtls_ecp_restart_ctx *rs_ctx,
431  unsigned ops);
432 
433 /* Utility macro for checking and updating ops budget */
434 #define MBEDTLS_ECP_BUDGET(ops) \
435  MBEDTLS_MPI_CHK(mbedtls_ecp_check_budget(grp, rs_ctx, \
436  (unsigned) (ops)));
437 
438 #else /* MBEDTLS_ECP_RESTARTABLE */
439 
440 #define MBEDTLS_ECP_BUDGET(ops) /* no-op; for compatibility */
441 
442 /* We want to declare restartable versions of existing functions anyway */
444 
445 #endif /* MBEDTLS_ECP_RESTARTABLE */
446 
455 typedef struct mbedtls_ecp_keypair {
459 }
461 
462 /*
463  * Point formats, from RFC 4492's enum ECPointFormat
464  */
465 #define MBEDTLS_ECP_PF_UNCOMPRESSED 0
466 #define MBEDTLS_ECP_PF_COMPRESSED 1
468 /*
469  * Some other constants from RFC 4492
470  */
471 #define MBEDTLS_ECP_TLS_NAMED_CURVE 3
473 #if defined(MBEDTLS_ECP_RESTARTABLE)
474 
531 void mbedtls_ecp_set_max_ops(unsigned max_ops);
532 
539 int mbedtls_ecp_restart_is_enabled(void);
540 #endif /* MBEDTLS_ECP_RESTARTABLE */
541 
542 /*
543  * Get the type of a curve
544  */
546 
560 
576 
587 
598 
609 
616 
627 
634 
641 
650 
659 
660 #if defined(MBEDTLS_ECP_RESTARTABLE)
661 
667 void mbedtls_ecp_restart_init(mbedtls_ecp_restart_ctx *ctx);
668 
676 void mbedtls_ecp_restart_free(mbedtls_ecp_restart_ctx *ctx);
677 #endif /* MBEDTLS_ECP_RESTARTABLE */
678 
691 
704  const mbedtls_ecp_group *src);
705 
716 
727 
741  const mbedtls_ecp_point *Q);
742 
756  const char *x, const char *y);
757 
784  const mbedtls_ecp_point *P,
785  int format, size_t *olen,
786  unsigned char *buf, size_t buflen);
787 
812  const unsigned char *buf, size_t ilen);
813 
833  mbedtls_ecp_point *pt,
834  const unsigned char **buf, size_t len);
835 
859  const mbedtls_ecp_point *pt,
860  int format, size_t *olen,
861  unsigned char *buf, size_t blen);
862 
881 
900  const unsigned char **buf, size_t len);
901 
921  const unsigned char **buf,
922  size_t len);
942  size_t *olen,
943  unsigned char *buf, size_t blen);
944 
982  const mbedtls_mpi *m, const mbedtls_ecp_point *P,
983  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng);
984 
1016  const mbedtls_mpi *m, const mbedtls_ecp_point *P,
1017  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
1018  mbedtls_ecp_restart_ctx *rs_ctx);
1019 
1020 #if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED)
1021 
1037 {
1038  return grp->A.p == NULL;
1039 }
1040 
1077  const mbedtls_mpi *m, const mbedtls_ecp_point *P,
1078  const mbedtls_mpi *n, const mbedtls_ecp_point *Q);
1079 
1122  const mbedtls_mpi *m, const mbedtls_ecp_point *P,
1123  const mbedtls_mpi *n, const mbedtls_ecp_point *Q,
1124  mbedtls_ecp_restart_ctx *rs_ctx);
1125 #endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */
1126 
1155  const mbedtls_ecp_point *pt);
1156 
1177  const mbedtls_mpi *d);
1178 
1195  mbedtls_mpi *d,
1196  int (*f_rng)(void *, unsigned char *, size_t),
1197  void *p_rng);
1198 
1227  const mbedtls_ecp_point *G,
1229  int (*f_rng)(void *, unsigned char *, size_t),
1230  void *p_rng);
1231 
1256  mbedtls_ecp_point *Q,
1257  int (*f_rng)(void *, unsigned char *, size_t),
1258  void *p_rng);
1259 
1274  int (*f_rng)(void *, unsigned char *, size_t),
1275  void *p_rng);
1276 
1296  const unsigned char *buf, size_t buflen);
1297 
1315  unsigned char *buf, size_t buflen);
1316 
1335  const mbedtls_ecp_keypair *prv);
1336 
1337 #if defined(MBEDTLS_SELF_TEST)
1338 
1345 int mbedtls_ecp_self_test(int verbose);
1346 
1347 #endif /* MBEDTLS_SELF_TEST */
1348 
1349 #ifdef __cplusplus
1350 }
1351 #endif
1352 
1353 #endif /* ecp.h */
uint16_t tls_id
Definition: ecp.h:163
int(* modp)(mbedtls_mpi *)
Definition: ecp.h:299
int mbedtls_ecp_is_zero(mbedtls_ecp_point *pt)
This function checks if a point is the point at infinity.
mbedtls_mpi N
Definition: ecp.h:293
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...
int(* t_post)(mbedtls_ecp_point *, void *)
Definition: ecp.h:302
mbedtls_mpi Z
Definition: ecp.h:182
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_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 poi...
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_curve_type mbedtls_ecp_get_type(const mbedtls_ecp_group *grp)
mbedtls_mpi Y
Definition: ecp.h:181
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_group grp
Definition: ecp.h:456
struct mbedtls_ecp_curve_info mbedtls_ecp_curve_info
The ECP key-pair structure.
Definition: ecp.h:455
int mbedtls_ecp_set_zero(mbedtls_ecp_point *pt)
This function sets a point to the point at infinity.
int mbedtls_ecp_copy(mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
This function copies the contents of point Q into point P.
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...
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.
Configuration options (set of defines)
size_t nbits
Definition: ecp.h:295
struct mbedtls_ecp_group mbedtls_ecp_group
The ECP group structure.
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.
void mbedtls_ecp_point_free(mbedtls_ecp_point *pt)
This function frees the components of a point.
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.
void mbedtls_ecp_keypair_init(mbedtls_ecp_keypair *key)
This function initializes a key pair as an invalid one.
size_t pbits
Definition: ecp.h:294
mbedtls_mpi X
Definition: ecp.h:180
Multi-precision integer library.
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.
The ECP group structure.
Definition: ecp.h:282
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_mpi_uint * p
Definition: bignum.h:229
mbedtls_ecp_group_id id
Definition: ecp.h:283
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_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...
void mbedtls_ecp_group_free(mbedtls_ecp_group *grp)
This function frees the components of an ECP group.
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.
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_mpi A
Definition: ecp.h:285
mbedtls_mpi P
Definition: ecp.h:284
int mbedtls_ecp_write_key(mbedtls_ecp_keypair *key, unsigned char *buf, size_t buflen)
This function exports an elliptic curve private key.
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:1036
void mbedtls_ecp_keypair_free(mbedtls_ecp_keypair *key)
This function frees the components of a key pair.
struct mbedtls_ecp_keypair mbedtls_ecp_keypair
The ECP key-pair structure.
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_restart_ctx
Definition: ecp.h:443
mbedtls_ecp_point Q
Definition: ecp.h:458
void * t_data
Definition: ecp.h:303
void mbedtls_ecp_point_init(mbedtls_ecp_point *pt)
This function initializes a point as zero.
mbedtls_ecp_group_id
Definition: ecp.h:125
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_self_test(int verbose)
The ECP checkup routine.
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.
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_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_group_id grp_id
Definition: ecp.h:162
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...
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_mpi d
Definition: ecp.h:457
unsigned int h
Definition: ecp.h:298
int mbedtls_ecp_point_cmp(const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
This function compares two points.
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...
size_t T_size
Definition: ecp.h:305
mbedtls_ecp_point * T
Definition: ecp.h:304
mbedtls_ecp_point G
Definition: ecp.h:292
MPI structure.
Definition: bignum.h:208
struct mbedtls_ecp_point mbedtls_ecp_point
The ECP point structure, in Jacobian coordinates.
The ECP point structure, in Jacobian coordinates.
Definition: ecp.h:179
const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_name(const char *name)
This function retrieves curve information from a human-readable name.
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_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.
const char * name
Definition: ecp.h:165
int(* t_pre)(mbedtls_ecp_point *, void *)
Definition: ecp.h:301
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.
uint16_t bit_size
Definition: ecp.h:164
mbedtls_mpi B
Definition: ecp.h:290
mbedtls_ecp_curve_type
Definition: ecp.h:152
void mbedtls_ecp_group_init(mbedtls_ecp_group *grp)
This function initializes an ECP group context without loading any domain parameters.