xref: /freebsd/crypto/libecc/include/libecc/curves/known/ec_params_brainpoolp256r1.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_BRAINPOOLP256R1
18 
19 #ifndef __EC_PARAMS_BRAINPOOLP256R1_H__
20 #define __EC_PARAMS_BRAINPOOLP256R1_H__
21 #include "ec_params_external.h"
22 
23 static const u8 brainpoolp256r1_p[] = {
24 	0xA9, 0xFB, 0x57, 0xDB, 0xA1, 0xEE, 0xA9, 0xBC,
25 	0x3E, 0x66, 0x0A, 0x90, 0x9D, 0x83, 0x8D, 0x72,
26 	0x6E, 0x3B, 0xF6, 0x23, 0xD5, 0x26, 0x20, 0x28,
27 	0x20, 0x13, 0x48, 0x1D, 0x1F, 0x6E, 0x53, 0x77
28 };
29 
30 TO_EC_STR_PARAM(brainpoolp256r1_p);
31 
32 #define CURVE_BRAINPOOLP256R1_P_BITLEN 256
33 static const u8 brainpoolp256r1_p_bitlen[] = { 0x01, 0x00 };
34 
35 TO_EC_STR_PARAM(brainpoolp256r1_p_bitlen);
36 
37 static const u8 brainpoolp256r1_r[] = {
38 	0x56, 0x04, 0xa8, 0x24, 0x5e, 0x11, 0x56, 0x43,
39 	0xc1, 0x99, 0xf5, 0x6f, 0x62, 0x7c, 0x72, 0x8d,
40 	0x91, 0xc4, 0x09, 0xdc, 0x2a, 0xd9, 0xdf, 0xd7,
41 	0xdf, 0xec, 0xb7, 0xe2, 0xe0, 0x91, 0xac, 0x89
42 };
43 
44 TO_EC_STR_PARAM(brainpoolp256r1_r);
45 
46 static const u8 brainpoolp256r1_r_square[] = {
47 	0x47, 0x17, 0xaa, 0x21, 0xe5, 0x95, 0x7f, 0xa8,
48 	0xa1, 0xec, 0xda, 0xcd, 0x6b, 0x1a, 0xc8, 0x07,
49 	0x5c, 0xce, 0x4c, 0x26, 0x61, 0x4d, 0x4f, 0x4d,
50 	0x8c, 0xfe, 0xdf, 0x7b, 0xa6, 0x46, 0x5b, 0x6c
51 };
52 
53 TO_EC_STR_PARAM(brainpoolp256r1_r_square);
54 
55 static const u8 brainpoolp256r1_mpinv[] = {
56 	0xc6, 0xa7, 0x55, 0x90, 0xce, 0xfd, 0x89, 0xb9
57 };
58 
59 TO_EC_STR_PARAM(brainpoolp256r1_mpinv);
60 
61 static const u8 brainpoolp256r1_p_shift[] = {
62 	0x00
63 };
64 
65 TO_EC_STR_PARAM(brainpoolp256r1_p_shift);
66 
67 #if (WORD_BYTES == 8)		/* 64-bit words */
68 static const u8 brainpoolp256r1_p_reciprocal[] = {
69 	0x81, 0x8c, 0x11, 0x31, 0xa1, 0xc5, 0x5b, 0x7e
70 };
71 #elif (WORD_BYTES == 4)		/* 32-bit words */
72 static const u8 brainpoolp256r1_p_reciprocal[] = {
73 	0x81, 0x8c, 0x11, 0x31
74 };
75 #elif (WORD_BYTES == 2)		/* 16-bit words */
76 static const u8 brainpoolp256r1_p_reciprocal[] = {
77 	0x81, 0x8c
78 };
79 #else /* unknown word size */
80 #error "Unsupported word size"
81 #endif
82 TO_EC_STR_PARAM(brainpoolp256r1_p_reciprocal);
83 
84 static const u8 brainpoolp256r1_a[] = {
85 	0x7D, 0x5A, 0x09, 0x75, 0xFC, 0x2C, 0x30, 0x57, 0xEE, 0xF6, 0x75, 0x30,
86 	0x41, 0x7A, 0xFF, 0xE7, 0xFB, 0x80, 0x55, 0xC1, 0x26, 0xDC, 0x5C, 0x6C,
87 	0xE9, 0x4A, 0x4B, 0x44, 0xF3, 0x30, 0xB5, 0xD9
88 };
89 
90 TO_EC_STR_PARAM(brainpoolp256r1_a);
91 
92 static const u8 brainpoolp256r1_b[] = {
93 	0x26, 0xDC, 0x5C, 0x6C, 0xE9, 0x4A, 0x4B, 0x44, 0xF3, 0x30, 0xB5, 0xD9,
94 	0xBB, 0xD7, 0x7C, 0xBF, 0x95, 0x84, 0x16, 0x29, 0x5C, 0xF7, 0xE1, 0xCE,
95 	0x6B, 0xCC, 0xDC, 0x18, 0xFF, 0x8C, 0x07, 0xB6
96 };
97 
98 TO_EC_STR_PARAM(brainpoolp256r1_b);
99 
100 #define CURVE_BRAINPOOLP256R1_CURVE_ORDER_BITLEN 256
101 static const u8 brainpoolp256r1_curve_order[] = {
102 	0xA9, 0xFB, 0x57, 0xDB, 0xA1, 0xEE, 0xA9, 0xBC, 0x3E, 0x66, 0x0A, 0x90,
103 	0x9D, 0x83, 0x8D, 0x71, 0x8C, 0x39, 0x7A, 0xA3, 0xB5, 0x61, 0xA6, 0xF7,
104 	0x90, 0x1E, 0x0E, 0x82, 0x97, 0x48, 0x56, 0xA7
105 };
106 
107 TO_EC_STR_PARAM(brainpoolp256r1_curve_order);
108 
109 static const u8 brainpoolp256r1_gx[] = {
110 	0x8B, 0xD2, 0xAE, 0xB9, 0xCB, 0x7E, 0x57, 0xCB, 0x2C, 0x4B, 0x48, 0x2F,
111 	0xFC, 0x81, 0xB7, 0xAF, 0xB9, 0xDE, 0x27, 0xE1, 0xE3, 0xBD, 0x23, 0xC2,
112 	0x3A, 0x44, 0x53, 0xBD, 0x9A, 0xCE, 0x32, 0x62
113 };
114 
115 TO_EC_STR_PARAM(brainpoolp256r1_gx);
116 
117 static const u8 brainpoolp256r1_gy[] = {
118 	0x54, 0x7E, 0xF8, 0x35, 0xC3, 0xDA, 0xC4, 0xFD, 0x97, 0xF8, 0x46, 0x1A,
119 	0x14, 0x61, 0x1D, 0xC9, 0xC2, 0x77, 0x45, 0x13, 0x2D, 0xED, 0x8E, 0x54,
120 	0x5C, 0x1D, 0x54, 0xC7, 0x2F, 0x04, 0x69, 0x97
121 };
122 
123 TO_EC_STR_PARAM(brainpoolp256r1_gy);
124 
125 static const u8 brainpoolp256r1_gz[] = {
126 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
127 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
128 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
129 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
130 };
131 
132 TO_EC_STR_PARAM(brainpoolp256r1_gz);
133 
134 static const u8 brainpoolp256r1_gen_order[] = {
135 	0xA9, 0xFB, 0x57, 0xDB, 0xA1, 0xEE, 0xA9, 0xBC, 0x3E, 0x66, 0x0A, 0x90,
136 	0x9D, 0x83, 0x8D, 0x71, 0x8C, 0x39, 0x7A, 0xA3, 0xB5, 0x61, 0xA6, 0xF7,
137 	0x90, 0x1E, 0x0E, 0x82, 0x97, 0x48, 0x56, 0xA7
138 };
139 
140 TO_EC_STR_PARAM(brainpoolp256r1_gen_order);
141 
142 #define CURVE_BRAINPOOLP256R1_Q_BITLEN 256
143 static const u8 brainpoolp256r1_gen_order_bitlen[] = { 0x01, 0x00 };
144 
145 TO_EC_STR_PARAM(brainpoolp256r1_gen_order_bitlen);
146 
147 static const u8 brainpoolp256r1_cofactor[] = { 0x01 };
148 
149 TO_EC_STR_PARAM(brainpoolp256r1_cofactor);
150 
151 static const u8 brainpoolp256r1_alpha_montgomery[] = {
152 	0x00,
153 };
154 
155 TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp256r1_alpha_montgomery, 0);
156 
157 static const u8 brainpoolp256r1_gamma_montgomery[] = {
158 	0x00,
159 };
160 
161 TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp256r1_gamma_montgomery, 0);
162 
163 static const u8 brainpoolp256r1_alpha_edwards[] = {
164 	0x00,
165 };
166 
167 TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp256r1_alpha_edwards, 0);
168 
169 static const u8 brainpoolp256r1_oid[] = "1.3.36.3.3.2.8.1.1.7";
170 TO_EC_STR_PARAM(brainpoolp256r1_oid);
171 
172 static const u8 brainpoolp256r1_name[] = "BRAINPOOLP256R1";
173 TO_EC_STR_PARAM(brainpoolp256r1_name);
174 
175 static const ec_str_params brainpoolp256r1_str_params = {
176 	.p = &brainpoolp256r1_p_str_param,
177 	.p_bitlen = &brainpoolp256r1_p_bitlen_str_param,
178 	.r = &brainpoolp256r1_r_str_param,
179 	.r_square = &brainpoolp256r1_r_square_str_param,
180 	.mpinv = &brainpoolp256r1_mpinv_str_param,
181 	.p_shift = &brainpoolp256r1_p_shift_str_param,
182 	.p_normalized = &brainpoolp256r1_p_str_param,
183 	.p_reciprocal = &brainpoolp256r1_p_reciprocal_str_param,
184 	.a = &brainpoolp256r1_a_str_param,
185 	.b = &brainpoolp256r1_b_str_param,
186 	.curve_order = &brainpoolp256r1_curve_order_str_param,
187 	.gx = &brainpoolp256r1_gx_str_param,
188 	.gy = &brainpoolp256r1_gy_str_param,
189 	.gz = &brainpoolp256r1_gz_str_param,
190 	.gen_order = &brainpoolp256r1_gen_order_str_param,
191 	.gen_order_bitlen = &brainpoolp256r1_gen_order_bitlen_str_param,
192 	.cofactor = &brainpoolp256r1_cofactor_str_param,
193 	.alpha_montgomery = &brainpoolp256r1_alpha_montgomery_str_param,
194 	.gamma_montgomery = &brainpoolp256r1_gamma_montgomery_str_param,
195 	.alpha_edwards = &brainpoolp256r1_alpha_edwards_str_param,
196 	.oid = &brainpoolp256r1_oid_str_param,
197 	.name = &brainpoolp256r1_name_str_param,
198 };
199 
200 /*
201  * Compute max bit length of all curves for p and q
202  */
203 #ifndef CURVES_MAX_P_BIT_LEN
204 #define CURVES_MAX_P_BIT_LEN    0
205 #endif
206 #if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP256R1_P_BITLEN)
207 #undef CURVES_MAX_P_BIT_LEN
208 #define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP256R1_P_BITLEN
209 #endif
210 #ifndef CURVES_MAX_Q_BIT_LEN
211 #define CURVES_MAX_Q_BIT_LEN    0
212 #endif
213 #if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP256R1_Q_BITLEN)
214 #undef CURVES_MAX_Q_BIT_LEN
215 #define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP256R1_Q_BITLEN
216 #endif
217 #ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN
218 #define CURVES_MAX_CURVE_ORDER_BIT_LEN    0
219 #endif
220 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP256R1_CURVE_ORDER_BITLEN)
221 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN
222 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP256R1_CURVE_ORDER_BITLEN
223 #endif
224 
225 #endif /* __EC_PARAMS_BRAINPOOLP256R1_H__ */
226 
227 #endif /* WITH_CURVE_BRAINPOOLP256R1 */
228