1 #include <libecc/lib_ecc_config.h> 2 #ifdef WITH_CURVE_GOST_R3410_2012_256_PARAMSETB 3 4 #ifndef __EC_PARAMS_GOST_R3410_2012_256_PARAMSETB_H__ 5 #define __EC_PARAMS_GOST_R3410_2012_256_PARAMSETB_H__ 6 #include <libecc/curves/known/ec_params_external.h> 7 static const u8 gost_R3410_2012_256_paramSetB_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, 0xfd, 0x97, 12 }; 13 14 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p); 15 16 #define CURVE_GOST_R3410_2012_256_PARAMSETB_P_BITLEN 256 17 static const u8 gost_R3410_2012_256_paramSetB_p_bitlen[] = { 18 0x01, 0x00, 19 }; 20 21 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_bitlen); 22 23 #if (WORD_BYTES == 8) /* 64-bit words */ 24 static const u8 gost_R3410_2012_256_paramSetB_r[] = { 25 0x02, 0x69, 26 }; 27 28 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_r); 29 30 static const u8 gost_R3410_2012_256_paramSetB_r_square[] = { 31 0x05, 0xcf, 0x11, 32 }; 33 34 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_r_square); 35 36 static const u8 gost_R3410_2012_256_paramSetB_mpinv[] = { 37 0x46, 0xf3, 0x23, 0x44, 0x75, 0xd5, 0xad, 0xd9, 38 }; 39 40 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_mpinv); 41 42 static const u8 gost_R3410_2012_256_paramSetB_p_shift[] = { 43 0x00, 44 }; 45 46 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_shift); 47 48 static const u8 gost_R3410_2012_256_paramSetB_p_normalized[] = { 49 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 50 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 51 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 52 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97, 53 }; 54 55 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_normalized); 56 57 static const u8 gost_R3410_2012_256_paramSetB_p_reciprocal[] = { 58 0x00, 59 }; 60 61 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_reciprocal); 62 63 #elif (WORD_BYTES == 4) /* 32-bit words */ 64 static const u8 gost_R3410_2012_256_paramSetB_r[] = { 65 0x02, 0x69, 66 }; 67 68 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_r); 69 70 static const u8 gost_R3410_2012_256_paramSetB_r_square[] = { 71 0x05, 0xcf, 0x11, 72 }; 73 74 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_r_square); 75 76 static const u8 gost_R3410_2012_256_paramSetB_mpinv[] = { 77 0x75, 0xd5, 0xad, 0xd9, 78 }; 79 80 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_mpinv); 81 82 static const u8 gost_R3410_2012_256_paramSetB_p_shift[] = { 83 0x00, 84 }; 85 86 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_shift); 87 88 static const u8 gost_R3410_2012_256_paramSetB_p_normalized[] = { 89 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 90 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 91 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 92 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97, 93 }; 94 95 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_normalized); 96 97 static const u8 gost_R3410_2012_256_paramSetB_p_reciprocal[] = { 98 0x00, 99 }; 100 101 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_reciprocal); 102 103 #elif (WORD_BYTES == 2) /* 16-bit words */ 104 static const u8 gost_R3410_2012_256_paramSetB_r[] = { 105 0x02, 0x69, 106 }; 107 108 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_r); 109 110 static const u8 gost_R3410_2012_256_paramSetB_r_square[] = { 111 0x05, 0xcf, 0x11, 112 }; 113 114 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_r_square); 115 116 static const u8 gost_R3410_2012_256_paramSetB_mpinv[] = { 117 0xad, 0xd9, 118 }; 119 120 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_mpinv); 121 122 static const u8 gost_R3410_2012_256_paramSetB_p_shift[] = { 123 0x00, 124 }; 125 126 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_shift); 127 128 static const u8 gost_R3410_2012_256_paramSetB_p_normalized[] = { 129 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 130 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 131 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 132 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x97, 133 }; 134 135 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_normalized); 136 137 static const u8 gost_R3410_2012_256_paramSetB_p_reciprocal[] = { 138 0x00, 139 }; 140 141 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_p_reciprocal); 142 143 #else /* unknown word size */ 144 #error "Unsupported word size" 145 #endif 146 147 static const u8 gost_R3410_2012_256_paramSetB_a[] = { 148 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 149 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 150 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 151 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x94, 152 }; 153 154 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_a); 155 156 static const u8 gost_R3410_2012_256_paramSetB_b[] = { 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, 0xa6, 161 }; 162 163 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_b); 164 165 #define CURVE_GOST_R3410_2012_256_PARAMSETB_CURVE_ORDER_BITLEN 256 166 static const u8 gost_R3410_2012_256_paramSetB_curve_order[] = { 167 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 168 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 169 0x6c, 0x61, 0x10, 0x70, 0x99, 0x5a, 0xd1, 0x00, 170 0x45, 0x84, 0x1b, 0x09, 0xb7, 0x61, 0xb8, 0x93, 171 }; 172 173 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_curve_order); 174 175 static const u8 gost_R3410_2012_256_paramSetB_gx[] = { 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, 0x00, 0x00, 179 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 180 }; 181 182 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_gx); 183 184 static const u8 gost_R3410_2012_256_paramSetB_gy[] = { 185 0x8d, 0x91, 0xe4, 0x71, 0xe0, 0x98, 0x9c, 0xda, 186 0x27, 0xdf, 0x50, 0x5a, 0x45, 0x3f, 0x2b, 0x76, 187 0x35, 0x29, 0x4f, 0x2d, 0xdf, 0x23, 0xe3, 0xb1, 188 0x22, 0xac, 0xc9, 0x9c, 0x9e, 0x9f, 0x1e, 0x14, 189 }; 190 191 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_gy); 192 193 static const u8 gost_R3410_2012_256_paramSetB_gz[] = { 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, 0x01, 198 }; 199 200 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_gz); 201 202 static const u8 gost_R3410_2012_256_paramSetB_gen_order[] = { 203 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 204 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 205 0x6c, 0x61, 0x10, 0x70, 0x99, 0x5a, 0xd1, 0x00, 206 0x45, 0x84, 0x1b, 0x09, 0xb7, 0x61, 0xb8, 0x93, 207 }; 208 209 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_gen_order); 210 211 #define CURVE_GOST_R3410_2012_256_PARAMSETB_Q_BITLEN 256 212 static const u8 gost_R3410_2012_256_paramSetB_gen_order_bitlen[] = { 213 0x01, 0x00, 214 }; 215 216 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_gen_order_bitlen); 217 218 static const u8 gost_R3410_2012_256_paramSetB_cofactor[] = { 219 0x01, 220 }; 221 222 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_cofactor); 223 224 static const u8 gost_R3410_2012_256_paramSetB_alpha_montgomery[] = { 225 0x00, 226 }; 227 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetB_alpha_montgomery, 0); 228 229 static const u8 gost_R3410_2012_256_paramSetB_gamma_montgomery[] = { 230 0x00, 231 }; 232 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetB_gamma_montgomery, 0); 233 234 static const u8 gost_R3410_2012_256_paramSetB_alpha_edwards[] = { 235 0x00, 236 }; 237 TO_EC_STR_PARAM_FIXED_SIZE(gost_R3410_2012_256_paramSetB_alpha_edwards, 0); 238 239 static const u8 gost_R3410_2012_256_paramSetB_name[] = "GOST_R3410_2012_256_PARAMSETB"; 240 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_name); 241 242 static const u8 gost_R3410_2012_256_paramSetB_oid[] = "1.2.643.7.1.2.1.1.2"; 243 TO_EC_STR_PARAM(gost_R3410_2012_256_paramSetB_oid); 244 245 static const ec_str_params gost_R3410_2012_256_paramSetB_str_params = { 246 .p = &gost_R3410_2012_256_paramSetB_p_str_param, 247 .p_bitlen = &gost_R3410_2012_256_paramSetB_p_bitlen_str_param, 248 .r = &gost_R3410_2012_256_paramSetB_r_str_param, 249 .r_square = &gost_R3410_2012_256_paramSetB_r_square_str_param, 250 .mpinv = &gost_R3410_2012_256_paramSetB_mpinv_str_param, 251 .p_shift = &gost_R3410_2012_256_paramSetB_p_shift_str_param, 252 .p_normalized = &gost_R3410_2012_256_paramSetB_p_normalized_str_param, 253 .p_reciprocal = &gost_R3410_2012_256_paramSetB_p_reciprocal_str_param, 254 .a = &gost_R3410_2012_256_paramSetB_a_str_param, 255 .b = &gost_R3410_2012_256_paramSetB_b_str_param, 256 .curve_order = &gost_R3410_2012_256_paramSetB_curve_order_str_param, 257 .gx = &gost_R3410_2012_256_paramSetB_gx_str_param, 258 .gy = &gost_R3410_2012_256_paramSetB_gy_str_param, 259 .gz = &gost_R3410_2012_256_paramSetB_gz_str_param, 260 .gen_order = &gost_R3410_2012_256_paramSetB_gen_order_str_param, 261 .gen_order_bitlen = &gost_R3410_2012_256_paramSetB_gen_order_bitlen_str_param, 262 .cofactor = &gost_R3410_2012_256_paramSetB_cofactor_str_param, 263 .alpha_montgomery = &gost_R3410_2012_256_paramSetB_alpha_montgomery_str_param, 264 .gamma_montgomery = &gost_R3410_2012_256_paramSetB_gamma_montgomery_str_param, 265 .alpha_edwards = &gost_R3410_2012_256_paramSetB_alpha_edwards_str_param, 266 .oid = &gost_R3410_2012_256_paramSetB_oid_str_param, 267 .name = &gost_R3410_2012_256_paramSetB_name_str_param, 268 }; 269 270 /* 271 * Compute max bit length of all curves for p and q 272 */ 273 #ifndef CURVES_MAX_P_BIT_LEN 274 #define CURVES_MAX_P_BIT_LEN 0 275 #endif 276 #if (CURVES_MAX_P_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETB_P_BITLEN) 277 #undef CURVES_MAX_P_BIT_LEN 278 #define CURVES_MAX_P_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETB_P_BITLEN 279 #endif 280 #ifndef CURVES_MAX_Q_BIT_LEN 281 #define CURVES_MAX_Q_BIT_LEN 0 282 #endif 283 #if (CURVES_MAX_Q_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETB_Q_BITLEN) 284 #undef CURVES_MAX_Q_BIT_LEN 285 #define CURVES_MAX_Q_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETB_Q_BITLEN 286 #endif 287 #ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN 288 #define CURVES_MAX_CURVE_ORDER_BIT_LEN 0 289 #endif 290 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_GOST_R3410_2012_256_PARAMSETB_CURVE_ORDER_BITLEN) 291 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN 292 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_GOST_R3410_2012_256_PARAMSETB_CURVE_ORDER_BITLEN 293 #endif 294 295 /* 296 * Compute and adapt max name and oid length 297 */ 298 #ifndef MAX_CURVE_OID_LEN 299 #define MAX_CURVE_OID_LEN 0 300 #endif 301 #ifndef MAX_CURVE_NAME_LEN 302 #define MAX_CURVE_NAME_LEN 0 303 #endif 304 #if (MAX_CURVE_OID_LEN < 20) 305 #undef MAX_CURVE_OID_LEN 306 #define MAX_CURVE_OID_LEN 20 307 #endif 308 #if (MAX_CURVE_NAME_LEN < 50) 309 #undef MAX_CURVE_NAME_LEN 310 #define MAX_CURVE_NAME_LEN 50 311 #endif 312 313 #endif /* __EC_PARAMS_GOST_R3410_2012_256_PARAMSETB_H__ */ 314 315 #endif /* WITH_CURVE_GOST_R3410_2012_256_PARAMSETB */ 316