1 /* 2 * Copyright (C) 2017 - This file is part of libecc project 3 * 4 * Authors: 5 * Ryad BENADJILA <ryadbenadjila@gmail.com> 6 * Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr> 7 * Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr> 8 * 9 * Contributors: 10 * Nicolas VIVET <nicolas.vivet@ssi.gouv.fr> 11 * Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr> 12 * 13 * This software is licensed under a dual BSD and GPL v2 license. 14 * See LICENSE file at the root folder of the project. 15 */ 16 #include <libecc/lib_ecc_config.h> 17 #ifdef WITH_CURVE_SECP192R1 18 19 #ifndef __EC_PARAMS_SECP192R1_H__ 20 #define __EC_PARAMS_SECP192R1_H__ 21 #include "ec_params_external.h" 22 23 static const u8 secp192r1_p[] = { 24 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 25 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 26 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 27 }; 28 29 TO_EC_STR_PARAM(secp192r1_p); 30 31 #define CURVE_SECP192R1_P_BITLEN 192 32 static const u8 secp192r1_p_bitlen[] = { 0xc0 }; 33 34 TO_EC_STR_PARAM(secp192r1_p_bitlen); 35 36 #if (WORD_BYTES == 8) /* 64-bit words */ 37 static const u8 secp192r1_r[] = { 38 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 0x01 40 }; 41 42 TO_EC_STR_PARAM(secp192r1_r); 43 44 static const u8 secp192r1_r_square[] = { 45 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 46 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 0x01 48 }; 49 50 TO_EC_STR_PARAM(secp192r1_r_square); 51 52 static const u8 secp192r1_mpinv[] = { 53 0x01 54 }; 55 56 TO_EC_STR_PARAM(secp192r1_mpinv); 57 58 static const u8 secp192r1_p_shift[] = { 59 0x00 60 }; 61 62 TO_EC_STR_PARAM(secp192r1_p_shift); 63 64 static const u8 secp192r1_p_normalized[] = { 65 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 66 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 67 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 68 }; 69 70 TO_EC_STR_PARAM(secp192r1_p_normalized); 71 72 static const u8 secp192r1_p_reciprocal[] = { 73 0x00 74 }; 75 76 TO_EC_STR_PARAM(secp192r1_p_reciprocal); 77 78 #elif (WORD_BYTES == 4) /* 32-bit words */ 79 static const u8 secp192r1_r[] = { 80 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 81 0x01 82 }; 83 84 TO_EC_STR_PARAM(secp192r1_r); 85 86 static const u8 secp192r1_r_square[] = { 87 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 88 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 89 0x01 90 }; 91 92 TO_EC_STR_PARAM(secp192r1_r_square); 93 94 static const u8 secp192r1_mpinv[] = { 95 0x01 96 }; 97 98 TO_EC_STR_PARAM(secp192r1_mpinv); 99 100 static const u8 secp192r1_p_shift[] = { 101 0x00 102 }; 103 104 TO_EC_STR_PARAM(secp192r1_p_shift); 105 106 static const u8 secp192r1_p_normalized[] = { 107 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 108 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 109 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 110 }; 111 112 TO_EC_STR_PARAM(secp192r1_p_normalized); 113 114 static const u8 secp192r1_p_reciprocal[] = { 115 0x00 116 }; 117 118 TO_EC_STR_PARAM(secp192r1_p_reciprocal); 119 120 #elif (WORD_BYTES == 2) /* 16-bit words */ 121 static const u8 secp192r1_r[] = { 122 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 123 0x01 124 }; 125 126 TO_EC_STR_PARAM(secp192r1_r); 127 128 static const u8 secp192r1_r_square[] = { 129 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 130 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 131 0x01 132 }; 133 134 TO_EC_STR_PARAM(secp192r1_r_square); 135 136 static const u8 secp192r1_mpinv[] = { 137 0x01 138 }; 139 140 TO_EC_STR_PARAM(secp192r1_mpinv); 141 142 static const u8 secp192r1_p_shift[] = { 143 0x00 144 }; 145 146 TO_EC_STR_PARAM(secp192r1_p_shift); 147 148 static const u8 secp192r1_p_normalized[] = { 149 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 150 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 151 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 152 }; 153 154 TO_EC_STR_PARAM(secp192r1_p_normalized); 155 156 static const u8 secp192r1_p_reciprocal[] = { 157 0x00 158 }; 159 160 TO_EC_STR_PARAM(secp192r1_p_reciprocal); 161 162 #else /* unknown word size */ 163 #error "Unsupported word size" 164 #endif 165 166 static const u8 secp192r1_a[] = { 167 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 168 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 169 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc 170 }; 171 172 TO_EC_STR_PARAM(secp192r1_a); 173 174 static const u8 secp192r1_b[] = { 175 0x64, 0x21, 0x05, 0x19, 0xe5, 0x9c, 0x80, 0xe7, 176 0x0f, 0xa7, 0xe9, 0xab, 0x72, 0x24, 0x30, 0x49, 177 0xfe, 0xb8, 0xde, 0xec, 0xc1, 0x46, 0xb9, 0xb1 178 }; 179 180 TO_EC_STR_PARAM(secp192r1_b); 181 182 #define CURVE_SECP192R1_CURVE_ORDER_BITLEN 192 183 static const u8 secp192r1_curve_order[] = { 184 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 185 0xff, 0xff, 0xff, 0xff, 0x99, 0xde, 0xf8, 0x36, 186 0x14, 0x6b, 0xc9, 0xb1, 0xb4, 0xd2, 0x28, 0x31 187 }; 188 189 TO_EC_STR_PARAM(secp192r1_curve_order); 190 191 static const u8 secp192r1_gx[] = { 192 0x18, 0x8d, 0xa8, 0x0e, 0xb0, 0x30, 0x90, 0xf6, 193 0x7c, 0xbf, 0x20, 0xeb, 0x43, 0xa1, 0x88, 0x00, 194 0xf4, 0xff, 0x0a, 0xfd, 0x82, 0xff, 0x10, 0x12 195 }; 196 197 TO_EC_STR_PARAM(secp192r1_gx); 198 199 static const u8 secp192r1_gy[] = { 200 0x07, 0x19, 0x2b, 0x95, 0xff, 0xc8, 0xda, 0x78, 201 0x63, 0x10, 0x11, 0xed, 0x6b, 0x24, 0xcd, 0xd5, 202 0x73, 0xf9, 0x77, 0xa1, 0x1e, 0x79, 0x48, 0x11 203 }; 204 205 TO_EC_STR_PARAM(secp192r1_gy); 206 207 static const u8 secp192r1_gz[] = { 208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 210 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 211 }; 212 213 TO_EC_STR_PARAM(secp192r1_gz); 214 215 static const u8 secp192r1_gen_order[] = { 216 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 217 0xff, 0xff, 0xff, 0xff, 0x99, 0xde, 0xf8, 0x36, 218 0x14, 0x6b, 0xc9, 0xb1, 0xb4, 0xd2, 0x28, 0x31 219 }; 220 221 TO_EC_STR_PARAM(secp192r1_gen_order); 222 223 #define CURVE_SECP192R1_Q_BITLEN 192 224 static const u8 secp192r1_gen_order_bitlen[] = { 225 0xc0 226 }; 227 228 TO_EC_STR_PARAM(secp192r1_gen_order_bitlen); 229 230 static const u8 secp192r1_cofactor[] = { 231 0x01 232 }; 233 234 TO_EC_STR_PARAM(secp192r1_cofactor); 235 236 static const u8 secp192r1_alpha_montgomery[] = { 237 0x00, 238 }; 239 240 TO_EC_STR_PARAM_FIXED_SIZE(secp192r1_alpha_montgomery, 0); 241 242 static const u8 secp192r1_gamma_montgomery[] = { 243 0x00, 244 }; 245 246 TO_EC_STR_PARAM_FIXED_SIZE(secp192r1_gamma_montgomery, 0); 247 248 static const u8 secp192r1_alpha_edwards[] = { 249 0x00, 250 }; 251 252 TO_EC_STR_PARAM_FIXED_SIZE(secp192r1_alpha_edwards, 0); 253 254 static const u8 secp192r1_name[] = "SECP192R1"; 255 TO_EC_STR_PARAM(secp192r1_name); 256 257 static const u8 secp192r1_oid[] = "1.2.840.10045.3.1.1"; 258 TO_EC_STR_PARAM(secp192r1_oid); 259 260 static const ec_str_params secp192r1_str_params = { 261 .p = &secp192r1_p_str_param, 262 .p_bitlen = &secp192r1_p_bitlen_str_param, 263 .r = &secp192r1_r_str_param, 264 .r_square = &secp192r1_r_square_str_param, 265 .mpinv = &secp192r1_mpinv_str_param, 266 .p_shift = &secp192r1_p_shift_str_param, 267 .p_normalized = &secp192r1_p_normalized_str_param, 268 .p_reciprocal = &secp192r1_p_reciprocal_str_param, 269 .a = &secp192r1_a_str_param, 270 .b = &secp192r1_b_str_param, 271 .curve_order = &secp192r1_curve_order_str_param, 272 .gx = &secp192r1_gx_str_param, 273 .gy = &secp192r1_gy_str_param, 274 .gz = &secp192r1_gz_str_param, 275 .gen_order = &secp192r1_gen_order_str_param, 276 .gen_order_bitlen = &secp192r1_gen_order_bitlen_str_param, 277 .cofactor = &secp192r1_cofactor_str_param, 278 .alpha_montgomery = &secp192r1_alpha_montgomery_str_param, 279 .gamma_montgomery = &secp192r1_gamma_montgomery_str_param, 280 .alpha_edwards = &secp192r1_alpha_edwards_str_param, 281 .oid = &secp192r1_oid_str_param, 282 .name = &secp192r1_name_str_param, 283 }; 284 285 /* 286 * Compute max bit length of all curves for p and q 287 */ 288 #ifndef CURVES_MAX_P_BIT_LEN 289 #define CURVES_MAX_P_BIT_LEN 0 290 #endif 291 #if (CURVES_MAX_P_BIT_LEN < CURVE_SECP192R1_P_BITLEN) 292 #undef CURVES_MAX_P_BIT_LEN 293 #define CURVES_MAX_P_BIT_LEN CURVE_SECP192R1_P_BITLEN 294 #endif 295 #ifndef CURVES_MAX_Q_BIT_LEN 296 #define CURVES_MAX_Q_BIT_LEN 0 297 #endif 298 #if (CURVES_MAX_Q_BIT_LEN < CURVE_SECP192R1_Q_BITLEN) 299 #undef CURVES_MAX_Q_BIT_LEN 300 #define CURVES_MAX_Q_BIT_LEN CURVE_SECP192R1_Q_BITLEN 301 #endif 302 #ifndef CURVES_MAX_CURVE_ORDER_BIT_LEN 303 #define CURVES_MAX_CURVE_ORDER_BIT_LEN 0 304 #endif 305 #if (CURVES_MAX_CURVE_ORDER_BIT_LEN < CURVE_SECP192R1_CURVE_ORDER_BITLEN) 306 #undef CURVES_MAX_CURVE_ORDER_BIT_LEN 307 #define CURVES_MAX_CURVE_ORDER_BIT_LEN CURVE_SECP192R1_CURVE_ORDER_BITLEN 308 #endif 309 310 #endif /* __EC_PARAMS_SECP192R1_H__ */ 311 312 #endif /* WITH_CURVE_SECP192R1 */ 313