xref: /freebsd/crypto/libecc/include/libecc/curves/known/ec_params_brainpoolp320r1.h (revision f0865ec9906d5a18fa2a3b61381f22ce16e606ad)
1 #include <libecc/lib_ecc_config.h>
2 #ifdef WITH_CURVE_BRAINPOOLP320R1
3 
4 #ifndef __EC_PARAMS_BRAINPOOLP320R1_H__
5 #define __EC_PARAMS_BRAINPOOLP320R1_H__
6 #include <libecc/curves/known/ec_params_external.h>
7 static const u8 brainpoolp320r1_p[] = {
8 	0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
9 	0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
10 	0xf9, 0x8f, 0xcf, 0xa6, 0xf6, 0xf4, 0x0d, 0xef,
11 	0x4f, 0x92, 0xb9, 0xec, 0x78, 0x93, 0xec, 0x28,
12 	0xfc, 0xd4, 0x12, 0xb1, 0xf1, 0xb3, 0x2e, 0x27,
13 };
14 
15 TO_EC_STR_PARAM(brainpoolp320r1_p);
16 
17 #define CURVE_BRAINPOOLP320R1_P_BITLEN 320
18 static const u8 brainpoolp320r1_p_bitlen[] = {
19 	0x01, 0x40,
20 };
21 
22 TO_EC_STR_PARAM(brainpoolp320r1_p_bitlen);
23 
24 #if (WORD_BYTES == 8)     /* 64-bit words */
25 static const u8 brainpoolp320r1_r[] = {
26 	0x2c, 0xa1, 0xb8, 0xdf, 0xc9, 0x43, 0xb0, 0x48,
27 	0x1e, 0xc3, 0x87, 0xa1, 0x2d, 0xfe, 0x1f, 0x9a,
28 	0x06, 0x70, 0x30, 0x59, 0x09, 0x0b, 0xf2, 0x10,
29 	0xb0, 0x6d, 0x46, 0x13, 0x87, 0x6c, 0x13, 0xd7,
30 	0x03, 0x2b, 0xed, 0x4e, 0x0e, 0x4c, 0xd1, 0xd9,
31 };
32 
33 TO_EC_STR_PARAM(brainpoolp320r1_r);
34 
35 static const u8 brainpoolp320r1_r_square[] = {
36 	0xa2, 0x59, 0xba, 0x4a, 0x6c, 0x2d, 0x92, 0x52,
37 	0x54, 0x55, 0xa9, 0x64, 0xe6, 0x14, 0xd6, 0xd2,
38 	0x1f, 0x4c, 0x88, 0x1f, 0x30, 0xc5, 0xb6, 0x76,
39 	0xc2, 0x47, 0x8a, 0x8d, 0x90, 0x69, 0x78, 0xef,
40 	0x99, 0x4e, 0xe8, 0x8a, 0x74, 0x3b, 0x52, 0xf9,
41 };
42 
43 TO_EC_STR_PARAM(brainpoolp320r1_r_square);
44 
45 static const u8 brainpoolp320r1_mpinv[] = {
46 	0x3d, 0x1e, 0x9b, 0xa2, 0x2a, 0x8a, 0x9e, 0x69,
47 };
48 
49 TO_EC_STR_PARAM(brainpoolp320r1_mpinv);
50 
51 static const u8 brainpoolp320r1_p_shift[] = {
52 	0x00,
53 };
54 
55 TO_EC_STR_PARAM(brainpoolp320r1_p_shift);
56 
57 static const u8 brainpoolp320r1_p_normalized[] = {
58 	0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
59 	0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
60 	0xf9, 0x8f, 0xcf, 0xa6, 0xf6, 0xf4, 0x0d, 0xef,
61 	0x4f, 0x92, 0xb9, 0xec, 0x78, 0x93, 0xec, 0x28,
62 	0xfc, 0xd4, 0x12, 0xb1, 0xf1, 0xb3, 0x2e, 0x27,
63 };
64 
65 TO_EC_STR_PARAM(brainpoolp320r1_p_normalized);
66 
67 static const u8 brainpoolp320r1_p_reciprocal[] = {
68 	0x36, 0x0e, 0x55, 0xa5, 0xaf, 0x1a, 0xa1, 0x20,
69 };
70 
71 TO_EC_STR_PARAM(brainpoolp320r1_p_reciprocal);
72 
73 #elif (WORD_BYTES == 4)   /* 32-bit words */
74 static const u8 brainpoolp320r1_r[] = {
75 	0x2c, 0xa1, 0xb8, 0xdf, 0xc9, 0x43, 0xb0, 0x48,
76 	0x1e, 0xc3, 0x87, 0xa1, 0x2d, 0xfe, 0x1f, 0x9a,
77 	0x06, 0x70, 0x30, 0x59, 0x09, 0x0b, 0xf2, 0x10,
78 	0xb0, 0x6d, 0x46, 0x13, 0x87, 0x6c, 0x13, 0xd7,
79 	0x03, 0x2b, 0xed, 0x4e, 0x0e, 0x4c, 0xd1, 0xd9,
80 };
81 
82 TO_EC_STR_PARAM(brainpoolp320r1_r);
83 
84 static const u8 brainpoolp320r1_r_square[] = {
85 	0xa2, 0x59, 0xba, 0x4a, 0x6c, 0x2d, 0x92, 0x52,
86 	0x54, 0x55, 0xa9, 0x64, 0xe6, 0x14, 0xd6, 0xd2,
87 	0x1f, 0x4c, 0x88, 0x1f, 0x30, 0xc5, 0xb6, 0x76,
88 	0xc2, 0x47, 0x8a, 0x8d, 0x90, 0x69, 0x78, 0xef,
89 	0x99, 0x4e, 0xe8, 0x8a, 0x74, 0x3b, 0x52, 0xf9,
90 };
91 
92 TO_EC_STR_PARAM(brainpoolp320r1_r_square);
93 
94 static const u8 brainpoolp320r1_mpinv[] = {
95 	0x2a, 0x8a, 0x9e, 0x69,
96 };
97 
98 TO_EC_STR_PARAM(brainpoolp320r1_mpinv);
99 
100 static const u8 brainpoolp320r1_p_shift[] = {
101 	0x00,
102 };
103 
104 TO_EC_STR_PARAM(brainpoolp320r1_p_shift);
105 
106 static const u8 brainpoolp320r1_p_normalized[] = {
107 	0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
108 	0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
109 	0xf9, 0x8f, 0xcf, 0xa6, 0xf6, 0xf4, 0x0d, 0xef,
110 	0x4f, 0x92, 0xb9, 0xec, 0x78, 0x93, 0xec, 0x28,
111 	0xfc, 0xd4, 0x12, 0xb1, 0xf1, 0xb3, 0x2e, 0x27,
112 };
113 
114 TO_EC_STR_PARAM(brainpoolp320r1_p_normalized);
115 
116 static const u8 brainpoolp320r1_p_reciprocal[] = {
117 	0x36, 0x0e, 0x55, 0xa5,
118 };
119 
120 TO_EC_STR_PARAM(brainpoolp320r1_p_reciprocal);
121 
122 #elif (WORD_BYTES == 2)   /* 16-bit words */
123 static const u8 brainpoolp320r1_r[] = {
124 	0x2c, 0xa1, 0xb8, 0xdf, 0xc9, 0x43, 0xb0, 0x48,
125 	0x1e, 0xc3, 0x87, 0xa1, 0x2d, 0xfe, 0x1f, 0x9a,
126 	0x06, 0x70, 0x30, 0x59, 0x09, 0x0b, 0xf2, 0x10,
127 	0xb0, 0x6d, 0x46, 0x13, 0x87, 0x6c, 0x13, 0xd7,
128 	0x03, 0x2b, 0xed, 0x4e, 0x0e, 0x4c, 0xd1, 0xd9,
129 };
130 
131 TO_EC_STR_PARAM(brainpoolp320r1_r);
132 
133 static const u8 brainpoolp320r1_r_square[] = {
134 	0xa2, 0x59, 0xba, 0x4a, 0x6c, 0x2d, 0x92, 0x52,
135 	0x54, 0x55, 0xa9, 0x64, 0xe6, 0x14, 0xd6, 0xd2,
136 	0x1f, 0x4c, 0x88, 0x1f, 0x30, 0xc5, 0xb6, 0x76,
137 	0xc2, 0x47, 0x8a, 0x8d, 0x90, 0x69, 0x78, 0xef,
138 	0x99, 0x4e, 0xe8, 0x8a, 0x74, 0x3b, 0x52, 0xf9,
139 };
140 
141 TO_EC_STR_PARAM(brainpoolp320r1_r_square);
142 
143 static const u8 brainpoolp320r1_mpinv[] = {
144 	0x9e, 0x69,
145 };
146 
147 TO_EC_STR_PARAM(brainpoolp320r1_mpinv);
148 
149 static const u8 brainpoolp320r1_p_shift[] = {
150 	0x00,
151 };
152 
153 TO_EC_STR_PARAM(brainpoolp320r1_p_shift);
154 
155 static const u8 brainpoolp320r1_p_normalized[] = {
156 	0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
157 	0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
158 	0xf9, 0x8f, 0xcf, 0xa6, 0xf6, 0xf4, 0x0d, 0xef,
159 	0x4f, 0x92, 0xb9, 0xec, 0x78, 0x93, 0xec, 0x28,
160 	0xfc, 0xd4, 0x12, 0xb1, 0xf1, 0xb3, 0x2e, 0x27,
161 };
162 
163 TO_EC_STR_PARAM(brainpoolp320r1_p_normalized);
164 
165 static const u8 brainpoolp320r1_p_reciprocal[] = {
166 	0x36, 0x0e,
167 };
168 
169 TO_EC_STR_PARAM(brainpoolp320r1_p_reciprocal);
170 
171 #else                     /* unknown word size */
172 #error "Unsupported word size"
173 #endif
174 
175 static const u8 brainpoolp320r1_a[] = {
176 	0x3e, 0xe3, 0x0b, 0x56, 0x8f, 0xba, 0xb0, 0xf8,
177 	0x83, 0xcc, 0xeb, 0xd4, 0x6d, 0x3f, 0x3b, 0xb8,
178 	0xa2, 0xa7, 0x35, 0x13, 0xf5, 0xeb, 0x79, 0xda,
179 	0x66, 0x19, 0x0e, 0xb0, 0x85, 0xff, 0xa9, 0xf4,
180 	0x92, 0xf3, 0x75, 0xa9, 0x7d, 0x86, 0x0e, 0xb4,
181 };
182 
183 TO_EC_STR_PARAM(brainpoolp320r1_a);
184 
185 static const u8 brainpoolp320r1_b[] = {
186 	0x52, 0x08, 0x83, 0x94, 0x9d, 0xfd, 0xbc, 0x42,
187 	0xd3, 0xad, 0x19, 0x86, 0x40, 0x68, 0x8a, 0x6f,
188 	0xe1, 0x3f, 0x41, 0x34, 0x95, 0x54, 0xb4, 0x9a,
189 	0xcc, 0x31, 0xdc, 0xcd, 0x88, 0x45, 0x39, 0x81,
190 	0x6f, 0x5e, 0xb4, 0xac, 0x8f, 0xb1, 0xf1, 0xa6,
191 };
192 
193 TO_EC_STR_PARAM(brainpoolp320r1_b);
194 
195 #define CURVE_BRAINPOOLP320R1_CURVE_ORDER_BITLEN 320
196 static const u8 brainpoolp320r1_curve_order[] = {
197 	0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
198 	0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
199 	0xf9, 0x8f, 0xcf, 0xa5, 0xb6, 0x8f, 0x12, 0xa3,
200 	0x2d, 0x48, 0x2e, 0xc7, 0xee, 0x86, 0x58, 0xe9,
201 	0x86, 0x91, 0x55, 0x5b, 0x44, 0xc5, 0x93, 0x11,
202 };
203 
204 TO_EC_STR_PARAM(brainpoolp320r1_curve_order);
205 
206 static const u8 brainpoolp320r1_gx[] = {
207 	0x43, 0xbd, 0x7e, 0x9a, 0xfb, 0x53, 0xd8, 0xb8,
208 	0x52, 0x89, 0xbc, 0xc4, 0x8e, 0xe5, 0xbf, 0xe6,
209 	0xf2, 0x01, 0x37, 0xd1, 0x0a, 0x08, 0x7e, 0xb6,
210 	0xe7, 0x87, 0x1e, 0x2a, 0x10, 0xa5, 0x99, 0xc7,
211 	0x10, 0xaf, 0x8d, 0x0d, 0x39, 0xe2, 0x06, 0x11,
212 };
213 
214 TO_EC_STR_PARAM(brainpoolp320r1_gx);
215 
216 static const u8 brainpoolp320r1_gy[] = {
217 	0x14, 0xfd, 0xd0, 0x55, 0x45, 0xec, 0x1c, 0xc8,
218 	0xab, 0x40, 0x93, 0x24, 0x7f, 0x77, 0x27, 0x5e,
219 	0x07, 0x43, 0xff, 0xed, 0x11, 0x71, 0x82, 0xea,
220 	0xa9, 0xc7, 0x78, 0x77, 0xaa, 0xac, 0x6a, 0xc7,
221 	0xd3, 0x52, 0x45, 0xd1, 0x69, 0x2e, 0x8e, 0xe1,
222 };
223 
224 TO_EC_STR_PARAM(brainpoolp320r1_gy);
225 
226 static const u8 brainpoolp320r1_gz[] = {
227 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
228 	0x00, 0x00, 0x00, 0x00, 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, 0x00, 0x01,
232 };
233 
234 TO_EC_STR_PARAM(brainpoolp320r1_gz);
235 
236 static const u8 brainpoolp320r1_gen_order[] = {
237 	0xd3, 0x5e, 0x47, 0x20, 0x36, 0xbc, 0x4f, 0xb7,
238 	0xe1, 0x3c, 0x78, 0x5e, 0xd2, 0x01, 0xe0, 0x65,
239 	0xf9, 0x8f, 0xcf, 0xa5, 0xb6, 0x8f, 0x12, 0xa3,
240 	0x2d, 0x48, 0x2e, 0xc7, 0xee, 0x86, 0x58, 0xe9,
241 	0x86, 0x91, 0x55, 0x5b, 0x44, 0xc5, 0x93, 0x11,
242 };
243 
244 TO_EC_STR_PARAM(brainpoolp320r1_gen_order);
245 
246 #define CURVE_BRAINPOOLP320R1_Q_BITLEN 320
247 static const u8 brainpoolp320r1_gen_order_bitlen[] = {
248 	0x01, 0x40,
249 };
250 
251 TO_EC_STR_PARAM(brainpoolp320r1_gen_order_bitlen);
252 
253 static const u8 brainpoolp320r1_cofactor[] = {
254 	0x01,
255 };
256 
257 TO_EC_STR_PARAM(brainpoolp320r1_cofactor);
258 
259 static const u8 brainpoolp320r1_alpha_montgomery[] = {
260 	0x00,
261 };
262 TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp320r1_alpha_montgomery, 0);
263 
264 static const u8 brainpoolp320r1_gamma_montgomery[] = {
265 	0x00,
266 };
267 TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp320r1_gamma_montgomery, 0);
268 
269 static const u8 brainpoolp320r1_alpha_edwards[] = {
270 	0x00,
271 };
272 TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp320r1_alpha_edwards, 0);
273 
274 static const u8 brainpoolp320r1_name[] = "BRAINPOOLP320R1";
275 TO_EC_STR_PARAM(brainpoolp320r1_name);
276 
277 static const u8 brainpoolp320r1_oid[] = "1.3.36.3.3.2.8.1.1.9";
278 TO_EC_STR_PARAM(brainpoolp320r1_oid);
279 
280 static const ec_str_params brainpoolp320r1_str_params = {
281 	.p = &brainpoolp320r1_p_str_param,
282 	.p_bitlen = &brainpoolp320r1_p_bitlen_str_param,
283 	.r = &brainpoolp320r1_r_str_param,
284 	.r_square = &brainpoolp320r1_r_square_str_param,
285 	.mpinv = &brainpoolp320r1_mpinv_str_param,
286 	.p_shift = &brainpoolp320r1_p_shift_str_param,
287 	.p_normalized = &brainpoolp320r1_p_normalized_str_param,
288 	.p_reciprocal = &brainpoolp320r1_p_reciprocal_str_param,
289 	.a = &brainpoolp320r1_a_str_param,
290 	.b = &brainpoolp320r1_b_str_param,
291 	.curve_order = &brainpoolp320r1_curve_order_str_param,
292 	.gx = &brainpoolp320r1_gx_str_param,
293 	.gy = &brainpoolp320r1_gy_str_param,
294 	.gz = &brainpoolp320r1_gz_str_param,
295 	.gen_order = &brainpoolp320r1_gen_order_str_param,
296 	.gen_order_bitlen = &brainpoolp320r1_gen_order_bitlen_str_param,
297 	.cofactor = &brainpoolp320r1_cofactor_str_param,
298 	.alpha_montgomery = &brainpoolp320r1_alpha_montgomery_str_param,
299 	.gamma_montgomery = &brainpoolp320r1_gamma_montgomery_str_param,
300 	.alpha_edwards = &brainpoolp320r1_alpha_edwards_str_param,
301 	.oid = &brainpoolp320r1_oid_str_param,
302 	.name = &brainpoolp320r1_name_str_param,
303 };
304 
305 /*
306  * Compute max bit length of all curves for p and q
307  */
308 #ifndef CURVES_MAX_P_BIT_LEN
309 #define CURVES_MAX_P_BIT_LEN    0
310 #endif
311 #if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP320R1_P_BITLEN)
312 #undef CURVES_MAX_P_BIT_LEN
313 #define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP320R1_P_BITLEN
314 #endif
315 #ifndef CURVES_MAX_Q_BIT_LEN
316 #define CURVES_MAX_Q_BIT_LEN    0
317 #endif
318 #if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP320R1_Q_BITLEN)
319 #undef CURVES_MAX_Q_BIT_LEN
320 #define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP320R1_Q_BITLEN
321 #endif
322 #ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
323 #define CURVES_MAX_CURVE_ORDER_BIT_LEN    0
324 #endif
325 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP320R1_CURVE_ORDER_BITLEN)
326 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN
327 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP320R1_CURVE_ORDER_BITLEN
328 #endif
329 
330 /*
331  * Compute and adapt max name and oid length
332  */
333 #ifndef MAX_CURVE_OID_LEN
334 #define MAX_CURVE_OID_LEN 0
335 #endif
336 #ifndef MAX_CURVE_NAME_LEN
337 #define MAX_CURVE_NAME_LEN 0
338 #endif
339 #if (MAX_CURVE_OID_LEN < 1)
340 #undef MAX_CURVE_OID_LEN
341 #define MAX_CURVE_OID_LEN 1
342 #endif
343 #if (MAX_CURVE_NAME_LEN < 29)
344 #undef MAX_CURVE_NAME_LEN
345 #define MAX_CURVE_NAME_LEN 29
346 #endif
347 
348 #endif /* __EC_PARAMS_BRAINPOOLP320R1_H__ */
349 
350 #endif /* WITH_CURVE_BRAINPOOLP320R1 */
351