ec_curves.h
Go to the documentation of this file.
1 /**
2  * @file ec_curves.h
3  * @brief Elliptic curves
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _EC_CURVES_H
32 #define _EC_CURVES_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 #include "mpi/mpi.h"
37 
38 //secp112r1 elliptic curve support
39 #ifndef SECP112R1_SUPPORT
40  #define SECP112R1_SUPPORT DISABLED
41 #elif (SECP112R1_SUPPORT != ENABLED && SECP112R1_SUPPORT != DISABLED)
42  #error SECP112R1_SUPPORT parameter is not valid
43 #endif
44 
45 //secp112r2 elliptic curve support
46 #ifndef SECP112R2_SUPPORT
47  #define SECP112R2_SUPPORT DISABLED
48 #elif (SECP112R2_SUPPORT != ENABLED && SECP112R2_SUPPORT != DISABLED)
49  #error SECP112R2_SUPPORT parameter is not valid
50 #endif
51 
52 //secp128r1 elliptic curve support
53 #ifndef SECP128R1_SUPPORT
54  #define SECP128R1_SUPPORT DISABLED
55 #elif (SECP128R1_SUPPORT != ENABLED && SECP128R1_SUPPORT != DISABLED)
56  #error SECP128R1_SUPPORT parameter is not valid
57 #endif
58 
59 //secp128r2 elliptic curve support
60 #ifndef SECP128R2_SUPPORT
61  #define SECP128R2_SUPPORT DISABLED
62 #elif (SECP128R2_SUPPORT != ENABLED && SECP128R2_SUPPORT != DISABLED)
63  #error SECP128R2_SUPPORT parameter is not valid
64 #endif
65 
66 //secp160k1 elliptic curve support
67 #ifndef SECP160K1_SUPPORT
68  #define SECP160K1_SUPPORT DISABLED
69 #elif (SECP160K1_SUPPORT != ENABLED && SECP160K1_SUPPORT != DISABLED)
70  #error SECP160K1_SUPPORT parameter is not valid
71 #endif
72 
73 //secp160r1 elliptic curve support
74 #ifndef SECP160R1_SUPPORT
75  #define SECP160R1_SUPPORT DISABLED
76 #elif (SECP160R1_SUPPORT != ENABLED && SECP160R1_SUPPORT != DISABLED)
77  #error SECP160R1_SUPPORT parameter is not valid
78 #endif
79 
80 //secp160r2 elliptic curve support
81 #ifndef SECP160R2_SUPPORT
82  #define SECP160R2_SUPPORT DISABLED
83 #elif (SECP160R2_SUPPORT != ENABLED && SECP160R2_SUPPORT != DISABLED)
84  #error SECP160R2_SUPPORT parameter is not valid
85 #endif
86 
87 //secp192k1 elliptic curve support
88 #ifndef SECP192K1_SUPPORT
89  #define SECP192K1_SUPPORT DISABLED
90 #elif (SECP192K1_SUPPORT != ENABLED && SECP192K1_SUPPORT != DISABLED)
91  #error SECP192K1_SUPPORT parameter is not valid
92 #endif
93 
94 //secp192r1 elliptic curve support (NIST P-192)
95 #ifndef SECP192R1_SUPPORT
96  #define SECP192R1_SUPPORT DISABLED
97 #elif (SECP192R1_SUPPORT != ENABLED && SECP192R1_SUPPORT != DISABLED)
98  #error SECP192R1_SUPPORT parameter is not valid
99 #endif
100 
101 //secp224k1 elliptic curve support
102 #ifndef SECP224K1_SUPPORT
103  #define SECP224K1_SUPPORT DISABLED
104 #elif (SECP224K1_SUPPORT != ENABLED && SECP224K1_SUPPORT != DISABLED)
105  #error SECP224K1_SUPPORT parameter is not valid
106 #endif
107 
108 //secp224r1 elliptic curve support (NIST P-224)
109 #ifndef SECP224R1_SUPPORT
110  #define SECP224R1_SUPPORT ENABLED
111 #elif (SECP224R1_SUPPORT != ENABLED && SECP224R1_SUPPORT != DISABLED)
112  #error SECP224R1_SUPPORT parameter is not valid
113 #endif
114 
115 //secp256k1 elliptic curve support
116 #ifndef SECP256K1_SUPPORT
117  #define SECP256K1_SUPPORT DISABLED
118 #elif (SECP256K1_SUPPORT != ENABLED && SECP256K1_SUPPORT != DISABLED)
119  #error SECP256K1_SUPPORT parameter is not valid
120 #endif
121 
122 //secp256r1 elliptic curve support (NIST P-256)
123 #ifndef SECP256R1_SUPPORT
124  #define SECP256R1_SUPPORT ENABLED
125 #elif (SECP256R1_SUPPORT != ENABLED && SECP256R1_SUPPORT != DISABLED)
126  #error SECP256R1_SUPPORT parameter is not valid
127 #endif
128 
129 //secp384r1 elliptic curve support (NIST P-384)
130 #ifndef SECP384R1_SUPPORT
131  #define SECP384R1_SUPPORT ENABLED
132 #elif (SECP384R1_SUPPORT != ENABLED && SECP384R1_SUPPORT != DISABLED)
133  #error SECP384R1_SUPPORT parameter is not valid
134 #endif
135 
136 //secp521r1 elliptic curve support (NIST P-521)
137 #ifndef SECP521R1_SUPPORT
138  #define SECP521R1_SUPPORT ENABLED
139 #elif (SECP521R1_SUPPORT != ENABLED && SECP521R1_SUPPORT != DISABLED)
140  #error SECP521R1_SUPPORT parameter is not valid
141 #endif
142 
143 //brainpoolP160r1 elliptic curve support
144 #ifndef BRAINPOOLP160R1_SUPPORT
145  #define BRAINPOOLP160R1_SUPPORT DISABLED
146 #elif (BRAINPOOLP160R1_SUPPORT != ENABLED && BRAINPOOLP160R1_SUPPORT != DISABLED)
147  #error BRAINPOOLP160R1_SUPPORT parameter is not valid
148 #endif
149 
150 //brainpoolP192r1 elliptic curve support
151 #ifndef BRAINPOOLP192R1_SUPPORT
152  #define BRAINPOOLP192R1_SUPPORT DISABLED
153 #elif (BRAINPOOLP192R1_SUPPORT != ENABLED && BRAINPOOLP192R1_SUPPORT != DISABLED)
154  #error BRAINPOOLP192R1_SUPPORT parameter is not valid
155 #endif
156 
157 //brainpoolP224r1 elliptic curve support
158 #ifndef BRAINPOOLP224R1_SUPPORT
159  #define BRAINPOOLP224R1_SUPPORT DISABLED
160 #elif (BRAINPOOLP224R1_SUPPORT != ENABLED && BRAINPOOLP224R1_SUPPORT != DISABLED)
161  #error BRAINPOOLP224R1_SUPPORT parameter is not valid
162 #endif
163 
164 //brainpoolP256r1 elliptic curve support
165 #ifndef BRAINPOOLP256R1_SUPPORT
166  #define BRAINPOOLP256R1_SUPPORT DISABLED
167 #elif (BRAINPOOLP256R1_SUPPORT != ENABLED && BRAINPOOLP256R1_SUPPORT != DISABLED)
168  #error BRAINPOOLP256R1_SUPPORT parameter is not valid
169 #endif
170 
171 //brainpoolP320r1 elliptic curve support
172 #ifndef BRAINPOOLP320R1_SUPPORT
173  #define BRAINPOOLP320R1_SUPPORT DISABLED
174 #elif (BRAINPOOLP320R1_SUPPORT != ENABLED && BRAINPOOLP320R1_SUPPORT != DISABLED)
175  #error BRAINPOOLP320R1_SUPPORT parameter is not valid
176 #endif
177 
178 //brainpoolP384r1 elliptic curve support
179 #ifndef BRAINPOOLP384R1_SUPPORT
180  #define BRAINPOOLP384R1_SUPPORT DISABLED
181 #elif (BRAINPOOLP384R1_SUPPORT != ENABLED && BRAINPOOLP384R1_SUPPORT != DISABLED)
182  #error BRAINPOOLP384R1_SUPPORT parameter is not valid
183 #endif
184 
185 //brainpoolP512r1 elliptic curve support
186 #ifndef BRAINPOOLP512R1_SUPPORT
187  #define BRAINPOOLP512R1_SUPPORT DISABLED
188 #elif (BRAINPOOLP512R1_SUPPORT != ENABLED && BRAINPOOLP512R1_SUPPORT != DISABLED)
189  #error BRAINPOOLP512R1_SUPPORT parameter is not valid
190 #endif
191 
192 //FRP256v1 elliptic curve support
193 #ifndef FRP256V1_SUPPORT
194  #define FRP256V1_SUPPORT DISABLED
195 #elif (FRP256V1_SUPPORT != ENABLED && FRP256V1_SUPPORT != DISABLED)
196  #error FRP256V1_SUPPORT parameter is not valid
197 #endif
198 
199 //SM2 elliptic curve support
200 #ifndef SM2_SUPPORT
201  #define SM2_SUPPORT DISABLED
202 #elif (SM2_SUPPORT != ENABLED && SM2_SUPPORT != DISABLED)
203  #error SM2_SUPPORT parameter is not valid
204 #endif
205 
206 //Curve25519 elliptic curve support
207 #ifndef X25519_SUPPORT
208  #define X25519_SUPPORT DISABLED
209 #elif (X25519_SUPPORT != ENABLED && X25519_SUPPORT != DISABLED)
210  #error X25519_SUPPORT parameter is not valid
211 #endif
212 
213 //Curve448 elliptic curve support
214 #ifndef X448_SUPPORT
215  #define X448_SUPPORT DISABLED
216 #elif (X448_SUPPORT != ENABLED && X448_SUPPORT != DISABLED)
217  #error X448_SUPPORT parameter is not valid
218 #endif
219 
220 //Ed25519 elliptic curve support
221 #ifndef ED25519_SUPPORT
222  #define ED25519_SUPPORT DISABLED
223 #elif (ED25519_SUPPORT != ENABLED && ED25519_SUPPORT != DISABLED)
224  #error ED25519_SUPPORT parameter is not valid
225 #endif
226 
227 //Ed448 elliptic curve support
228 #ifndef ED448_SUPPORT
229  #define ED448_SUPPORT DISABLED
230 #elif (ED448_SUPPORT != ENABLED && ED448_SUPPORT != DISABLED)
231  #error ED448_SUPPORT parameter is not valid
232 #endif
233 
234 //Elliptic curves
235 #define SECP112R1_CURVE (&secp112r1Curve)
236 #define SECP112R2_CURVE (&secp112r2Curve)
237 #define SECP128R1_CURVE (&secp128r1Curve)
238 #define SECP128R2_CURVE (&secp128r2Curve)
239 #define SECP160K1_CURVE (&secp160k1Curve)
240 #define SECP160R1_CURVE (&secp160r1Curve)
241 #define SECP160R2_CURVE (&secp160r2Curve)
242 #define SECP192K1_CURVE (&secp192k1Curve)
243 #define SECP192R1_CURVE (&secp192r1Curve)
244 #define SECP224K1_CURVE (&secp224k1Curve)
245 #define SECP224R1_CURVE (&secp224r1Curve)
246 #define SECP256K1_CURVE (&secp256k1Curve)
247 #define SECP256R1_CURVE (&secp256r1Curve)
248 #define SECP384R1_CURVE (&secp384r1Curve)
249 #define SECP521R1_CURVE (&secp521r1Curve)
250 #define BRAINPOOLP160R1_CURVE (&brainpoolP160r1Curve)
251 #define BRAINPOOLP192R1_CURVE (&brainpoolP192r1Curve)
252 #define BRAINPOOLP224R1_CURVE (&brainpoolP224r1Curve)
253 #define BRAINPOOLP256R1_CURVE (&brainpoolP256r1Curve)
254 #define BRAINPOOLP320R1_CURVE (&brainpoolP320r1Curve)
255 #define BRAINPOOLP384R1_CURVE (&brainpoolP384r1Curve)
256 #define BRAINPOOLP512R1_CURVE (&brainpoolP512r1Curve)
257 #define SM2_CURVE (&sm2Curve)
258 #define X25519_CURVE (&x25519Curve)
259 #define X448_CURVE (&x448Curve)
260 #define ED25519_CURVE (&ed25519Curve)
261 #define ED448_CURVE (&ed448Curve)
262 
263 //C++ guard
264 #ifdef __cplusplus
265 extern "C" {
266 #endif
267 
268 
269 /**
270  * @brief Elliptic curve type
271  **/
272 
273 typedef enum
274 {
288 
289 
290 /**
291  * @brief Fast modular reduction
292  **/
293 
294 typedef error_t (*EcFastModAlgo)(Mpi *a, const Mpi *p);
295 
296 
297 /**
298  * @brief Elliptic curve parameters
299  **/
300 
301 typedef struct
302 {
303  const char_t *name; ///<Curve name
304  const uint8_t *oid; ///<Object identifier
305  size_t oidSize; ///<OID size
306  EcCurveType type; ///<Curve type
307  const uint8_t p[66]; ///<Prime modulus p
308  size_t pLen; ///<Length of p
309  const uint8_t a[66]; ///<Curve parameter a
310  size_t aLen; ///<Length of a
311  const uint8_t b[66]; ///<Curve parameter b
312  size_t bLen; ///<Length of b
313  const uint8_t gx[66]; ///<x-coordinate of the base point G
314  size_t gxLen; ///<Length of Gx
315  const uint8_t gy[66]; ///<y-coordinate of the base point G
316  size_t gyLen; ///<Length of Gy
317  const uint8_t q[66]; ///<Order of the base point G
318  size_t qLen; ///<Length of q
319  uint32_t h; ///<Cofactor h
320  EcFastModAlgo mod; ///<Fast modular reduction
321 } EcCurveInfo;
322 
323 
324 //Constants
325 extern const uint8_t SECP112R1_OID[5];
326 extern const uint8_t SECP112R2_OID[5];
327 extern const uint8_t SECP128R1_OID[5];
328 extern const uint8_t SECP128R2_OID[5];
329 extern const uint8_t SECP160K1_OID[5];
330 extern const uint8_t SECP160R1_OID[5];
331 extern const uint8_t SECP160R2_OID[5];
332 extern const uint8_t SECP192K1_OID[5];
333 extern const uint8_t SECP192R1_OID[8];
334 extern const uint8_t SECP224K1_OID[5];
335 extern const uint8_t SECP224R1_OID[5];
336 extern const uint8_t SECP256K1_OID[5];
337 extern const uint8_t SECP256R1_OID[8];
338 extern const uint8_t SECP384R1_OID[5];
339 extern const uint8_t SECP521R1_OID[5];
340 extern const uint8_t BRAINPOOLP160R1_OID[9];
341 extern const uint8_t BRAINPOOLP192R1_OID[9];
342 extern const uint8_t BRAINPOOLP224R1_OID[9];
343 extern const uint8_t BRAINPOOLP256R1_OID[9];
344 extern const uint8_t BRAINPOOLP320R1_OID[9];
345 extern const uint8_t BRAINPOOLP384R1_OID[9];
346 extern const uint8_t BRAINPOOLP512R1_OID[9];
347 extern const uint8_t FRP256V1_OID[10];
348 extern const uint8_t SM2_OID[8];
349 extern const uint8_t X25519_OID[3];
350 extern const uint8_t X448_OID[3];
351 extern const uint8_t ED25519_OID[3];
352 extern const uint8_t ED448_OID[3];
353 
354 extern const EcCurveInfo secp112r1Curve;
355 extern const EcCurveInfo secp112r2Curve;
356 extern const EcCurveInfo secp128r1Curve;
357 extern const EcCurveInfo secp128r2Curve;
358 extern const EcCurveInfo secp160k1Curve;
359 extern const EcCurveInfo secp160r1Curve;
360 extern const EcCurveInfo secp160r2Curve;
361 extern const EcCurveInfo secp192k1Curve;
362 extern const EcCurveInfo secp192r1Curve;
363 extern const EcCurveInfo secp224k1Curve;
364 extern const EcCurveInfo secp224r1Curve;
365 extern const EcCurveInfo secp256k1Curve;
366 extern const EcCurveInfo secp256r1Curve;
367 extern const EcCurveInfo secp384r1Curve;
368 extern const EcCurveInfo secp521r1Curve;
369 extern const EcCurveInfo brainpoolP160r1Curve;
370 extern const EcCurveInfo brainpoolP192r1Curve;
371 extern const EcCurveInfo brainpoolP224r1Curve;
372 extern const EcCurveInfo brainpoolP256r1Curve;
373 extern const EcCurveInfo brainpoolP320r1Curve;
374 extern const EcCurveInfo brainpoolP384r1Curve;
375 extern const EcCurveInfo brainpoolP512r1Curve;
376 extern const EcCurveInfo frp256v1Curve;
377 extern const EcCurveInfo sm2Curve;
378 extern const EcCurveInfo x25519Curve;
379 extern const EcCurveInfo x448Curve;
380 extern const EcCurveInfo ed25519Curve;
381 extern const EcCurveInfo ed448Curve;
382 
383 //Fast modular reduction
384 error_t secp128r1Mod(Mpi *a, const Mpi *p);
385 error_t secp128r2Mod(Mpi *a, const Mpi *p);
386 error_t secp160k1Mod(Mpi *a, const Mpi *p);
387 error_t secp160r1Mod(Mpi *a, const Mpi *p);
388 error_t secp160r2Mod(Mpi *a, const Mpi *p);
389 error_t secp192k1Mod(Mpi *a, const Mpi *p);
390 error_t secp192r1Mod(Mpi *a, const Mpi *p);
391 error_t secp224k1Mod(Mpi *a, const Mpi *p);
392 error_t secp224r1Mod(Mpi *a, const Mpi *p);
393 error_t secp256k1Mod(Mpi *a, const Mpi *p);
394 error_t secp256r1Mod(Mpi *a, const Mpi *p);
395 error_t secp384r1Mod(Mpi *a, const Mpi *p);
396 error_t secp521r1Mod(Mpi *a, const Mpi *p);
405 error_t sm2Mod(Mpi *a, const Mpi *p);
406 
407 const EcCurveInfo *ecGetCurveInfo(const uint8_t *oid, size_t length);
408 
409 //C++ guard
410 #ifdef __cplusplus
411 }
412 #endif
413 
414 #endif
const uint8_t BRAINPOOLP224R1_OID[9]
Definition: ec_curves.c:82
error_t secp256k1Mod(Mpi *a, const Mpi *p)
Fast modular reduction (secp256k1 curve)
Definition: ec_curves.c:1940
const EcCurveInfo brainpoolP256r1Curve
brainpoolP256r1 elliptic curve
Definition: ec_curves.c:939
error_t brainpoolP256r1Mod(Mpi *a, const Mpi *p)
uint8_t b
Definition: nbns_common.h:104
error_t secp521r1Mod(Mpi *a, const Mpi *p)
Fast modular reduction (secp521r1 curve)
Definition: ec_curves.c:2222
uint8_t a
Definition: ndp.h:411
Arbitrary precision integer.
Definition: mpi.h:80
error_t secp192k1Mod(Mpi *a, const Mpi *p)
Fast modular reduction (secp192k1 curve)
Definition: ec_curves.c:1696
const uint8_t SM2_OID[8]
Definition: ec_curves.c:94
const EcCurveInfo secp160k1Curve
secp160k1 elliptic curve
Definition: ec_curves.c:271
size_t aLen
Length of a.
Definition: ec_curves.h:310
error_t frp256v1Mod(Mpi *a, const Mpi *p)
uint8_t p
Definition: ndp.h:300
const uint8_t BRAINPOOLP256R1_OID[9]
Definition: ec_curves.c:84
const EcCurveInfo secp224k1Curve
secp224k1 elliptic curve
Definition: ec_curves.c:501
const EcCurveInfo frp256v1Curve
FRP256v1 elliptic curve.
Definition: ec_curves.c:1147
uint32_t h
Cofactor h.
Definition: ec_curves.h:319
const EcCurveInfo brainpoolP512r1Curve
brainpoolP512r1 elliptic curve
Definition: ec_curves.c:1089
const uint8_t X448_OID[3]
Definition: ec_curves.c:98
const uint8_t * oid
Object identifier.
Definition: ec_curves.h:304
error_t secp160k1Mod(Mpi *a, const Mpi *p)
Fast modular reduction (secp160k1 curve)
Definition: ec_curves.c:1546
error_t brainpoolP512r1Mod(Mpi *a, const Mpi *p)
@ EC_CURVE_TYPE_ED25519
Definition: ec_curves.h:285
@ EC_CURVE_TYPE_SECP_K1
Definition: ec_curves.h:279
error_t secp224k1Mod(Mpi *a, const Mpi *p)
Fast modular reduction (secp224k1 curve)
Definition: ec_curves.c:1814
error_t secp192r1Mod(Mpi *a, const Mpi *p)
Fast modular reduction (secp192r1 curve)
Definition: ec_curves.c:1747
const uint8_t BRAINPOOLP320R1_OID[9]
Definition: ec_curves.c:86
error_t brainpoolP320r1Mod(Mpi *a, const Mpi *p)
const EcCurveInfo secp224r1Curve
secp224r1 elliptic curve
Definition: ec_curves.c:547
@ EC_CURVE_TYPE_X448
Definition: ec_curves.h:284
error_t secp160r2Mod(Mpi *a, const Mpi *p)
Fast modular reduction (secp160r2 curve)
Definition: ec_curves.c:1645
const uint8_t SECP160R2_OID[5]
Definition: ec_curves.c:60
uint8_t oid[]
Definition: lldp_tlv.h:300
const EcCurveInfo secp112r1Curve
secp112r1 elliptic curve
Definition: ec_curves.c:111
error_t secp160r1Mod(Mpi *a, const Mpi *p)
Fast modular reduction (secp160r1 curve)
Definition: ec_curves.c:1597
const EcCurveInfo x448Curve
Curve448 elliptic curve.
Definition: ec_curves.c:1285
const uint8_t SECP128R1_OID[5]
Definition: ec_curves.c:52
const EcCurveInfo brainpoolP384r1Curve
brainpoolP384r1 elliptic curve
Definition: ec_curves.c:1037
const EcCurveInfo x25519Curve
Curve25519 elliptic curve.
Definition: ec_curves.c:1239
@ EC_CURVE_TYPE_SECP_R1
Definition: ec_curves.h:280
Elliptic curve parameters.
Definition: ec_curves.h:302
const uint8_t SECP192R1_OID[8]
Definition: ec_curves.c:64
const EcCurveInfo brainpoolP320r1Curve
brainpoolP320r1 elliptic curve
Definition: ec_curves.c:985
const EcCurveInfo secp256r1Curve
secp256r1 elliptic curve
Definition: ec_curves.c:639
const uint8_t SECP384R1_OID[5]
Definition: ec_curves.c:74
size_t bLen
Length of b.
Definition: ec_curves.h:312
error_t
Error codes.
Definition: error.h:43
const EcCurveInfo ed448Curve
Ed448 elliptic curve.
Definition: ec_curves.c:1389
const EcCurveInfo secp112r2Curve
secp112r2 elliptic curve
Definition: ec_curves.c:151
error_t brainpoolP384r1Mod(Mpi *a, const Mpi *p)
size_t qLen
Length of q.
Definition: ec_curves.h:318
const uint8_t SECP256R1_OID[8]
Definition: ec_curves.c:72
const EcCurveInfo brainpoolP224r1Curve
brainpoolP224r1 elliptic curve
Definition: ec_curves.c:893
const uint8_t SECP160K1_OID[5]
Definition: ec_curves.c:56
@ EC_CURVE_TYPE_SECT_R1
Definition: ec_curves.h:277
error_t secp224r1Mod(Mpi *a, const Mpi *p)
Fast modular reduction (secp224r1 curve)
Definition: ec_curves.c:1865
EcFastModAlgo mod
Fast modular reduction.
Definition: ec_curves.h:320
MPI (Multiple Precision Integer Arithmetic)
@ EC_CURVE_TYPE_SECT_K1
Definition: ec_curves.h:276
const uint8_t SECP160R1_OID[5]
Definition: ec_curves.c:58
General definitions for cryptographic algorithms.
const uint8_t SECP224K1_OID[5]
Definition: ec_curves.c:66
const uint8_t ED448_OID[3]
Definition: ec_curves.c:102
const EcCurveInfo brainpoolP192r1Curve
brainpoolP192r1 elliptic curve
Definition: ec_curves.c:847
const uint8_t SECP521R1_OID[5]
Definition: ec_curves.c:76
uint8_t length
Definition: tcp.h:368
const uint8_t SECP112R2_OID[5]
Definition: ec_curves.c:50
const uint8_t SECP256K1_OID[5]
Definition: ec_curves.c:70
@ EC_CURVE_TYPE_SECT_R2
Definition: ec_curves.h:278
error_t sm2Mod(Mpi *a, const Mpi *p)
Fast modular reduction (SM2 curve)
Definition: ec_curves.c:2268
size_t gyLen
Length of Gy.
Definition: ec_curves.h:316
error_t brainpoolP192r1Mod(Mpi *a, const Mpi *p)
const char_t * name
Curve name.
Definition: ec_curves.h:303
error_t brainpoolP224r1Mod(Mpi *a, const Mpi *p)
const uint8_t ED25519_OID[3]
Definition: ec_curves.c:100
const EcCurveInfo ed25519Curve
Ed25519 elliptic curve.
Definition: ec_curves.c:1343
@ EC_CURVE_TYPE_ED448
Definition: ec_curves.h:286
const EcCurveInfo secp521r1Curve
secp521r1 elliptic curve
Definition: ec_curves.c:737
char char_t
Definition: compiler_port.h:48
error_t secp256r1Mod(Mpi *a, const Mpi *p)
Fast modular reduction (secp256r1 curve)
Definition: ec_curves.c:1991
const uint8_t FRP256V1_OID[10]
Definition: ec_curves.c:92
error_t secp384r1Mod(Mpi *a, const Mpi *p)
Fast modular reduction (secp384r1 curve)
Definition: ec_curves.c:2107
const uint8_t X25519_OID[3]
Definition: ec_curves.c:96
const EcCurveInfo secp128r2Curve
secp128r2 elliptic curve
Definition: ec_curves.c:231
@ EC_CURVE_TYPE_X25519
Definition: ec_curves.h:283
error_t secp128r2Mod(Mpi *a, const Mpi *p)
Fast modular reduction (secp128r2 curve)
Definition: ec_curves.c:1498
const uint8_t BRAINPOOLP384R1_OID[9]
Definition: ec_curves.c:88
@ EC_CURVE_TYPE_SECP_R2
Definition: ec_curves.h:281
const EcCurveInfo sm2Curve
SM2 elliptic curve.
Definition: ec_curves.c:1193
const EcCurveInfo secp128r1Curve
secp128r1 elliptic curve
Definition: ec_curves.c:191
const uint8_t SECP128R2_OID[5]
Definition: ec_curves.c:54
const EcCurveInfo secp192r1Curve
secp192r1 elliptic curve
Definition: ec_curves.c:455
const EcCurveInfo secp384r1Curve
secp384r1 elliptic curve
Definition: ec_curves.c:685
const EcCurveInfo secp160r2Curve
secp160r2 elliptic curve
Definition: ec_curves.c:363
const EcCurveInfo * ecGetCurveInfo(const uint8_t *oid, size_t length)
Get the elliptic curve that matches the specified OID.
Definition: ec_curves.c:2422
const uint8_t SECP192K1_OID[5]
Definition: ec_curves.c:62
const uint8_t BRAINPOOLP160R1_OID[9]
Definition: ec_curves.c:78
size_t gxLen
Length of Gx.
Definition: ec_curves.h:314
@ EC_CURVE_TYPE_NONE
Definition: ec_curves.h:275
size_t oidSize
OID size.
Definition: ec_curves.h:305
const uint8_t SECP112R1_OID[5]
Definition: ec_curves.c:48
const EcCurveInfo secp192k1Curve
secp192k1 elliptic curve
Definition: ec_curves.c:409
error_t(* EcFastModAlgo)(Mpi *a, const Mpi *p)
Fast modular reduction.
Definition: ec_curves.h:294
const EcCurveInfo secp160r1Curve
secp160r1 elliptic curve
Definition: ec_curves.c:317
EcCurveType
Elliptic curve type.
Definition: ec_curves.h:274
const uint8_t BRAINPOOLP512R1_OID[9]
Definition: ec_curves.c:90
const uint8_t BRAINPOOLP192R1_OID[9]
Definition: ec_curves.c:80
@ EC_CURVE_TYPE_BRAINPOOLP_R1
Definition: ec_curves.h:282
size_t pLen
Length of p.
Definition: ec_curves.h:308
error_t secp128r1Mod(Mpi *a, const Mpi *p)
Fast modular reduction (secp128r1 curve)
Definition: ec_curves.c:1450
const uint8_t SECP224R1_OID[5]
Definition: ec_curves.c:68
const EcCurveInfo brainpoolP160r1Curve
brainpoolP160r1 elliptic curve
Definition: ec_curves.c:801
EcCurveType type
Curve type.
Definition: ec_curves.h:306
const EcCurveInfo secp256k1Curve
secp256k1 elliptic curve
Definition: ec_curves.c:593
error_t brainpoolP160r1Mod(Mpi *a, const Mpi *p)