1 #include <libecc/lib_ecc_config.h> 2 #ifdef WITH_CURVE_GOST_R3410_2001_TESTPARAMSET 3 4 #ifndef __EC_PARAMS_GOST_R3410_2001_TESTPARAMSET_H__ 5 #define __EC_PARAMS_GOST_R3410_2001_TESTPARAMSET_H__ 6 #include <libecc/curves/known/ec_params_external.h> 7 static const u8 gost_R3410_2001_TestParamSet_p[] = { 8 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 10 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 11 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x31, 12 }; 13 14 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p); 15 16 #define CURVE_GOST_R3410_2001_TESTPARAMSET_P_BITLEN 256 17 static const u8 gost_R3410_2001_TestParamSet_p_bitlen[] = { 18 0x01, 0x00, 19 }; 20 21 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_bitlen); 22 23 #if (WORD_BYTES == 8) /* 64-bit words */ 24 static const u8 gost_R3410_2001_TestParamSet_r[] = { 25 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 26 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 27 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 28 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xcf, 29 }; 30 31 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_r); 32 33 static const u8 gost_R3410_2001_TestParamSet_r_square[] = { 34 0x46, 0x45, 0x84, 35 }; 36 37 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_r_square); 38 39 static const u8 gost_R3410_2001_TestParamSet_mpinv[] = { 40 0xdb, 0xf9, 0x51, 0xd5, 0x88, 0x3b, 0x2b, 0x2f, 41 }; 42 43 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_mpinv); 44 45 static const u8 gost_R3410_2001_TestParamSet_p_shift[] = { 46 0x00, 47 }; 48 49 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_shift); 50 51 static const u8 gost_R3410_2001_TestParamSet_p_normalized[] = { 52 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 54 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 55 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x31, 56 }; 57 58 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_normalized); 59 60 static const u8 gost_R3410_2001_TestParamSet_p_reciprocal[] = { 61 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 62 }; 63 64 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_reciprocal); 65 66 #elif (WORD_BYTES == 4) /* 32-bit words */ 67 static const u8 gost_R3410_2001_TestParamSet_r[] = { 68 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 69 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 70 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 71 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xcf, 72 }; 73 74 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_r); 75 76 static const u8 gost_R3410_2001_TestParamSet_r_square[] = { 77 0x46, 0x45, 0x84, 78 }; 79 80 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_r_square); 81 82 static const u8 gost_R3410_2001_TestParamSet_mpinv[] = { 83 0x88, 0x3b, 0x2b, 0x2f, 84 }; 85 86 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_mpinv); 87 88 static const u8 gost_R3410_2001_TestParamSet_p_shift[] = { 89 0x00, 90 }; 91 92 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_shift); 93 94 static const u8 gost_R3410_2001_TestParamSet_p_normalized[] = { 95 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 96 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 97 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 98 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x31, 99 }; 100 101 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_normalized); 102 103 static const u8 gost_R3410_2001_TestParamSet_p_reciprocal[] = { 104 0xff, 0xff, 0xff, 0xff, 105 }; 106 107 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_reciprocal); 108 109 #elif (WORD_BYTES == 2) /* 16-bit words */ 110 static const u8 gost_R3410_2001_TestParamSet_r[] = { 111 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 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, 0xfb, 0xcf, 115 }; 116 117 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_r); 118 119 static const u8 gost_R3410_2001_TestParamSet_r_square[] = { 120 0x46, 0x45, 0x84, 121 }; 122 123 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_r_square); 124 125 static const u8 gost_R3410_2001_TestParamSet_mpinv[] = { 126 0x2b, 0x2f, 127 }; 128 129 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_mpinv); 130 131 static const u8 gost_R3410_2001_TestParamSet_p_shift[] = { 132 0x00, 133 }; 134 135 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_shift); 136 137 static const u8 gost_R3410_2001_TestParamSet_p_normalized[] = { 138 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 139 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 140 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 141 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x31, 142 }; 143 144 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_normalized); 145 146 static const u8 gost_R3410_2001_TestParamSet_p_reciprocal[] = { 147 0xff, 0xff, 148 }; 149 150 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_p_reciprocal); 151 152 #else /* unknown word size */ 153 #error "Unsupported word size" 154 #endif 155 156 static const u8 gost_R3410_2001_TestParamSet_a[] = { 157 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 158 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 159 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 160 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 161 }; 162 163 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_a); 164 165 static const u8 gost_R3410_2001_TestParamSet_b[] = { 166 0x5f, 0xbf, 0xf4, 0x98, 0xaa, 0x93, 0x8c, 0xe7, 167 0x39, 0xb8, 0xe0, 0x22, 0xfb, 0xaf, 0xef, 0x40, 168 0x56, 0x3f, 0x6e, 0x6a, 0x34, 0x72, 0xfc, 0x2a, 169 0x51, 0x4c, 0x0c, 0xe9, 0xda, 0xe2, 0x3b, 0x7e, 170 }; 171 172 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_b); 173 174 #define CURVE_GOST_R3410_2001_TESTPARAMSET_CURVE_ORDER_BITLEN 256 175 static const u8 gost_R3410_2001_TestParamSet_curve_order[] = { 176 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 177 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 178 0x50, 0xfe, 0x8a, 0x18, 0x92, 0x97, 0x61, 0x54, 179 0xc5, 0x9c, 0xfc, 0x19, 0x3a, 0xcc, 0xf5, 0xb3, 180 }; 181 182 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_curve_order); 183 184 static const u8 gost_R3410_2001_TestParamSet_gx[] = { 185 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 186 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 187 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 188 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 189 }; 190 191 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_gx); 192 193 static const u8 gost_R3410_2001_TestParamSet_gy[] = { 194 0x08, 0xe2, 0xa8, 0xa0, 0xe6, 0x51, 0x47, 0xd4, 195 0xbd, 0x63, 0x16, 0x03, 0x0e, 0x16, 0xd1, 0x9c, 196 0x85, 0xc9, 0x7f, 0x0a, 0x9c, 0xa2, 0x67, 0x12, 197 0x2b, 0x96, 0xab, 0xbc, 0xea, 0x7e, 0x8f, 0xc8, 198 }; 199 200 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_gy); 201 202 static const u8 gost_R3410_2001_TestParamSet_gz[] = { 203 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 204 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 206 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 207 }; 208 209 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_gz); 210 211 static const u8 gost_R3410_2001_TestParamSet_gen_order[] = { 212 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 213 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 214 0x50, 0xfe, 0x8a, 0x18, 0x92, 0x97, 0x61, 0x54, 215 0xc5, 0x9c, 0xfc, 0x19, 0x3a, 0xcc, 0xf5, 0xb3, 216 }; 217 218 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_gen_order); 219 220 #define CURVE_GOST_R3410_2001_TESTPARAMSET_Q_BITLEN 256 221 static const u8 gost_R3410_2001_TestParamSet_gen_order_bitlen[] = { 222 0x01, 0x00, 223 }; 224 225 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_gen_order_bitlen); 226 227 static const u8 gost_R3410_2001_TestParamSet_cofactor[] = { 228 0x01, 229 }; 230 231 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_cofactor); 232 233 static const u8 gost_R3410_2001_TestParamSet_alpha_montgomery[] = { 234 0x00, 235 }; 236 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_TestParamSet_alpha_montgomery, 0); 237 238 static const u8 gost_R3410_2001_TestParamSet_gamma_montgomery[] = { 239 0x00, 240 }; 241 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_TestParamSet_gamma_montgomery, 0); 242 243 static const u8 gost_R3410_2001_TestParamSet_alpha_edwards[] = { 244 0x00, 245 }; 246 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2001_TestParamSet_alpha_edwards, 0); 247 248 static const u8 gost_R3410_2001_TestParamSet_name[] = "GOST_R3410_2001_TESTPARAMSET"; 249 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_name); 250 251 static const u8 gost_R3410_2001_TestParamSet_oid[] = "1.2.643.2.2.35.0"; 252 TO_EC_STR_PARAM(gost_R3410_2001_TestParamSet_oid); 253 254 static const ec_str_params gost_R3410_2001_TestParamSet_str_params = { 255 .p = &gost_R3410_2001_TestParamSet_p_str_param, 256 .p_bitlen = &gost_R3410_2001_TestParamSet_p_bitlen_str_param, 257 .r = &gost_R3410_2001_TestParamSet_r_str_param, 258 .r_square = &gost_R3410_2001_TestParamSet_r_square_str_param, 259 .mpinv = &gost_R3410_2001_TestParamSet_mpinv_str_param, 260 .p_shift = &gost_R3410_2001_TestParamSet_p_shift_str_param, 261 .p_normalized = &gost_R3410_2001_TestParamSet_p_normalized_str_param, 262 .p_reciprocal = &gost_R3410_2001_TestParamSet_p_reciprocal_str_param, 263 .a = &gost_R3410_2001_TestParamSet_a_str_param, 264 .b = &gost_R3410_2001_TestParamSet_b_str_param, 265 .curve_order = &gost_R3410_2001_TestParamSet_curve_order_str_param, 266 .gx = &gost_R3410_2001_TestParamSet_gx_str_param, 267 .gy = &gost_R3410_2001_TestParamSet_gy_str_param, 268 .gz = &gost_R3410_2001_TestParamSet_gz_str_param, 269 .gen_order = &gost_R3410_2001_TestParamSet_gen_order_str_param, 270 .gen_order_bitlen = &gost_R3410_2001_TestParamSet_gen_order_bitlen_str_param, 271 .cofactor = &gost_R3410_2001_TestParamSet_cofactor_str_param, 272 .alpha_montgomery = &gost_R3410_2001_TestParamSet_alpha_montgomery_str_param, 273 .gamma_montgomery = &gost_R3410_2001_TestParamSet_gamma_montgomery_str_param, 274 .alpha_edwards = &gost_R3410_2001_TestParamSet_alpha_edwards_str_param, 275 .oid = &gost_R3410_2001_TestParamSet_oid_str_param, 276 .name = &gost_R3410_2001_TestParamSet_name_str_param, 277 }; 278 279 /* 280 * Compute max bit length of all curves for p and q 281 */ 282 #ifndef CURVES_MAX_P_BIT_LEN 283 #define CURVES_MAX_P_BIT_LEN 0 284 #endif 285 #if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2001_TESTPARAMSET_P_BITLEN) 286 #undef CURVES_MAX_P_BIT_LEN 287 #define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2001_TESTPARAMSET_P_BITLEN 288 #endif 289 #ifndef CURVES_MAX_Q_BIT_LEN 290 #define CURVES_MAX_Q_BIT_LEN 0 291 #endif 292 #if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2001_TESTPARAMSET_Q_BITLEN) 293 #undef CURVES_MAX_Q_BIT_LEN 294 #define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2001_TESTPARAMSET_Q_BITLEN 295 #endif 296 #ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN 297 #define CURVES_MAX_CURVE_ORDER_BIT_LEN 0 298 #endif 299 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2001_TESTPARAMSET_CURVE_ORDER_BITLEN) 300 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN 301 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2001_TESTPARAMSET_CURVE_ORDER_BITLEN 302 #endif 303 304 /* 305 * Compute and adapt max name and oid length 306 */ 307 #ifndef MAX_CURVE_OID_LEN 308 #define MAX_CURVE_OID_LEN 0 309 #endif 310 #ifndef MAX_CURVE_NAME_LEN 311 #define MAX_CURVE_NAME_LEN 0 312 #endif 313 #if (MAX_CURVE_OID_LEN < 17) 314 #undef MAX_CURVE_OID_LEN 315 #define MAX_CURVE_OID_LEN 17 316 #endif 317 #if (MAX_CURVE_NAME_LEN < 44) 318 #undef MAX_CURVE_NAME_LEN 319 #define MAX_CURVE_NAME_LEN 44 320 #endif 321 322 #endif /* __EC_PARAMS_GOST_R3410_2001_TESTPARAMSET_H__ */ 323 324 #endif /* WITH_CURVE_GOST_R3410_2001_TESTPARAMSET */ 325