xref: /freebsd/crypto/libecc/include/libecc/curves/known/ec_params_sm2p192test.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_SM2P192TEST
13 
14 #ifndef __EC_PARAMS_SM2P192TEST_H__
15 #define __EC_PARAMS_SM2P192TEST_H__
16 #include <libecc/curves/known/ec_params_external.h>
17 static const u8 sm2p192test_p[] = {
18 	0xbd, 0xb6, 0xf4, 0xfe, 0x3e, 0x8b, 0x1d, 0x9e,
19 	0x0d, 0xa8, 0xc0, 0xd4, 0x6f, 0x4c, 0x31, 0x8c,
20 	0xef, 0xe4, 0xaf, 0xe3, 0xb6, 0xb8, 0x55, 0x1f,
21 };
22 
23 TO_EC_STR_PARAM(sm2p192test_p);
24 
25 #define CURVE_SM2P192TEST_P_BITLEN 192
26 static const u8 sm2p192test_p_bitlen[] = {
27 	0xc0,
28 };
29 
30 TO_EC_STR_PARAM(sm2p192test_p_bitlen);
31 
32 #if (WORD_BYTES == 8)     /* 64-bit words */
33 static const u8 sm2p192test_r[] = {
34 	0x42, 0x49, 0x0b, 0x01, 0xc1, 0x74, 0xe2, 0x61,
35 	0xf2, 0x57, 0x3f, 0x2b, 0x90, 0xb3, 0xce, 0x73,
36 	0x10, 0x1b, 0x50, 0x1c, 0x49, 0x47, 0xaa, 0xe1,
37 };
38 
39 TO_EC_STR_PARAM(sm2p192test_r);
40 
41 static const u8 sm2p192test_r_square[] = {
42 	0xa8, 0x9e, 0x36, 0x8f, 0xa3, 0xa3, 0x5f, 0x24,
43 	0x9c, 0xeb, 0x34, 0x38, 0x97, 0x1b, 0x28, 0x1a,
44 	0xab, 0xb1, 0xe2, 0x02, 0xf0, 0x63, 0x41, 0x2c,
45 };
46 
47 TO_EC_STR_PARAM(sm2p192test_r_square);
48 
49 static const u8 sm2p192test_mpinv[] = {
50 	0xc9, 0x95, 0x02, 0xed, 0x2b, 0x73, 0x19, 0x21,
51 };
52 
53 TO_EC_STR_PARAM(sm2p192test_mpinv);
54 
55 static const u8 sm2p192test_p_shift[] = {
56 	0x00,
57 };
58 
59 TO_EC_STR_PARAM(sm2p192test_p_shift);
60 
61 static const u8 sm2p192test_p_normalized[] = {
62 	0xbd, 0xb6, 0xf4, 0xfe, 0x3e, 0x8b, 0x1d, 0x9e,
63 	0x0d, 0xa8, 0xc0, 0xd4, 0x6f, 0x4c, 0x31, 0x8c,
64 	0xef, 0xe4, 0xaf, 0xe3, 0xb6, 0xb8, 0x55, 0x1f,
65 };
66 
67 TO_EC_STR_PARAM(sm2p192test_p_normalized);
68 
69 static const u8 sm2p192test_p_reciprocal[] = {
70 	0x59, 0x71, 0xf0, 0x4b, 0x2a, 0x1c, 0x05, 0xe0,
71 };
72 
73 TO_EC_STR_PARAM(sm2p192test_p_reciprocal);
74 
75 #elif (WORD_BYTES == 4)   /* 32-bit words */
76 static const u8 sm2p192test_r[] = {
77 	0x42, 0x49, 0x0b, 0x01, 0xc1, 0x74, 0xe2, 0x61,
78 	0xf2, 0x57, 0x3f, 0x2b, 0x90, 0xb3, 0xce, 0x73,
79 	0x10, 0x1b, 0x50, 0x1c, 0x49, 0x47, 0xaa, 0xe1,
80 };
81 
82 TO_EC_STR_PARAM(sm2p192test_r);
83 
84 static const u8 sm2p192test_r_square[] = {
85 	0xa8, 0x9e, 0x36, 0x8f, 0xa3, 0xa3, 0x5f, 0x24,
86 	0x9c, 0xeb, 0x34, 0x38, 0x97, 0x1b, 0x28, 0x1a,
87 	0xab, 0xb1, 0xe2, 0x02, 0xf0, 0x63, 0x41, 0x2c,
88 };
89 
90 TO_EC_STR_PARAM(sm2p192test_r_square);
91 
92 static const u8 sm2p192test_mpinv[] = {
93 	0x2b, 0x73, 0x19, 0x21,
94 };
95 
96 TO_EC_STR_PARAM(sm2p192test_mpinv);
97 
98 static const u8 sm2p192test_p_shift[] = {
99 	0x00,
100 };
101 
102 TO_EC_STR_PARAM(sm2p192test_p_shift);
103 
104 static const u8 sm2p192test_p_normalized[] = {
105 	0xbd, 0xb6, 0xf4, 0xfe, 0x3e, 0x8b, 0x1d, 0x9e,
106 	0x0d, 0xa8, 0xc0, 0xd4, 0x6f, 0x4c, 0x31, 0x8c,
107 	0xef, 0xe4, 0xaf, 0xe3, 0xb6, 0xb8, 0x55, 0x1f,
108 };
109 
110 TO_EC_STR_PARAM(sm2p192test_p_normalized);
111 
112 static const u8 sm2p192test_p_reciprocal[] = {
113 	0x59, 0x71, 0xf0, 0x4b,
114 };
115 
116 TO_EC_STR_PARAM(sm2p192test_p_reciprocal);
117 
118 #elif (WORD_BYTES == 2)   /* 16-bit words */
119 static const u8 sm2p192test_r[] = {
120 	0x42, 0x49, 0x0b, 0x01, 0xc1, 0x74, 0xe2, 0x61,
121 	0xf2, 0x57, 0x3f, 0x2b, 0x90, 0xb3, 0xce, 0x73,
122 	0x10, 0x1b, 0x50, 0x1c, 0x49, 0x47, 0xaa, 0xe1,
123 };
124 
125 TO_EC_STR_PARAM(sm2p192test_r);
126 
127 static const u8 sm2p192test_r_square[] = {
128 	0xa8, 0x9e, 0x36, 0x8f, 0xa3, 0xa3, 0x5f, 0x24,
129 	0x9c, 0xeb, 0x34, 0x38, 0x97, 0x1b, 0x28, 0x1a,
130 	0xab, 0xb1, 0xe2, 0x02, 0xf0, 0x63, 0x41, 0x2c,
131 };
132 
133 TO_EC_STR_PARAM(sm2p192test_r_square);
134 
135 static const u8 sm2p192test_mpinv[] = {
136 	0x19, 0x21,
137 };
138 
139 TO_EC_STR_PARAM(sm2p192test_mpinv);
140 
141 static const u8 sm2p192test_p_shift[] = {
142 	0x00,
143 };
144 
145 TO_EC_STR_PARAM(sm2p192test_p_shift);
146 
147 static const u8 sm2p192test_p_normalized[] = {
148 	0xbd, 0xb6, 0xf4, 0xfe, 0x3e, 0x8b, 0x1d, 0x9e,
149 	0x0d, 0xa8, 0xc0, 0xd4, 0x6f, 0x4c, 0x31, 0x8c,
150 	0xef, 0xe4, 0xaf, 0xe3, 0xb6, 0xb8, 0x55, 0x1f,
151 };
152 
153 TO_EC_STR_PARAM(sm2p192test_p_normalized);
154 
155 static const u8 sm2p192test_p_reciprocal[] = {
156 	0x59, 0x71,
157 };
158 
159 TO_EC_STR_PARAM(sm2p192test_p_reciprocal);
160 
161 #else                     /* unknown word size */
162 #error "Unsupported word size"
163 #endif
164 
165 static const u8 sm2p192test_a[] = {
166 	0xbb, 0x8e, 0x5e, 0x8f, 0xbc, 0x11, 0x5e, 0x13,
167 	0x9f, 0xe6, 0xa8, 0x14, 0xfe, 0x48, 0xaa, 0xa6,
168 	0xf0, 0xad, 0xa1, 0xaa, 0x5d, 0xf9, 0x19, 0x85,
169 };
170 
171 TO_EC_STR_PARAM(sm2p192test_a);
172 
173 static const u8 sm2p192test_b[] = {
174 	0x18, 0x54, 0xbe, 0xbd, 0xc3, 0x1b, 0x21, 0xb7,
175 	0xae, 0xfc, 0x80, 0xab, 0x0e, 0xcd, 0x10, 0xd5,
176 	0xb1, 0xb3, 0x30, 0x8e, 0x6d, 0xbf, 0x11, 0xc1,
177 };
178 
179 TO_EC_STR_PARAM(sm2p192test_b);
180 
181 #define CURVE_SM2P192TEST_CURVE_ORDER_BITLEN 192
182 static const u8 sm2p192test_curve_order[] = {
183 	0xbd, 0xb6, 0xf4, 0xfe, 0x3e, 0x8b, 0x1d, 0x9e,
184 	0x0d, 0xa8, 0xc0, 0xd4, 0x0f, 0xc9, 0x62, 0x19,
185 	0x5d, 0xfa, 0xe7, 0x6f, 0x56, 0x56, 0x46, 0x77,
186 };
187 
188 TO_EC_STR_PARAM(sm2p192test_curve_order);
189 
190 static const u8 sm2p192test_gx[] = {
191 	0x4a, 0xd5, 0xf7, 0x04, 0x8d, 0xe7, 0x09, 0xad,
192 	0x51, 0x23, 0x6d, 0xe6, 0x5e, 0x4d, 0x4b, 0x48,
193 	0x2c, 0x83, 0x6d, 0xc6, 0xe4, 0x10, 0x66, 0x40,
194 };
195 
196 TO_EC_STR_PARAM(sm2p192test_gx);
197 
198 static const u8 sm2p192test_gy[] = {
199 	0x02, 0xbb, 0x3a, 0x02, 0xd4, 0xaa, 0xad, 0xac,
200 	0xae, 0x24, 0x81, 0x7a, 0x4c, 0xa3, 0xa1, 0xb0,
201 	0x14, 0xb5, 0x27, 0x04, 0x32, 0xdb, 0x27, 0xd2,
202 };
203 
204 TO_EC_STR_PARAM(sm2p192test_gy);
205 
206 static const u8 sm2p192test_gz[] = {
207 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
209 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
210 };
211 
212 TO_EC_STR_PARAM(sm2p192test_gz);
213 
214 static const u8 sm2p192test_gen_order[] = {
215 	0xbd, 0xb6, 0xf4, 0xfe, 0x3e, 0x8b, 0x1d, 0x9e,
216 	0x0d, 0xa8, 0xc0, 0xd4, 0x0f, 0xc9, 0x62, 0x19,
217 	0x5d, 0xfa, 0xe7, 0x6f, 0x56, 0x56, 0x46, 0x77,
218 };
219 
220 TO_EC_STR_PARAM(sm2p192test_gen_order);
221 
222 #define CURVE_SM2P192TEST_Q_BITLEN 192
223 static const u8 sm2p192test_gen_order_bitlen[] = {
224 	0xc0,
225 };
226 
227 TO_EC_STR_PARAM(sm2p192test_gen_order_bitlen);
228 
229 static const u8 sm2p192test_cofactor[] = {
230 	0x01,
231 };
232 
233 TO_EC_STR_PARAM(sm2p192test_cofactor);
234 
235 static const u8 sm2p192test_alpha_montgomery[] = {
236 	0x00,
237 };
238 TO_EC_STR_PARAM_FIXED_SIZE(sm2p192test_alpha_montgomery, 0);
239 
240 static const u8 sm2p192test_gamma_montgomery[] = {
241 	0x00,
242 };
243 TO_EC_STR_PARAM_FIXED_SIZE(sm2p192test_gamma_montgomery, 0);
244 
245 static const u8 sm2p192test_alpha_edwards[] = {
246 	0x00,
247 };
248 TO_EC_STR_PARAM_FIXED_SIZE(sm2p192test_alpha_edwards, 0);
249 
250 static const u8 sm2p192test_name[] = "SM2P192TEST";
251 TO_EC_STR_PARAM(sm2p192test_name);
252 
253 static const u8 sm2p192test_oid[] = "";
254 TO_EC_STR_PARAM(sm2p192test_oid);
255 
256 static const ec_str_params sm2p192test_str_params = {
257 	.p = &sm2p192test_p_str_param,
258 	.p_bitlen = &sm2p192test_p_bitlen_str_param,
259 	.r = &sm2p192test_r_str_param,
260 	.r_square = &sm2p192test_r_square_str_param,
261 	.mpinv = &sm2p192test_mpinv_str_param,
262 	.p_shift = &sm2p192test_p_shift_str_param,
263 	.p_normalized = &sm2p192test_p_normalized_str_param,
264 	.p_reciprocal = &sm2p192test_p_reciprocal_str_param,
265 	.a = &sm2p192test_a_str_param,
266 	.b = &sm2p192test_b_str_param,
267 	.curve_order = &sm2p192test_curve_order_str_param,
268 	.gx = &sm2p192test_gx_str_param,
269 	.gy = &sm2p192test_gy_str_param,
270 	.gz = &sm2p192test_gz_str_param,
271 	.gen_order = &sm2p192test_gen_order_str_param,
272 	.gen_order_bitlen = &sm2p192test_gen_order_bitlen_str_param,
273 	.cofactor = &sm2p192test_cofactor_str_param,
274 	.alpha_montgomery = &sm2p192test_alpha_montgomery_str_param,
275 	.gamma_montgomery = &sm2p192test_gamma_montgomery_str_param,
276 	.alpha_edwards = &sm2p192test_alpha_edwards_str_param,
277 	.oid = &sm2p192test_oid_str_param,
278 	.name = &sm2p192test_name_str_param,
279 };
280 
281 /*
282  * Compute max bit length of all curves for p and q
283  */
284 #ifndef CURVES_MAX_P_BIT_LEN
285 #define CURVES_MAX_P_BIT_LEN    0
286 #endif
287 #if (CURVES_MAX_P_BIT_LEN < CURVE_SM2P192TEST_P_BITLEN)
288 #undef CURVES_MAX_P_BIT_LEN
289 #define CURVES_MAX_P_BIT_LEN CURVE_SM2P192TEST_P_BITLEN
290 #endif
291 #ifndef CURVES_MAX_Q_BIT_LEN
292 #define CURVES_MAX_Q_BIT_LEN    0
293 #endif
294 #if (CURVES_MAX_Q_BIT_LEN < CURVE_SM2P192TEST_Q_BITLEN)
295 #undef CURVES_MAX_Q_BIT_LEN
296 #define CURVES_MAX_Q_BIT_LEN CURVE_SM2P192TEST_Q_BITLEN
297 #endif
298 #ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
299 #define CURVES_MAX_CURVE_ORDER_BIT_LEN    0
300 #endif
301 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SM2P192TEST_CURVE_ORDER_BITLEN)
302 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN
303 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SM2P192TEST_CURVE_ORDER_BITLEN
304 #endif
305 
306 /*
307  * Compute and adapt max name and oid length
308  */
309 #ifndef MAX_CURVE_OID_LEN
310 #define MAX_CURVE_OID_LEN 0
311 #endif
312 #ifndef MAX_CURVE_NAME_LEN
313 #define MAX_CURVE_NAME_LEN 0
314 #endif
315 #if (MAX_CURVE_OID_LEN < 1)
316 #undef MAX_CURVE_OID_LEN
317 #define MAX_CURVE_OID_LEN 1
318 #endif
319 #if (MAX_CURVE_NAME_LEN < 12)
320 #undef MAX_CURVE_NAME_LEN
321 #define MAX_CURVE_NAME_LEN 12
322 #endif
323 
324 #endif /* __EC_PARAMS_SM2P192TEST_H__ */
325 
326 #endif /* WITH_CURVE_SM2P192TEST */
327