xref: /freebsd/crypto/libecc/include/libecc/curves/known/ec_params_gost_R3410_2012_256_paramSetA.h (revision f0865ec9906d5a18fa2a3b61381f22ce16e606ad)
1 #include <libecc/lib_ecc_config.h>
2 #ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETA
3 
4 #ifndef __EC_PARAMS_GOST_R3410_2012_256_PARAMSETA_H__
5 #define __EC_PARAMS_GOST_R3410_2012_256_PARAMSETA_H__
6 #include <libecc/curves/known/ec_params_external.h>
7 static const u8 gost_R3410_2012_256_paramSetA_p[] = {
8 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
9 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
10 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
11 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
12 };
13 
14 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p);
15 
16 #define CURVE_GOST_R3410_2012_256_PARAMSETA_P_BITLEN 256
17 static const u8 gost_R3410_2012_256_paramSetA_p_bitlen[] = {
18 	0x01, 0x00,
19 };
20 
21 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_bitlen);
22 
23 #if (WORD_BYTES == 8)     /* 64-bit words */
24 static const u8 gost_R3410_2012_256_paramSetA_r[] = {
25 	0x02, 0x69,
26 };
27 
28 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_r);
29 
30 static const u8 gost_R3410_2012_256_paramSetA_r_square[] = {
31 	0x05, 0xcf, 0x11,
32 };
33 
34 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_r_square);
35 
36 static const u8 gost_R3410_2012_256_paramSetA_mpinv[] = {
37 	0x46, 0xf3, 0x23, 0x44, 0x75, 0xd5, 0xad, 0xd9,
38 };
39 
40 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_mpinv);
41 
42 static const u8 gost_R3410_2012_256_paramSetA_p_shift[] = {
43 	0x00,
44 };
45 
46 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_shift);
47 
48 static const u8 gost_R3410_2012_256_paramSetA_p_normalized[] = {
49 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
50 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
51 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
52 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
53 };
54 
55 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_normalized);
56 
57 static const u8 gost_R3410_2012_256_paramSetA_p_reciprocal[] = {
58 	0x00,
59 };
60 
61 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_reciprocal);
62 
63 #elif (WORD_BYTES == 4)   /* 32-bit words */
64 static const u8 gost_R3410_2012_256_paramSetA_r[] = {
65 	0x02, 0x69,
66 };
67 
68 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_r);
69 
70 static const u8 gost_R3410_2012_256_paramSetA_r_square[] = {
71 	0x05, 0xcf, 0x11,
72 };
73 
74 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_r_square);
75 
76 static const u8 gost_R3410_2012_256_paramSetA_mpinv[] = {
77 	0x75, 0xd5, 0xad, 0xd9,
78 };
79 
80 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_mpinv);
81 
82 static const u8 gost_R3410_2012_256_paramSetA_p_shift[] = {
83 	0x00,
84 };
85 
86 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_shift);
87 
88 static const u8 gost_R3410_2012_256_paramSetA_p_normalized[] = {
89 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
90 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
91 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
92 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
93 };
94 
95 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_normalized);
96 
97 static const u8 gost_R3410_2012_256_paramSetA_p_reciprocal[] = {
98 	0x00,
99 };
100 
101 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_reciprocal);
102 
103 #elif (WORD_BYTES == 2)   /* 16-bit words */
104 static const u8 gost_R3410_2012_256_paramSetA_r[] = {
105 	0x02, 0x69,
106 };
107 
108 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_r);
109 
110 static const u8 gost_R3410_2012_256_paramSetA_r_square[] = {
111 	0x05, 0xcf, 0x11,
112 };
113 
114 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_r_square);
115 
116 static const u8 gost_R3410_2012_256_paramSetA_mpinv[] = {
117 	0xad, 0xd9,
118 };
119 
120 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_mpinv);
121 
122 static const u8 gost_R3410_2012_256_paramSetA_p_shift[] = {
123 	0x00,
124 };
125 
126 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_shift);
127 
128 static const u8 gost_R3410_2012_256_paramSetA_p_normalized[] = {
129 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
130 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
131 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
132 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97,
133 };
134 
135 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_normalized);
136 
137 static const u8 gost_R3410_2012_256_paramSetA_p_reciprocal[] = {
138 	0x00,
139 };
140 
141 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_p_reciprocal);
142 
143 #else                     /* unknown word size */
144 #error "Unsupported word size"
145 #endif
146 
147 static const u8 gost_R3410_2012_256_paramSetA_a[] = {
148 	0xc2, 0x17, 0x3f, 0x15, 0x13, 0x98, 0x16, 0x73,
149 	0xaf, 0x48, 0x92, 0xc2, 0x30, 0x35, 0xa2, 0x7c,
150 	0xe2, 0x5e, 0x20, 0x13, 0xbf, 0x95, 0xaa, 0x33,
151 	0xb2, 0x2c, 0x65, 0x6f, 0x27, 0x7e, 0x73, 0x35,
152 };
153 
154 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_a);
155 
156 static const u8 gost_R3410_2012_256_paramSetA_b[] = {
157 	0x29, 0x5f, 0x9b, 0xae, 0x74, 0x28, 0xed, 0x9c,
158 	0xcc, 0x20, 0xe7, 0xc3, 0x59, 0xa9, 0xd4, 0x1a,
159 	0x22, 0xfc, 0xcd, 0x91, 0x08, 0xe1, 0x7b, 0xf7,
160 	0xba, 0x93, 0x37, 0xa6, 0xf8, 0xae, 0x95, 0x13,
161 };
162 
163 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_b);
164 
165 #define CURVE_GOST_R3410_2012_256_PARAMSETA_CURVE_ORDER_BITLEN 257
166 static const u8 gost_R3410_2012_256_paramSetA_curve_order[] = {
167 	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
168 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
169 	0x00, 0x3f, 0x63, 0x37, 0x7f, 0x21, 0xed, 0x98,
170 	0xd7, 0x04, 0x56, 0xbd, 0x55, 0xb0, 0xd8, 0x31,
171 	0x9c,
172 };
173 
174 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_curve_order);
175 
176 static const u8 gost_R3410_2012_256_paramSetA_gx[] = {
177 	0x91, 0xe3, 0x84, 0x43, 0xa5, 0xe8, 0x2c, 0x0d,
178 	0x88, 0x09, 0x23, 0x42, 0x57, 0x12, 0xb2, 0xbb,
179 	0x65, 0x8b, 0x91, 0x96, 0x93, 0x2e, 0x02, 0xc7,
180 	0x8b, 0x25, 0x82, 0xfe, 0x74, 0x2d, 0xaa, 0x28,
181 };
182 
183 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_gx);
184 
185 static const u8 gost_R3410_2012_256_paramSetA_gy[] = {
186 	0x32, 0x87, 0x94, 0x23, 0xab, 0x1a, 0x03, 0x75,
187 	0x89, 0x57, 0x86, 0xc4, 0xbb, 0x46, 0xe9, 0x56,
188 	0x5f, 0xde, 0x0b, 0x53, 0x44, 0x76, 0x67, 0x40,
189 	0xaf, 0x26, 0x8a, 0xdb, 0x32, 0x32, 0x2e, 0x5c,
190 };
191 
192 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_gy);
193 
194 static const u8 gost_R3410_2012_256_paramSetA_gz[] = {
195 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
196 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
197 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
198 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
199 };
200 
201 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_gz);
202 
203 static const u8 gost_R3410_2012_256_paramSetA_gen_order[] = {
204 	0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
205 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
206 	0x0f, 0xd8, 0xcd, 0xdf, 0xc8, 0x7b, 0x66, 0x35,
207 	0xc1, 0x15, 0xaf, 0x55, 0x6c, 0x36, 0x0c, 0x67,
208 };
209 
210 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_gen_order);
211 
212 #define CURVE_GOST_R3410_2012_256_PARAMSETA_Q_BITLEN 255
213 static const u8 gost_R3410_2012_256_paramSetA_gen_order_bitlen[] = {
214 	0xff,
215 };
216 
217 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_gen_order_bitlen);
218 
219 static const u8 gost_R3410_2012_256_paramSetA_cofactor[] = {
220 	0x04,
221 };
222 
223 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_cofactor);
224 
225 static const u8 gost_R3410_2012_256_paramSetA_alpha_montgomery[] = {
226 	0x00,
227 };
228 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetA_alpha_montgomery, 0);
229 
230 static const u8 gost_R3410_2012_256_paramSetA_gamma_montgomery[] = {
231 	0x00,
232 };
233 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetA_gamma_montgomery, 0);
234 
235 static const u8 gost_R3410_2012_256_paramSetA_alpha_edwards[] = {
236 	0x00,
237 };
238 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetA_alpha_edwards, 0);
239 
240 static const u8 gost_R3410_2012_256_paramSetA_name[] = "GOST_R3410_2012_256_PARAMSETA";
241 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_name);
242 
243 static const u8 gost_R3410_2012_256_paramSetA_oid[] = "1.2.643.7.1.2.1.1.1";
244 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetA_oid);
245 
246 static const ec_str_params gost_R3410_2012_256_paramSetA_str_params = {
247 	.p = &gost_R3410_2012_256_paramSetA_p_str_param,
248 	.p_bitlen = &gost_R3410_2012_256_paramSetA_p_bitlen_str_param,
249 	.r = &gost_R3410_2012_256_paramSetA_r_str_param,
250 	.r_square = &gost_R3410_2012_256_paramSetA_r_square_str_param,
251 	.mpinv = &gost_R3410_2012_256_paramSetA_mpinv_str_param,
252 	.p_shift = &gost_R3410_2012_256_paramSetA_p_shift_str_param,
253 	.p_normalized = &gost_R3410_2012_256_paramSetA_p_normalized_str_param,
254 	.p_reciprocal = &gost_R3410_2012_256_paramSetA_p_reciprocal_str_param,
255 	.a = &gost_R3410_2012_256_paramSetA_a_str_param,
256 	.b = &gost_R3410_2012_256_paramSetA_b_str_param,
257 	.curve_order = &gost_R3410_2012_256_paramSetA_curve_order_str_param,
258 	.gx = &gost_R3410_2012_256_paramSetA_gx_str_param,
259 	.gy = &gost_R3410_2012_256_paramSetA_gy_str_param,
260 	.gz = &gost_R3410_2012_256_paramSetA_gz_str_param,
261 	.gen_order = &gost_R3410_2012_256_paramSetA_gen_order_str_param,
262 	.gen_order_bitlen = &gost_R3410_2012_256_paramSetA_gen_order_bitlen_str_param,
263 	.cofactor = &gost_R3410_2012_256_paramSetA_cofactor_str_param,
264 	.alpha_montgomery = &gost_R3410_2012_256_paramSetA_alpha_montgomery_str_param,
265 	.gamma_montgomery = &gost_R3410_2012_256_paramSetA_gamma_montgomery_str_param,
266 	.alpha_edwards = &gost_R3410_2012_256_paramSetA_alpha_edwards_str_param,
267 	.oid = &gost_R3410_2012_256_paramSetA_oid_str_param,
268 	.name = &gost_R3410_2012_256_paramSetA_name_str_param,
269 };
270 
271 /*
272  * Compute max bit length of all curves for p and q
273  */
274 #ifndef CURVES_MAX_P_BIT_LEN
275 #define CURVES_MAX_P_BIT_LEN    0
276 #endif
277 #if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETA_P_BITLEN)
278 #undef CURVES_MAX_P_BIT_LEN
279 #define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETA_P_BITLEN
280 #endif
281 #ifndef CURVES_MAX_Q_BIT_LEN
282 #define CURVES_MAX_Q_BIT_LEN    0
283 #endif
284 #if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETA_Q_BITLEN)
285 #undef CURVES_MAX_Q_BIT_LEN
286 #define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETA_Q_BITLEN
287 #endif
288 #ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
289 #define CURVES_MAX_CURVE_ORDER_BIT_LEN    0
290 #endif
291 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETA_CURVE_ORDER_BITLEN)
292 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN
293 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETA_CURVE_ORDER_BITLEN
294 #endif
295 
296 /*
297  * Compute and adapt max name and oid length
298  */
299 #ifndef MAX_CURVE_OID_LEN
300 #define MAX_CURVE_OID_LEN 0
301 #endif
302 #ifndef MAX_CURVE_NAME_LEN
303 #define MAX_CURVE_NAME_LEN 0
304 #endif
305 #if (MAX_CURVE_OID_LEN < 20)
306 #undef MAX_CURVE_OID_LEN
307 #define MAX_CURVE_OID_LEN 20
308 #endif
309 #if (MAX_CURVE_NAME_LEN < 50)
310 #undef MAX_CURVE_NAME_LEN
311 #define MAX_CURVE_NAME_LEN 50
312 #endif
313 
314 #endif /* __EC_PARAMS_GOST_R3410_2012_256_PARAMSETA_H__ */
315 
316 #endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETA */
317