1 #include <libecc/lib_ecc_config.h> 2 #ifdef WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET 3 4 #ifndef __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_H__ 5 #define __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_H__ 6 #include <libecc/curves/known/ec_params_external.h> 7 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p[] = { 8 0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07, 9 0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa, 10 0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3, 11 0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b, 12 }; 13 14 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p); 15 16 #define CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_P_BITLEN 256 17 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_bitlen[] = { 18 0x01, 0x00, 19 }; 20 21 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_bitlen); 22 23 #if (WORD_BYTES == 8) /* 64-bit words */ 24 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_r[] = { 25 0x64, 0x60, 0x9f, 0xa0, 0xa5, 0x7a, 0x7e, 0xf8, 26 0x54, 0xe1, 0x37, 0xa1, 0x94, 0xbe, 0x37, 0x55, 27 0x30, 0x7b, 0x91, 0x79, 0x87, 0x6f, 0xae, 0x2c, 28 0x86, 0x67, 0x08, 0x46, 0xfd, 0xd2, 0x8a, 0x65, 29 }; 30 31 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_r); 32 33 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_r_square[] = { 34 0x80, 0x7a, 0x39, 0x4e, 0xde, 0x09, 0x76, 0x52, 35 0x18, 0x63, 0x04, 0x21, 0x28, 0x49, 0xc0, 0x7b, 36 0x10, 0x17, 0xbb, 0x39, 0xc2, 0xd3, 0x46, 0xc5, 37 0x40, 0x99, 0x73, 0xb4, 0xc4, 0x27, 0xfc, 0xea, 38 }; 39 40 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_r_square); 41 42 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_mpinv[] = { 43 0xdf, 0x6e, 0x6c, 0x2c, 0x72, 0x7c, 0x17, 0x6d, 44 }; 45 46 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_mpinv); 47 48 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_shift[] = { 49 0x00, 50 }; 51 52 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_shift); 53 54 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized[] = { 55 0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07, 56 0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa, 57 0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3, 58 0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b, 59 }; 60 61 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized); 62 63 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal[] = { 64 0xa5, 0x1f, 0x17, 0x61, 0x61, 0xf1, 0xd7, 0x34, 65 }; 66 67 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal); 68 69 #elif (WORD_BYTES == 4) /* 32-bit words */ 70 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_r[] = { 71 0x64, 0x60, 0x9f, 0xa0, 0xa5, 0x7a, 0x7e, 0xf8, 72 0x54, 0xe1, 0x37, 0xa1, 0x94, 0xbe, 0x37, 0x55, 73 0x30, 0x7b, 0x91, 0x79, 0x87, 0x6f, 0xae, 0x2c, 74 0x86, 0x67, 0x08, 0x46, 0xfd, 0xd2, 0x8a, 0x65, 75 }; 76 77 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_r); 78 79 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_r_square[] = { 80 0x80, 0x7a, 0x39, 0x4e, 0xde, 0x09, 0x76, 0x52, 81 0x18, 0x63, 0x04, 0x21, 0x28, 0x49, 0xc0, 0x7b, 82 0x10, 0x17, 0xbb, 0x39, 0xc2, 0xd3, 0x46, 0xc5, 83 0x40, 0x99, 0x73, 0xb4, 0xc4, 0x27, 0xfc, 0xea, 84 }; 85 86 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_r_square); 87 88 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_mpinv[] = { 89 0x72, 0x7c, 0x17, 0x6d, 90 }; 91 92 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_mpinv); 93 94 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_shift[] = { 95 0x00, 96 }; 97 98 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_shift); 99 100 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized[] = { 101 0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07, 102 0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa, 103 0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3, 104 0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b, 105 }; 106 107 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized); 108 109 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal[] = { 110 0xa5, 0x1f, 0x17, 0x61, 111 }; 112 113 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal); 114 115 #elif (WORD_BYTES == 2) /* 16-bit words */ 116 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_r[] = { 117 0x64, 0x60, 0x9f, 0xa0, 0xa5, 0x7a, 0x7e, 0xf8, 118 0x54, 0xe1, 0x37, 0xa1, 0x94, 0xbe, 0x37, 0x55, 119 0x30, 0x7b, 0x91, 0x79, 0x87, 0x6f, 0xae, 0x2c, 120 0x86, 0x67, 0x08, 0x46, 0xfd, 0xd2, 0x8a, 0x65, 121 }; 122 123 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_r); 124 125 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_r_square[] = { 126 0x80, 0x7a, 0x39, 0x4e, 0xde, 0x09, 0x76, 0x52, 127 0x18, 0x63, 0x04, 0x21, 0x28, 0x49, 0xc0, 0x7b, 128 0x10, 0x17, 0xbb, 0x39, 0xc2, 0xd3, 0x46, 0xc5, 129 0x40, 0x99, 0x73, 0xb4, 0xc4, 0x27, 0xfc, 0xea, 130 }; 131 132 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_r_square); 133 134 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_mpinv[] = { 135 0x17, 0x6d, 136 }; 137 138 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_mpinv); 139 140 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_shift[] = { 141 0x00, 142 }; 143 144 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_shift); 145 146 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized[] = { 147 0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07, 148 0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa, 149 0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3, 150 0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x9b, 151 }; 152 153 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized); 154 155 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal[] = { 156 0xa5, 0x1f, 157 }; 158 159 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal); 160 161 #else /* unknown word size */ 162 #error "Unsupported word size" 163 #endif 164 165 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_a[] = { 166 0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07, 167 0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa, 168 0xcf, 0x84, 0x6e, 0x86, 0x78, 0x90, 0x51, 0xd3, 169 0x79, 0x98, 0xf7, 0xb9, 0x02, 0x2d, 0x75, 0x98, 170 }; 171 172 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_a); 173 174 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_b[] = { 175 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 176 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 177 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x5a, 179 }; 180 181 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_b); 182 183 #define CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_CURVE_ORDER_BITLEN 256 184 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_curve_order[] = { 185 0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07, 186 0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa, 187 0x58, 0x2c, 0xa3, 0x51, 0x1e, 0xdd, 0xfb, 0x74, 188 0xf0, 0x2f, 0x3a, 0x65, 0x98, 0x98, 0x0b, 0xb9, 189 }; 190 191 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_curve_order); 192 193 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_gx[] = { 194 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 195 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 197 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 198 }; 199 200 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_gx); 201 202 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_gy[] = { 203 0x41, 0xec, 0xe5, 0x57, 0x43, 0x71, 0x1a, 0x8c, 204 0x3c, 0xbf, 0x37, 0x83, 0xcd, 0x08, 0xc0, 0xee, 205 0x4d, 0x4d, 0xc4, 0x40, 0xd4, 0x64, 0x1a, 0x8f, 206 0x36, 0x6e, 0x55, 0x0d, 0xfd, 0xb3, 0xbb, 0x67, 207 }; 208 209 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_gy); 210 211 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_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(gost_R3410_2001_CryptoPro_C_ParamSet_gz); 219 220 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_gen_order[] = { 221 0x9b, 0x9f, 0x60, 0x5f, 0x5a, 0x85, 0x81, 0x07, 222 0xab, 0x1e, 0xc8, 0x5e, 0x6b, 0x41, 0xc8, 0xaa, 223 0x58, 0x2c, 0xa3, 0x51, 0x1e, 0xdd, 0xfb, 0x74, 224 0xf0, 0x2f, 0x3a, 0x65, 0x98, 0x98, 0x0b, 0xb9, 225 }; 226 227 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_gen_order); 228 229 #define CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_Q_BITLEN 256 230 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_gen_order_bitlen[] = { 231 0x01, 0x00, 232 }; 233 234 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_gen_order_bitlen); 235 236 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_cofactor[] = { 237 0x01, 238 }; 239 240 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_cofactor); 241 242 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_alpha_montgomery[] = { 243 0x00, 244 }; 245 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_C_ParamSet_alpha_montgomery, 0); 246 247 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_gamma_montgomery[] = { 248 0x00, 249 }; 250 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_C_ParamSet_gamma_montgomery, 0); 251 252 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_alpha_edwards[] = { 253 0x00, 254 }; 255 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_CryptoPro_C_ParamSet_alpha_edwards, 0); 256 257 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_name[] = "GOST_R3410_2001_CRYPTOPRO_C_PARAMSET"; 258 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_name); 259 260 static const u8 gost_R3410_2001_CryptoPro_C_ParamSet_oid[] = "1.2.643.2.2.35.3"; 261 TO_EC_STR_PARAM(gost_R3410_2001_CryptoPro_C_ParamSet_oid); 262 263 static const ec_str_params gost_R3410_2001_CryptoPro_C_ParamSet_str_params = { 264 .p = &gost_R3410_2001_CryptoPro_C_ParamSet_p_str_param, 265 .p_bitlen = &gost_R3410_2001_CryptoPro_C_ParamSet_p_bitlen_str_param, 266 .r = &gost_R3410_2001_CryptoPro_C_ParamSet_r_str_param, 267 .r_square = &gost_R3410_2001_CryptoPro_C_ParamSet_r_square_str_param, 268 .mpinv = &gost_R3410_2001_CryptoPro_C_ParamSet_mpinv_str_param, 269 .p_shift = &gost_R3410_2001_CryptoPro_C_ParamSet_p_shift_str_param, 270 .p_normalized = &gost_R3410_2001_CryptoPro_C_ParamSet_p_normalized_str_param, 271 .p_reciprocal = &gost_R3410_2001_CryptoPro_C_ParamSet_p_reciprocal_str_param, 272 .a = &gost_R3410_2001_CryptoPro_C_ParamSet_a_str_param, 273 .b = &gost_R3410_2001_CryptoPro_C_ParamSet_b_str_param, 274 .curve_order = &gost_R3410_2001_CryptoPro_C_ParamSet_curve_order_str_param, 275 .gx = &gost_R3410_2001_CryptoPro_C_ParamSet_gx_str_param, 276 .gy = &gost_R3410_2001_CryptoPro_C_ParamSet_gy_str_param, 277 .gz = &gost_R3410_2001_CryptoPro_C_ParamSet_gz_str_param, 278 .gen_order = &gost_R3410_2001_CryptoPro_C_ParamSet_gen_order_str_param, 279 .gen_order_bitlen = &gost_R3410_2001_CryptoPro_C_ParamSet_gen_order_bitlen_str_param, 280 .cofactor = &gost_R3410_2001_CryptoPro_C_ParamSet_cofactor_str_param, 281 .alpha_montgomery = &gost_R3410_2001_CryptoPro_C_ParamSet_alpha_montgomery_str_param, 282 .gamma_montgomery = &gost_R3410_2001_CryptoPro_C_ParamSet_gamma_montgomery_str_param, 283 .alpha_edwards = &gost_R3410_2001_CryptoPro_C_ParamSet_alpha_edwards_str_param, 284 .oid = &gost_R3410_2001_CryptoPro_C_ParamSet_oid_str_param, 285 .name = &gost_R3410_2001_CryptoPro_C_ParamSet_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_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_P_BITLEN) 295 #undef CURVES_MAX_P_BIT_LEN 296 #define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_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_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_Q_BITLEN) 302 #undef CURVES_MAX_Q_BIT_LEN 303 #define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_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_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_CURVE_ORDER_BITLEN) 309 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN 310 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_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 < 17) 323 #undef MAX_CURVE_OID_LEN 324 #define MAX_CURVE_OID_LEN 17 325 #endif 326 #if (MAX_CURVE_NAME_LEN < 52) 327 #undef MAX_CURVE_NAME_LEN 328 #define MAX_CURVE_NAME_LEN 52 329 #endif 330 331 #endif /* __EC_PARAMS_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET_H__ */ 332 333 #endif /* WITH_CURVE_GOST_R3410_2001_CRYPTOPRO_C_PARAMSET */ 334