This repository has been archived by the owner on Jan 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
/
ec_params_secp224k1.h
320 lines (251 loc) · 7.78 KB
/
ec_params_secp224k1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#include "../../lib_ecc_config.h"
#ifdef WITH_CURVE_SECP224K1
#ifndef __EC_PARAMS_SECP224K1_H__
#define __EC_PARAMS_SECP224K1_H__
#include "../known/ec_params_external.h"
static const u8 secp224k1_p[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xe5, 0x6d,
};
TO_EC_STR_PARAM(secp224k1_p);
#define CURVE_SECP224K1_P_BITLEN 224
static const u8 secp224k1_p_bitlen[] = {
0xe0,
};
TO_EC_STR_PARAM(secp224k1_p_bitlen);
#if (WORD_BYTES == 8) /* 64-bit words */
static const u8 secp224k1_r[] = {
0x01, 0x00, 0x00, 0x1a, 0x93, 0x00, 0x00, 0x00,
0x00,
};
TO_EC_STR_PARAM(secp224k1_r);
static const u8 secp224k1_r_square[] = {
0x01, 0x00, 0x00, 0x35, 0x26, 0x02, 0xc2, 0x30,
0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
};
TO_EC_STR_PARAM(secp224k1_r_square);
static const u8 secp224k1_mpinv[] = {
0x5a, 0x92, 0xa0, 0x0a, 0x19, 0x8d, 0x13, 0x9b,
};
TO_EC_STR_PARAM(secp224k1_mpinv);
static const u8 secp224k1_p_shift[] = {
0x20,
};
TO_EC_STR_PARAM(secp224k1_p_shift);
static const u8 secp224k1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xe5, 0x6d, 0x00, 0x00, 0x00, 0x00,
};
TO_EC_STR_PARAM(secp224k1_p_normalized);
static const u8 secp224k1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(secp224k1_p_reciprocal);
#elif (WORD_BYTES == 4) /* 32-bit words */
static const u8 secp224k1_r[] = {
0x01, 0x00, 0x00, 0x1a, 0x93,
};
TO_EC_STR_PARAM(secp224k1_r);
static const u8 secp224k1_r_square[] = {
0x01, 0x00, 0x00, 0x35, 0x26, 0x02, 0xc2, 0x30,
0x69,
};
TO_EC_STR_PARAM(secp224k1_r_square);
static const u8 secp224k1_mpinv[] = {
0x19, 0x8d, 0x13, 0x9b,
};
TO_EC_STR_PARAM(secp224k1_mpinv);
static const u8 secp224k1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(secp224k1_p_shift);
static const u8 secp224k1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xe5, 0x6d,
};
TO_EC_STR_PARAM(secp224k1_p_normalized);
static const u8 secp224k1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(secp224k1_p_reciprocal);
#elif (WORD_BYTES == 2) /* 16-bit words */
static const u8 secp224k1_r[] = {
0x01, 0x00, 0x00, 0x1a, 0x93,
};
TO_EC_STR_PARAM(secp224k1_r);
static const u8 secp224k1_r_square[] = {
0x01, 0x00, 0x00, 0x35, 0x26, 0x02, 0xc2, 0x30,
0x69,
};
TO_EC_STR_PARAM(secp224k1_r_square);
static const u8 secp224k1_mpinv[] = {
0x13, 0x9b,
};
TO_EC_STR_PARAM(secp224k1_mpinv);
static const u8 secp224k1_p_shift[] = {
0x00,
};
TO_EC_STR_PARAM(secp224k1_p_shift);
static const u8 secp224k1_p_normalized[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xe5, 0x6d,
};
TO_EC_STR_PARAM(secp224k1_p_normalized);
static const u8 secp224k1_p_reciprocal[] = {
0x00,
};
TO_EC_STR_PARAM(secp224k1_p_reciprocal);
#else /* unknown word size */
#error "Unsupported word size"
#endif
static const u8 secp224k1_a[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
TO_EC_STR_PARAM(secp224k1_a);
static const u8 secp224k1_b[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x05,
};
TO_EC_STR_PARAM(secp224k1_b);
#define CURVE_SECP224K1_CURVE_ORDER_BITLEN 225
static const u8 secp224k1_curve_order[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xdc,
0xe8, 0xd2, 0xec, 0x61, 0x84, 0xca, 0xf0, 0xa9,
0x71, 0x76, 0x9f, 0xb1, 0xf7,
};
TO_EC_STR_PARAM(secp224k1_curve_order);
static const u8 secp224k1_gx[] = {
0xa1, 0x45, 0x5b, 0x33, 0x4d, 0xf0, 0x99, 0xdf,
0x30, 0xfc, 0x28, 0xa1, 0x69, 0xa4, 0x67, 0xe9,
0xe4, 0x70, 0x75, 0xa9, 0x0f, 0x7e, 0x65, 0x0e,
0xb6, 0xb7, 0xa4, 0x5c,
};
TO_EC_STR_PARAM(secp224k1_gx);
static const u8 secp224k1_gy[] = {
0x7e, 0x08, 0x9f, 0xed, 0x7f, 0xba, 0x34, 0x42,
0x82, 0xca, 0xfb, 0xd6, 0xf7, 0xe3, 0x19, 0xf7,
0xc0, 0xb0, 0xbd, 0x59, 0xe2, 0xca, 0x4b, 0xdb,
0x55, 0x6d, 0x61, 0xa5,
};
TO_EC_STR_PARAM(secp224k1_gy);
static const u8 secp224k1_gz[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
};
TO_EC_STR_PARAM(secp224k1_gz);
static const u8 secp224k1_gen_order[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xdc,
0xe8, 0xd2, 0xec, 0x61, 0x84, 0xca, 0xf0, 0xa9,
0x71, 0x76, 0x9f, 0xb1, 0xf7,
};
TO_EC_STR_PARAM(secp224k1_gen_order);
#define CURVE_SECP224K1_Q_BITLEN 225
static const u8 secp224k1_gen_order_bitlen[] = {
0xe1,
};
TO_EC_STR_PARAM(secp224k1_gen_order_bitlen);
static const u8 secp224k1_cofactor[] = {
0x01,
};
TO_EC_STR_PARAM(secp224k1_cofactor);
static const u8 secp224k1_alpha_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp224k1_alpha_montgomery, 0);
static const u8 secp224k1_gamma_montgomery[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp224k1_gamma_montgomery, 0);
static const u8 secp224k1_alpha_edwards[] = {
0x00,
};
TO_EC_STR_PARAM_FIXED_SIZE(secp224k1_alpha_edwards, 0);
static const u8 secp224k1_name[] = "SECP224K1";
TO_EC_STR_PARAM(secp224k1_name);
static const u8 secp224k1_oid[] = "1.3.132.0.32";
TO_EC_STR_PARAM(secp224k1_oid);
static const ec_str_params secp224k1_str_params = {
.p = &secp224k1_p_str_param,
.p_bitlen = &secp224k1_p_bitlen_str_param,
.r = &secp224k1_r_str_param,
.r_square = &secp224k1_r_square_str_param,
.mpinv = &secp224k1_mpinv_str_param,
.p_shift = &secp224k1_p_shift_str_param,
.p_normalized = &secp224k1_p_normalized_str_param,
.p_reciprocal = &secp224k1_p_reciprocal_str_param,
.a = &secp224k1_a_str_param,
.b = &secp224k1_b_str_param,
.curve_order = &secp224k1_curve_order_str_param,
.gx = &secp224k1_gx_str_param,
.gy = &secp224k1_gy_str_param,
.gz = &secp224k1_gz_str_param,
.gen_order = &secp224k1_gen_order_str_param,
.gen_order_bitlen = &secp224k1_gen_order_bitlen_str_param,
.cofactor = &secp224k1_cofactor_str_param,
.alpha_montgomery = &secp224k1_alpha_montgomery_str_param,
.gamma_montgomery = &secp224k1_gamma_montgomery_str_param,
.alpha_edwards = &secp224k1_alpha_edwards_str_param,
.oid = &secp224k1_oid_str_param,
.name = &secp224k1_name_str_param,
};
/*
* Compute max bit length of all curves for p and q
*/
#ifndef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN 0
#endif
#if (CURVES_MAX_P_BIT_LEN < CURVE_SECP224K1_P_BITLEN)
#undef CURVES_MAX_P_BIT_LEN
#define CURVES_MAX_P_BIT_LEN CURVE_SECP224K1_P_BITLEN
#endif
#ifndef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN 0
#endif
#if (CURVES_MAX_Q_BIT_LEN < CURVE_SECP224K1_Q_BITLEN)
#undef CURVES_MAX_Q_BIT_LEN
#define CURVES_MAX_Q_BIT_LEN CURVE_SECP224K1_Q_BITLEN
#endif
#ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN 0
#endif
#if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SECP224K1_CURVE_ORDER_BITLEN)
#undef CURVES_MAX_CURVE_ORDER_BIT_LEN
#define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SECP224K1_CURVE_ORDER_BITLEN
#endif
/*
* Compute and adapt max name and oid length
*/
#ifndef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 0
#endif
#ifndef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 0
#endif
#if (MAX_CURVE_OID_LEN < 1)
#undef MAX_CURVE_OID_LEN
#define MAX_CURVE_OID_LEN 1
#endif
#if (MAX_CURVE_NAME_LEN < 23)
#undef MAX_CURVE_NAME_LEN
#define MAX_CURVE_NAME_LEN 23
#endif
#endif /* __EC_PARAMS_SECP224K1_H__ */
#endif /* WITH_CURVE_SECP224K1 */