mbed TLS v2.23.0

ecp.h
Go to the documentation of this file.
1
17 /*
18 * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
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 * This file is part of Mbed TLS (https://tls.mbed.org)
34 */
35
36 #ifndef MBEDTLS_ECP_H
37 #define MBEDTLS_ECP_H
38
39 #if !defined(MBEDTLS_CONFIG_FILE)
40 #include "mbedtls/config.h"
41 #else
42 #include MBEDTLS_CONFIG_FILE
43 #endif
44
45 #include "mbedtls/bignum.h"
46
47 /*
48 * ECP error codes
49 */
50 #define MBEDTLS_ERR_ECP_BAD_INPUT_DATA -0x4F80
51 #define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL -0x4F00
52 #define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE -0x4E80
53 #define MBEDTLS_ERR_ECP_VERIFY_FAILED -0x4E00
54 #define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80
55 #define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00
56 #define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80
57 #define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00
59 /* MBEDTLS_ERR_ECP_HW_ACCEL_FAILED is deprecated and should not be used. */
60 #define MBEDTLS_ERR_ECP_HW_ACCEL_FAILED -0x4B80
62 #define MBEDTLS_ERR_ECP_IN_PROGRESS -0x4B00
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67
77 typedef enum
78 {
79 MBEDTLS_ECP_DP_NONE = 0,
80 MBEDTLS_ECP_DP_SECP192R1,
81 MBEDTLS_ECP_DP_SECP224R1,
82 MBEDTLS_ECP_DP_SECP256R1,
83 MBEDTLS_ECP_DP_SECP384R1,
84 MBEDTLS_ECP_DP_SECP521R1,
85 MBEDTLS_ECP_DP_BP256R1,
86 MBEDTLS_ECP_DP_BP384R1,
87 MBEDTLS_ECP_DP_BP512R1,
88 MBEDTLS_ECP_DP_CURVE25519,
89 MBEDTLS_ECP_DP_SECP192K1,
90 MBEDTLS_ECP_DP_SECP224K1,
91 MBEDTLS_ECP_DP_SECP256K1,
92 MBEDTLS_ECP_DP_CURVE448,
93 } mbedtls_ecp_group_id;
94
100 #define MBEDTLS_ECP_DP_MAX 12
101
102 /*
103 * Curve types
104 */
105 typedef enum
106 {
107 MBEDTLS_ECP_TYPE_NONE = 0,
108 MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS, /* y^2 = x^3 + a x + b */
109 MBEDTLS_ECP_TYPE_MONTGOMERY, /* y^2 = x^3 + a x^2 + x */
110 } mbedtls_ecp_curve_type;
111
115 typedef struct mbedtls_ecp_curve_info
116 {
117 mbedtls_ecp_group_id grp_id;
118 uint16_t tls_id;
119 uint16_t bit_size;
120 const char *name;
121 } mbedtls_ecp_curve_info;
122
134 typedef struct mbedtls_ecp_point
135 {
136 mbedtls_mpi X;
137 mbedtls_mpi Y;
138 mbedtls_mpi Z;
139 }
140 mbedtls_ecp_point;
141
142 #if !defined(MBEDTLS_ECP_ALT)
143 /*
144 * default mbed TLS elliptic curve arithmetic implementation
145 *
146 * (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an
147 * alternative implementation for the whole module and it will replace this
148 * one.)
149 */
150
183 typedef struct mbedtls_ecp_group
184 {
185 mbedtls_ecp_group_id id;
186 mbedtls_mpi P;
187 mbedtls_mpi A;
189 mbedtls_mpi B;
191 mbedtls_ecp_point G;
192 mbedtls_mpi N;
193 size_t pbits;
194 size_t nbits;
197 unsigned int h;
198 int (*modp)(mbedtls_mpi *);
200 int (*t_pre)(mbedtls_ecp_point *, void *);
201 int (*t_post)(mbedtls_ecp_point *, void *);
202 void *t_data;
203 mbedtls_ecp_point *T;
204 size_t T_size;
205 }
206 mbedtls_ecp_group;
207
216 #if !defined(MBEDTLS_ECP_MAX_BITS)
217
220 #define MBEDTLS_ECP_MAX_BITS 521
221 #endif
222
223 #define MBEDTLS_ECP_MAX_BYTES ( ( MBEDTLS_ECP_MAX_BITS + 7 ) / 8 )
224 #define MBEDTLS_ECP_MAX_PT_LEN ( 2 * MBEDTLS_ECP_MAX_BYTES + 1 )
225
226 #if !defined(MBEDTLS_ECP_WINDOW_SIZE)
227 /*
228 * Maximum "window" size used for point multiplication.
229 * Default: 6.
230 * Minimum value: 2. Maximum value: 7.
231 *
232 * Result is an array of at most ( 1 << ( MBEDTLS_ECP_WINDOW_SIZE - 1 ) )
233 * points used for point multiplication. This value is directly tied to EC
234 * peak memory usage, so decreasing it by one should roughly cut memory usage
235 * by two (if large curves are in use).
236 *
237 * Reduction in size may reduce speed, but larger curves are impacted first.
238 * Sample performances (in ECDHE handshakes/s, with FIXED_POINT_OPTIM = 1):
239 * w-size: 6 5 4 3 2
240 * 521 145 141 135 120 97
241 * 384 214 209 198 177 146
242 * 256 320 320 303 262 226
243 * 224 475 475 453 398 342
244 * 192 640 640 633 587 476
245 */
246 #define MBEDTLS_ECP_WINDOW_SIZE 6
247 #endif /* MBEDTLS_ECP_WINDOW_SIZE */
248
249 #if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM)
250 /*
251 * Trade memory for speed on fixed-point multiplication.
252 *
253 * This speeds up repeated multiplication of the generator (that is, the
254 * multiplication in ECDSA signatures, and half of the multiplications in
255 * ECDSA verification and ECDHE) by a factor roughly 3 to 4.
256 *
257 * The cost is increasing EC peak memory usage by a factor roughly 2.
258 *
259 * Change this value to 0 to reduce peak memory usage.
260 */
261 #define MBEDTLS_ECP_FIXED_POINT_OPTIM 1
262 #endif /* MBEDTLS_ECP_FIXED_POINT_OPTIM */
263
264 /* \} name SECTION: Module settings */
265
266 #else /* MBEDTLS_ECP_ALT */
267 #include "ecp_alt.h"
268 #endif /* MBEDTLS_ECP_ALT */
269
270 #if defined(MBEDTLS_ECP_RESTARTABLE)
271
277 typedef struct mbedtls_ecp_restart_mul mbedtls_ecp_restart_mul_ctx;
278
284 typedef struct mbedtls_ecp_restart_muladd mbedtls_ecp_restart_muladd_ctx;
285
289 typedef struct
290 {
291 unsigned ops_done;
292 unsigned depth;
293 mbedtls_ecp_restart_mul_ctx *rsm;
294 mbedtls_ecp_restart_muladd_ctx *ma;
295 } mbedtls_ecp_restart_ctx;
296
297 /*
298 * Operation counts for restartable functions
299 */
300 #define MBEDTLS_ECP_OPS_CHK 3
301 #define MBEDTLS_ECP_OPS_DBL 8
302 #define MBEDTLS_ECP_OPS_ADD 11
303 #define MBEDTLS_ECP_OPS_INV 120
316 int mbedtls_ecp_check_budget( const mbedtls_ecp_group *grp,
317 mbedtls_ecp_restart_ctx *rs_ctx,
318 unsigned ops );
319
320 /* Utility macro for checking and updating ops budget */
321 #define MBEDTLS_ECP_BUDGET( ops ) \
322 MBEDTLS_MPI_CHK( mbedtls_ecp_check_budget( grp, rs_ctx, \
323 (unsigned) (ops) ) );
324
325 #else /* MBEDTLS_ECP_RESTARTABLE */
326
327 #define MBEDTLS_ECP_BUDGET( ops ) /* no-op; for compatibility */
328
329 /* We want to declare restartable versions of existing functions anyway */
330 typedef void mbedtls_ecp_restart_ctx;
331
332 #endif /* MBEDTLS_ECP_RESTARTABLE */
333
342 typedef struct mbedtls_ecp_keypair
343 {
344 mbedtls_ecp_group grp;
345 mbedtls_mpi d;
346 mbedtls_ecp_point Q;
347 }
348 mbedtls_ecp_keypair;
349
350 /*
351 * Point formats, from RFC 4492's enum ECPointFormat
352 */
353 #define MBEDTLS_ECP_PF_UNCOMPRESSED 0
354 #define MBEDTLS_ECP_PF_COMPRESSED 1
356 /*
357 * Some other constants from RFC 4492
358 */
359 #define MBEDTLS_ECP_TLS_NAMED_CURVE 3
361 #if defined(MBEDTLS_ECP_RESTARTABLE)
362
419 void mbedtls_ecp_set_max_ops( unsigned max_ops );
420
427 int mbedtls_ecp_restart_is_enabled( void );
428 #endif /* MBEDTLS_ECP_RESTARTABLE */
429
430 /*
431 * Get the type of a curve
432 */
433 mbedtls_ecp_curve_type mbedtls_ecp_get_type( const mbedtls_ecp_group *grp );
434
448 const mbedtls_ecp_curve_info *mbedtls_ecp_curve_list( void );
449
464 const mbedtls_ecp_group_id *mbedtls_ecp_grp_id_list( void );
465
475 const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_grp_id( mbedtls_ecp_group_id grp_id );
476
486 const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_tls_id( uint16_t tls_id );
487
497 const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_name( const char *name );
498
504 void mbedtls_ecp_point_init( mbedtls_ecp_point *pt );
505
515 void mbedtls_ecp_group_init( mbedtls_ecp_group *grp );
516
522 void mbedtls_ecp_keypair_init( mbedtls_ecp_keypair *key );
523
529 void mbedtls_ecp_point_free( mbedtls_ecp_point *pt );
530
538 void mbedtls_ecp_group_free( mbedtls_ecp_group *grp );
539
547 void mbedtls_ecp_keypair_free( mbedtls_ecp_keypair *key );
548
549 #if defined(MBEDTLS_ECP_RESTARTABLE)
550
556 void mbedtls_ecp_restart_init( mbedtls_ecp_restart_ctx *ctx );
557
565 void mbedtls_ecp_restart_free( mbedtls_ecp_restart_ctx *ctx );
566 #endif /* MBEDTLS_ECP_RESTARTABLE */
567
579 int mbedtls_ecp_copy( mbedtls_ecp_point *P, const mbedtls_ecp_point *Q );
580
592 int mbedtls_ecp_group_copy( mbedtls_ecp_group *dst,
593 const mbedtls_ecp_group *src );
594
604 int mbedtls_ecp_set_zero( mbedtls_ecp_point *pt );
605
615 int mbedtls_ecp_is_zero( mbedtls_ecp_point *pt );
616
629 int mbedtls_ecp_point_cmp( const mbedtls_ecp_point *P,
630 const mbedtls_ecp_point *Q );
631
644 int mbedtls_ecp_point_read_string( mbedtls_ecp_point *P, int radix,
645 const char *x, const char *y );
646
672 int mbedtls_ecp_point_write_binary( const mbedtls_ecp_group *grp,
673 const mbedtls_ecp_point *P,
674 int format, size_t *olen,
675 unsigned char *buf, size_t buflen );
676
699 int mbedtls_ecp_point_read_binary( const mbedtls_ecp_group *grp,
700 mbedtls_ecp_point *P,
701 const unsigned char *buf, size_t ilen );
702
721 int mbedtls_ecp_tls_read_point( const mbedtls_ecp_group *grp,
722 mbedtls_ecp_point *pt,
723 const unsigned char **buf, size_t len );
724
747 int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp,
748 const mbedtls_ecp_point *pt,
749 int format, size_t *olen,
750 unsigned char *buf, size_t blen );
751
769 int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id id );
770
788 int mbedtls_ecp_tls_read_group( mbedtls_ecp_group *grp,
789 const unsigned char **buf, size_t len );
790
809 int mbedtls_ecp_tls_read_group_id( mbedtls_ecp_group_id *grp,
810 const unsigned char **buf,
811 size_t len );
830 int mbedtls_ecp_tls_write_group( const mbedtls_ecp_group *grp,
831 size_t *olen,
832 unsigned char *buf, size_t blen );
833
870 int mbedtls_ecp_mul( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
871 const mbedtls_mpi *m, const mbedtls_ecp_point *P,
872 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
873
904 int mbedtls_ecp_mul_restartable( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
905 const mbedtls_mpi *m, const mbedtls_ecp_point *P,
906 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
907 mbedtls_ecp_restart_ctx *rs_ctx );
908
938 int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
939 const mbedtls_mpi *m, const mbedtls_ecp_point *P,
940 const mbedtls_mpi *n, const mbedtls_ecp_point *Q );
941
976 int mbedtls_ecp_muladd_restartable(
977 mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
978 const mbedtls_mpi *m, const mbedtls_ecp_point *P,
979 const mbedtls_mpi *n, const mbedtls_ecp_point *Q,
980 mbedtls_ecp_restart_ctx *rs_ctx );
981
1009 int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp,
1010 const mbedtls_ecp_point *pt );
1011
1031 int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp,
1032 const mbedtls_mpi *d );
1033
1049 int mbedtls_ecp_gen_privkey( const mbedtls_ecp_group *grp,
1050 mbedtls_mpi *d,
1051 int (*f_rng)(void *, unsigned char *, size_t),
1052 void *p_rng );
1053
1081 int mbedtls_ecp_gen_keypair_base( mbedtls_ecp_group *grp,
1082 const mbedtls_ecp_point *G,
1083 mbedtls_mpi *d, mbedtls_ecp_point *Q,
1084 int (*f_rng)(void *, unsigned char *, size_t),
1085 void *p_rng );
1086
1110 int mbedtls_ecp_gen_keypair( mbedtls_ecp_group *grp, mbedtls_mpi *d,
1111 mbedtls_ecp_point *Q,
1112 int (*f_rng)(void *, unsigned char *, size_t),
1113 void *p_rng );
1114
1128 int mbedtls_ecp_gen_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
1129 int (*f_rng)(void *, unsigned char *, size_t),
1130 void *p_rng );
1131
1150 int mbedtls_ecp_read_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
1151 const unsigned char *buf, size_t buflen );
1169 int mbedtls_ecp_check_pub_priv( const mbedtls_ecp_keypair *pub,
1170 const mbedtls_ecp_keypair *prv );
1171
1172 #if defined(MBEDTLS_SELF_TEST)
1173
1180 int mbedtls_ecp_self_test( int verbose );
1181
1182 #endif /* MBEDTLS_SELF_TEST */
1183
1184 #ifdef __cplusplus
1185 }
1186 #endif
1187
1188 #endif /* ecp.h */
mbedtls_ecp_group_free
void mbedtls_ecp_group_free(mbedtls_ecp_group *grp)
This function frees the components of an ECP group.
mbedtls_ecp_group
The ECP group structure.
Definition: ecp.h:184
mbedtls_ecp_point::X
mbedtls_mpi X
Definition: ecp.h:136
MBEDTLS_ECP_DP_SECP224K1
@ MBEDTLS_ECP_DP_SECP224K1
Definition: ecp.h:90
mbedtls_ecp_point_init
void mbedtls_ecp_point_init(mbedtls_ecp_point *pt)
This function initializes a point as zero.
mbedtls_mpi
MPI structure.
Definition: bignum.h:187
mbedtls_ecp_group::G
mbedtls_ecp_point G
Definition: ecp.h:191
mbedtls_ecp_keypair::grp
mbedtls_ecp_group grp
Definition: ecp.h:344
mbedtls_ecp_curve_info_from_tls_id
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.
mbedtls_ecp_point::Z
mbedtls_mpi Z
Definition: ecp.h:138
MBEDTLS_ECP_DP_SECP224R1
@ MBEDTLS_ECP_DP_SECP224R1
Definition: ecp.h:81
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(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates a keypair with a configurable base point.
mbedtls_ecp_group::h
unsigned int h
Definition: ecp.h:197
mbedtls_ecp_curve_info::grp_id
mbedtls_ecp_group_id grp_id
Definition: ecp.h:117
mbedtls_ecp_check_privkey
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_ecp_restart_ctx
void mbedtls_ecp_restart_ctx
Definition: ecp.h:330
MBEDTLS_ECP_DP_SECP384R1
@ MBEDTLS_ECP_DP_SECP384R1
Definition: ecp.h:83
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)
This function performs multiplication and addition of two points by integers: R = m * P + n * Q.
MBEDTLS_ECP_DP_SECP256R1
@ MBEDTLS_ECP_DP_SECP256R1
Definition: ecp.h:82
mbedtls_ecp_set_zero
int mbedtls_ecp_set_zero(mbedtls_ecp_point *pt)
This function sets a point to the point at infinity.
mbedtls_ecp_curve_info::tls_id
uint16_t tls_id
Definition: ecp.h:118
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)
This function exports an elliptic curve as a TLS ECParameters record as defined in RFC 4492,...
mbedtls_ecp_keypair::Q
mbedtls_ecp_point Q
Definition: ecp.h:346
mbedtls_ecp_keypair::d
mbedtls_mpi d
Definition: ecp.h:345
mbedtls_ecp_group_copy
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_point_cmp
int mbedtls_ecp_point_cmp(const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
This function compares two points.
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)
This function exports a point as a TLS ECPoint record defined in RFC 4492, Section 5....
mbedtls_ecp_point
struct mbedtls_ecp_point mbedtls_ecp_point
The ECP point structure, in Jacobian coordinates.
MBEDTLS_ECP_DP_CURVE448
@ MBEDTLS_ECP_DP_CURVE448
Definition: ecp.h:92
mbedtls_ecp_point_free
void mbedtls_ecp_point_free(mbedtls_ecp_point *pt)
This function frees the components of a point.
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)
This function imports a point from a TLS ECPoint record.
mbedtls_ecp_read_key
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.
bignum.h
Multi-precision integer library.
mbedtls_ecp_grp_id_list
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...
mbedtls_ecp_gen_privkey
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.
mbedtls_ecp_muladd_restartable
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_tls_read_group_id
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...
mbedtls_ecp_group::t_pre
int(* t_pre)(mbedtls_ecp_point *, void *)
Definition: ecp.h:200
mbedtls_ecp_copy
int mbedtls_ecp_copy(mbedtls_ecp_point *P, const mbedtls_ecp_point *Q)
This function copies the contents of point Q into point P.
mbedtls_ecp_check_pub_priv
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...
mbedtls_ecp_keypair
The ECP key-pair structure.
Definition: ecp.h:343
mbedtls_ecp_group::N
mbedtls_mpi N
Definition: ecp.h:192
MBEDTLS_ECP_DP_BP384R1
@ MBEDTLS_ECP_DP_BP384R1
Definition: ecp.h:86
mbedtls_ecp_group_id
mbedtls_ecp_group_id
Definition: ecp.h:78
MBEDTLS_ECP_DP_BP256R1
@ MBEDTLS_ECP_DP_BP256R1
Definition: ecp.h:85
MBEDTLS_ECP_DP_CURVE25519
@ MBEDTLS_ECP_DP_CURVE25519
Definition: ecp.h:88
mbedtls_ecp_curve_info::bit_size
uint16_t bit_size
Definition: ecp.h:119
mbedtls_ecp_group_load
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.
mbedtls_ecp_curve_info::name
const char * name
Definition: ecp.h:120
MBEDTLS_ECP_DP_SECP256K1
@ MBEDTLS_ECP_DP_SECP256K1
Definition: ecp.h:91
MBEDTLS_ECP_TYPE_MONTGOMERY
@ MBEDTLS_ECP_TYPE_MONTGOMERY
Definition: ecp.h:109
mbedtls_ecp_check_pubkey
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_ecp_mul
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_point::Y
mbedtls_mpi Y
Definition: ecp.h:137
mbedtls_ecp_gen_key
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.
mbedtls_ecp_group::B
mbedtls_mpi B
Definition: ecp.h:189
mbedtls_ecp_mul_restartable
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.
MBEDTLS_ECP_DP_SECP192K1
@ MBEDTLS_ECP_DP_SECP192K1
Definition: ecp.h:89
mbedtls_ecp_group::modp
int(* modp)(mbedtls_mpi *)
Definition: ecp.h:198
MBEDTLS_ECP_TYPE_NONE
@ MBEDTLS_ECP_TYPE_NONE
Definition: ecp.h:107
mbedtls_ecp_self_test
int mbedtls_ecp_self_test(int verbose)
The ECP checkup routine.
mbedtls_ecp_group::id
mbedtls_ecp_group_id id
Definition: ecp.h:185
mbedtls_ecp_keypair_free
void mbedtls_ecp_keypair_free(mbedtls_ecp_keypair *key)
This function frees the components of a key pair.
mbedtls_ecp_curve_info
struct mbedtls_ecp_curve_info mbedtls_ecp_curve_info
MBEDTLS_ECP_DP_SECP521R1
@ MBEDTLS_ECP_DP_SECP521R1
Definition: ecp.h:84
mbedtls_ecp_curve_info
Definition: ecp.h:116
mbedtls_ecp_group::pbits
size_t pbits
Definition: ecp.h:193
mbedtls_ecp_group::t_post
int(* t_post)(mbedtls_ecp_point *, void *)
Definition: ecp.h:201
mbedtls_ecp_group::t_data
void * t_data
Definition: ecp.h:202
MBEDTLS_ECP_DP_SECP192R1
@ MBEDTLS_ECP_DP_SECP192R1
Definition: ecp.h:80
mbedtls_ecp_group
struct mbedtls_ecp_group mbedtls_ecp_group
The ECP group structure.
mbedtls_ecp_curve_list
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_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)
This function imports a point from unsigned binary data.
mbedtls_ecp_is_zero
int mbedtls_ecp_is_zero(mbedtls_ecp_point *pt)
This function checks if a point is the point at infinity.
mbedtls_ecp_gen_keypair
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.
config.h
Configuration options (set of defines)
mbedtls_ecp_group::nbits
size_t nbits
Definition: ecp.h:194
mbedtls_ecp_group_init
void mbedtls_ecp_group_init(mbedtls_ecp_group *grp)
This function initializes an ECP group context without loading any domain parameters.
mbedtls_ecp_group::T
mbedtls_ecp_point * T
Definition: ecp.h:203
mbedtls_ecp_keypair_init
void mbedtls_ecp_keypair_init(mbedtls_ecp_keypair *key)
This function initializes a key pair as an invalid one.
mbedtls_ecp_keypair
struct mbedtls_ecp_keypair mbedtls_ecp_keypair
The ECP key-pair structure.
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)
This function exports a point into unsigned binary data.
mbedtls_ecp_point
The ECP point structure, in Jacobian coordinates.
Definition: ecp.h:135
mbedtls_ecp_tls_read_group
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,...
MBEDTLS_ECP_DP_NONE
@ MBEDTLS_ECP_DP_NONE
Definition: ecp.h:79
mbedtls_ecp_curve_type
mbedtls_ecp_curve_type
Definition: ecp.h:106
mbedtls_ecp_get_type
mbedtls_ecp_curve_type mbedtls_ecp_get_type(const mbedtls_ecp_group *grp)
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)
This function retrieves curve information from an internal group identifier.
mbedtls_ecp_point_read_string
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.
MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS
@ MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS
Definition: ecp.h:108
mbedtls_ecp_group::A
mbedtls_mpi A
Definition: ecp.h:187
mbedtls_ecp_group::P
mbedtls_mpi P
Definition: ecp.h:186
MBEDTLS_ECP_DP_BP512R1
@ MBEDTLS_ECP_DP_BP512R1
Definition: ecp.h:87
mbedtls_ecp_group::T_size
size_t T_size
Definition: ecp.h:204
mbedtls_ecp_curve_info_from_name
const mbedtls_ecp_curve_info * mbedtls_ecp_curve_info_from_name(const char *name)
This function retrieves curve information from a human-readable name.