xref: /freebsd/crypto/libecc/include/libecc/curves/known/ec_params_wei448.h (revision f0865ec9906d5a18fa2a3b61381f22ce16e606ad)
1 /*
2  *  Copyright (C) 2021 - This file is part of libecc project
3  *
4  *  Authors:
5  *      Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
6  *      Ryad BENADJILA <ryadbenadjila@gmail.com>
7  *
8  *  This software is licensed under a dual BSD and GPL v2 license.
9  *  See LICENSE file at the root folder of the project.
10  */
11 #include <libecc/lib_ecc_config.h>
12 #ifdef WITH_CURVE_WEI448
13 
14 #ifndef __EC_PARAMS_WEI448_H__
15 #define __EC_PARAMS_WEI448_H__
16 #include <libecc/curves/known/ec_params_external.h>
17 static const u8 wei448_p[] = {
18 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
19 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
20 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
21 	0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
22 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
23 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
24 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
25 };
26 
27 TO_EC_STR_PARAM(wei448_p);
28 
29 #define CURVE_WEI448_P_BITLEN 448
30 static const u8 wei448_p_bitlen[] = {
31 	0x01, 0xc0,
32 };
33 
34 TO_EC_STR_PARAM(wei448_p_bitlen);
35 
36 #if (WORD_BYTES == 8)     /* 64-bit words */
37 static const u8 wei448_r[] = {
38 	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 	0x00, 0x00, 0x00, 0x00, 0x01,
42 };
43 
44 TO_EC_STR_PARAM(wei448_r);
45 
46 static const u8 wei448_r_square[] = {
47 	0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50 	0x00, 0x00, 0x00, 0x00, 0x02,
51 };
52 
53 TO_EC_STR_PARAM(wei448_r_square);
54 
55 static const u8 wei448_mpinv[] = {
56 	0x01,
57 };
58 
59 TO_EC_STR_PARAM(wei448_mpinv);
60 
61 static const u8 wei448_p_shift[] = {
62 	0x00,
63 };
64 
65 TO_EC_STR_PARAM(wei448_p_shift);
66 
67 static const u8 wei448_p_normalized[] = {
68 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
69 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
70 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
71 	0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
72 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
73 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
74 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
75 };
76 
77 TO_EC_STR_PARAM(wei448_p_normalized);
78 
79 static const u8 wei448_p_reciprocal[] = {
80 	0x00,
81 };
82 
83 TO_EC_STR_PARAM(wei448_p_reciprocal);
84 
85 #elif (WORD_BYTES == 4)   /* 32-bit words */
86 static const u8 wei448_r[] = {
87 	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
88 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
89 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
90 	0x00, 0x00, 0x00, 0x00, 0x01,
91 };
92 
93 TO_EC_STR_PARAM(wei448_r);
94 
95 static const u8 wei448_r_square[] = {
96 	0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
97 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
98 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
99 	0x00, 0x00, 0x00, 0x00, 0x02,
100 };
101 
102 TO_EC_STR_PARAM(wei448_r_square);
103 
104 static const u8 wei448_mpinv[] = {
105 	0x01,
106 };
107 
108 TO_EC_STR_PARAM(wei448_mpinv);
109 
110 static const u8 wei448_p_shift[] = {
111 	0x00,
112 };
113 
114 TO_EC_STR_PARAM(wei448_p_shift);
115 
116 static const u8 wei448_p_normalized[] = {
117 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
118 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
119 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
120 	0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
121 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
122 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
123 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
124 };
125 
126 TO_EC_STR_PARAM(wei448_p_normalized);
127 
128 static const u8 wei448_p_reciprocal[] = {
129 	0x00,
130 };
131 
132 TO_EC_STR_PARAM(wei448_p_reciprocal);
133 
134 #elif (WORD_BYTES == 2)   /* 16-bit words */
135 static const u8 wei448_r[] = {
136 	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
137 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
138 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
139 	0x00, 0x00, 0x00, 0x00, 0x01,
140 };
141 
142 TO_EC_STR_PARAM(wei448_r);
143 
144 static const u8 wei448_r_square[] = {
145 	0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
146 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
147 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
148 	0x00, 0x00, 0x00, 0x00, 0x02,
149 };
150 
151 TO_EC_STR_PARAM(wei448_r_square);
152 
153 static const u8 wei448_mpinv[] = {
154 	0x01,
155 };
156 
157 TO_EC_STR_PARAM(wei448_mpinv);
158 
159 static const u8 wei448_p_shift[] = {
160 	0x00,
161 };
162 
163 TO_EC_STR_PARAM(wei448_p_shift);
164 
165 static const u8 wei448_p_normalized[] = {
166 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
167 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
168 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
169 	0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
170 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
171 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
172 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
173 };
174 
175 TO_EC_STR_PARAM(wei448_p_normalized);
176 
177 static const u8 wei448_p_reciprocal[] = {
178 	0x00,
179 };
180 
181 TO_EC_STR_PARAM(wei448_p_reciprocal);
182 
183 #else                     /* unknown word size */
184 #error "Unsupported word size"
185 #endif
186 
187 static const u8 wei448_a[] = {
188 	0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
189 	0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
190 	0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
191 	0xaa, 0xaa, 0xaa, 0xa9, 0xff, 0xff, 0xff, 0xff,
192 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
193 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
194 	0xff, 0xff, 0xff, 0xfe, 0x1a, 0x76, 0xd4, 0x1f,
195 };
196 
197 TO_EC_STR_PARAM(wei448_a);
198 
199 static const u8 wei448_b[] = {
200 	0x5e, 0xd0, 0x97, 0xb4, 0x25, 0xed, 0x09, 0x7b,
201 	0x42, 0x5e, 0xd0, 0x97, 0xb4, 0x25, 0xed, 0x09,
202 	0x7b, 0x42, 0x5e, 0xd0, 0x97, 0xb4, 0x25, 0xed,
203 	0x09, 0x7b, 0x42, 0x5e, 0x71, 0xc7, 0x1c, 0x71,
204 	0xc7, 0x1c, 0x71, 0xc7, 0x1c, 0x71, 0xc7, 0x1c,
205 	0x71, 0xc7, 0x1c, 0x71, 0xc7, 0x1c, 0x71, 0xc7,
206 	0x1c, 0x72, 0xc8, 0x7b, 0x7c, 0xc6, 0x9f, 0x70,
207 };
208 
209 TO_EC_STR_PARAM(wei448_b);
210 
211 #define CURVE_WEI448_CURVE_ORDER_BITLEN 448
212 static const u8 wei448_curve_order[] = {
213 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
214 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
215 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
216 	0xff, 0xff, 0xff, 0xfd, 0xf3, 0x28, 0x8f, 0xa7,
217 	0x11, 0x3b, 0x6d, 0x26, 0xbb, 0x58, 0xda, 0x40,
218 	0x85, 0xb3, 0x09, 0xca, 0x37, 0x16, 0x3d, 0x54,
219 	0x8d, 0xe3, 0x0a, 0x4a, 0xad, 0x61, 0x13, 0xcc,
220 };
221 
222 TO_EC_STR_PARAM(wei448_curve_order);
223 
224 static const u8 wei448_gx[] = {
225 	0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
226 	0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
227 	0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
228 	0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
229 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
230 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
231 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x91,
232 };
233 
234 TO_EC_STR_PARAM(wei448_gx);
235 
236 static const u8 wei448_gy[] = {
237 	0x7d, 0x23, 0x5d, 0x12, 0x95, 0xf5, 0xb1, 0xf6,
238 	0x6c, 0x98, 0xab, 0x6e, 0x58, 0x32, 0x6f, 0xce,
239 	0xcb, 0xae, 0x5d, 0x34, 0xf5, 0x55, 0x45, 0xd0,
240 	0x60, 0xf7, 0x5d, 0xc2, 0x8d, 0xf3, 0xf6, 0xed,
241 	0xb8, 0x02, 0x7e, 0x23, 0x46, 0x43, 0x0d, 0x21,
242 	0x13, 0x12, 0xc4, 0xb1, 0x50, 0x67, 0x7a, 0xf7,
243 	0x6f, 0xd7, 0x22, 0x3d, 0x45, 0x7b, 0x5b, 0x1a,
244 };
245 
246 TO_EC_STR_PARAM(wei448_gy);
247 
248 static const u8 wei448_gz[] = {
249 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
250 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
251 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
252 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
253 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
254 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
255 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
256 };
257 
258 TO_EC_STR_PARAM(wei448_gz);
259 
260 static const u8 wei448_gen_order[] = {
261 	0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
262 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
263 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
264 	0xff, 0xff, 0xff, 0xff, 0x7c, 0xca, 0x23, 0xe9,
265 	0xc4, 0x4e, 0xdb, 0x49, 0xae, 0xd6, 0x36, 0x90,
266 	0x21, 0x6c, 0xc2, 0x72, 0x8d, 0xc5, 0x8f, 0x55,
267 	0x23, 0x78, 0xc2, 0x92, 0xab, 0x58, 0x44, 0xf3,
268 };
269 
270 TO_EC_STR_PARAM(wei448_gen_order);
271 
272 #define CURVE_WEI448_Q_BITLEN 446
273 static const u8 wei448_gen_order_bitlen[] = {
274 	0x01, 0xbe,
275 };
276 
277 TO_EC_STR_PARAM(wei448_gen_order_bitlen);
278 
279 static const u8 wei448_cofactor[] = {
280 	0x04,
281 };
282 
283 TO_EC_STR_PARAM(wei448_cofactor);
284 
285 static const u8 wei448_alpha_montgomery[] = {
286 	0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
287 	0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
288 	0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
289 	0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
290 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
291 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
292 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0x8c,
293 };
294 
295 TO_EC_STR_PARAM(wei448_alpha_montgomery);
296 
297 static const u8 wei448_gamma_montgomery[] = {
298 	0x01,
299 };
300 
301 TO_EC_STR_PARAM(wei448_gamma_montgomery);
302 
303 static const u8 wei448_alpha_edwards[] = {
304 	0x45, 0xb2, 0xc5, 0xf7, 0xd6, 0x49, 0xee, 0xd0,
305 	0x77, 0xed, 0x1a, 0xe4, 0x5f, 0x44, 0xd5, 0x41,
306 	0x43, 0xe3, 0x4f, 0x71, 0x4b, 0x71, 0xaa, 0x96,
307 	0xc9, 0x45, 0xaf, 0x01, 0x2d, 0x18, 0x29, 0x75,
308 	0x07, 0x34, 0xcd, 0xe9, 0xfa, 0xdd, 0xbd, 0xa4,
309 	0xc0, 0x66, 0xf7, 0xed, 0x54, 0x41, 0x9c, 0xa5,
310 	0x2c, 0x85, 0xde, 0x1e, 0x8a, 0xae, 0x4e, 0x6c,
311 };
312 
313 TO_EC_STR_PARAM(wei448_alpha_edwards);
314 
315 static const u8 wei448_name[] = "WEI448";
316 TO_EC_STR_PARAM(wei448_name);
317 
318 static const u8 wei448_oid[] = "";
319 TO_EC_STR_PARAM(wei448_oid);
320 
321 static const ec_str_params wei448_str_params = {
322 	.p = &wei448_p_str_param,
323 	.p_bitlen = &wei448_p_bitlen_str_param,
324 	.r = &wei448_r_str_param,
325 	.r_square = &wei448_r_square_str_param,
326 	.mpinv = &wei448_mpinv_str_param,
327 	.p_shift = &wei448_p_shift_str_param,
328 	.p_normalized = &wei448_p_normalized_str_param,
329 	.p_reciprocal = &wei448_p_reciprocal_str_param,
330 	.a = &wei448_a_str_param,
331 	.b = &wei448_b_str_param,
332 	.curve_order = &wei448_curve_order_str_param,
333 	.gx = &wei448_gx_str_param,
334 	.gy = &wei448_gy_str_param,
335 	.gz = &wei448_gz_str_param,
336 	.gen_order = &wei448_gen_order_str_param,
337 	.gen_order_bitlen = &wei448_gen_order_bitlen_str_param,
338 	.cofactor = &wei448_cofactor_str_param,
339 	.alpha_montgomery = &wei448_alpha_montgomery_str_param,
340 	.gamma_montgomery = &wei448_gamma_montgomery_str_param,
341 	.alpha_edwards = &wei448_alpha_edwards_str_param,
342 	.oid = &wei448_oid_str_param,
343 	.name = &wei448_name_str_param,
344 };
345 
346 /*
347  * Compute max bit length of all curves for p and q
348  */
349 #ifndef CURVES_MAX_P_BIT_LEN
350 #define CURVES_MAX_P_BIT_LEN    0
351 #endif
352 #if (CURVES_MAX_P_BIT_LEN < CURVE_WEI448_P_BITLEN)
353 #undef CURVES_MAX_P_BIT_LEN
354 #define CURVES_MAX_P_BIT_LEN CURVE_WEI448_P_BITLEN
355 #endif
356 #ifndef CURVES_MAX_Q_BIT_LEN
357 #define CURVES_MAX_Q_BIT_LEN    0
358 #endif
359 #if (CURVES_MAX_Q_BIT_LEN < CURVE_WEI448_Q_BITLEN)
360 #undef CURVES_MAX_Q_BIT_LEN
361 #define CURVES_MAX_Q_BIT_LEN CURVE_WEI448_Q_BITLEN
362 #endif
363 #ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
364 #define CURVES_MAX_CURVE_ORDER_BIT_LEN    0
365 #endif
366 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_WEI448_CURVE_ORDER_BITLEN)
367 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN
368 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_WEI448_CURVE_ORDER_BITLEN
369 #endif
370 
371 /*
372  * Compute and adapt max name and oid length
373  */
374 #ifndef MAX_CURVE_OID_LEN
375 #define MAX_CURVE_OID_LEN 0
376 #endif
377 #ifndef MAX_CURVE_NAME_LEN
378 #define MAX_CURVE_NAME_LEN 0
379 #endif
380 #if (MAX_CURVE_OID_LEN < 1)
381 #undef MAX_CURVE_OID_LEN
382 #define MAX_CURVE_OID_LEN 1
383 #endif
384 #if (MAX_CURVE_NAME_LEN < 20)
385 #undef MAX_CURVE_NAME_LEN
386 #define MAX_CURVE_NAME_LEN 20
387 #endif
388 
389 #endif /* __EC_PARAMS_WEI448_H__ */
390 
391 #endif /* WITH_CURVE_WEI448 */
392