xref: /freebsd/crypto/libecc/include/libecc/curves/known/ec_params_secp224r1.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 #include <libecc/lib_ecc_config.h>
17 #ifdef WITH_CURVE_SECP224R1
18 
19 #ifndef __EC_PARAMS_SECP224R1_H__
20 #define __EC_PARAMS_SECP224R1_H__
21 #include "ec_params_external.h"
22 
23 static const u8 secp224r1_p[] = {
24 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
25 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
26 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 	0x00, 0x00, 0x00, 0x01
28 };
29 
30 TO_EC_STR_PARAM(secp224r1_p);
31 
32 #define CURVE_SECP224R1_P_BITLEN 224
33 static const u8 secp224r1_p_bitlen[] = { 0xE0 };
34 
35 TO_EC_STR_PARAM(secp224r1_p_bitlen);
36 
37 #if (WORD_BYTES == 8)		/* 64-bit words */
38 static const u8 secp224r1_p_normalized[] = {
39 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
40 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
41 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 	0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
43 };
44 
45 static const u8 secp224r1_p_shift[] = {
46 	0x20
47 };
48 
49 static const u8 secp224r1_r[] = {
50 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
53 	0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
54 };
55 
56 static const u8 secp224r1_r_square[] = {
57 	0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
58 	0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00,
59 	0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
60 	0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01
61 };
62 
63 static const u8 secp224r1_mpinv[] = {
64 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
65 };
66 #elif (WORD_BYTES == 4)		/* 32-bit words */
67 static const u8 secp224r1_p_normalized[] = {
68 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
69 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
70 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71 	0x00, 0x00, 0x00, 0x01
72 };
73 
74 static const u8 secp224r1_p_shift[] = {
75 	0x00
76 };
77 
78 static const u8 secp224r1_r[] = {
79 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
80 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
81 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
82 	0xff, 0xff, 0xff, 0xff
83 };
84 
85 static const u8 secp224r1_r_square[] = {
86 	0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
87 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
88 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
89 	0x00, 0x00, 0x00, 0x01
90 };
91 
92 static const u8 secp224r1_mpinv[] = {
93 	0xff, 0xff, 0xff, 0xff
94 };
95 #elif (WORD_BYTES == 2)		/* 16-bit words */
96 static const u8 secp224r1_p_normalized[] = {
97 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
98 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
99 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
100 	0x00, 0x00, 0x00, 0x01
101 };
102 
103 static const u8 secp224r1_p_shift[] = {
104 	0x00
105 };
106 
107 static const u8 secp224r1_r[] = {
108 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
109 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
110 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
111 	0xff, 0xff, 0xff, 0xff
112 };
113 
114 static const u8 secp224r1_r_square[] = {
115 	0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
116 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
117 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
118 	0x00, 0x00, 0x00, 0x01
119 };
120 
121 static const u8 secp224r1_mpinv[] = {
122 	0xff, 0xff
123 };
124 #else /* unknown word size */
125 #error "Unsupported word size"
126 #endif
127 TO_EC_STR_PARAM(secp224r1_r);
128 TO_EC_STR_PARAM(secp224r1_r_square);
129 TO_EC_STR_PARAM(secp224r1_p_normalized);
130 TO_EC_STR_PARAM(secp224r1_mpinv);
131 TO_EC_STR_PARAM(secp224r1_p_shift);
132 
133 static const u8 secp224r1_p_reciprocal[] = {
134 	0x00
135 };
136 
137 TO_EC_STR_PARAM(secp224r1_p_reciprocal);
138 
139 static const u8 secp224r1_a[] = {
140 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
141 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
142 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
143 	0xFF, 0xFF, 0xFF, 0xFE
144 };
145 
146 TO_EC_STR_PARAM(secp224r1_a);
147 
148 static const u8 secp224r1_b[] = {
149 	0xB4, 0x05, 0x0A, 0x85, 0x0C, 0x04, 0xB3, 0xAB,
150 	0xF5, 0x41, 0x32, 0x56, 0x50, 0x44, 0xB0, 0xB7,
151 	0xD7, 0xBF, 0xD8, 0xBA, 0x27, 0x0B, 0x39, 0x43,
152 	0x23, 0x55, 0xFF, 0xB4
153 };
154 
155 TO_EC_STR_PARAM(secp224r1_b);
156 
157 #define CURVE_SECP224R1_CURVE_ORDER_BITLEN 224
158 static const u8 secp224r1_curve_order[] = {
159 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
160 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x16, 0xA2,
161 	0xE0, 0xB8, 0xF0, 0x3E, 0x13, 0xDD, 0x29, 0x45,
162 	0x5C, 0x5C, 0x2A, 0x3D
163 };
164 
165 TO_EC_STR_PARAM(secp224r1_curve_order);
166 
167 static const u8 secp224r1_gx[] = {
168 	0xB7, 0x0E, 0x0C, 0xBD, 0x6B, 0xB4, 0xBF, 0x7F,
169 	0x32, 0x13, 0x90, 0xB9, 0x4A, 0x03, 0xC1, 0xD3,
170 	0x56, 0xC2, 0x11, 0x22, 0x34, 0x32, 0x80, 0xD6,
171 	0x11, 0x5C, 0x1D, 0x21
172 };
173 
174 TO_EC_STR_PARAM(secp224r1_gx);
175 
176 static const u8 secp224r1_gy[] = {
177 	0xBD, 0x37, 0x63, 0x88, 0xB5, 0xF7, 0x23, 0xFB,
178 	0x4C, 0x22, 0xDF, 0xE6, 0xCD, 0x43, 0x75, 0xA0,
179 	0x5A, 0x07, 0x47, 0x64, 0x44, 0xD5, 0x81, 0x99,
180 	0x85, 0x00, 0x7E, 0x34
181 };
182 
183 TO_EC_STR_PARAM(secp224r1_gy);
184 
185 static const u8 secp224r1_gz[] = {
186 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
187 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
188 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
189 	0x00, 0x00, 0x00, 0x01
190 };
191 
192 TO_EC_STR_PARAM(secp224r1_gz);
193 
194 static const u8 secp224r1_gen_order[] = {
195 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
196 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x16, 0xA2,
197 	0xE0, 0xB8, 0xF0, 0x3E, 0x13, 0xDD, 0x29, 0x45,
198 	0x5C, 0x5C, 0x2A, 0x3D
199 };
200 
201 TO_EC_STR_PARAM(secp224r1_gen_order);
202 
203 #define CURVE_SECP224R1_Q_BITLEN 224
204 static const u8 secp224r1_gen_order_bitlen[] = { 0xE0 };
205 
206 TO_EC_STR_PARAM(secp224r1_gen_order_bitlen);
207 
208 static const u8 secp224r1_cofactor[] = { 0x01 };
209 
210 TO_EC_STR_PARAM(secp224r1_cofactor);
211 
212 static const u8 secp224r1_alpha_montgomery[] = {
213 	0x00,
214 };
215 
216 TO_EC_STR_PARAM_FIXED_SIZE(secp224r1_alpha_montgomery, 0);
217 
218 static const u8 secp224r1_gamma_montgomery[] = {
219 	0x00,
220 };
221 
222 TO_EC_STR_PARAM_FIXED_SIZE(secp224r1_gamma_montgomery, 0);
223 
224 static const u8 secp224r1_alpha_edwards[] = {
225 	0x00,
226 };
227 
228 TO_EC_STR_PARAM_FIXED_SIZE(secp224r1_alpha_edwards, 0);
229 
230 static const u8 secp224r1_oid[] = "1.3.132.0.33";
231 TO_EC_STR_PARAM(secp224r1_oid);
232 
233 static const u8 secp224r1_name[] = "SECP224R1";
234 TO_EC_STR_PARAM(secp224r1_name);
235 
236 static const ec_str_params secp224r1_str_params = {
237 	.p = &secp224r1_p_str_param,
238 	.p_bitlen = &secp224r1_p_bitlen_str_param,
239 	.r = &secp224r1_r_str_param,
240 	.r_square = &secp224r1_r_square_str_param,
241 	.mpinv = &secp224r1_mpinv_str_param,
242 	.p_shift = &secp224r1_p_shift_str_param,
243 	.p_normalized = &secp224r1_p_normalized_str_param,
244 	.p_reciprocal = &secp224r1_p_reciprocal_str_param,
245 	.a = &secp224r1_a_str_param,
246 	.b = &secp224r1_b_str_param,
247 	.curve_order = &secp224r1_curve_order_str_param,
248 	.gx = &secp224r1_gx_str_param,
249 	.gy = &secp224r1_gy_str_param,
250 	.gz = &secp224r1_gz_str_param,
251 	.gen_order = &secp224r1_gen_order_str_param,
252 	.gen_order_bitlen = &secp224r1_gen_order_bitlen_str_param,
253 	.cofactor = &secp224r1_cofactor_str_param,
254         .alpha_montgomery = &secp224r1_alpha_montgomery_str_param,
255         .gamma_montgomery = &secp224r1_gamma_montgomery_str_param,
256         .alpha_edwards = &secp224r1_alpha_edwards_str_param,
257 	.oid = &secp224r1_oid_str_param,
258 	.name = &secp224r1_name_str_param,
259 };
260 
261 /*
262  * Compute max bit length of all curves for p and q
263  */
264 #if (CURVES_MAX_P_BIT_LEN < CURVE_SECP224R1_P_BITLEN)
265 #undef CURVES_MAX_P_BIT_LEN
266 #define CURVES_MAX_P_BIT_LEN CURVE_SECP224R1_P_BITLEN
267 #endif
268 #if (CURVES_MAX_Q_BIT_LEN < CURVE_SECP224R1_Q_BITLEN)
269 #undef CURVES_MAX_Q_BIT_LEN
270 #define CURVES_MAX_Q_BIT_LEN CURVE_SECP224R1_Q_BITLEN
271 #endif
272 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SECP224R1_CURVE_ORDER_BITLEN)
273 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN
274 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SECP224R1_CURVE_ORDER_BITLEN
275 #endif
276 
277 #endif /* __EC_PARAMS_SECP224R1_H__ */
278 
279 #endif /* WITH_CURVE_SECP224R1 */
280