1 #include <libecc/lib_ecc_config.h> 2 #ifdef WITH_CURVE_GOST_R3410_2012_512_PARAMSETC 3 4 #ifndef __EC_PARAMS_GOST_R3410_2012_512_PARAMSETC_H__ 5 #define __EC_PARAMS_GOST_R3410_2012_512_PARAMSETC_H__ 6 #include <libecc/curves/known/ec_params_external.h> 7 static const u8 gost_R3410_2012_512_paramSetC_p[] = { 8 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 9 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 10 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 11 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 12 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 13 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 14 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 15 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7, 16 }; 17 18 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p); 19 20 #define CURVE_GOST_R3410_2012_512_PARAMSETC_P_BITLEN 512 21 static const u8 gost_R3410_2012_512_paramSetC_p_bitlen[] = { 22 0x02, 0x00, 23 }; 24 25 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_bitlen); 26 27 #if (WORD_BYTES == 8) /* 64-bit words */ 28 static const u8 gost_R3410_2012_512_paramSetC_r[] = { 29 0x02, 0x39, 30 }; 31 32 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_r); 33 34 static const u8 gost_R3410_2012_512_paramSetC_r_square[] = { 35 0x04, 0xf0, 0xb1, 36 }; 37 38 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_r_square); 39 40 static const u8 gost_R3410_2012_512_paramSetC_mpinv[] = { 41 0x58, 0xa1, 0xf7, 0xe6, 0xce, 0x0f, 0x4c, 0x09, 42 }; 43 44 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_mpinv); 45 46 static const u8 gost_R3410_2012_512_paramSetC_p_shift[] = { 47 0x00, 48 }; 49 50 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_shift); 51 52 static const u8 gost_R3410_2012_512_paramSetC_p_normalized[] = { 53 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 54 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 55 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 56 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 57 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 58 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 59 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 60 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7, 61 }; 62 63 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_normalized); 64 65 static const u8 gost_R3410_2012_512_paramSetC_p_reciprocal[] = { 66 0x00, 67 }; 68 69 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_reciprocal); 70 71 #elif (WORD_BYTES == 4) /* 32-bit words */ 72 static const u8 gost_R3410_2012_512_paramSetC_r[] = { 73 0x02, 0x39, 74 }; 75 76 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_r); 77 78 static const u8 gost_R3410_2012_512_paramSetC_r_square[] = { 79 0x04, 0xf0, 0xb1, 80 }; 81 82 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_r_square); 83 84 static const u8 gost_R3410_2012_512_paramSetC_mpinv[] = { 85 0xce, 0x0f, 0x4c, 0x09, 86 }; 87 88 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_mpinv); 89 90 static const u8 gost_R3410_2012_512_paramSetC_p_shift[] = { 91 0x00, 92 }; 93 94 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_shift); 95 96 static const u8 gost_R3410_2012_512_paramSetC_p_normalized[] = { 97 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 98 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 99 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 100 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 101 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 102 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 103 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 104 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7, 105 }; 106 107 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_normalized); 108 109 static const u8 gost_R3410_2012_512_paramSetC_p_reciprocal[] = { 110 0x00, 111 }; 112 113 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_reciprocal); 114 115 #elif (WORD_BYTES == 2) /* 16-bit words */ 116 static const u8 gost_R3410_2012_512_paramSetC_r[] = { 117 0x02, 0x39, 118 }; 119 120 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_r); 121 122 static const u8 gost_R3410_2012_512_paramSetC_r_square[] = { 123 0x04, 0xf0, 0xb1, 124 }; 125 126 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_r_square); 127 128 static const u8 gost_R3410_2012_512_paramSetC_mpinv[] = { 129 0x4c, 0x09, 130 }; 131 132 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_mpinv); 133 134 static const u8 gost_R3410_2012_512_paramSetC_p_shift[] = { 135 0x00, 136 }; 137 138 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_shift); 139 140 static const u8 gost_R3410_2012_512_paramSetC_p_normalized[] = { 141 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 142 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 143 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 144 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 145 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 146 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 147 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 148 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xc7, 149 }; 150 151 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_normalized); 152 153 static const u8 gost_R3410_2012_512_paramSetC_p_reciprocal[] = { 154 0x00, 155 }; 156 157 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_p_reciprocal); 158 159 #else /* unknown word size */ 160 #error "Unsupported word size" 161 #endif 162 163 static const u8 gost_R3410_2012_512_paramSetC_a[] = { 164 0xdc, 0x92, 0x03, 0xe5, 0x14, 0xa7, 0x21, 0x87, 165 0x54, 0x85, 0xa5, 0x29, 0xd2, 0xc7, 0x22, 0xfb, 166 0x18, 0x7b, 0xc8, 0x98, 0x0e, 0xb8, 0x66, 0x64, 167 0x4d, 0xe4, 0x1c, 0x68, 0xe1, 0x43, 0x06, 0x45, 168 0x46, 0xe8, 0x61, 0xc0, 0xe2, 0xc9, 0xed, 0xd9, 169 0x2a, 0xde, 0x71, 0xf4, 0x6f, 0xcf, 0x50, 0xff, 170 0x2a, 0xd9, 0x7f, 0x95, 0x1f, 0xda, 0x9f, 0x2a, 171 0x2e, 0xb6, 0x54, 0x6f, 0x39, 0x68, 0x9b, 0xd3, 172 }; 173 174 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_a); 175 176 static const u8 gost_R3410_2012_512_paramSetC_b[] = { 177 0xb4, 0xc4, 0xee, 0x28, 0xce, 0xbc, 0x6c, 0x2c, 178 0x8a, 0xc1, 0x29, 0x52, 0xcf, 0x37, 0xf1, 0x6a, 179 0xc7, 0xef, 0xb6, 0xa9, 0xf6, 0x9f, 0x4b, 0x57, 180 0xff, 0xda, 0x2e, 0x4f, 0x0d, 0xe5, 0xad, 0xe0, 181 0x38, 0xcb, 0xc2, 0xff, 0xf7, 0x19, 0xd2, 0xc1, 182 0x8d, 0xe0, 0x28, 0x4b, 0x8b, 0xfe, 0xf3, 0xb5, 183 0x2b, 0x8c, 0xc7, 0xa5, 0xf5, 0xbf, 0x0a, 0x3c, 184 0x8d, 0x23, 0x19, 0xa5, 0x31, 0x25, 0x57, 0xe1, 185 }; 186 187 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_b); 188 189 #define CURVE_GOST_R3410_2012_512_PARAMSETC_CURVE_ORDER_BITLEN 512 190 static const u8 gost_R3410_2012_512_paramSetC_curve_order[] = { 191 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 192 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 193 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 194 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 195 0x26, 0x33, 0x6e, 0x91, 0x94, 0x1a, 0xac, 0x01, 196 0x30, 0xce, 0xa7, 0xfd, 0x45, 0x1d, 0x40, 0xb3, 197 0x23, 0xb6, 0xa7, 0x9e, 0x9d, 0xa6, 0x84, 0x9a, 198 0x51, 0x88, 0xf3, 0xbd, 0x1f, 0xc0, 0x8f, 0xb4, 199 }; 200 201 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_curve_order); 202 203 static const u8 gost_R3410_2012_512_paramSetC_gx[] = { 204 0xe2, 0xe3, 0x1e, 0xdf, 0xc2, 0x3d, 0xe7, 0xbd, 205 0xeb, 0xe2, 0x41, 0xce, 0x59, 0x3e, 0xf5, 0xde, 206 0x22, 0x95, 0xb7, 0xa9, 0xcb, 0xae, 0xf0, 0x21, 207 0xd3, 0x85, 0xf7, 0x07, 0x4c, 0xea, 0x04, 0x3a, 208 0xa2, 0x72, 0x72, 0xa7, 0xae, 0x60, 0x2b, 0xf2, 209 0xa7, 0xb9, 0x03, 0x3d, 0xb9, 0xed, 0x36, 0x10, 210 0xc6, 0xfb, 0x85, 0x48, 0x7e, 0xae, 0x97, 0xaa, 211 0xc5, 0xbc, 0x79, 0x28, 0xc1, 0x95, 0x01, 0x48, 212 }; 213 214 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_gx); 215 216 static const u8 gost_R3410_2012_512_paramSetC_gy[] = { 217 0xf5, 0xce, 0x40, 0xd9, 0x5b, 0x5e, 0xb8, 0x99, 218 0xab, 0xbc, 0xcf, 0xf5, 0x91, 0x1c, 0xb8, 0x57, 219 0x79, 0x39, 0x80, 0x4d, 0x65, 0x27, 0x37, 0x8b, 220 0x8c, 0x10, 0x8c, 0x3d, 0x20, 0x90, 0xff, 0x9b, 221 0xe1, 0x8e, 0x2d, 0x33, 0xe3, 0x02, 0x1e, 0xd2, 222 0xef, 0x32, 0xd8, 0x58, 0x22, 0x42, 0x3b, 0x63, 223 0x04, 0xf7, 0x26, 0xaa, 0x85, 0x4b, 0xae, 0x07, 224 0xd0, 0x39, 0x6e, 0x9a, 0x9a, 0xdd, 0xc4, 0x0f, 225 }; 226 227 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_gy); 228 229 static const u8 gost_R3410_2012_512_paramSetC_gz[] = { 230 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 232 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 233 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 234 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 235 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 236 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 237 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 238 }; 239 240 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_gz); 241 242 static const u8 gost_R3410_2012_512_paramSetC_gen_order[] = { 243 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 244 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 245 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 246 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 247 0xc9, 0x8c, 0xdb, 0xa4, 0x65, 0x06, 0xab, 0x00, 248 0x4c, 0x33, 0xa9, 0xff, 0x51, 0x47, 0x50, 0x2c, 249 0xc8, 0xed, 0xa9, 0xe7, 0xa7, 0x69, 0xa1, 0x26, 250 0x94, 0x62, 0x3c, 0xef, 0x47, 0xf0, 0x23, 0xed, 251 }; 252 253 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_gen_order); 254 255 #define CURVE_GOST_R3410_2012_512_PARAMSETC_Q_BITLEN 510 256 static const u8 gost_R3410_2012_512_paramSetC_gen_order_bitlen[] = { 257 0x01, 0xfe, 258 }; 259 260 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_gen_order_bitlen); 261 262 static const u8 gost_R3410_2012_512_paramSetC_cofactor[] = { 263 0x04, 264 }; 265 266 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_cofactor); 267 268 static const u8 gost_R3410_2012_512_paramSetC_alpha_montgomery[] = { 269 0x00, 270 }; 271 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetC_alpha_montgomery, 0); 272 273 static const u8 gost_R3410_2012_512_paramSetC_gamma_montgomery[] = { 274 0x00, 275 }; 276 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetC_gamma_montgomery, 0); 277 278 static const u8 gost_R3410_2012_512_paramSetC_alpha_edwards[] = { 279 0x00, 280 }; 281 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_512_paramSetC_alpha_edwards, 0); 282 283 static const u8 gost_R3410_2012_512_paramSetC_name[] = "GOST_R3410_2012_512_PARAMSETC"; 284 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_name); 285 286 static const u8 gost_R3410_2012_512_paramSetC_oid[] = "1.2.643.7.1.2.1.2.3"; 287 TO_EC_STR_PARAM(gost_R3410_2012_512_paramSetC_oid); 288 289 static const ec_str_params gost_R3410_2012_512_paramSetC_str_params = { 290 .p = &gost_R3410_2012_512_paramSetC_p_str_param, 291 .p_bitlen = &gost_R3410_2012_512_paramSetC_p_bitlen_str_param, 292 .r = &gost_R3410_2012_512_paramSetC_r_str_param, 293 .r_square = &gost_R3410_2012_512_paramSetC_r_square_str_param, 294 .mpinv = &gost_R3410_2012_512_paramSetC_mpinv_str_param, 295 .p_shift = &gost_R3410_2012_512_paramSetC_p_shift_str_param, 296 .p_normalized = &gost_R3410_2012_512_paramSetC_p_normalized_str_param, 297 .p_reciprocal = &gost_R3410_2012_512_paramSetC_p_reciprocal_str_param, 298 .a = &gost_R3410_2012_512_paramSetC_a_str_param, 299 .b = &gost_R3410_2012_512_paramSetC_b_str_param, 300 .curve_order = &gost_R3410_2012_512_paramSetC_curve_order_str_param, 301 .gx = &gost_R3410_2012_512_paramSetC_gx_str_param, 302 .gy = &gost_R3410_2012_512_paramSetC_gy_str_param, 303 .gz = &gost_R3410_2012_512_paramSetC_gz_str_param, 304 .gen_order = &gost_R3410_2012_512_paramSetC_gen_order_str_param, 305 .gen_order_bitlen = &gost_R3410_2012_512_paramSetC_gen_order_bitlen_str_param, 306 .cofactor = &gost_R3410_2012_512_paramSetC_cofactor_str_param, 307 .alpha_montgomery = &gost_R3410_2012_512_paramSetC_alpha_montgomery_str_param, 308 .gamma_montgomery = &gost_R3410_2012_512_paramSetC_gamma_montgomery_str_param, 309 .alpha_edwards = &gost_R3410_2012_512_paramSetC_alpha_edwards_str_param, 310 .oid = &gost_R3410_2012_512_paramSetC_oid_str_param, 311 .name = &gost_R3410_2012_512_paramSetC_name_str_param, 312 }; 313 314 /* 315 * Compute max bit length of all curves for p and q 316 */ 317 #ifndef CURVES_MAX_P_BIT_LEN 318 #define CURVES_MAX_P_BIT_LEN 0 319 #endif 320 #if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETC_P_BITLEN) 321 #undef CURVES_MAX_P_BIT_LEN 322 #define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETC_P_BITLEN 323 #endif 324 #ifndef CURVES_MAX_Q_BIT_LEN 325 #define CURVES_MAX_Q_BIT_LEN 0 326 #endif 327 #if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETC_Q_BITLEN) 328 #undef CURVES_MAX_Q_BIT_LEN 329 #define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETC_Q_BITLEN 330 #endif 331 #ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN 332 #define CURVES_MAX_CURVE_ORDER_BIT_LEN 0 333 #endif 334 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2012_512_PARAMSETC_CURVE_ORDER_BITLEN) 335 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN 336 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2012_512_PARAMSETC_CURVE_ORDER_BITLEN 337 #endif 338 339 /* 340 * Compute and adapt max name and oid length 341 */ 342 #ifndef MAX_CURVE_OID_LEN 343 #define MAX_CURVE_OID_LEN 0 344 #endif 345 #ifndef MAX_CURVE_NAME_LEN 346 #define MAX_CURVE_NAME_LEN 0 347 #endif 348 #if (MAX_CURVE_OID_LEN < 20) 349 #undef MAX_CURVE_OID_LEN 350 #define MAX_CURVE_OID_LEN 20 351 #endif 352 #if (MAX_CURVE_NAME_LEN < 50) 353 #undef MAX_CURVE_NAME_LEN 354 #define MAX_CURVE_NAME_LEN 50 355 #endif 356 357 #endif /* __EC_PARAMS_GOST_R3410_2012_512_PARAMSETC_H__ */ 358 359 #endif /* WITH_CURVE_GOST_R3410_2012_512_PARAMSETC */ 360