1 #include <libecc/lib_ecc_config.h> 2 #ifdef WITH_CURVE_BIGN256V1 3 4 #ifndef __EC_PARAMS_BIGN256V1_H__ 5 #define __EC_PARAMS_BIGN256V1_H__ 6 #include <libecc/curves/known/ec_params_external.h> 7 static const u8 bign256v1_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, 0x43, 12 }; 13 14 TO_EC_STR_PARAM(bign256v1_p); 15 16 #define CURVE_BIGN256V1_P_BITLEN 256 17 static const u8 bign256v1_p_bitlen[] = { 18 0x01, 0x00, 19 }; 20 21 TO_EC_STR_PARAM(bign256v1_p_bitlen); 22 23 #if (WORD_BYTES == 8) /* 64-bit words */ 24 static const u8 bign256v1_r[] = { 25 0xbd, 26 }; 27 28 TO_EC_STR_PARAM(bign256v1_r); 29 30 static const u8 bign256v1_r_square[] = { 31 0x8b, 0x89, 32 }; 33 34 TO_EC_STR_PARAM(bign256v1_r_square); 35 36 static const u8 bign256v1_mpinv[] = { 37 0xa5, 0x3f, 0xa9, 0x4f, 0xea, 0x53, 0xfa, 0x95, 38 }; 39 40 TO_EC_STR_PARAM(bign256v1_mpinv); 41 42 static const u8 bign256v1_p_shift[] = { 43 0x00, 44 }; 45 46 TO_EC_STR_PARAM(bign256v1_p_shift); 47 48 static const u8 bign256v1_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, 0xff, 0x43, 53 }; 54 55 TO_EC_STR_PARAM(bign256v1_p_normalized); 56 57 static const u8 bign256v1_p_reciprocal[] = { 58 0x00, 59 }; 60 61 TO_EC_STR_PARAM(bign256v1_p_reciprocal); 62 63 #elif (WORD_BYTES == 4) /* 32-bit words */ 64 static const u8 bign256v1_r[] = { 65 0xbd, 66 }; 67 68 TO_EC_STR_PARAM(bign256v1_r); 69 70 static const u8 bign256v1_r_square[] = { 71 0x8b, 0x89, 72 }; 73 74 TO_EC_STR_PARAM(bign256v1_r_square); 75 76 static const u8 bign256v1_mpinv[] = { 77 0xea, 0x53, 0xfa, 0x95, 78 }; 79 80 TO_EC_STR_PARAM(bign256v1_mpinv); 81 82 static const u8 bign256v1_p_shift[] = { 83 0x00, 84 }; 85 86 TO_EC_STR_PARAM(bign256v1_p_shift); 87 88 static const u8 bign256v1_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, 0xff, 0x43, 93 }; 94 95 TO_EC_STR_PARAM(bign256v1_p_normalized); 96 97 static const u8 bign256v1_p_reciprocal[] = { 98 0x00, 99 }; 100 101 TO_EC_STR_PARAM(bign256v1_p_reciprocal); 102 103 #elif (WORD_BYTES == 2) /* 16-bit words */ 104 static const u8 bign256v1_r[] = { 105 0xbd, 106 }; 107 108 TO_EC_STR_PARAM(bign256v1_r); 109 110 static const u8 bign256v1_r_square[] = { 111 0x8b, 0x89, 112 }; 113 114 TO_EC_STR_PARAM(bign256v1_r_square); 115 116 static const u8 bign256v1_mpinv[] = { 117 0xfa, 0x95, 118 }; 119 120 TO_EC_STR_PARAM(bign256v1_mpinv); 121 122 static const u8 bign256v1_p_shift[] = { 123 0x00, 124 }; 125 126 TO_EC_STR_PARAM(bign256v1_p_shift); 127 128 static const u8 bign256v1_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, 0xff, 0x43, 133 }; 134 135 TO_EC_STR_PARAM(bign256v1_p_normalized); 136 137 static const u8 bign256v1_p_reciprocal[] = { 138 0x00, 139 }; 140 141 TO_EC_STR_PARAM(bign256v1_p_reciprocal); 142 143 #else /* unknown word size */ 144 #error "Unsupported word size" 145 #endif 146 147 static const u8 bign256v1_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, 0xff, 0x40, 152 }; 153 154 TO_EC_STR_PARAM(bign256v1_a); 155 156 static const u8 bign256v1_b[] = { 157 0x77, 0xce, 0x6c, 0x15, 0x15, 0xf3, 0xa8, 0xed, 158 0xd2, 0xc1, 0x3a, 0xab, 0xe4, 0xd8, 0xfb, 0xbe, 159 0x4c, 0xf5, 0x50, 0x69, 0x97, 0x8b, 0x92, 0x53, 160 0xb2, 0x2e, 0x7d, 0x6b, 0xd6, 0x9c, 0x03, 0xf1, 161 }; 162 163 TO_EC_STR_PARAM(bign256v1_b); 164 165 #define CURVE_BIGN256V1_CURVE_ORDER_BITLEN 256 166 static const u8 bign256v1_curve_order[] = { 167 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 168 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 169 0xd9, 0x5c, 0x8e, 0xd6, 0x0d, 0xfb, 0x4d, 0xfc, 170 0x7e, 0x5a, 0xbf, 0x99, 0x26, 0x3d, 0x66, 0x07, 171 }; 172 173 TO_EC_STR_PARAM(bign256v1_curve_order); 174 175 static const u8 bign256v1_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, 0x00, 180 }; 181 182 TO_EC_STR_PARAM(bign256v1_gx); 183 184 static const u8 bign256v1_gy[] = { 185 0x6b, 0xf7, 0xfc, 0x3c, 0xfb, 0x16, 0xd6, 0x9f, 186 0x5c, 0xe4, 0xc9, 0xa3, 0x51, 0xd6, 0x83, 0x5d, 187 0x78, 0x91, 0x39, 0x66, 0xc4, 0x08, 0xf6, 0x52, 188 0x1e, 0x29, 0xcf, 0x18, 0x04, 0x51, 0x6a, 0x93, 189 }; 190 191 TO_EC_STR_PARAM(bign256v1_gy); 192 193 static const u8 bign256v1_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(bign256v1_gz); 201 202 static const u8 bign256v1_gen_order[] = { 203 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 204 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 205 0xd9, 0x5c, 0x8e, 0xd6, 0x0d, 0xfb, 0x4d, 0xfc, 206 0x7e, 0x5a, 0xbf, 0x99, 0x26, 0x3d, 0x66, 0x07, 207 }; 208 209 TO_EC_STR_PARAM(bign256v1_gen_order); 210 211 #define CURVE_BIGN256V1_Q_BITLEN 256 212 static const u8 bign256v1_gen_order_bitlen[] = { 213 0x01, 0x00, 214 }; 215 216 TO_EC_STR_PARAM(bign256v1_gen_order_bitlen); 217 218 static const u8 bign256v1_cofactor[] = { 219 0x01, 220 }; 221 222 TO_EC_STR_PARAM(bign256v1_cofactor); 223 224 static const u8 bign256v1_alpha_montgomery[] = { 225 0x00, 226 }; 227 TO_EC_STR_PARAM_FIXED_SIZE(bign256v1_alpha_montgomery, 0); 228 229 static const u8 bign256v1_gamma_montgomery[] = { 230 0x00, 231 }; 232 TO_EC_STR_PARAM_FIXED_SIZE(bign256v1_gamma_montgomery, 0); 233 234 static const u8 bign256v1_alpha_edwards[] = { 235 0x00, 236 }; 237 TO_EC_STR_PARAM_FIXED_SIZE(bign256v1_alpha_edwards, 0); 238 239 static const u8 bign256v1_name[] = "BIGN256V1"; 240 TO_EC_STR_PARAM(bign256v1_name); 241 242 static const u8 bign256v1_oid[] = "1.2.112.0.2.0.34.101.45.3.1"; 243 TO_EC_STR_PARAM(bign256v1_oid); 244 245 static const ec_str_params bign256v1_str_params = { 246 .p = &bign256v1_p_str_param, 247 .p_bitlen = &bign256v1_p_bitlen_str_param, 248 .r = &bign256v1_r_str_param, 249 .r_square = &bign256v1_r_square_str_param, 250 .mpinv = &bign256v1_mpinv_str_param, 251 .p_shift = &bign256v1_p_shift_str_param, 252 .p_normalized = &bign256v1_p_normalized_str_param, 253 .p_reciprocal = &bign256v1_p_reciprocal_str_param, 254 .a = &bign256v1_a_str_param, 255 .b = &bign256v1_b_str_param, 256 .curve_order = &bign256v1_curve_order_str_param, 257 .gx = &bign256v1_gx_str_param, 258 .gy = &bign256v1_gy_str_param, 259 .gz = &bign256v1_gz_str_param, 260 .gen_order = &bign256v1_gen_order_str_param, 261 .gen_order_bitlen = &bign256v1_gen_order_bitlen_str_param, 262 .cofactor = &bign256v1_cofactor_str_param, 263 .alpha_montgomery = &bign256v1_alpha_montgomery_str_param, 264 .gamma_montgomery = &bign256v1_gamma_montgomery_str_param, 265 .alpha_edwards = &bign256v1_alpha_edwards_str_param, 266 .oid = &bign256v1_oid_str_param, 267 .name = &bign256v1_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_BIGN256V1_P_BITLEN) 277 #undef CURVES_MAX_P_BIT_LEN 278 #define CURVES_MAX_P_BIT_LEN CURVE_BIGN256V1_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_BIGN256V1_Q_BITLEN) 284 #undef CURVES_MAX_Q_BIT_LEN 285 #define CURVES_MAX_Q_BIT_LEN CURVE_BIGN256V1_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_BIGN256V1_CURVE_ORDER_BITLEN) 291 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN 292 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BIGN256V1_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 < 1) 305 #undef MAX_CURVE_OID_LEN 306 #define MAX_CURVE_OID_LEN 1 307 #endif 308 #if (MAX_CURVE_NAME_LEN < 23) 309 #undef MAX_CURVE_NAME_LEN 310 #define MAX_CURVE_NAME_LEN 23 311 #endif 312 313 #endif /* __EC_PARAMS_BIGN256V1_H__ */ 314 315 #endif /* WITH_CURVE_BIGN256V1 */ 316