1 #include <libecc/lib_ecc_config.h> 2 #ifdef WITH_CURVE_BRAINPOOLP192T1 3 4 #ifndef __EC_PARAMS_BRAINPOOLP192T1_H__ 5 #define __EC_PARAMS_BRAINPOOLP192T1_H__ 6 #include <libecc/curves/known/ec_params_external.h> 7 static const u8 brainpoolp192t1_p[] = { 8 0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd, 9 0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7, 10 0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x97, 11 }; 12 13 TO_EC_STR_PARAM(brainpoolp192t1_p); 14 15 #define CURVE_BRAINPOOLP192T1_P_BITLEN 192 16 static const u8 brainpoolp192t1_p_bitlen[] = { 17 0xc0, 18 }; 19 20 TO_EC_STR_PARAM(brainpoolp192t1_p_bitlen); 21 22 #if (WORD_BYTES == 8) /* 64-bit words */ 23 static const u8 brainpoolp192t1_r[] = { 24 0x3c, 0xfd, 0x0b, 0xe2, 0x6c, 0xd5, 0xc9, 0x32, 25 0x58, 0x5c, 0xb9, 0xcf, 0x6c, 0x2e, 0x72, 0x48, 26 0x70, 0x31, 0xb8, 0x92, 0x1e, 0x57, 0x9d, 0x69, 27 }; 28 29 TO_EC_STR_PARAM(brainpoolp192t1_r); 30 31 static const u8 brainpoolp192t1_r_square[] = { 32 0xb6, 0x22, 0x51, 0x26, 0xee, 0xd3, 0x4f, 0x10, 33 0x33, 0xbf, 0x48, 0x46, 0x02, 0xc3, 0xfe, 0x69, 34 0xe2, 0x47, 0x4c, 0x69, 0x72, 0xc7, 0xb2, 0x1a, 35 }; 36 37 TO_EC_STR_PARAM(brainpoolp192t1_r_square); 38 39 static const u8 brainpoolp192t1_mpinv[] = { 40 0xe0, 0x84, 0x96, 0xdb, 0x56, 0xa2, 0xc2, 0xd9, 41 }; 42 43 TO_EC_STR_PARAM(brainpoolp192t1_mpinv); 44 45 static const u8 brainpoolp192t1_p_shift[] = { 46 0x00, 47 }; 48 49 TO_EC_STR_PARAM(brainpoolp192t1_p_shift); 50 51 static const u8 brainpoolp192t1_p_normalized[] = { 52 0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd, 53 0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7, 54 0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x97, 55 }; 56 57 TO_EC_STR_PARAM(brainpoolp192t1_p_normalized); 58 59 static const u8 brainpoolp192t1_p_reciprocal[] = { 60 0x50, 0x0f, 0xea, 0x39, 0xff, 0x17, 0x28, 0xc8, 61 }; 62 63 TO_EC_STR_PARAM(brainpoolp192t1_p_reciprocal); 64 65 #elif (WORD_BYTES == 4) /* 32-bit words */ 66 static const u8 brainpoolp192t1_r[] = { 67 0x3c, 0xfd, 0x0b, 0xe2, 0x6c, 0xd5, 0xc9, 0x32, 68 0x58, 0x5c, 0xb9, 0xcf, 0x6c, 0x2e, 0x72, 0x48, 69 0x70, 0x31, 0xb8, 0x92, 0x1e, 0x57, 0x9d, 0x69, 70 }; 71 72 TO_EC_STR_PARAM(brainpoolp192t1_r); 73 74 static const u8 brainpoolp192t1_r_square[] = { 75 0xb6, 0x22, 0x51, 0x26, 0xee, 0xd3, 0x4f, 0x10, 76 0x33, 0xbf, 0x48, 0x46, 0x02, 0xc3, 0xfe, 0x69, 77 0xe2, 0x47, 0x4c, 0x69, 0x72, 0xc7, 0xb2, 0x1a, 78 }; 79 80 TO_EC_STR_PARAM(brainpoolp192t1_r_square); 81 82 static const u8 brainpoolp192t1_mpinv[] = { 83 0x56, 0xa2, 0xc2, 0xd9, 84 }; 85 86 TO_EC_STR_PARAM(brainpoolp192t1_mpinv); 87 88 static const u8 brainpoolp192t1_p_shift[] = { 89 0x00, 90 }; 91 92 TO_EC_STR_PARAM(brainpoolp192t1_p_shift); 93 94 static const u8 brainpoolp192t1_p_normalized[] = { 95 0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd, 96 0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7, 97 0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x97, 98 }; 99 100 TO_EC_STR_PARAM(brainpoolp192t1_p_normalized); 101 102 static const u8 brainpoolp192t1_p_reciprocal[] = { 103 0x50, 0x0f, 0xea, 0x39, 104 }; 105 106 TO_EC_STR_PARAM(brainpoolp192t1_p_reciprocal); 107 108 #elif (WORD_BYTES == 2) /* 16-bit words */ 109 static const u8 brainpoolp192t1_r[] = { 110 0x3c, 0xfd, 0x0b, 0xe2, 0x6c, 0xd5, 0xc9, 0x32, 111 0x58, 0x5c, 0xb9, 0xcf, 0x6c, 0x2e, 0x72, 0x48, 112 0x70, 0x31, 0xb8, 0x92, 0x1e, 0x57, 0x9d, 0x69, 113 }; 114 115 TO_EC_STR_PARAM(brainpoolp192t1_r); 116 117 static const u8 brainpoolp192t1_r_square[] = { 118 0xb6, 0x22, 0x51, 0x26, 0xee, 0xd3, 0x4f, 0x10, 119 0x33, 0xbf, 0x48, 0x46, 0x02, 0xc3, 0xfe, 0x69, 120 0xe2, 0x47, 0x4c, 0x69, 0x72, 0xc7, 0xb2, 0x1a, 121 }; 122 123 TO_EC_STR_PARAM(brainpoolp192t1_r_square); 124 125 static const u8 brainpoolp192t1_mpinv[] = { 126 0xc2, 0xd9, 127 }; 128 129 TO_EC_STR_PARAM(brainpoolp192t1_mpinv); 130 131 static const u8 brainpoolp192t1_p_shift[] = { 132 0x00, 133 }; 134 135 TO_EC_STR_PARAM(brainpoolp192t1_p_shift); 136 137 static const u8 brainpoolp192t1_p_normalized[] = { 138 0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd, 139 0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7, 140 0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x97, 141 }; 142 143 TO_EC_STR_PARAM(brainpoolp192t1_p_normalized); 144 145 static const u8 brainpoolp192t1_p_reciprocal[] = { 146 0x50, 0x0f, 147 }; 148 149 TO_EC_STR_PARAM(brainpoolp192t1_p_reciprocal); 150 151 #else /* unknown word size */ 152 #error "Unsupported word size" 153 #endif 154 155 static const u8 brainpoolp192t1_a[] = { 156 0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd, 157 0xa7, 0xa3, 0x46, 0x30, 0x93, 0xd1, 0x8d, 0xb7, 158 0x8f, 0xce, 0x47, 0x6d, 0xe1, 0xa8, 0x62, 0x94, 159 }; 160 161 TO_EC_STR_PARAM(brainpoolp192t1_a); 162 163 static const u8 brainpoolp192t1_b[] = { 164 0x13, 0xd5, 0x6f, 0xfa, 0xec, 0x78, 0x68, 0x1e, 165 0x68, 0xf9, 0xde, 0xb4, 0x3b, 0x35, 0xbe, 0xc2, 166 0xfb, 0x68, 0x54, 0x2e, 0x27, 0x89, 0x7b, 0x79, 167 }; 168 169 TO_EC_STR_PARAM(brainpoolp192t1_b); 170 171 #define CURVE_BRAINPOOLP192T1_CURVE_ORDER_BITLEN 192 172 static const u8 brainpoolp192t1_curve_order[] = { 173 0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd, 174 0xa7, 0xa3, 0x46, 0x2f, 0x9e, 0x9e, 0x91, 0x6b, 175 0x5b, 0xe8, 0xf1, 0x02, 0x9a, 0xc4, 0xac, 0xc1, 176 }; 177 178 TO_EC_STR_PARAM(brainpoolp192t1_curve_order); 179 180 static const u8 brainpoolp192t1_gx[] = { 181 0x3a, 0xe9, 0xe5, 0x8c, 0x82, 0xf6, 0x3c, 0x30, 182 0x28, 0x2e, 0x1f, 0xe7, 0xbb, 0xf4, 0x3f, 0xa7, 183 0x2c, 0x44, 0x6a, 0xf6, 0xf4, 0x61, 0x81, 0x29, 184 }; 185 186 TO_EC_STR_PARAM(brainpoolp192t1_gx); 187 188 static const u8 brainpoolp192t1_gy[] = { 189 0x09, 0x7e, 0x2c, 0x56, 0x67, 0xc2, 0x22, 0x3a, 190 0x90, 0x2a, 0xb5, 0xca, 0x44, 0x9d, 0x00, 0x84, 191 0xb7, 0xe5, 0xb3, 0xde, 0x7c, 0xcc, 0x01, 0xc9, 192 }; 193 194 TO_EC_STR_PARAM(brainpoolp192t1_gy); 195 196 static const u8 brainpoolp192t1_gz[] = { 197 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 198 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 200 }; 201 202 TO_EC_STR_PARAM(brainpoolp192t1_gz); 203 204 static const u8 brainpoolp192t1_gen_order[] = { 205 0xc3, 0x02, 0xf4, 0x1d, 0x93, 0x2a, 0x36, 0xcd, 206 0xa7, 0xa3, 0x46, 0x2f, 0x9e, 0x9e, 0x91, 0x6b, 207 0x5b, 0xe8, 0xf1, 0x02, 0x9a, 0xc4, 0xac, 0xc1, 208 }; 209 210 TO_EC_STR_PARAM(brainpoolp192t1_gen_order); 211 212 #define CURVE_BRAINPOOLP192T1_Q_BITLEN 192 213 static const u8 brainpoolp192t1_gen_order_bitlen[] = { 214 0xc0, 215 }; 216 217 TO_EC_STR_PARAM(brainpoolp192t1_gen_order_bitlen); 218 219 static const u8 brainpoolp192t1_cofactor[] = { 220 0x01, 221 }; 222 223 TO_EC_STR_PARAM(brainpoolp192t1_cofactor); 224 225 static const u8 brainpoolp192t1_alpha_montgomery[] = { 226 0x00, 227 }; 228 TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp192t1_alpha_montgomery, 0); 229 230 static const u8 brainpoolp192t1_gamma_montgomery[] = { 231 0x00, 232 }; 233 TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp192t1_gamma_montgomery, 0); 234 235 static const u8 brainpoolp192t1_alpha_edwards[] = { 236 0x00, 237 }; 238 TO_EC_STR_PARAM_FIXED_SIZE(brainpoolp192t1_alpha_edwards, 0); 239 240 static const u8 brainpoolp192t1_name[] = "BRAINPOOLP192T1"; 241 TO_EC_STR_PARAM(brainpoolp192t1_name); 242 243 static const u8 brainpoolp192t1_oid[] = "1.3.36.3.3.2.8.1.1.4"; 244 TO_EC_STR_PARAM(brainpoolp192t1_oid); 245 246 static const ec_str_params brainpoolp192t1_str_params = { 247 .p = &brainpoolp192t1_p_str_param, 248 .p_bitlen = &brainpoolp192t1_p_bitlen_str_param, 249 .r = &brainpoolp192t1_r_str_param, 250 .r_square = &brainpoolp192t1_r_square_str_param, 251 .mpinv = &brainpoolp192t1_mpinv_str_param, 252 .p_shift = &brainpoolp192t1_p_shift_str_param, 253 .p_normalized = &brainpoolp192t1_p_normalized_str_param, 254 .p_reciprocal = &brainpoolp192t1_p_reciprocal_str_param, 255 .a = &brainpoolp192t1_a_str_param, 256 .b = &brainpoolp192t1_b_str_param, 257 .curve_order = &brainpoolp192t1_curve_order_str_param, 258 .gx = &brainpoolp192t1_gx_str_param, 259 .gy = &brainpoolp192t1_gy_str_param, 260 .gz = &brainpoolp192t1_gz_str_param, 261 .gen_order = &brainpoolp192t1_gen_order_str_param, 262 .gen_order_bitlen = &brainpoolp192t1_gen_order_bitlen_str_param, 263 .cofactor = &brainpoolp192t1_cofactor_str_param, 264 .alpha_montgomery = &brainpoolp192t1_alpha_montgomery_str_param, 265 .gamma_montgomery = &brainpoolp192t1_gamma_montgomery_str_param, 266 .alpha_edwards = &brainpoolp192t1_alpha_edwards_str_param, 267 .oid = &brainpoolp192t1_oid_str_param, 268 .name = &brainpoolp192t1_name_str_param, 269 }; 270 271 /* 272 * Compute max bit length of all curves for p and q 273 */ 274 #ifndef CURVES_MAX_P_BIT_LEN 275 #define CURVES_MAX_P_BIT_LEN 0 276 #endif 277 #if (CURVES_MAX_P_BIT_LEN < CURVE_BRAINPOOLP192T1_P_BITLEN) 278 #undef CURVES_MAX_P_BIT_LEN 279 #define CURVES_MAX_P_BIT_LEN CURVE_BRAINPOOLP192T1_P_BITLEN 280 #endif 281 #ifndef CURVES_MAX_Q_BIT_LEN 282 #define CURVES_MAX_Q_BIT_LEN 0 283 #endif 284 #if (CURVES_MAX_Q_BIT_LEN < CURVE_BRAINPOOLP192T1_Q_BITLEN) 285 #undef CURVES_MAX_Q_BIT_LEN 286 #define CURVES_MAX_Q_BIT_LEN CURVE_BRAINPOOLP192T1_Q_BITLEN 287 #endif 288 #ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN 289 #define CURVES_MAX_CURVE_ORDER_BIT_LEN 0 290 #endif 291 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_BRAINPOOLP192T1_CURVE_ORDER_BITLEN) 292 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN 293 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_BRAINPOOLP192T1_CURVE_ORDER_BITLEN 294 #endif 295 296 /* 297 * Compute and adapt max name and oid length 298 */ 299 #ifndef MAX_CURVE_OID_LEN 300 #define MAX_CURVE_OID_LEN 0 301 #endif 302 #ifndef MAX_CURVE_NAME_LEN 303 #define MAX_CURVE_NAME_LEN 0 304 #endif 305 #if (MAX_CURVE_OID_LEN < 1) 306 #undef MAX_CURVE_OID_LEN 307 #define MAX_CURVE_OID_LEN 1 308 #endif 309 #if (MAX_CURVE_NAME_LEN < 29) 310 #undef MAX_CURVE_NAME_LEN 311 #define MAX_CURVE_NAME_LEN 29 312 #endif 313 314 #endif /* __EC_PARAMS_BRAINPOOLP192T1_H__ */ 315 316 #endif /* WITH_CURVE_BRAINPOOLP192T1 */ 317