1 #include <libecc/lib_ecc_config.h> 2 #ifdef WITH_CURVE_BRAINPOOLP256T1 3 4 #ifndef __EC_PARAMS_BRAINPOOLP256T1_H__ 5 #define __EC_PARAMS_BRAINPOOLP256T1_H__ 6 #include <libecc/curves/known/ec_params_external.h> 7 static const u8 brainpoolp256t1_p[] = { 8 0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc, 9 0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x72, 10 0x6e, 0x3b, 0xf6, 0x23, 0xd5, 0x26, 0x20, 0x28, 11 0x20, 0x13, 0x48, 0x1d, 0x1f, 0x6e, 0x53, 0x77, 12 }; 13 14 TO_EC_STR_PARAM(brainpoolp256t1_p); 15 16 #define CURVE_BRAINPOOLP256T1_P_BITLEN 256 17 static const u8 brainpoolp256t1_p_bitlen[] = { 18 0x01, 0x00, 19 }; 20 21 TO_EC_STR_PARAM(brainpoolp256t1_p_bitlen); 22 23 #if (WORD_BYTES == 8) /* 64-bit words */ 24 static const u8 brainpoolp256t1_r[] = { 25 0x56, 0x04, 0xa8, 0x24, 0x5e, 0x11, 0x56, 0x43, 26 0xc1, 0x99, 0xf5, 0x6f, 0x62, 0x7c, 0x72, 0x8d, 27 0x91, 0xc4, 0x09, 0xdc, 0x2a, 0xd9, 0xdf, 0xd7, 28 0xdf, 0xec, 0xb7, 0xe2, 0xe0, 0x91, 0xac, 0x89, 29 }; 30 31 TO_EC_STR_PARAM(brainpoolp256t1_r); 32 33 static const u8 brainpoolp256t1_r_square[] = { 34 0x47, 0x17, 0xaa, 0x21, 0xe5, 0x95, 0x7f, 0xa8, 35 0xa1, 0xec, 0xda, 0xcd, 0x6b, 0x1a, 0xc8, 0x07, 36 0x5c, 0xce, 0x4c, 0x26, 0x61, 0x4d, 0x4f, 0x4d, 37 0x8c, 0xfe, 0xdf, 0x7b, 0xa6, 0x46, 0x5b, 0x6c, 38 }; 39 40 TO_EC_STR_PARAM(brainpoolp256t1_r_square); 41 42 static const u8 brainpoolp256t1_mpinv[] = { 43 0xc6, 0xa7, 0x55, 0x90, 0xce, 0xfd, 0x89, 0xb9, 44 }; 45 46 TO_EC_STR_PARAM(brainpoolp256t1_mpinv); 47 48 static const u8 brainpoolp256t1_p_shift[] = { 49 0x00, 50 }; 51 52 TO_EC_STR_PARAM(brainpoolp256t1_p_shift); 53 54 static const u8 brainpoolp256t1_p_normalized[] = { 55 0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc, 56 0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x72, 57 0x6e, 0x3b, 0xf6, 0x23, 0xd5, 0x26, 0x20, 0x28, 58 0x20, 0x13, 0x48, 0x1d, 0x1f, 0x6e, 0x53, 0x77, 59 }; 60 61 TO_EC_STR_PARAM(brainpoolp256t1_p_normalized); 62 63 static const u8 brainpoolp256t1_p_reciprocal[] = { 64 0x81, 0x8c, 0x11, 0x31, 0xa1, 0xc5, 0x5b, 0x7e, 65 }; 66 67 TO_EC_STR_PARAM(brainpoolp256t1_p_reciprocal); 68 69 #elif (WORD_BYTES == 4) /* 32-bit words */ 70 static const u8 brainpoolp256t1_r[] = { 71 0x56, 0x04, 0xa8, 0x24, 0x5e, 0x11, 0x56, 0x43, 72 0xc1, 0x99, 0xf5, 0x6f, 0x62, 0x7c, 0x72, 0x8d, 73 0x91, 0xc4, 0x09, 0xdc, 0x2a, 0xd9, 0xdf, 0xd7, 74 0xdf, 0xec, 0xb7, 0xe2, 0xe0, 0x91, 0xac, 0x89, 75 }; 76 77 TO_EC_STR_PARAM(brainpoolp256t1_r); 78 79 static const u8 brainpoolp256t1_r_square[] = { 80 0x47, 0x17, 0xaa, 0x21, 0xe5, 0x95, 0x7f, 0xa8, 81 0xa1, 0xec, 0xda, 0xcd, 0x6b, 0x1a, 0xc8, 0x07, 82 0x5c, 0xce, 0x4c, 0x26, 0x61, 0x4d, 0x4f, 0x4d, 83 0x8c, 0xfe, 0xdf, 0x7b, 0xa6, 0x46, 0x5b, 0x6c, 84 }; 85 86 TO_EC_STR_PARAM(brainpoolp256t1_r_square); 87 88 static const u8 brainpoolp256t1_mpinv[] = { 89 0xce, 0xfd, 0x89, 0xb9, 90 }; 91 92 TO_EC_STR_PARAM(brainpoolp256t1_mpinv); 93 94 static const u8 brainpoolp256t1_p_shift[] = { 95 0x00, 96 }; 97 98 TO_EC_STR_PARAM(brainpoolp256t1_p_shift); 99 100 static const u8 brainpoolp256t1_p_normalized[] = { 101 0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc, 102 0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x72, 103 0x6e, 0x3b, 0xf6, 0x23, 0xd5, 0x26, 0x20, 0x28, 104 0x20, 0x13, 0x48, 0x1d, 0x1f, 0x6e, 0x53, 0x77, 105 }; 106 107 TO_EC_STR_PARAM(brainpoolp256t1_p_normalized); 108 109 static const u8 brainpoolp256t1_p_reciprocal[] = { 110 0x81, 0x8c, 0x11, 0x31, 111 }; 112 113 TO_EC_STR_PARAM(brainpoolp256t1_p_reciprocal); 114 115 #elif (WORD_BYTES == 2) /* 16-bit words */ 116 static const u8 brainpoolp256t1_r[] = { 117 0x56, 0x04, 0xa8, 0x24, 0x5e, 0x11, 0x56, 0x43, 118 0xc1, 0x99, 0xf5, 0x6f, 0x62, 0x7c, 0x72, 0x8d, 119 0x91, 0xc4, 0x09, 0xdc, 0x2a, 0xd9, 0xdf, 0xd7, 120 0xdf, 0xec, 0xb7, 0xe2, 0xe0, 0x91, 0xac, 0x89, 121 }; 122 123 TO_EC_STR_PARAM(brainpoolp256t1_r); 124 125 static const u8 brainpoolp256t1_r_square[] = { 126 0x47, 0x17, 0xaa, 0x21, 0xe5, 0x95, 0x7f, 0xa8, 127 0xa1, 0xec, 0xda, 0xcd, 0x6b, 0x1a, 0xc8, 0x07, 128 0x5c, 0xce, 0x4c, 0x26, 0x61, 0x4d, 0x4f, 0x4d, 129 0x8c, 0xfe, 0xdf, 0x7b, 0xa6, 0x46, 0x5b, 0x6c, 130 }; 131 132 TO_EC_STR_PARAM(brainpoolp256t1_r_square); 133 134 static const u8 brainpoolp256t1_mpinv[] = { 135 0x89, 0xb9, 136 }; 137 138 TO_EC_STR_PARAM(brainpoolp256t1_mpinv); 139 140 static const u8 brainpoolp256t1_p_shift[] = { 141 0x00, 142 }; 143 144 TO_EC_STR_PARAM(brainpoolp256t1_p_shift); 145 146 static const u8 brainpoolp256t1_p_normalized[] = { 147 0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc, 148 0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x72, 149 0x6e, 0x3b, 0xf6, 0x23, 0xd5, 0x26, 0x20, 0x28, 150 0x20, 0x13, 0x48, 0x1d, 0x1f, 0x6e, 0x53, 0x77, 151 }; 152 153 TO_EC_STR_PARAM(brainpoolp256t1_p_normalized); 154 155 static const u8 brainpoolp256t1_p_reciprocal[] = { 156 0x81, 0x8c, 157 }; 158 159 TO_EC_STR_PARAM(brainpoolp256t1_p_reciprocal); 160 161 #else /* unknown word size */ 162 #error "Unsupported word size" 163 #endif 164 165 static const u8 brainpoolp256t1_a[] = { 166 0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc, 167 0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x72, 168 0x6e, 0x3b, 0xf6, 0x23, 0xd5, 0x26, 0x20, 0x28, 169 0x20, 0x13, 0x48, 0x1d, 0x1f, 0x6e, 0x53, 0x74, 170 }; 171 172 TO_EC_STR_PARAM(brainpoolp256t1_a); 173 174 static const u8 brainpoolp256t1_b[] = { 175 0x66, 0x2c, 0x61, 0xc4, 0x30, 0xd8, 0x4e, 0xa4, 176 0xfe, 0x66, 0xa7, 0x73, 0x3d, 0x0b, 0x76, 0xb7, 177 0xbf, 0x93, 0xeb, 0xc4, 0xaf, 0x2f, 0x49, 0x25, 178 0x6a, 0xe5, 0x81, 0x01, 0xfe, 0xe9, 0x2b, 0x04, 179 }; 180 181 TO_EC_STR_PARAM(brainpoolp256t1_b); 182 183 #define CURVE_BRAINPOOLP256T1_CURVE_ORDER_BITLEN 256 184 static const u8 brainpoolp256t1_curve_order[] = { 185 0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc, 186 0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x71, 187 0x8c, 0x39, 0x7a, 0xa3, 0xb5, 0x61, 0xa6, 0xf7, 188 0x90, 0x1e, 0x0e, 0x82, 0x97, 0x48, 0x56, 0xa7, 189 }; 190 191 TO_EC_STR_PARAM(brainpoolp256t1_curve_order); 192 193 static const u8 brainpoolp256t1_gx[] = { 194 0xa3, 0xe8, 0xeb, 0x3c, 0xc1, 0xcf, 0xe7, 0xb7, 195 0x73, 0x22, 0x13, 0xb2, 0x3a, 0x65, 0x61, 0x49, 196 0xaf, 0xa1, 0x42, 0xc4, 0x7a, 0xaf, 0xbc, 0x2b, 197 0x79, 0xa1, 0x91, 0x56, 0x2e, 0x13, 0x05, 0xf4, 198 }; 199 200 TO_EC_STR_PARAM(brainpoolp256t1_gx); 201 202 static const u8 brainpoolp256t1_gy[] = { 203 0x2d, 0x99, 0x6c, 0x82, 0x34, 0x39, 0xc5, 0x6d, 204 0x7f, 0x7b, 0x22, 0xe1, 0x46, 0x44, 0x41, 0x7e, 205 0x69, 0xbc, 0xb6, 0xde, 0x39, 0xd0, 0x27, 0x00, 206 0x1d, 0xab, 0xe8, 0xf3, 0x5b, 0x25, 0xc9, 0xbe, 207 }; 208 209 TO_EC_STR_PARAM(brainpoolp256t1_gy); 210 211 static const u8 brainpoolp256t1_gz[] = { 212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 213 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 216 }; 217 218 TO_EC_STR_PARAM(brainpoolp256t1_gz); 219 220 static const u8 brainpoolp256t1_gen_order[] = { 221 0xa9, 0xfb, 0x57, 0xdb, 0xa1, 0xee, 0xa9, 0xbc, 222 0x3e, 0x66, 0x0a, 0x90, 0x9d, 0x83, 0x8d, 0x71, 223 0x8c, 0x39, 0x7a, 0xa3, 0xb5, 0x61, 0xa6, 0xf7, 224 0x90, 0x1e, 0x0e, 0x82, 0x97, 0x48, 0x56, 0xa7, 225 }; 226 227 TO_EC_STR_PARAM(brainpoolp256t1_gen_order); 228 229 #define CURVE_BRAINPOOLP256T1_Q_BITLEN 256 230 static const u8 brainpoolp256t1_gen_order_bitlen[] = { 231 0x01, 0x00, 232 }; 233 234 TO_EC_STR_PARAM(brainpoolp256t1_gen_order_bitlen); 235 236 static const u8 brainpoolp256t1_cofactor[] = { 237 0x01, 238 }; 239 240 TO_EC_STR_PARAM(brainpoolp256t1_cofactor); 241 242 static const u8 brainpoolp256t1_alpha_montgomery[] = { 243 0x00, 244 }; 245 TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp256t1_alpha_montgomery, 0); 246 247 static const u8 brainpoolp256t1_gamma_montgomery[] = { 248 0x00, 249 }; 250 TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp256t1_gamma_montgomery, 0); 251 252 static const u8 brainpoolp256t1_alpha_edwards[] = { 253 0x00, 254 }; 255 TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp256t1_alpha_edwards, 0); 256 257 static const u8 brainpoolp256t1_name[] = "BRAINPOOLP256T1"; 258 TO_EC_STR_PARAM(brainpoolp256t1_name); 259 260 static const u8 brainpoolp256t1_oid[] = "1.3.36.3.3.2.8.1.1.8"; 261 TO_EC_STR_PARAM(brainpoolp256t1_oid); 262 263 static const ec_str_params brainpoolp256t1_str_params = { 264 .p = &brainpoolp256t1_p_str_param, 265 .p_bitlen = &brainpoolp256t1_p_bitlen_str_param, 266 .r = &brainpoolp256t1_r_str_param, 267 .r_square = &brainpoolp256t1_r_square_str_param, 268 .mpinv = &brainpoolp256t1_mpinv_str_param, 269 .p_shift = &brainpoolp256t1_p_shift_str_param, 270 .p_normalized = &brainpoolp256t1_p_normalized_str_param, 271 .p_reciprocal = &brainpoolp256t1_p_reciprocal_str_param, 272 .a = &brainpoolp256t1_a_str_param, 273 .b = &brainpoolp256t1_b_str_param, 274 .curve_order = &brainpoolp256t1_curve_order_str_param, 275 .gx = &brainpoolp256t1_gx_str_param, 276 .gy = &brainpoolp256t1_gy_str_param, 277 .gz = &brainpoolp256t1_gz_str_param, 278 .gen_order = &brainpoolp256t1_gen_order_str_param, 279 .gen_order_bitlen = &brainpoolp256t1_gen_order_bitlen_str_param, 280 .cofactor = &brainpoolp256t1_cofactor_str_param, 281 .alpha_montgomery = &brainpoolp256t1_alpha_montgomery_str_param, 282 .gamma_montgomery = &brainpoolp256t1_gamma_montgomery_str_param, 283 .alpha_edwards = &brainpoolp256t1_alpha_edwards_str_param, 284 .oid = &brainpoolp256t1_oid_str_param, 285 .name = &brainpoolp256t1_name_str_param, 286 }; 287 288 /* 289 * Compute max bit length of all curves for p and q 290 */ 291 #ifndef CURVES_MAX_P_BIT_LEN 292 #define CURVES_MAX_P_BIT_LEN 0 293 #endif 294 #if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP256T1_P_BITLEN) 295 #undef CURVES_MAX_P_BIT_LEN 296 #define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP256T1_P_BITLEN 297 #endif 298 #ifndef CURVES_MAX_Q_BIT_LEN 299 #define CURVES_MAX_Q_BIT_LEN 0 300 #endif 301 #if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP256T1_Q_BITLEN) 302 #undef CURVES_MAX_Q_BIT_LEN 303 #define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP256T1_Q_BITLEN 304 #endif 305 #ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN 306 #define CURVES_MAX_CURVE_ORDER_BIT_LEN 0 307 #endif 308 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP256T1_CURVE_ORDER_BITLEN) 309 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN 310 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP256T1_CURVE_ORDER_BITLEN 311 #endif 312 313 /* 314 * Compute and adapt max name and oid length 315 */ 316 #ifndef MAX_CURVE_OID_LEN 317 #define MAX_CURVE_OID_LEN 0 318 #endif 319 #ifndef MAX_CURVE_NAME_LEN 320 #define MAX_CURVE_NAME_LEN 0 321 #endif 322 #if (MAX_CURVE_OID_LEN < 1) 323 #undef MAX_CURVE_OID_LEN 324 #define MAX_CURVE_OID_LEN 1 325 #endif 326 #if (MAX_CURVE_NAME_LEN < 29) 327 #undef MAX_CURVE_NAME_LEN 328 #define MAX_CURVE_NAME_LEN 29 329 #endif 330 331 #endif /* __EC_PARAMS_BRAINPOOLP256T1_H__ */ 332 333 #endif /* WITH_CURVE_BRAINPOOLP256T1 */ 334