mbed TLS v2.28.4
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 /*
46  * ECP error codes
47  */
49 #define MBEDTLS_ERR_ECP_BAD_INPUT_DATA -0x4F80
51 #define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL -0x4F00
53 #define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE -0x4E80
55 #define MBEDTLS_ERR_ECP_VERIFY_FAILED -0x4E00
57 #define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80
59 #define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00
61 #define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80
63 #define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00
64 
65 /* MBEDTLS_ERR_ECP_HW_ACCEL_FAILED is deprecated and should not be used. */
67 #define MBEDTLS_ERR_ECP_HW_ACCEL_FAILED -0x4B80
68 
70 #define MBEDTLS_ERR_ECP_IN_PROGRESS -0x4B00
71 
72 /* Flags indicating whether to include code that is specific to certain
73  * types of curves. These flags are for internal library use only. */
74 #if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) || \
75  defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) || \
76  defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \
77  defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) || \
78  defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) || \
79  defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) || \
80  defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) || \
81  defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) || \
82  defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) || \
83  defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \
84  defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
85 #define MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED
86 #endif
87 #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) || \
88  defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
89 #define MBEDTLS_ECP_MONTGOMERY_ENABLED
90 #endif
91 
92 #ifdef __cplusplus
93 extern "C" {
94 #endif
95 
105 /* Note: when adding a new curve:
106  * - Add it at the end of this enum, otherwise you'll break the ABI by
107  * changing the numerical value for existing curves.
108  * - Increment MBEDTLS_ECP_DP_MAX below if needed.
109  * - Update the calculation of MBEDTLS_ECP_MAX_BITS_MIN below.
110  * - Add the corresponding MBEDTLS_ECP_DP_xxx_ENABLED macro definition to
111  * config.h.
112  * - List the curve as a dependency of MBEDTLS_ECP_C and
113  * MBEDTLS_ECDSA_C if supported in check_config.h.
114  * - Add the curve to the appropriate curve type macro
115  * MBEDTLS_ECP_yyy_ENABLED above.
116  * - Add the necessary definitions to ecp_curves.c.
117  * - Add the curve to the ecp_supported_curves array in ecp.c.
118  * - Add the curve to applicable profiles in x509_crt.c if applicable.
119  */
120 typedef enum {
136 
142 #define MBEDTLS_ECP_DP_MAX 12
143 
144 /*
145  * Curve types
146  */
147 typedef enum {
149  MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS, /* y^2 = x^3 + a x + b */
150  MBEDTLS_ECP_TYPE_MONTGOMERY, /* y^2 = x^3 + a x^2 + x */
152 
156 typedef struct mbedtls_ecp_curve_info {
158  uint16_t tls_id;
159  uint16_t bit_size;
160  const char *name;
162 
174 typedef struct mbedtls_ecp_point {
178 }
180 
181 /* Determine the minimum safe value of MBEDTLS_ECP_MAX_BITS. */
182 #if !defined(MBEDTLS_ECP_C)
183 #define MBEDTLS_ECP_MAX_BITS_MIN 0
184 /* Note: the curves must be listed in DECREASING size! */
185 #elif defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
186 #define MBEDTLS_ECP_MAX_BITS_MIN 521
187 #elif defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
188 #define MBEDTLS_ECP_MAX_BITS_MIN 512
189 #elif defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
190 #define MBEDTLS_ECP_MAX_BITS_MIN 448
191 #elif defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
192 #define MBEDTLS_ECP_MAX_BITS_MIN 384
193 #elif defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
194 #define MBEDTLS_ECP_MAX_BITS_MIN 384
195 #elif defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
196 #define MBEDTLS_ECP_MAX_BITS_MIN 256
197 #elif defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
198 #define MBEDTLS_ECP_MAX_BITS_MIN 256
199 #elif defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
200 #define MBEDTLS_ECP_MAX_BITS_MIN 256
201 #elif defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
202 #define MBEDTLS_ECP_MAX_BITS_MIN 255
203 #elif defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
204 #define MBEDTLS_ECP_MAX_BITS_MIN 225 // n is slightly above 2^224
205 #elif defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
206 #define MBEDTLS_ECP_MAX_BITS_MIN 224
207 #elif defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
208 #define MBEDTLS_ECP_MAX_BITS_MIN 192
209 #elif defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
210 #define MBEDTLS_ECP_MAX_BITS_MIN 192
211 #else
212 #error "MBEDTLS_ECP_C enabled, but no curve?"
213 #endif
214 
215 #if !defined(MBEDTLS_ECP_ALT)
216 /*
217  * default mbed TLS elliptic curve arithmetic implementation
218  *
219  * (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an
220  * alternative implementation for the whole module and it will replace this
221  * one.)
222  */
223 
256 typedef struct mbedtls_ecp_group {
265  size_t pbits;
266  size_t nbits;
269  unsigned int h;
270  int (*modp)(mbedtls_mpi *);
272  int (*t_pre)(mbedtls_ecp_point *, void *);
273  int (*t_post)(mbedtls_ecp_point *, void *);
274  void *t_data;
276  size_t T_size;
277 }
279 
288 #if defined(MBEDTLS_ECP_MAX_BITS)
289 
290 #if MBEDTLS_ECP_MAX_BITS < MBEDTLS_ECP_MAX_BITS_MIN
291 #error "MBEDTLS_ECP_MAX_BITS is smaller than the largest supported curve"
292 #endif
293 
294 #elif defined(MBEDTLS_ECP_C)
298 #define MBEDTLS_ECP_MAX_BITS MBEDTLS_ECP_MAX_BITS_MIN
299 
300 #else
301 /* MBEDTLS_ECP_MAX_BITS is not relevant without MBEDTLS_ECP_C, but set it
302  * to a nonzero value so that code that unconditionally allocates an array
303  * of a size based on it keeps working if built without ECC support. */
304 #define MBEDTLS_ECP_MAX_BITS 1
305 #endif
306 
307 #define MBEDTLS_ECP_MAX_BYTES ((MBEDTLS_ECP_MAX_BITS + 7) / 8)
308 #define MBEDTLS_ECP_MAX_PT_LEN (2 * MBEDTLS_ECP_MAX_BYTES + 1)
309 
310 #if !defined(MBEDTLS_ECP_WINDOW_SIZE)
311 /*
312  * Maximum "window" size used for point multiplication.
313  * Default: a point where higher memory usage yields diminishing performance
314  * returns.
315  * Minimum value: 2. Maximum value: 7.
316  *
317  * Result is an array of at most ( 1 << ( MBEDTLS_ECP_WINDOW_SIZE - 1 ) )
318  * points used for point multiplication. This value is directly tied to EC
319  * peak memory usage, so decreasing it by one should roughly cut memory usage
320  * by two (if large curves are in use).
321  *
322  * Reduction in size may reduce speed, but larger curves are impacted first.
323  * Sample performances (in ECDHE handshakes/s, with FIXED_POINT_OPTIM = 1):
324  * w-size: 6 5 4 3 2
325  * 521 145 141 135 120 97
326  * 384 214 209 198 177 146
327  * 256 320 320 303 262 226
328  * 224 475 475 453 398 342
329  * 192 640 640 633 587 476
330  */
331 #define MBEDTLS_ECP_WINDOW_SIZE 4
332 #endif /* MBEDTLS_ECP_WINDOW_SIZE */
333 
334 #if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM)
335 /*
336  * Trade memory for speed on fixed-point multiplication.
337  *
338  * This speeds up repeated multiplication of the generator (that is, the
339  * multiplication in ECDSA signatures, and half of the multiplications in
340  * ECDSA verification and ECDHE) by a factor roughly 3 to 4.
341  *
342  * The cost is increasing EC peak memory usage by a factor roughly 2.
343  *
344  * Change this value to 0 to reduce peak memory usage.
345  */
346 #define MBEDTLS_ECP_FIXED_POINT_OPTIM 1
347 #endif /* MBEDTLS_ECP_FIXED_POINT_OPTIM */
348 
351 #else /* MBEDTLS_ECP_ALT */
352 #include "ecp_alt.h"
353 #endif /* MBEDTLS_ECP_ALT */
354 
355 #if defined(MBEDTLS_ECP_RESTARTABLE)
356 
362 typedef struct mbedtls_ecp_restart_mul mbedtls_ecp_restart_mul_ctx;
363 
369 typedef struct mbedtls_ecp_restart_muladd mbedtls_ecp_restart_muladd_ctx;
370 
374 typedef struct {
375  unsigned ops_done;
376  unsigned depth;
377  mbedtls_ecp_restart_mul_ctx *rsm;
378  mbedtls_ecp_restart_muladd_ctx *ma;
380 
381 /*
382  * Operation counts for restartable functions
383  */
384 #define MBEDTLS_ECP_OPS_CHK 3
385 #define MBEDTLS_ECP_OPS_DBL 8
386 #define MBEDTLS_ECP_OPS_ADD 11
387 #define MBEDTLS_ECP_OPS_INV 120
400 int mbedtls_ecp_check_budget(const mbedtls_ecp_group *grp,
401  mbedtls_ecp_restart_ctx *rs_ctx,
402  unsigned ops);
403 
404 /* Utility macro for checking and updating ops budget */
405 #define MBEDTLS_ECP_BUDGET(ops) \
406  MBEDTLS_MPI_CHK(mbedtls_ecp_check_budget(grp, rs_ctx, \
407  (unsigned) (ops)));
408 
409 #else /* MBEDTLS_ECP_RESTARTABLE */
410 
411 #define MBEDTLS_ECP_BUDGET(ops) /* no-op; for compatibility */
412 
413 /* We want to declare restartable versions of existing functions anyway */
415 
416 #endif /* MBEDTLS_ECP_RESTARTABLE */
417 
426 typedef struct mbedtls_ecp_keypair {
430 }
432 
433 /*
434  * Point formats, from RFC 4492's enum ECPointFormat
435  */
436 #define MBEDTLS_ECP_PF_UNCOMPRESSED 0
437 #define MBEDTLS_ECP_PF_COMPRESSED 1
439 /*
440  * Some other constants from RFC 4492
441  */
442 #define MBEDTLS_ECP_TLS_NAMED_CURVE 3
444 #if defined(MBEDTLS_ECP_RESTARTABLE)
502 void mbedtls_ecp_set_max_ops(unsigned max_ops);
503 
510 int mbedtls_ecp_restart_is_enabled(void);
511 #endif /* MBEDTLS_ECP_RESTARTABLE */
512 
513 /*
514  * Get the type of a curve
515  */
517 
531 
547 
558 
569 
580 
587 
598 
605 
612 
621 
630 
631 #if defined(MBEDTLS_ECP_RESTARTABLE)
638 void mbedtls_ecp_restart_init(mbedtls_ecp_restart_ctx *ctx);
639 
647 void mbedtls_ecp_restart_free(mbedtls_ecp_restart_ctx *ctx);
648 #endif /* MBEDTLS_ECP_RESTARTABLE */
649 
662 
675  const mbedtls_ecp_group *src);
676 
687 
698 
712  const mbedtls_ecp_point *Q);
713 
727  const char *x, const char *y);
728 
755  const mbedtls_ecp_point *P,
756  int format, size_t *olen,
757  unsigned char *buf, size_t buflen);
758 
783  const unsigned char *buf, size_t ilen);
784 
804  mbedtls_ecp_point *pt,
805  const unsigned char **buf, size_t len);
806 
830  const mbedtls_ecp_point *pt,
831  int format, size_t *olen,
832  unsigned char *buf, size_t blen);
833 
852 
871  const unsigned char **buf, size_t len);
872 
892  const unsigned char **buf,
893  size_t len);
913  size_t *olen,
914  unsigned char *buf, size_t blen);
915 
953  const mbedtls_mpi *m, const mbedtls_ecp_point *P,
954  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng);
955 
987  const mbedtls_mpi *m, const mbedtls_ecp_point *P,
988  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
989  mbedtls_ecp_restart_ctx *rs_ctx);
990 
991 #if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED)
1028  const mbedtls_mpi *m, const mbedtls_ecp_point *P,
1029  const mbedtls_mpi *n, const mbedtls_ecp_point *Q);
1030 
1073  const mbedtls_mpi *m, const mbedtls_ecp_point *P,
1074  const mbedtls_mpi *n, const mbedtls_ecp_point *Q,
1075  mbedtls_ecp_restart_ctx *rs_ctx);
1076 #endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */
1077 
1106  const mbedtls_ecp_point *pt);
1107 
1128  const mbedtls_mpi *d);
1129 
1146  mbedtls_mpi *d,
1147  int (*f_rng)(void *, unsigned char *, size_t),
1148  void *p_rng);
1149 
1178  const mbedtls_ecp_point *G,
1180  int (*f_rng)(void *, unsigned char *, size_t),
1181  void *p_rng);
1182 
1207  mbedtls_ecp_point *Q,
1208  int (*f_rng)(void *, unsigned char *, size_t),
1209  void *p_rng);
1210 
1225  int (*f_rng)(void *, unsigned char *, size_t),
1226  void *p_rng);
1227 
1247  const unsigned char *buf, size_t buflen);
1248 
1266  unsigned char *buf, size_t buflen);
1267 
1286  const mbedtls_ecp_keypair *prv);
1287 
1288 #if defined(MBEDTLS_SELF_TEST)
1289 
1296 int mbedtls_ecp_self_test(int verbose);
1297 
1298 #endif /* MBEDTLS_SELF_TEST */
1299 
1300 #ifdef __cplusplus
1301 }
1302 #endif
1303 
1304 #endif /* ecp.h */
Multi-precision integer library.
Configuration options (set of defines)
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_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.
int mbedtls_ecp_is_zero(mbedtls_ecp_point *pt)
This function checks if a point is the point at infinity.
int mbedtls_ecp_write_key(mbedtls_ecp_keypair *key, unsigned char *buf, size_t buflen)
This function exports an elliptic curve private key.
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.
mbedtls_ecp_curve_type mbedtls_ecp_get_type(const mbedtls_ecp_group *grp)
void mbedtls_ecp_restart_ctx
Definition: ecp.h:414
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.
mbedtls_ecp_curve_type
Definition: ecp.h:147
@ MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS
Definition: ecp.h:149
@ MBEDTLS_ECP_TYPE_NONE
Definition: ecp.h:148
@ MBEDTLS_ECP_TYPE_MONTGOMERY
Definition: ecp.h:150
void mbedtls_ecp_group_init(mbedtls_ecp_group *grp)
This function initializes an ECP group context without loading any domain parameters.
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.
struct mbedtls_ecp_group mbedtls_ecp_group
The ECP group structure.
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...
struct mbedtls_ecp_keypair mbedtls_ecp_keypair
The ECP key-pair structure.
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 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.
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, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates a private key.
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.
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....
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_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.
mbedtls_ecp_group_id
Definition: ecp.h:120
@ MBEDTLS_ECP_DP_SECP192K1
Definition: ecp.h:131
@ MBEDTLS_ECP_DP_SECP384R1
Definition: ecp.h:125
@ MBEDTLS_ECP_DP_CURVE448
Definition: ecp.h:134
@ MBEDTLS_ECP_DP_CURVE25519
Definition: ecp.h:130
@ MBEDTLS_ECP_DP_NONE
Definition: ecp.h:121
@ MBEDTLS_ECP_DP_SECP256K1
Definition: ecp.h:133
@ MBEDTLS_ECP_DP_BP512R1
Definition: ecp.h:129
@ MBEDTLS_ECP_DP_SECP224R1
Definition: ecp.h:123
@ MBEDTLS_ECP_DP_SECP521R1
Definition: ecp.h:126
@ MBEDTLS_ECP_DP_BP384R1
Definition: ecp.h:128
@ MBEDTLS_ECP_DP_SECP224K1
Definition: ecp.h:132
@ MBEDTLS_ECP_DP_BP256R1
Definition: ecp.h:127
@ MBEDTLS_ECP_DP_SECP192R1
Definition: ecp.h:122
@ MBEDTLS_ECP_DP_SECP256R1
Definition: ecp.h:124
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.
const char * name
Definition: ecp.h:160
mbedtls_ecp_group_id grp_id
Definition: ecp.h:157
uint16_t bit_size
Definition: ecp.h:159
uint16_t tls_id
Definition: ecp.h:158
The ECP group structure.
Definition: ecp.h:256
size_t pbits
Definition: ecp.h:265
int(* t_pre)(mbedtls_ecp_point *, void *)
Definition: ecp.h:272
unsigned int h
Definition: ecp.h:269
mbedtls_ecp_group_id id
Definition: ecp.h:257
size_t T_size
Definition: ecp.h:276
mbedtls_ecp_point * T
Definition: ecp.h:275
mbedtls_mpi N
Definition: ecp.h:264
void * t_data
Definition: ecp.h:274
mbedtls_ecp_point G
Definition: ecp.h:263
int(* t_post)(mbedtls_ecp_point *, void *)
Definition: ecp.h:273
mbedtls_mpi B
Definition: ecp.h:261
int(* modp)(mbedtls_mpi *)
Definition: ecp.h:270
mbedtls_mpi P
Definition: ecp.h:258
size_t nbits
Definition: ecp.h:266
mbedtls_mpi A
Definition: ecp.h:259
The ECP key-pair structure.
Definition: ecp.h:426
mbedtls_ecp_point Q
Definition: ecp.h:429
mbedtls_mpi d
Definition: ecp.h:428
mbedtls_ecp_group grp
Definition: ecp.h:427
The ECP point structure, in Jacobian coordinates.
Definition: ecp.h:174
mbedtls_mpi Z
Definition: ecp.h:177
mbedtls_mpi X
Definition: ecp.h:175
mbedtls_mpi Y
Definition: ecp.h:176
MPI structure.
Definition: bignum.h:208