xref: /freebsd/crypto/libecc/include/libecc/curves/curves_list.h (revision f0865ec9906d5a18fa2a3b61381f22ce16e606ad)
1 /*
2  *  Copyright (C) 2017 - This file is part of libecc project
3  *
4  *  Authors:
5  *      Ryad BENADJILA <ryadbenadjila@gmail.com>
6  *      Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
7  *      Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
8  *
9  *  Contributors:
10  *      Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
11  *      Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
12  *
13  *  This software is licensed under a dual BSD and GPL v2 license.
14  *  See LICENSE file at the root folder of the project.
15  */
16 #ifndef __CURVES_LIST_H__
17 #define __CURVES_LIST_H__
18 
19 #include <libecc/lib_ecc_config.h>
20 #include <libecc/lib_ecc_types.h>
21 #include <libecc/words/words.h>
22 #include <libecc/curves/known/ec_params_brainpoolp192r1.h>
23 #include <libecc/curves/known/ec_params_brainpoolp224r1.h>
24 #include <libecc/curves/known/ec_params_brainpoolp256r1.h>
25 #include <libecc/curves/known/ec_params_brainpoolp384r1.h>
26 #include <libecc/curves/known/ec_params_brainpoolp512r1.h>
27 #include <libecc/curves/known/ec_params_secp192r1.h>
28 #include <libecc/curves/known/ec_params_secp224r1.h>
29 #include <libecc/curves/known/ec_params_secp256r1.h>
30 #include <libecc/curves/known/ec_params_secp384r1.h>
31 #include <libecc/curves/known/ec_params_secp521r1.h>
32 #include <libecc/curves/known/ec_params_frp256v1.h>
33 #include <libecc/curves/known/ec_params_gost256.h>
34 #include <libecc/curves/known/ec_params_gost512.h>
35 #include <libecc/curves/known/ec_params_sm2p192test.h>
36 #include <libecc/curves/known/ec_params_sm2p256test.h>
37 #include <libecc/curves/known/ec_params_sm2p256v1.h>
38 #include <libecc/curves/known/ec_params_wei25519.h>
39 #include <libecc/curves/known/ec_params_wei448.h>
40 #include <libecc/curves/known/ec_params_gost_R3410_2012_256_paramSetA.h>
41 #include <libecc/curves/known/ec_params_secp256k1.h>
42 #include <libecc/curves/known/ec_params_gost_R3410_2001_TestParamSet.h>
43 #include <libecc/curves/known/ec_params_gost_R3410_2001_CryptoPro_A_ParamSet.h>
44 #include <libecc/curves/known/ec_params_gost_R3410_2001_CryptoPro_B_ParamSet.h>
45 #include <libecc/curves/known/ec_params_gost_R3410_2001_CryptoPro_C_ParamSet.h>
46 #include <libecc/curves/known/ec_params_gost_R3410_2001_CryptoPro_XchA_ParamSet.h>
47 #include <libecc/curves/known/ec_params_gost_R3410_2001_CryptoPro_XchB_ParamSet.h>
48 #include <libecc/curves/known/ec_params_gost_R3410_2012_256_paramSetA.h>
49 #include <libecc/curves/known/ec_params_gost_R3410_2012_256_paramSetB.h>
50 #include <libecc/curves/known/ec_params_gost_R3410_2012_256_paramSetC.h>
51 #include <libecc/curves/known/ec_params_gost_R3410_2012_256_paramSetD.h>
52 #include <libecc/curves/known/ec_params_gost_R3410_2012_512_paramSetTest.h>
53 #include <libecc/curves/known/ec_params_gost_R3410_2012_512_paramSetA.h>
54 #include <libecc/curves/known/ec_params_gost_R3410_2012_512_paramSetB.h>
55 #include <libecc/curves/known/ec_params_gost_R3410_2012_512_paramSetC.h>
56 #include <libecc/curves/known/ec_params_secp192k1.h>
57 #include <libecc/curves/known/ec_params_secp224k1.h>
58 #include <libecc/curves/known/ec_params_brainpoolp192t1.h>
59 #include <libecc/curves/known/ec_params_brainpoolp224t1.h>
60 #include <libecc/curves/known/ec_params_brainpoolp256t1.h>
61 #include <libecc/curves/known/ec_params_brainpoolp320r1.h>
62 #include <libecc/curves/known/ec_params_brainpoolp320t1.h>
63 #include <libecc/curves/known/ec_params_brainpoolp384t1.h>
64 #include <libecc/curves/known/ec_params_brainpoolp512t1.h>
65 #include <libecc/curves/known/ec_params_bign256v1.h>
66 #include <libecc/curves/known/ec_params_bign384v1.h>
67 #include <libecc/curves/known/ec_params_bign512v1.h>
68 /* ADD curves header here */
69 /* XXX: Do not remove the comment above, as it is
70  * used by external tools as a placeholder to add or
71  * remove automatically generated code.
72  */
73 
74 #ifndef CURVES_MAX_P_BIT_LEN
75 #error "Max p bit length is 0; did you disable all curves in lib_ecc_config.h?"
76 #endif
77 #if (CURVES_MAX_P_BIT_LEN > 65535)
78 #error "Prime field length (in bytes) MUST fit on an u16!"
79 #endif
80 
81 #ifndef CURVES_MAX_Q_BIT_LEN
82 #error "Max q bit length is 0; did you disable all curves in lib_ecc_config.h?"
83 #endif
84 #if (CURVES_MAX_Q_BIT_LEN > 65535)
85 #error "Generator order length (in bytes) MUST fit on an u16!"
86 #endif
87 
88 #ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
89 #error "Max curve order bit length is 0; did you disable all curves in lib_ecc_config.h?"
90 #endif
91 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN > 65535)
92 #error "Curve order length (in bytes) MUST fit on an u16!"
93 #endif
94 
95 typedef struct {
96 	ec_curve_type type;
97 	const ec_str_params *params;
98 } ec_mapping;
99 
100 static const ec_mapping ec_maps[] = {
101 #ifdef WITH_CURVE_FRP256V1
102 	{.type = FRP256V1,.params = &frp256v1_str_params},
103 #endif /* WITH_CURVE_FRP256V1 */
104 #ifdef WITH_CURVE_SECP192R1
105 	{.type = SECP192R1,.params = &secp192r1_str_params},
106 #endif /* WITH_CURVE_SECP192R1 */
107 #ifdef WITH_CURVE_SECP224R1
108 	{.type = SECP224R1,.params = &secp224r1_str_params},
109 #endif /* WITH_CURVE_SECP224R1 */
110 #ifdef WITH_CURVE_SECP256R1
111 	{.type = SECP256R1,.params = &secp256r1_str_params},
112 #endif /* WITH_CURVE_SECP256R1 */
113 #ifdef WITH_CURVE_SECP384R1
114 	{.type = SECP384R1,.params = &secp384r1_str_params},
115 #endif /* WITH_CURVE_SECP384R1 */
116 #ifdef WITH_CURVE_SECP521R1
117 	{.type = SECP521R1,.params = &secp521r1_str_params},
118 #endif /* WITH_CURVE_SECP521R1 */
119 #ifdef WITH_CURVE_BRAINPOOLP192R1
120 	{.type = BRAINPOOLP192R1,.params = &brainpoolp192r1_str_params},
121 #endif /* WITH_CURVE_BRAINPOOLP192R1 */
122 #ifdef WITH_CURVE_BRAINPOOLP224R1
123 	{.type = BRAINPOOLP224R1,.params = &brainpoolp224r1_str_params},
124 #endif /* WITH_CURVE_BRAINPOOLP224R1 */
125 #ifdef WITH_CURVE_BRAINPOOLP256R1
126 	{.type = BRAINPOOLP256R1,.params = &brainpoolp256r1_str_params},
127 #endif /* WITH_CURVE_BRAINPOOLP256R1 */
128 #ifdef WITH_CURVE_BRAINPOOLP384R1
129 	{.type = BRAINPOOLP384R1,.params = &brainpoolp384r1_str_params},
130 #endif /* WITH_CURVE_BRAINPOOLP384R1 */
131 #ifdef WITH_CURVE_BRAINPOOLP512R1
132 	{.type = BRAINPOOLP512R1,.params = &brainpoolp512r1_str_params},
133 #endif /* WITH_CURVE_BRAINPOOLP512R1 */
134 #ifdef WITH_CURVE_GOST256
135 	{.type = GOST256,.params = &GOST_256bits_curve_str_params},
136 #endif /* WITH_CURVE_GOST256 */
137 #ifdef WITH_CURVE_GOST512
138 	{.type = GOST512,.params = &GOST_512bits_curve_str_params},
139 #endif /* WITH_CURVE_GOST512 */
140 #ifdef WITH_CURVE_SM2P256TEST
141 	{.type = SM2P256TEST,.params = &sm2p256test_str_params},
142 #endif /* WITH_CURVE_SM2P256TEST */
143 #ifdef WITH_CURVE_SM2P256V1
144 	{.type = SM2P256V1,.params = &sm2p256v1_str_params},
145 #endif /* WITH_CURVE_SM2P256V1 */
146 #ifdef WITH_CURVE_WEI25519
147 	{.type = WEI25519,.params = &wei25519_str_params},
148 #endif /* WITH_CURVE_WEI25519 */
149 #ifdef WITH_CURVE_WEI448
150 	{.type = WEI448,.params = &wei448_str_params},
151 #endif /* WITH_CURVE_WEI448 */
152 #ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETA
153 	{ .type = GOST_R3410_2012_256_PARAMSETA, .params = &gost_R3410_2012_256_paramSetA_str_params },
154 #endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETA */
155 #ifdef WITH_CURVE_SECP256K1
156 	{.type = SECP256K1,.params = &secp256k1_str_params},
157 #endif /* WITH_CURVE_SECP256K1 */
158 #ifdef WITH_CURVE_GOST_R3410_2001_TESTPARAMSET
159 	{ .type = GOST_R3410_2001_TESTPARAMSET, .params = &gost_R3410_2001_TestParamSet_str_params },
160 #endif /* WITH_CURVE_GOST_R3410_2001_TESTPARAMSET */
161 #ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET
162 	{ .type = GOST_R3410_2001_CRYPTOPRO_A_PARAMSET, .params = &gost_R3410_2001_CryptoPro_A_ParamSet_str_params },
163 #endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_A_PARAMSET */
164 #ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET
165 	{ .type = GOST_R3410_2001_CRYPTOPRO_B_PARAMSET, .params = &gost_R3410_2001_CryptoPro_B_ParamSet_str_params },
166 #endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_B_PARAMSET */
167 #ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET
168 	{ .type = GOST_R3410_2001_CRYPTOPRO_C_PARAMSET, .params = &gost_R3410_2001_CryptoPro_C_ParamSet_str_params },
169 #endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET */
170 #ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET
171 	{ .type = GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET, .params = &gost_R3410_2001_CryptoPro_XchA_ParamSet_str_params },
172 #endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_XCHA_PARAMSET */
173 #ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET
174 	{ .type = GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET, .params = &gost_R3410_2001_CryptoPro_XchB_ParamSet_str_params },
175 #endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_XCHB_PARAMSET */
176 #ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETA
177 	{ .type = GOST_R3410_2012_256_PARAMSETA, .params = &gost_R3410_2012_256_paramSetA_str_params },
178 #endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETA */
179 #ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETB
180 	{ .type = GOST_R3410_2012_256_PARAMSETB, .params = &gost_R3410_2012_256_paramSetB_str_params },
181 #endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETB */
182 #ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETC
183 	{ .type = GOST_R3410_2012_256_PARAMSETC, .params = &gost_R3410_2012_256_paramSetC_str_params },
184 #endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETC */
185 #ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETD
186 	{ .type = GOST_R3410_2012_256_PARAMSETD, .params = &gost_R3410_2012_256_paramSetD_str_params },
187 #endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETD */
188 #ifdef WITH_CURVE_GOST_R3410_2012_512_PARAMSETTEST
189 	{ .type = GOST_R3410_2012_512_PARAMSETTEST, .params = &gost_R3410_2012_512_paramSetTest_str_params },
190 #endif /* WITH_CURVE_GOST_R3410_2012_512_PARAMSETTEST */
191 #ifdef WITH_CURVE_GOST_R3410_2012_512_PARAMSETA
192 	{ .type = GOST_R3410_2012_512_PARAMSETA, .params = &gost_R3410_2012_512_paramSetA_str_params },
193 #endif /* WITH_CURVE_GOST_R3410_2012_512_PARAMSETA */
194 #ifdef WITH_CURVE_GOST_R3410_2012_512_PARAMSETB
195 	{ .type = GOST_R3410_2012_512_PARAMSETB, .params = &gost_R3410_2012_512_paramSetB_str_params },
196 #endif /* WITH_CURVE_GOST_R3410_2012_512_PARAMSETB */
197 #ifdef WITH_CURVE_GOST_R3410_2012_512_PARAMSETC
198 	{ .type = GOST_R3410_2012_512_PARAMSETC, .params = &gost_R3410_2012_512_paramSetC_str_params },
199 #endif /* WITH_CURVE_GOST_R3410_2012_512_PARAMSETC */
200 #ifdef WITH_CURVE_SECP192K1
201 	{.type = SECP192K1,.params = &secp192k1_str_params},
202 #endif /* WITH_CURVE_SECP192K1 */
203 #ifdef WITH_CURVE_SECP224K1
204 	{.type = SECP224K1,.params = &secp224k1_str_params},
205 #endif /* WITH_CURVE_SECP224K1 */
206 #ifdef WITH_CURVE_BRAINPOOLP192T1
207 	{.type = BRAINPOOLP192T1,.params = &brainpoolp192t1_str_params},
208 #endif /* WITH_CURVE_BRAINPOOLP192T1 */
209 #ifdef WITH_CURVE_BRAINPOOLP224T1
210 	{.type = BRAINPOOLP224T1,.params = &brainpoolp224t1_str_params},
211 #endif /* WITH_CURVE_BRAINPOOLP224T1 */
212 #ifdef WITH_CURVE_BRAINPOOLP256T1
213 	{.type = BRAINPOOLP256T1,.params = &brainpoolp256t1_str_params},
214 #endif /* WITH_CURVE_BRAINPOOLP256T1 */
215 #ifdef WITH_CURVE_BRAINPOOLP320R1
216 	{.type = BRAINPOOLP320R1,.params = &brainpoolp320r1_str_params},
217 #endif /* WITH_CURVE_BRAINPOOLP320R1 */
218 #ifdef WITH_CURVE_BRAINPOOLP320T1
219 	{.type = BRAINPOOLP320T1,.params = &brainpoolp320t1_str_params},
220 #endif /* WITH_CURVE_BRAINPOOLP320T1 */
221 #ifdef WITH_CURVE_BRAINPOOLP384T1
222 	{.type = BRAINPOOLP384T1,.params = &brainpoolp384t1_str_params},
223 #endif /* WITH_CURVE_BRAINPOOLP192T1 */
224 #ifdef WITH_CURVE_BRAINPOOLP512T1
225 	{.type = BRAINPOOLP512T1,.params = &brainpoolp512t1_str_params},
226 #endif /* WITH_CURVE_BRAINPOOLP512T1 */
227 #ifdef WITH_CURVE_BIGN256V1
228 	{.type = BIGN256V1,.params = &bign256v1_str_params},
229 #endif /* WITH_CURVE_BIGN256V1 */
230 #ifdef WITH_CURVE_BIGN384V1
231 	{.type = BIGN384V1,.params = &bign384v1_str_params},
232 #endif /* WITH_CURVE_BIGN384V1 */
233 #ifdef WITH_CURVE_BIGN512V1
234 	{.type = BIGN512V1,.params = &bign512v1_str_params},
235 #endif /* WITH_CURVE_BIGN512V1 */
236 /* ADD curves mapping here */
237 /* XXX: Do not remove the comment above, as it is
238  * used by external tools as a placeholder to add or
239  * remove automatically generated code.
240  */
241 };
242 
243 /*
244  * Number of cuvres supported by the lib, i.e. number of elements in
245  * ec_maps array above.
246  */
247 #define EC_CURVES_NUM (sizeof(ec_maps) / sizeof(ec_mapping))
248 #endif /* __CURVES_LIST_H__ */
249