xref: /freebsd/crypto/libecc/include/libecc/curves/known/ec_params_secp384r1.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_SECP384R1
18 
19 #ifndef __EC_PARAMS_SECP384R1_H__
20 #define __EC_PARAMS_SECP384R1_H__
21 #include "ec_params_external.h"
22 
23 static const u8 secp384r1_p[] = {
24 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
25 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
26 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
27 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
28 	0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
29 	0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF
30 };
31 
32 TO_EC_STR_PARAM(secp384r1_p);
33 
34 #define CURVE_SECP384R1_P_BITLEN 384
35 static const u8 secp384r1_p_bitlen[] = { 0x01, 0x80 };
36 
37 TO_EC_STR_PARAM(secp384r1_p_bitlen);
38 
39 static const u8 secp384r1_r[] = {
40 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
41 	0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
42 	0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01
43 };
44 
45 TO_EC_STR_PARAM(secp384r1_r);
46 
47 static const u8 secp384r1_r_square[] = {
48 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
50 	0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
51 	0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00,
52 	0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
53 	0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x01
54 };
55 
56 TO_EC_STR_PARAM(secp384r1_r_square);
57 
58 #if (WORD_BYTES == 8)		/* 64-bit words */
59 static const u8 secp384r1_mpinv[] = {
60 	0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01
61 };
62 #elif (WORD_BYTES == 4)		/* 32-bit words */
63 static const u8 secp384r1_mpinv[] = {
64 	0x00, 0x00, 0x00, 0x01
65 };
66 #elif (WORD_BYTES == 2)		/* 16-bit words */
67 static const u8 secp384r1_mpinv[] = {
68 	0x00, 0x01
69 };
70 #else /* unknown word size */
71 #error "Unsupported word size"
72 #endif
73 
74 TO_EC_STR_PARAM(secp384r1_mpinv);
75 
76 static const u8 secp384r1_p_shift[] = {
77 	0x00
78 };
79 
80 TO_EC_STR_PARAM(secp384r1_p_shift);
81 
82 static const u8 secp384r1_p_reciprocal[] = {
83 	0x00
84 };
85 
86 TO_EC_STR_PARAM(secp384r1_p_reciprocal);
87 
88 static const u8 secp384r1_a[] = {
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, 0xFF, 0xFE,
93 	0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
94 	0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFC,
95 };
96 
97 TO_EC_STR_PARAM(secp384r1_a);
98 
99 static const u8 secp384r1_b[] = {
100 	0xB3, 0x31, 0x2F, 0xA7, 0xE2, 0x3E, 0xE7, 0xE4,
101 	0x98, 0x8E, 0x05, 0x6B, 0xE3, 0xF8, 0x2D, 0x19,
102 	0x18, 0x1D, 0x9C, 0x6E, 0xFE, 0x81, 0x41, 0x12,
103 	0x03, 0x14, 0x08, 0x8F, 0x50, 0x13, 0x87, 0x5A,
104 	0xC6, 0x56, 0x39, 0x8D, 0x8A, 0x2E, 0xD1, 0x9D,
105 	0x2A, 0x85, 0xC8, 0xED, 0xD3, 0xEC, 0x2A, 0xEF
106 };
107 
108 TO_EC_STR_PARAM(secp384r1_b);
109 
110 #define CURVE_SECP384R1_CURVE_ORDER_BITLEN 384
111 static const u8 secp384r1_curve_order[] = {
112 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
113 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
114 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
115 	0xC7, 0x63, 0x4D, 0x81, 0xF4, 0x37, 0x2D, 0xDF,
116 	0x58, 0x1A, 0x0D, 0xB2, 0x48, 0xB0, 0xA7, 0x7A,
117 	0xEC, 0xEC, 0x19, 0x6A, 0xCC, 0xC5, 0x29, 0x73
118 };
119 
120 TO_EC_STR_PARAM(secp384r1_curve_order);
121 
122 static const u8 secp384r1_gx[] = {
123 	0xAA, 0x87, 0xCA, 0x22, 0xBE, 0x8B, 0x05, 0x37,
124 	0x8E, 0xB1, 0xC7, 0x1E, 0xF3, 0x20, 0xAD, 0x74,
125 	0x6E, 0x1D, 0x3B, 0x62, 0x8B, 0xA7, 0x9B, 0x98,
126 	0x59, 0xF7, 0x41, 0xE0, 0x82, 0x54, 0x2A, 0x38,
127 	0x55, 0x02, 0xF2, 0x5D, 0xBF, 0x55, 0x29, 0x6C,
128 	0x3A, 0x54, 0x5E, 0x38, 0x72, 0x76, 0x0A, 0xB7
129 };
130 
131 TO_EC_STR_PARAM(secp384r1_gx);
132 
133 static const u8 secp384r1_gy[] = {
134 	0x36, 0x17, 0xDE, 0x4A, 0x96, 0x26, 0x2C, 0x6F,
135 	0x5D, 0x9E, 0x98, 0xBF, 0x92, 0x92, 0xDC, 0x29,
136 	0xF8, 0xF4, 0x1D, 0xBD, 0x28, 0x9A, 0x14, 0x7C,
137 	0xE9, 0xDA, 0x31, 0x13, 0xB5, 0xF0, 0xB8, 0xC0,
138 	0x0A, 0x60, 0xB1, 0xCE, 0x1D, 0x7E, 0x81, 0x9D,
139 	0x7A, 0x43, 0x1D, 0x7C, 0x90, 0xEA, 0x0E, 0x5F
140 };
141 
142 TO_EC_STR_PARAM(secp384r1_gy);
143 
144 static const u8 secp384r1_gz[] = {
145 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
146 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
147 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
148 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
149 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
150 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
151 };
152 
153 TO_EC_STR_PARAM(secp384r1_gz);
154 
155 static const u8 secp384r1_gen_order[] = {
156 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
157 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
158 	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
159 	0xC7, 0x63, 0x4D, 0x81, 0xF4, 0x37, 0x2D, 0xDF,
160 	0x58, 0x1A, 0x0D, 0xB2, 0x48, 0xB0, 0xA7, 0x7A,
161 	0xEC, 0xEC, 0x19, 0x6A, 0xCC, 0xC5, 0x29, 0x73
162 };
163 
164 TO_EC_STR_PARAM(secp384r1_gen_order);
165 
166 #define CURVE_SECP384R1_Q_BITLEN 384
167 static const u8 secp384r1_gen_order_bitlen[] = { 0x01, 0x80 };
168 
169 TO_EC_STR_PARAM(secp384r1_gen_order_bitlen);
170 
171 static const u8 secp384r1_cofactor[] = { 0x01 };
172 
173 TO_EC_STR_PARAM(secp384r1_cofactor);
174 
175 static const u8 secp384r1_alpha_montgomery[] = {
176 	0x00,
177 };
178 
179 TO_EC_STR_PARAM_FIXED_SIZE(secp384r1_alpha_montgomery, 0);
180 
181 static const u8 secp384r1_gamma_montgomery[] = {
182 	0x00,
183 };
184 
185 TO_EC_STR_PARAM_FIXED_SIZE(secp384r1_gamma_montgomery, 0);
186 
187 static const u8 secp384r1_alpha_edwards[] = {
188 	0x00,
189 };
190 
191 TO_EC_STR_PARAM_FIXED_SIZE(secp384r1_alpha_edwards, 0);
192 
193 static const u8 secp384r1_oid[] = "1.3.132.0.34";
194 TO_EC_STR_PARAM(secp384r1_oid);
195 
196 static const u8 secp384r1_name[] = "SECP384R1";
197 TO_EC_STR_PARAM(secp384r1_name);
198 
199 static const ec_str_params secp384r1_str_params = {
200 	.p = &secp384r1_p_str_param,
201 	.p_bitlen = &secp384r1_p_bitlen_str_param,
202 	.r = &secp384r1_r_str_param,
203 	.r_square = &secp384r1_r_square_str_param,
204 	.mpinv = &secp384r1_mpinv_str_param,
205 	.p_shift = &secp384r1_p_shift_str_param,
206 	.p_normalized = &secp384r1_p_str_param,
207 	.p_reciprocal = &secp384r1_p_reciprocal_str_param,
208 	.a = &secp384r1_a_str_param,
209 	.b = &secp384r1_b_str_param,
210 	.curve_order = &secp384r1_curve_order_str_param,
211 	.gx = &secp384r1_gx_str_param,
212 	.gy = &secp384r1_gy_str_param,
213 	.gz = &secp384r1_gz_str_param,
214 	.gen_order = &secp384r1_gen_order_str_param,
215 	.gen_order_bitlen = &secp384r1_gen_order_bitlen_str_param,
216 	.cofactor = &secp384r1_cofactor_str_param,
217         .alpha_montgomery = &secp384r1_alpha_montgomery_str_param,
218         .gamma_montgomery = &secp384r1_gamma_montgomery_str_param,
219         .alpha_edwards = &secp384r1_alpha_edwards_str_param,
220 	.oid = &secp384r1_oid_str_param,
221 	.name = &secp384r1_name_str_param,
222 };
223 
224 /*
225  * Compute max bit length of all curves for p and q
226  */
227 #ifndef CURVES_MAX_P_BIT_LEN
228 #define CURVES_MAX_P_BIT_LEN    0
229 #endif
230 #if (CURVES_MAX_P_BIT_LEN < CURVE_SECP384R1_P_BITLEN)
231 #undef CURVES_MAX_P_BIT_LEN
232 #define CURVES_MAX_P_BIT_LEN CURVE_SECP384R1_P_BITLEN
233 #endif
234 #ifndef CURVES_MAX_Q_BIT_LEN
235 #define CURVES_MAX_Q_BIT_LEN    0
236 #endif
237 #if (CURVES_MAX_Q_BIT_LEN < CURVE_SECP384R1_Q_BITLEN)
238 #undef CURVES_MAX_Q_BIT_LEN
239 #define CURVES_MAX_Q_BIT_LEN CURVE_SECP384R1_Q_BITLEN
240 #endif
241 #ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
242 #define CURVES_MAX_CURVE_ORDER_BIT_LEN    0
243 #endif
244 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SECP384R1_CURVE_ORDER_BITLEN)
245 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN
246 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SECP384R1_CURVE_ORDER_BITLEN
247 #endif
248 
249 #endif /* __EC_PARAMS_SECP384R1_H__ */
250 #endif /* WITH_CURVE_SECP384R1 */
251