diff options
| author | djm <> | 2010-10-01 22:54:21 +0000 |
|---|---|---|
| committer | djm <> | 2010-10-01 22:54:21 +0000 |
| commit | 829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2 (patch) | |
| tree | e03b9f1bd051e844b971936729e9df549a209130 /src/lib/libcrypto/ec | |
| parent | e6b755d2a53d3cac7a344dfdd6bf7c951cac754c (diff) | |
| download | openbsd-829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2.tar.gz openbsd-829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2.tar.bz2 openbsd-829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2.zip | |
import OpenSSL-1.0.0a
Diffstat (limited to 'src/lib/libcrypto/ec')
| -rw-r--r-- | src/lib/libcrypto/ec/ec.h | 814 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec2_mult.c | 33 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec2_smpl.c | 114 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_ameth.c | 659 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_curve.c | 2593 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_err.c | 21 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_lcl.h | 13 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_lib.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_mult.c | 22 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_pmeth.c | 340 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/eck_prn.c | 391 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ecp_nist.c | 26 |
12 files changed, 3924 insertions, 1106 deletions
diff --git a/src/lib/libcrypto/ec/ec.h b/src/lib/libcrypto/ec/ec.h index 8bc2a235b1..ee7078130c 100644 --- a/src/lib/libcrypto/ec/ec.h +++ b/src/lib/libcrypto/ec/ec.h | |||
| @@ -2,8 +2,12 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
| 4 | */ | 4 | */ |
| 5 | /** | ||
| 6 | * \file crypto/ec/ec.h Include file for the OpenSSL EC functions | ||
| 7 | * \author Originally written by Bodo Moeller for the OpenSSL project | ||
| 8 | */ | ||
| 5 | /* ==================================================================== | 9 | /* ==================================================================== |
| 6 | * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. | 10 | * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. |
| 7 | * | 11 | * |
| 8 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions |
| @@ -92,15 +96,21 @@ extern "C" { | |||
| 92 | # endif | 96 | # endif |
| 93 | #endif | 97 | #endif |
| 94 | 98 | ||
| 95 | 99 | ||
| 96 | #ifndef OPENSSL_ECC_MAX_FIELD_BITS | 100 | #ifndef OPENSSL_ECC_MAX_FIELD_BITS |
| 97 | # define OPENSSL_ECC_MAX_FIELD_BITS 661 | 101 | # define OPENSSL_ECC_MAX_FIELD_BITS 661 |
| 98 | #endif | 102 | #endif |
| 99 | 103 | ||
| 104 | /** Enum for the point conversion form as defined in X9.62 (ECDSA) | ||
| 105 | * for the encoding of a elliptic curve point (x,y) */ | ||
| 100 | typedef enum { | 106 | typedef enum { |
| 101 | /* values as defined in X9.62 (ECDSA) and elsewhere */ | 107 | /** the point is encoded as z||x, where the octet z specifies |
| 108 | * which solution of the quadratic equation y is */ | ||
| 102 | POINT_CONVERSION_COMPRESSED = 2, | 109 | POINT_CONVERSION_COMPRESSED = 2, |
| 110 | /** the point is encoded as z||x||y, where z is the octet 0x02 */ | ||
| 103 | POINT_CONVERSION_UNCOMPRESSED = 4, | 111 | POINT_CONVERSION_UNCOMPRESSED = 4, |
| 112 | /** the point is encoded as z||x||y, where the octet z specifies | ||
| 113 | * which solution of the quadratic equation y is */ | ||
| 104 | POINT_CONVERSION_HYBRID = 6 | 114 | POINT_CONVERSION_HYBRID = 6 |
| 105 | } point_conversion_form_t; | 115 | } point_conversion_form_t; |
| 106 | 116 | ||
| @@ -121,37 +131,129 @@ typedef struct ec_group_st | |||
| 121 | typedef struct ec_point_st EC_POINT; | 131 | typedef struct ec_point_st EC_POINT; |
| 122 | 132 | ||
| 123 | 133 | ||
| 124 | /* EC_METHODs for curves over GF(p). | 134 | /********************************************************************/ |
| 125 | * EC_GFp_simple_method provides the basis for the optimized methods. | 135 | /* EC_METHODs for curves over GF(p) */ |
| 136 | /********************************************************************/ | ||
| 137 | |||
| 138 | /** Returns the basic GFp ec methods which provides the basis for the | ||
| 139 | * optimized methods. | ||
| 140 | * \return EC_METHOD object | ||
| 126 | */ | 141 | */ |
| 127 | const EC_METHOD *EC_GFp_simple_method(void); | 142 | const EC_METHOD *EC_GFp_simple_method(void); |
| 143 | |||
| 144 | /** Returns GFp methods using montgomery multiplication. | ||
| 145 | * \return EC_METHOD object | ||
| 146 | */ | ||
| 128 | const EC_METHOD *EC_GFp_mont_method(void); | 147 | const EC_METHOD *EC_GFp_mont_method(void); |
| 148 | |||
| 149 | /** Returns GFp methods using optimized methods for NIST recommended curves | ||
| 150 | * \return EC_METHOD object | ||
| 151 | */ | ||
| 129 | const EC_METHOD *EC_GFp_nist_method(void); | 152 | const EC_METHOD *EC_GFp_nist_method(void); |
| 130 | 153 | ||
| 131 | /* EC_METHOD for curves over GF(2^m). | 154 | |
| 155 | /********************************************************************/ | ||
| 156 | /* EC_METHOD for curves over GF(2^m) */ | ||
| 157 | /********************************************************************/ | ||
| 158 | |||
| 159 | /** Returns the basic GF2m ec method | ||
| 160 | * \return EC_METHOD object | ||
| 132 | */ | 161 | */ |
| 133 | const EC_METHOD *EC_GF2m_simple_method(void); | 162 | const EC_METHOD *EC_GF2m_simple_method(void); |
| 134 | 163 | ||
| 135 | 164 | ||
| 136 | EC_GROUP *EC_GROUP_new(const EC_METHOD *); | 165 | /********************************************************************/ |
| 137 | void EC_GROUP_free(EC_GROUP *); | 166 | /* EC_GROUP functions */ |
| 138 | void EC_GROUP_clear_free(EC_GROUP *); | 167 | /********************************************************************/ |
| 139 | int EC_GROUP_copy(EC_GROUP *, const EC_GROUP *); | ||
| 140 | EC_GROUP *EC_GROUP_dup(const EC_GROUP *); | ||
| 141 | 168 | ||
| 142 | const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *); | 169 | /** Creates a new EC_GROUP object |
| 143 | int EC_METHOD_get_field_type(const EC_METHOD *); | 170 | * \param meth EC_METHOD to use |
| 171 | * \return newly created EC_GROUP object or NULL in case of an error. | ||
| 172 | */ | ||
| 173 | EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); | ||
| 144 | 174 | ||
| 145 | int EC_GROUP_set_generator(EC_GROUP *, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); | 175 | /** Frees a EC_GROUP object |
| 146 | const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *); | 176 | * \param group EC_GROUP object to be freed. |
| 147 | int EC_GROUP_get_order(const EC_GROUP *, BIGNUM *order, BN_CTX *); | 177 | */ |
| 148 | int EC_GROUP_get_cofactor(const EC_GROUP *, BIGNUM *cofactor, BN_CTX *); | 178 | void EC_GROUP_free(EC_GROUP *group); |
| 149 | 179 | ||
| 150 | void EC_GROUP_set_curve_name(EC_GROUP *, int nid); | 180 | /** Clears and frees a EC_GROUP object |
| 151 | int EC_GROUP_get_curve_name(const EC_GROUP *); | 181 | * \param group EC_GROUP object to be cleared and freed. |
| 182 | */ | ||
| 183 | void EC_GROUP_clear_free(EC_GROUP *group); | ||
| 152 | 184 | ||
| 153 | void EC_GROUP_set_asn1_flag(EC_GROUP *, int flag); | 185 | /** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD. |
| 154 | int EC_GROUP_get_asn1_flag(const EC_GROUP *); | 186 | * \param dst destination EC_GROUP object |
| 187 | * \param src source EC_GROUP object | ||
| 188 | * \return 1 on success and 0 if an error occurred. | ||
| 189 | */ | ||
| 190 | int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src); | ||
| 191 | |||
| 192 | /** Creates a new EC_GROUP object and copies the copies the content | ||
| 193 | * form src to the newly created EC_KEY object | ||
| 194 | * \param src source EC_GROUP object | ||
| 195 | * \return newly created EC_GROUP object or NULL in case of an error. | ||
| 196 | */ | ||
| 197 | EC_GROUP *EC_GROUP_dup(const EC_GROUP *src); | ||
| 198 | |||
| 199 | /** Returns the EC_METHOD of the EC_GROUP object. | ||
| 200 | * \param group EC_GROUP object | ||
| 201 | * \return EC_METHOD used in this EC_GROUP object. | ||
| 202 | */ | ||
| 203 | const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); | ||
| 204 | |||
| 205 | /** Returns the field type of the EC_METHOD. | ||
| 206 | * \param meth EC_METHOD object | ||
| 207 | * \return NID of the underlying field type OID. | ||
| 208 | */ | ||
| 209 | int EC_METHOD_get_field_type(const EC_METHOD *meth); | ||
| 210 | |||
| 211 | /** Sets the generator and it's order/cofactor of a EC_GROUP object. | ||
| 212 | * \param group EC_GROUP object | ||
| 213 | * \param generator EC_POINT object with the generator. | ||
| 214 | * \param order the order of the group generated by the generator. | ||
| 215 | * \param cofactor the index of the sub-group generated by the generator | ||
| 216 | * in the group of all points on the elliptic curve. | ||
| 217 | * \return 1 on success and 0 if an error occured | ||
| 218 | */ | ||
| 219 | int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); | ||
| 220 | |||
| 221 | /** Returns the generator of a EC_GROUP object. | ||
| 222 | * \param group EC_GROUP object | ||
| 223 | * \return the currently used generator (possibly NULL). | ||
| 224 | */ | ||
| 225 | const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); | ||
| 226 | |||
| 227 | /** Gets the order of a EC_GROUP | ||
| 228 | * \param group EC_GROUP object | ||
| 229 | * \param order BIGNUM to which the order is copied | ||
| 230 | * \param ctx BN_CTX object (optional) | ||
| 231 | * \return 1 on success and 0 if an error occured | ||
| 232 | */ | ||
| 233 | int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx); | ||
| 234 | |||
| 235 | /** Gets the cofactor of a EC_GROUP | ||
| 236 | * \param group EC_GROUP object | ||
| 237 | * \param cofactor BIGNUM to which the cofactor is copied | ||
| 238 | * \param ctx BN_CTX object (optional) | ||
| 239 | * \return 1 on success and 0 if an error occured | ||
| 240 | */ | ||
| 241 | int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx); | ||
| 242 | |||
| 243 | /** Sets the name of a EC_GROUP object | ||
| 244 | * \param group EC_GROUP object | ||
| 245 | * \param nid NID of the curve name OID | ||
| 246 | */ | ||
| 247 | void EC_GROUP_set_curve_name(EC_GROUP *group, int nid); | ||
| 248 | |||
| 249 | /** Returns the curve name of a EC_GROUP object | ||
| 250 | * \param group EC_GROUP object | ||
| 251 | * \return NID of the curve name OID or 0 if not set. | ||
| 252 | */ | ||
| 253 | int EC_GROUP_get_curve_name(const EC_GROUP *group); | ||
| 254 | |||
| 255 | void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); | ||
| 256 | int EC_GROUP_get_asn1_flag(const EC_GROUP *group); | ||
| 155 | 257 | ||
| 156 | void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t); | 258 | void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t); |
| 157 | point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); | 259 | point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); |
| @@ -160,36 +262,114 @@ unsigned char *EC_GROUP_get0_seed(const EC_GROUP *); | |||
| 160 | size_t EC_GROUP_get_seed_len(const EC_GROUP *); | 262 | size_t EC_GROUP_get_seed_len(const EC_GROUP *); |
| 161 | size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); | 263 | size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); |
| 162 | 264 | ||
| 163 | int EC_GROUP_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); | 265 | /** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b |
| 164 | int EC_GROUP_get_curve_GFp(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); | 266 | * \param group EC_GROUP object |
| 165 | int EC_GROUP_set_curve_GF2m(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); | 267 | * \param p BIGNUM with the prime number |
| 166 | int EC_GROUP_get_curve_GF2m(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); | 268 | * \param a BIGNUM with parameter a of the equation |
| 269 | * \param b BIGNUM with parameter b of the equation | ||
| 270 | * \param ctx BN_CTX object (optional) | ||
| 271 | * \return 1 on success and 0 if an error occured | ||
| 272 | */ | ||
| 273 | int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); | ||
| 274 | |||
| 275 | /** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b | ||
| 276 | * \param group EC_GROUP object | ||
| 277 | * \param p BIGNUM for the prime number | ||
| 278 | * \param a BIGNUM for parameter a of the equation | ||
| 279 | * \param b BIGNUM for parameter b of the equation | ||
| 280 | * \param ctx BN_CTX object (optional) | ||
| 281 | * \return 1 on success and 0 if an error occured | ||
| 282 | */ | ||
| 283 | int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); | ||
| 284 | |||
| 285 | /** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b | ||
| 286 | * \param group EC_GROUP object | ||
| 287 | * \param p BIGNUM with the polynomial defining the underlying field | ||
| 288 | * \param a BIGNUM with parameter a of the equation | ||
| 289 | * \param b BIGNUM with parameter b of the equation | ||
| 290 | * \param ctx BN_CTX object (optional) | ||
| 291 | * \return 1 on success and 0 if an error occured | ||
| 292 | */ | ||
| 293 | int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); | ||
| 294 | |||
| 295 | /** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b | ||
| 296 | * \param group EC_GROUP object | ||
| 297 | * \param p BIGNUM for the polynomial defining the underlying field | ||
| 298 | * \param a BIGNUM for parameter a of the equation | ||
| 299 | * \param b BIGNUM for parameter b of the equation | ||
| 300 | * \param ctx BN_CTX object (optional) | ||
| 301 | * \return 1 on success and 0 if an error occured | ||
| 302 | */ | ||
| 303 | int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); | ||
| 167 | 304 | ||
| 168 | /* returns the number of bits needed to represent a field element */ | 305 | /** Returns the number of bits needed to represent a field element |
| 169 | int EC_GROUP_get_degree(const EC_GROUP *); | 306 | * \param group EC_GROUP object |
| 307 | * \return number of bits needed to represent a field element | ||
| 308 | */ | ||
| 309 | int EC_GROUP_get_degree(const EC_GROUP *group); | ||
| 170 | 310 | ||
| 171 | /* EC_GROUP_check() returns 1 if 'group' defines a valid group, 0 otherwise */ | 311 | /** Checks whether the parameter in the EC_GROUP define a valid ec group |
| 312 | * \param group EC_GROUP object | ||
| 313 | * \param ctx BN_CTX object (optional) | ||
| 314 | * \return 1 if group is a valid ec group and 0 otherwise | ||
| 315 | */ | ||
| 172 | int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); | 316 | int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); |
| 173 | /* EC_GROUP_check_discriminant() returns 1 if the discriminant of the | ||
| 174 | * elliptic curve is not zero, 0 otherwise */ | ||
| 175 | int EC_GROUP_check_discriminant(const EC_GROUP *, BN_CTX *); | ||
| 176 | 317 | ||
| 177 | /* EC_GROUP_cmp() returns 0 if both groups are equal and 1 otherwise */ | 318 | /** Checks whether the discriminant of the elliptic curve is zero or not |
| 178 | int EC_GROUP_cmp(const EC_GROUP *, const EC_GROUP *, BN_CTX *); | 319 | * \param group EC_GROUP object |
| 320 | * \param ctx BN_CTX object (optional) | ||
| 321 | * \return 1 if the discriminant is not zero and 0 otherwise | ||
| 322 | */ | ||
| 323 | int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx); | ||
| 324 | |||
| 325 | /** Compares two EC_GROUP objects | ||
| 326 | * \param a first EC_GROUP object | ||
| 327 | * \param b second EC_GROUP object | ||
| 328 | * \param ctx BN_CTX object (optional) | ||
| 329 | * \return 0 if both groups are equal and 1 otherwise | ||
| 330 | */ | ||
| 331 | int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); | ||
| 179 | 332 | ||
| 180 | /* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() | 333 | /* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() |
| 181 | * after choosing an appropriate EC_METHOD */ | 334 | * after choosing an appropriate EC_METHOD */ |
| 182 | EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); | ||
| 183 | EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); | ||
| 184 | 335 | ||
| 185 | /* EC_GROUP_new_by_curve_name() creates a EC_GROUP structure | 336 | /** Creates a new EC_GROUP object with the specified parameters defined |
| 186 | * specified by a curve name (in form of a NID) */ | 337 | * over GFp (defined by the equation y^2 = x^3 + a*x + b) |
| 338 | * \param p BIGNUM with the prime number | ||
| 339 | * \param a BIGNUM with the parameter a of the equation | ||
| 340 | * \param b BIGNUM with the parameter b of the equation | ||
| 341 | * \param ctx BN_CTX object (optional) | ||
| 342 | * \return newly created EC_GROUP object with the specified parameters | ||
| 343 | */ | ||
| 344 | EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); | ||
| 345 | |||
| 346 | /** Creates a new EC_GROUP object with the specified parameters defined | ||
| 347 | * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b) | ||
| 348 | * \param p BIGNUM with the polynomial defining the underlying field | ||
| 349 | * \param a BIGNUM with the parameter a of the equation | ||
| 350 | * \param b BIGNUM with the parameter b of the equation | ||
| 351 | * \param ctx BN_CTX object (optional) | ||
| 352 | * \return newly created EC_GROUP object with the specified parameters | ||
| 353 | */ | ||
| 354 | EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); | ||
| 355 | |||
| 356 | /** Creates a EC_GROUP object with a curve specified by a NID | ||
| 357 | * \param nid NID of the OID of the curve name | ||
| 358 | * \return newly created EC_GROUP object with specified curve or NULL | ||
| 359 | * if an error occurred | ||
| 360 | */ | ||
| 187 | EC_GROUP *EC_GROUP_new_by_curve_name(int nid); | 361 | EC_GROUP *EC_GROUP_new_by_curve_name(int nid); |
| 188 | /* handling of internal curves */ | 362 | |
| 363 | |||
| 364 | /********************************************************************/ | ||
| 365 | /* handling of internal curves */ | ||
| 366 | /********************************************************************/ | ||
| 367 | |||
| 189 | typedef struct { | 368 | typedef struct { |
| 190 | int nid; | 369 | int nid; |
| 191 | const char *comment; | 370 | const char *comment; |
| 192 | } EC_builtin_curve; | 371 | } EC_builtin_curve; |
| 372 | |||
| 193 | /* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number | 373 | /* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number |
| 194 | * of all available curves or zero if a error occurred. | 374 | * of all available curves or zero if a error occurred. |
| 195 | * In case r ist not zero nitems EC_builtin_curve structures | 375 | * In case r ist not zero nitems EC_builtin_curve structures |
| @@ -197,39 +377,168 @@ typedef struct { | |||
| 197 | size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); | 377 | size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); |
| 198 | 378 | ||
| 199 | 379 | ||
| 200 | /* EC_POINT functions */ | 380 | /********************************************************************/ |
| 381 | /* EC_POINT functions */ | ||
| 382 | /********************************************************************/ | ||
| 383 | |||
| 384 | /** Creates a new EC_POINT object for the specified EC_GROUP | ||
| 385 | * \param group EC_GROUP the underlying EC_GROUP object | ||
| 386 | * \return newly created EC_POINT object or NULL if an error occurred | ||
| 387 | */ | ||
| 388 | EC_POINT *EC_POINT_new(const EC_GROUP *group); | ||
| 389 | |||
| 390 | /** Frees a EC_POINT object | ||
| 391 | * \param point EC_POINT object to be freed | ||
| 392 | */ | ||
| 393 | void EC_POINT_free(EC_POINT *point); | ||
| 394 | |||
| 395 | /** Clears and frees a EC_POINT object | ||
| 396 | * \param point EC_POINT object to be cleared and freed | ||
| 397 | */ | ||
| 398 | void EC_POINT_clear_free(EC_POINT *point); | ||
| 399 | |||
| 400 | /** Copies EC_POINT object | ||
| 401 | * \param dst destination EC_POINT object | ||
| 402 | * \param src source EC_POINT object | ||
| 403 | * \return 1 on success and 0 if an error occured | ||
| 404 | */ | ||
| 405 | int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); | ||
| 201 | 406 | ||
| 202 | EC_POINT *EC_POINT_new(const EC_GROUP *); | 407 | /** Creates a new EC_POINT object and copies the content of the supplied |
| 203 | void EC_POINT_free(EC_POINT *); | 408 | * EC_POINT |
| 204 | void EC_POINT_clear_free(EC_POINT *); | 409 | * \param src source EC_POINT object |
| 205 | int EC_POINT_copy(EC_POINT *, const EC_POINT *); | 410 | * \param group underlying the EC_GROUP object |
| 206 | EC_POINT *EC_POINT_dup(const EC_POINT *, const EC_GROUP *); | 411 | * \return newly created EC_POINT object or NULL if an error occurred |
| 412 | */ | ||
| 413 | EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); | ||
| 207 | 414 | ||
| 208 | const EC_METHOD *EC_POINT_method_of(const EC_POINT *); | 415 | /** Returns the EC_METHOD used in EC_POINT object |
| 209 | 416 | * \param point EC_POINT object | |
| 210 | int EC_POINT_set_to_infinity(const EC_GROUP *, EC_POINT *); | 417 | * \return the EC_METHOD used |
| 211 | int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *, | 418 | */ |
| 212 | const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); | 419 | const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); |
| 213 | int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *, const EC_POINT *, | 420 | |
| 214 | BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); | 421 | /** Sets a point to infinity (neutral element) |
| 215 | int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *, EC_POINT *, | 422 | * \param group underlying EC_GROUP object |
| 216 | const BIGNUM *x, const BIGNUM *y, BN_CTX *); | 423 | * \param point EC_POINT to set to infinity |
| 217 | int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *, const EC_POINT *, | 424 | * \return 1 on success and 0 if an error occured |
| 218 | BIGNUM *x, BIGNUM *y, BN_CTX *); | 425 | */ |
| 219 | int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *, EC_POINT *, | 426 | int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); |
| 220 | const BIGNUM *x, int y_bit, BN_CTX *); | 427 | |
| 221 | 428 | /** Sets the jacobian projective coordinates of a EC_POINT over GFp | |
| 222 | int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *, EC_POINT *, | 429 | * \param group underlying EC_GROUP object |
| 223 | const BIGNUM *x, const BIGNUM *y, BN_CTX *); | 430 | * \param p EC_POINT object |
| 224 | int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *, const EC_POINT *, | 431 | * \param x BIGNUM with the x-coordinate |
| 225 | BIGNUM *x, BIGNUM *y, BN_CTX *); | 432 | * \param y BIGNUM with the y-coordinate |
| 226 | int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *, EC_POINT *, | 433 | * \param z BIGNUM with the z-coordinate |
| 227 | const BIGNUM *x, int y_bit, BN_CTX *); | 434 | * \param ctx BN_CTX object (optional) |
| 228 | 435 | * \return 1 on success and 0 if an error occured | |
| 229 | size_t EC_POINT_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, | 436 | */ |
| 230 | unsigned char *buf, size_t len, BN_CTX *); | 437 | int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, |
| 231 | int EC_POINT_oct2point(const EC_GROUP *, EC_POINT *, | 438 | const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx); |
| 232 | const unsigned char *buf, size_t len, BN_CTX *); | 439 | |
| 440 | /** Gets the jacobian projective coordinates of a EC_POINT over GFp | ||
| 441 | * \param group underlying EC_GROUP object | ||
| 442 | * \param p EC_POINT object | ||
| 443 | * \param x BIGNUM for the x-coordinate | ||
| 444 | * \param y BIGNUM for the y-coordinate | ||
| 445 | * \param z BIGNUM for the z-coordinate | ||
| 446 | * \param ctx BN_CTX object (optional) | ||
| 447 | * \return 1 on success and 0 if an error occured | ||
| 448 | */ | ||
| 449 | int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, | ||
| 450 | const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx); | ||
| 451 | |||
| 452 | /** Sets the affine coordinates of a EC_POINT over GFp | ||
| 453 | * \param group underlying EC_GROUP object | ||
| 454 | * \param p EC_POINT object | ||
| 455 | * \param x BIGNUM with the x-coordinate | ||
| 456 | * \param y BIGNUM with the y-coordinate | ||
| 457 | * \param ctx BN_CTX object (optional) | ||
| 458 | * \return 1 on success and 0 if an error occured | ||
| 459 | */ | ||
| 460 | int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, | ||
| 461 | const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); | ||
| 462 | |||
| 463 | /** Gets the affine coordinates of a EC_POINT over GFp | ||
| 464 | * \param group underlying EC_GROUP object | ||
| 465 | * \param p EC_POINT object | ||
| 466 | * \param x BIGNUM for the x-coordinate | ||
| 467 | * \param y BIGNUM for the y-coordinate | ||
| 468 | * \param ctx BN_CTX object (optional) | ||
| 469 | * \return 1 on success and 0 if an error occured | ||
| 470 | */ | ||
| 471 | int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, | ||
| 472 | const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); | ||
| 473 | |||
| 474 | /** Sets the x9.62 compressed coordinates of a EC_POINT over GFp | ||
| 475 | * \param group underlying EC_GROUP object | ||
| 476 | * \param p EC_POINT object | ||
| 477 | * \param x BIGNUM with x-coordinate | ||
| 478 | * \param y_bit integer with the y-Bit (either 0 or 1) | ||
| 479 | * \param ctx BN_CTX object (optional) | ||
| 480 | * \return 1 on success and 0 if an error occured | ||
| 481 | */ | ||
| 482 | int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, | ||
| 483 | const BIGNUM *x, int y_bit, BN_CTX *ctx); | ||
| 484 | |||
| 485 | /** Sets the affine coordinates of a EC_POINT over GF2m | ||
| 486 | * \param group underlying EC_GROUP object | ||
| 487 | * \param p EC_POINT object | ||
| 488 | * \param x BIGNUM with the x-coordinate | ||
| 489 | * \param y BIGNUM with the y-coordinate | ||
| 490 | * \param ctx BN_CTX object (optional) | ||
| 491 | * \return 1 on success and 0 if an error occured | ||
| 492 | */ | ||
| 493 | int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, | ||
| 494 | const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); | ||
| 495 | |||
| 496 | /** Gets the affine coordinates of a EC_POINT over GF2m | ||
| 497 | * \param group underlying EC_GROUP object | ||
| 498 | * \param p EC_POINT object | ||
| 499 | * \param x BIGNUM for the x-coordinate | ||
| 500 | * \param y BIGNUM for the y-coordinate | ||
| 501 | * \param ctx BN_CTX object (optional) | ||
| 502 | * \return 1 on success and 0 if an error occured | ||
| 503 | */ | ||
| 504 | int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, | ||
| 505 | const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); | ||
| 506 | |||
| 507 | /** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m | ||
| 508 | * \param group underlying EC_GROUP object | ||
| 509 | * \param p EC_POINT object | ||
| 510 | * \param x BIGNUM with x-coordinate | ||
| 511 | * \param y_bit integer with the y-Bit (either 0 or 1) | ||
| 512 | * \param ctx BN_CTX object (optional) | ||
| 513 | * \return 1 on success and 0 if an error occured | ||
| 514 | */ | ||
| 515 | int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, | ||
| 516 | const BIGNUM *x, int y_bit, BN_CTX *ctx); | ||
| 517 | |||
| 518 | /** Encodes a EC_POINT object to a octet string | ||
| 519 | * \param group underlying EC_GROUP object | ||
| 520 | * \param p EC_POINT object | ||
| 521 | * \param form point conversion form | ||
| 522 | * \param buf memory buffer for the result. If NULL the function returns | ||
| 523 | * required buffer size. | ||
| 524 | * \param len length of the memory buffer | ||
| 525 | * \param ctx BN_CTX object (optional) | ||
| 526 | * \return the length of the encoded octet string or 0 if an error occurred | ||
| 527 | */ | ||
| 528 | size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, | ||
| 529 | point_conversion_form_t form, | ||
| 530 | unsigned char *buf, size_t len, BN_CTX *ctx); | ||
| 531 | |||
| 532 | /** Decodes a EC_POINT from a octet string | ||
| 533 | * \param group underlying EC_GROUP object | ||
| 534 | * \param p EC_POINT object | ||
| 535 | * \param buf memory buffer with the encoded ec point | ||
| 536 | * \param len length of the encoded ec point | ||
| 537 | * \param ctx BN_CTX object (optional) | ||
| 538 | * \return 1 on success and 0 if an error occured | ||
| 539 | */ | ||
| 540 | int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, | ||
| 541 | const unsigned char *buf, size_t len, BN_CTX *ctx); | ||
| 233 | 542 | ||
| 234 | /* other interfaces to point2oct/oct2point: */ | 543 | /* other interfaces to point2oct/oct2point: */ |
| 235 | BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, | 544 | BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, |
| @@ -241,29 +550,105 @@ char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, | |||
| 241 | EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, | 550 | EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, |
| 242 | EC_POINT *, BN_CTX *); | 551 | EC_POINT *, BN_CTX *); |
| 243 | 552 | ||
| 244 | int EC_POINT_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); | ||
| 245 | int EC_POINT_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); | ||
| 246 | int EC_POINT_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); | ||
| 247 | 553 | ||
| 248 | int EC_POINT_is_at_infinity(const EC_GROUP *, const EC_POINT *); | 554 | /********************************************************************/ |
| 249 | int EC_POINT_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); | 555 | /* functions for doing EC_POINT arithmetic */ |
| 250 | int EC_POINT_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); | 556 | /********************************************************************/ |
| 557 | |||
| 558 | /** Computes the sum of two EC_POINT | ||
| 559 | * \param group underlying EC_GROUP object | ||
| 560 | * \param r EC_POINT object for the result (r = a + b) | ||
| 561 | * \param a EC_POINT object with the first summand | ||
| 562 | * \param b EC_POINT object with the second summand | ||
| 563 | * \param ctx BN_CTX object (optional) | ||
| 564 | * \return 1 on success and 0 if an error occured | ||
| 565 | */ | ||
| 566 | int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx); | ||
| 567 | |||
| 568 | /** Computes the double of a EC_POINT | ||
| 569 | * \param group underlying EC_GROUP object | ||
| 570 | * \param r EC_POINT object for the result (r = 2 * a) | ||
| 571 | * \param a EC_POINT object | ||
| 572 | * \param ctx BN_CTX object (optional) | ||
| 573 | * \return 1 on success and 0 if an error occured | ||
| 574 | */ | ||
| 575 | int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx); | ||
| 576 | |||
| 577 | /** Computes the inverse of a EC_POINT | ||
| 578 | * \param group underlying EC_GROUP object | ||
| 579 | * \param a EC_POINT object to be inverted (it's used for the result as well) | ||
| 580 | * \param ctx BN_CTX object (optional) | ||
| 581 | * \return 1 on success and 0 if an error occured | ||
| 582 | */ | ||
| 583 | int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); | ||
| 584 | |||
| 585 | /** Checks whether the point is the neutral element of the group | ||
| 586 | * \param group the underlying EC_GROUP object | ||
| 587 | * \param p EC_POINT object | ||
| 588 | * \return 1 if the point is the neutral element and 0 otherwise | ||
| 589 | */ | ||
| 590 | int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p); | ||
| 591 | |||
| 592 | /** Checks whether the point is on the curve | ||
| 593 | * \param group underlying EC_GROUP object | ||
| 594 | * \param point EC_POINT object to check | ||
| 595 | * \param ctx BN_CTX object (optional) | ||
| 596 | * \return 1 if point if on the curve and 0 otherwise | ||
| 597 | */ | ||
| 598 | int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx); | ||
| 599 | |||
| 600 | /** Compares two EC_POINTs | ||
| 601 | * \param group underlying EC_GROUP object | ||
| 602 | * \param a first EC_POINT object | ||
| 603 | * \param b second EC_POINT object | ||
| 604 | * \param ctx BN_CTX object (optional) | ||
| 605 | * \return 0 if both points are equal and a value != 0 otherwise | ||
| 606 | */ | ||
| 607 | int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx); | ||
| 251 | 608 | ||
| 252 | int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); | 609 | int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); |
| 253 | int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); | 610 | int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); |
| 254 | 611 | ||
| 612 | /** Computes r = generator * n sum_{i=0}^num p[i] * m[i] | ||
| 613 | * \param group underlying EC_GROUP object | ||
| 614 | * \param r EC_POINT object for the result | ||
| 615 | * \param n BIGNUM with the multiplier for the group generator (optional) | ||
| 616 | * \param num number futher summands | ||
| 617 | * \param p array of size num of EC_POINT objects | ||
| 618 | * \param m array of size num of BIGNUM objects | ||
| 619 | * \param ctx BN_CTX object (optional) | ||
| 620 | * \return 1 on success and 0 if an error occured | ||
| 621 | */ | ||
| 622 | int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t num, const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx); | ||
| 623 | |||
| 624 | /** Computes r = generator * n + q * m | ||
| 625 | * \param group underlying EC_GROUP object | ||
| 626 | * \param r EC_POINT object for the result | ||
| 627 | * \param n BIGNUM with the multiplier for the group generator (optional) | ||
| 628 | * \param q EC_POINT object with the first factor of the second summand | ||
| 629 | * \param m BIGNUM with the second factor of the second summand | ||
| 630 | * \param ctx BN_CTX object (optional) | ||
| 631 | * \return 1 on success and 0 if an error occured | ||
| 632 | */ | ||
| 633 | int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); | ||
| 255 | 634 | ||
| 256 | int EC_POINTs_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, size_t num, const EC_POINT *[], const BIGNUM *[], BN_CTX *); | 635 | /** Stores multiples of generator for faster point multiplication |
| 257 | int EC_POINT_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, const EC_POINT *, const BIGNUM *, BN_CTX *); | 636 | * \param group EC_GROUP object |
| 258 | 637 | * \param ctx BN_CTX object (optional) | |
| 259 | /* EC_GROUP_precompute_mult() stores multiples of generator for faster point multiplication */ | 638 | * \return 1 on success and 0 if an error occured |
| 260 | int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *); | 639 | */ |
| 261 | /* EC_GROUP_have_precompute_mult() reports whether such precomputation has been done */ | 640 | int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); |
| 262 | int EC_GROUP_have_precompute_mult(const EC_GROUP *); | ||
| 263 | 641 | ||
| 642 | /** Reports whether a precomputation has been done | ||
| 643 | * \param group EC_GROUP object | ||
| 644 | * \return 1 if a pre-computation has been done and 0 otherwise | ||
| 645 | */ | ||
| 646 | int EC_GROUP_have_precompute_mult(const EC_GROUP *group); | ||
| 264 | 647 | ||
| 265 | 648 | ||
| 266 | /* ASN1 stuff */ | 649 | /********************************************************************/ |
| 650 | /* ASN1 stuff */ | ||
| 651 | /********************************************************************/ | ||
| 267 | 652 | ||
| 268 | /* EC_GROUP_get_basis_type() returns the NID of the basis type | 653 | /* EC_GROUP_get_basis_type() returns the NID of the basis type |
| 269 | * used to represent the field elements */ | 654 | * used to represent the field elements */ |
| @@ -293,28 +678,96 @@ int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); | |||
| 293 | int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); | 678 | int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); |
| 294 | #endif | 679 | #endif |
| 295 | 680 | ||
| 296 | /* the EC_KEY stuff */ | 681 | |
| 682 | /********************************************************************/ | ||
| 683 | /* EC_KEY functions */ | ||
| 684 | /********************************************************************/ | ||
| 685 | |||
| 297 | typedef struct ec_key_st EC_KEY; | 686 | typedef struct ec_key_st EC_KEY; |
| 298 | 687 | ||
| 299 | /* some values for the encoding_flag */ | 688 | /* some values for the encoding_flag */ |
| 300 | #define EC_PKEY_NO_PARAMETERS 0x001 | 689 | #define EC_PKEY_NO_PARAMETERS 0x001 |
| 301 | #define EC_PKEY_NO_PUBKEY 0x002 | 690 | #define EC_PKEY_NO_PUBKEY 0x002 |
| 302 | 691 | ||
| 692 | /** Creates a new EC_KEY object. | ||
| 693 | * \return EC_KEY object or NULL if an error occurred. | ||
| 694 | */ | ||
| 303 | EC_KEY *EC_KEY_new(void); | 695 | EC_KEY *EC_KEY_new(void); |
| 696 | |||
| 697 | /** Creates a new EC_KEY object using a named curve as underlying | ||
| 698 | * EC_GROUP object. | ||
| 699 | * \param nid NID of the named curve. | ||
| 700 | * \return EC_KEY object or NULL if an error occurred. | ||
| 701 | */ | ||
| 304 | EC_KEY *EC_KEY_new_by_curve_name(int nid); | 702 | EC_KEY *EC_KEY_new_by_curve_name(int nid); |
| 305 | void EC_KEY_free(EC_KEY *); | 703 | |
| 306 | EC_KEY *EC_KEY_copy(EC_KEY *, const EC_KEY *); | 704 | /** Frees a EC_KEY object. |
| 307 | EC_KEY *EC_KEY_dup(const EC_KEY *); | 705 | * \param key EC_KEY object to be freed. |
| 308 | 706 | */ | |
| 309 | int EC_KEY_up_ref(EC_KEY *); | 707 | void EC_KEY_free(EC_KEY *key); |
| 310 | 708 | ||
| 311 | const EC_GROUP *EC_KEY_get0_group(const EC_KEY *); | 709 | /** Copies a EC_KEY object. |
| 312 | int EC_KEY_set_group(EC_KEY *, const EC_GROUP *); | 710 | * \param dst destination EC_KEY object |
| 313 | const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *); | 711 | * \param src src EC_KEY object |
| 314 | int EC_KEY_set_private_key(EC_KEY *, const BIGNUM *); | 712 | * \return dst or NULL if an error occurred. |
| 315 | const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *); | 713 | */ |
| 316 | int EC_KEY_set_public_key(EC_KEY *, const EC_POINT *); | 714 | EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src); |
| 317 | unsigned EC_KEY_get_enc_flags(const EC_KEY *); | 715 | |
| 716 | /** Creates a new EC_KEY object and copies the content from src to it. | ||
| 717 | * \param src the source EC_KEY object | ||
| 718 | * \return newly created EC_KEY object or NULL if an error occurred. | ||
| 719 | */ | ||
| 720 | EC_KEY *EC_KEY_dup(const EC_KEY *src); | ||
| 721 | |||
| 722 | /** Increases the internal reference count of a EC_KEY object. | ||
| 723 | * \param key EC_KEY object | ||
| 724 | * \return 1 on success and 0 if an error occurred. | ||
| 725 | */ | ||
| 726 | int EC_KEY_up_ref(EC_KEY *key); | ||
| 727 | |||
| 728 | /** Returns the EC_GROUP object of a EC_KEY object | ||
| 729 | * \param key EC_KEY object | ||
| 730 | * \return the EC_GROUP object (possibly NULL). | ||
| 731 | */ | ||
| 732 | const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key); | ||
| 733 | |||
| 734 | /** Sets the EC_GROUP of a EC_KEY object. | ||
| 735 | * \param key EC_KEY object | ||
| 736 | * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY | ||
| 737 | * object will use an own copy of the EC_GROUP). | ||
| 738 | * \return 1 on success and 0 if an error occurred. | ||
| 739 | */ | ||
| 740 | int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group); | ||
| 741 | |||
| 742 | /** Returns the private key of a EC_KEY object. | ||
| 743 | * \param key EC_KEY object | ||
| 744 | * \return a BIGNUM with the private key (possibly NULL). | ||
| 745 | */ | ||
| 746 | const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); | ||
| 747 | |||
| 748 | /** Sets the private key of a EC_KEY object. | ||
| 749 | * \param key EC_KEY object | ||
| 750 | * \param prv BIGNUM with the private key (note: the EC_KEY object | ||
| 751 | * will use an own copy of the BIGNUM). | ||
| 752 | * \return 1 on success and 0 if an error occurred. | ||
| 753 | */ | ||
| 754 | int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); | ||
| 755 | |||
| 756 | /** Returns the public key of a EC_KEY object. | ||
| 757 | * \param key the EC_KEY object | ||
| 758 | * \return a EC_POINT object with the public key (possibly NULL) | ||
| 759 | */ | ||
| 760 | const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); | ||
| 761 | |||
| 762 | /** Sets the public key of a EC_KEY object. | ||
| 763 | * \param key EC_KEY object | ||
| 764 | * \param pub EC_POINT object with the public key (note: the EC_KEY object | ||
| 765 | * will use an own copy of the EC_POINT object). | ||
| 766 | * \return 1 on success and 0 if an error occurred. | ||
| 767 | */ | ||
| 768 | int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); | ||
| 769 | |||
| 770 | unsigned EC_KEY_get_enc_flags(const EC_KEY *key); | ||
| 318 | void EC_KEY_set_enc_flags(EC_KEY *, unsigned int); | 771 | void EC_KEY_set_enc_flags(EC_KEY *, unsigned int); |
| 319 | point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *); | 772 | point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *); |
| 320 | void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t); | 773 | void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t); |
| @@ -325,31 +778,126 @@ void EC_KEY_insert_key_method_data(EC_KEY *, void *data, | |||
| 325 | void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); | 778 | void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); |
| 326 | /* wrapper functions for the underlying EC_GROUP object */ | 779 | /* wrapper functions for the underlying EC_GROUP object */ |
| 327 | void EC_KEY_set_asn1_flag(EC_KEY *, int); | 780 | void EC_KEY_set_asn1_flag(EC_KEY *, int); |
| 328 | int EC_KEY_precompute_mult(EC_KEY *, BN_CTX *ctx); | 781 | |
| 329 | 782 | /** Creates a table of pre-computed multiples of the generator to | |
| 330 | /* EC_KEY_generate_key() creates a ec private (public) key */ | 783 | * accelerate further EC_KEY operations. |
| 331 | int EC_KEY_generate_key(EC_KEY *); | 784 | * \param key EC_KEY object |
| 332 | /* EC_KEY_check_key() */ | 785 | * \param ctx BN_CTX object (optional) |
| 333 | int EC_KEY_check_key(const EC_KEY *); | 786 | * \return 1 on success and 0 if an error occurred. |
| 334 | 787 | */ | |
| 335 | /* de- and encoding functions for SEC1 ECPrivateKey */ | 788 | int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx); |
| 336 | EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len); | 789 | |
| 337 | int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out); | 790 | /** Creates a new ec private (and optional a new public) key. |
| 338 | /* de- and encoding functions for EC parameters */ | 791 | * \param key EC_KEY object |
| 339 | EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len); | 792 | * \return 1 on success and 0 if an error occurred. |
| 340 | int i2d_ECParameters(EC_KEY *a, unsigned char **out); | 793 | */ |
| 341 | /* de- and encoding functions for EC public key | 794 | int EC_KEY_generate_key(EC_KEY *key); |
| 342 | * (octet string, not DER -- hence 'o2i' and 'i2o') */ | 795 | |
| 343 | EC_KEY *o2i_ECPublicKey(EC_KEY **a, const unsigned char **in, long len); | 796 | /** Verifies that a private and/or public key is valid. |
| 344 | int i2o_ECPublicKey(EC_KEY *a, unsigned char **out); | 797 | * \param key the EC_KEY object |
| 798 | * \return 1 on success and 0 otherwise. | ||
| 799 | */ | ||
| 800 | int EC_KEY_check_key(const EC_KEY *key); | ||
| 801 | |||
| 802 | |||
| 803 | /********************************************************************/ | ||
| 804 | /* de- and encoding functions for SEC1 ECPrivateKey */ | ||
| 805 | /********************************************************************/ | ||
| 806 | |||
| 807 | /** Decodes a private key from a memory buffer. | ||
| 808 | * \param key a pointer to a EC_KEY object which should be used (or NULL) | ||
| 809 | * \param in pointer to memory with the DER encoded private key | ||
| 810 | * \param len length of the DER encoded private key | ||
| 811 | * \return the decoded private key or NULL if an error occurred. | ||
| 812 | */ | ||
| 813 | EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len); | ||
| 814 | |||
| 815 | /** Encodes a private key object and stores the result in a buffer. | ||
| 816 | * \param key the EC_KEY object to encode | ||
| 817 | * \param out the buffer for the result (if NULL the function returns number | ||
| 818 | * of bytes needed). | ||
| 819 | * \return 1 on success and 0 if an error occurred. | ||
| 820 | */ | ||
| 821 | int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out); | ||
| 822 | |||
| 823 | |||
| 824 | /********************************************************************/ | ||
| 825 | /* de- and encoding functions for EC parameters */ | ||
| 826 | /********************************************************************/ | ||
| 827 | |||
| 828 | /** Decodes ec parameter from a memory buffer. | ||
| 829 | * \param key a pointer to a EC_KEY object which should be used (or NULL) | ||
| 830 | * \param in pointer to memory with the DER encoded ec parameters | ||
| 831 | * \param len length of the DER encoded ec parameters | ||
| 832 | * \return a EC_KEY object with the decoded parameters or NULL if an error | ||
| 833 | * occurred. | ||
| 834 | */ | ||
| 835 | EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len); | ||
| 836 | |||
| 837 | /** Encodes ec parameter and stores the result in a buffer. | ||
| 838 | * \param key the EC_KEY object with ec paramters to encode | ||
| 839 | * \param out the buffer for the result (if NULL the function returns number | ||
| 840 | * of bytes needed). | ||
| 841 | * \return 1 on success and 0 if an error occurred. | ||
| 842 | */ | ||
| 843 | int i2d_ECParameters(EC_KEY *key, unsigned char **out); | ||
| 844 | |||
| 845 | |||
| 846 | /********************************************************************/ | ||
| 847 | /* de- and encoding functions for EC public key */ | ||
| 848 | /* (octet string, not DER -- hence 'o2i' and 'i2o') */ | ||
| 849 | /********************************************************************/ | ||
| 850 | |||
| 851 | /** Decodes a ec public key from a octet string. | ||
| 852 | * \param key a pointer to a EC_KEY object which should be used | ||
| 853 | * \param in memory buffer with the encoded public key | ||
| 854 | * \param len length of the encoded public key | ||
| 855 | * \return EC_KEY object with decoded public key or NULL if an error | ||
| 856 | * occurred. | ||
| 857 | */ | ||
| 858 | EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len); | ||
| 859 | |||
| 860 | /** Encodes a ec public key in an octet string. | ||
| 861 | * \param key the EC_KEY object with the public key | ||
| 862 | * \param out the buffer for the result (if NULL the function returns number | ||
| 863 | * of bytes needed). | ||
| 864 | * \return 1 on success and 0 if an error occurred | ||
| 865 | */ | ||
| 866 | int i2o_ECPublicKey(EC_KEY *key, unsigned char **out); | ||
| 345 | 867 | ||
| 346 | #ifndef OPENSSL_NO_BIO | 868 | #ifndef OPENSSL_NO_BIO |
| 347 | int ECParameters_print(BIO *bp, const EC_KEY *x); | 869 | /** Prints out the ec parameters on human readable form. |
| 348 | int EC_KEY_print(BIO *bp, const EC_KEY *x, int off); | 870 | * \param bp BIO object to which the information is printed |
| 871 | * \param key EC_KEY object | ||
| 872 | * \return 1 on success and 0 if an error occurred | ||
| 873 | */ | ||
| 874 | int ECParameters_print(BIO *bp, const EC_KEY *key); | ||
| 875 | |||
| 876 | /** Prints out the contents of a EC_KEY object | ||
| 877 | * \param bp BIO object to which the information is printed | ||
| 878 | * \param key EC_KEY object | ||
| 879 | * \param off line offset | ||
| 880 | * \return 1 on success and 0 if an error occurred | ||
| 881 | */ | ||
| 882 | int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); | ||
| 883 | |||
| 349 | #endif | 884 | #endif |
| 350 | #ifndef OPENSSL_NO_FP_API | 885 | #ifndef OPENSSL_NO_FP_API |
| 351 | int ECParameters_print_fp(FILE *fp, const EC_KEY *x); | 886 | /** Prints out the ec parameters on human readable form. |
| 352 | int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off); | 887 | * \param fp file descriptor to which the information is printed |
| 888 | * \param key EC_KEY object | ||
| 889 | * \return 1 on success and 0 if an error occurred | ||
| 890 | */ | ||
| 891 | int ECParameters_print_fp(FILE *fp, const EC_KEY *key); | ||
| 892 | |||
| 893 | /** Prints out the contents of a EC_KEY object | ||
| 894 | * \param fp file descriptor to which the information is printed | ||
| 895 | * \param key EC_KEY object | ||
| 896 | * \param off line offset | ||
| 897 | * \return 1 on success and 0 if an error occurred | ||
| 898 | */ | ||
| 899 | int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); | ||
| 900 | |||
| 353 | #endif | 901 | #endif |
| 354 | 902 | ||
| 355 | #define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) | 903 | #define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) |
| @@ -362,6 +910,13 @@ int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off); | |||
| 362 | # endif | 910 | # endif |
| 363 | #endif | 911 | #endif |
| 364 | 912 | ||
| 913 | #define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \ | ||
| 914 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \ | ||
| 915 | EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL) | ||
| 916 | |||
| 917 | |||
| 918 | #define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1) | ||
| 919 | |||
| 365 | /* BEGIN ERROR CODES */ | 920 | /* BEGIN ERROR CODES */ |
| 366 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 921 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
| 367 | * made after this point may be overwritten when the script is next run. | 922 | * made after this point may be overwritten when the script is next run. |
| @@ -375,6 +930,14 @@ void ERR_load_EC_strings(void); | |||
| 375 | #define EC_F_D2I_ECPARAMETERS 144 | 930 | #define EC_F_D2I_ECPARAMETERS 144 |
| 376 | #define EC_F_D2I_ECPKPARAMETERS 145 | 931 | #define EC_F_D2I_ECPKPARAMETERS 145 |
| 377 | #define EC_F_D2I_ECPRIVATEKEY 146 | 932 | #define EC_F_D2I_ECPRIVATEKEY 146 |
| 933 | #define EC_F_DO_EC_KEY_PRINT 221 | ||
| 934 | #define EC_F_ECKEY_PARAM2TYPE 223 | ||
| 935 | #define EC_F_ECKEY_PARAM_DECODE 212 | ||
| 936 | #define EC_F_ECKEY_PRIV_DECODE 213 | ||
| 937 | #define EC_F_ECKEY_PRIV_ENCODE 214 | ||
| 938 | #define EC_F_ECKEY_PUB_DECODE 215 | ||
| 939 | #define EC_F_ECKEY_PUB_ENCODE 216 | ||
| 940 | #define EC_F_ECKEY_TYPE2PARAM 220 | ||
| 378 | #define EC_F_ECPARAMETERS_PRINT 147 | 941 | #define EC_F_ECPARAMETERS_PRINT 147 |
| 379 | #define EC_F_ECPARAMETERS_PRINT_FP 148 | 942 | #define EC_F_ECPARAMETERS_PRINT_FP 148 |
| 380 | #define EC_F_ECPKPARAMETERS_PRINT 149 | 943 | #define EC_F_ECPKPARAMETERS_PRINT 149 |
| @@ -448,7 +1011,6 @@ void ERR_load_EC_strings(void); | |||
| 448 | #define EC_F_EC_KEY_PRINT 180 | 1011 | #define EC_F_EC_KEY_PRINT 180 |
| 449 | #define EC_F_EC_KEY_PRINT_FP 181 | 1012 | #define EC_F_EC_KEY_PRINT_FP 181 |
| 450 | #define EC_F_EC_POINTS_MAKE_AFFINE 136 | 1013 | #define EC_F_EC_POINTS_MAKE_AFFINE 136 |
| 451 | #define EC_F_EC_POINTS_MUL 138 | ||
| 452 | #define EC_F_EC_POINT_ADD 112 | 1014 | #define EC_F_EC_POINT_ADD 112 |
| 453 | #define EC_F_EC_POINT_CMP 113 | 1015 | #define EC_F_EC_POINT_CMP 113 |
| 454 | #define EC_F_EC_POINT_COPY 114 | 1016 | #define EC_F_EC_POINT_COPY 114 |
| @@ -479,21 +1041,31 @@ void ERR_load_EC_strings(void); | |||
| 479 | #define EC_F_I2D_ECPRIVATEKEY 192 | 1041 | #define EC_F_I2D_ECPRIVATEKEY 192 |
| 480 | #define EC_F_I2O_ECPUBLICKEY 151 | 1042 | #define EC_F_I2O_ECPUBLICKEY 151 |
| 481 | #define EC_F_O2I_ECPUBLICKEY 152 | 1043 | #define EC_F_O2I_ECPUBLICKEY 152 |
| 1044 | #define EC_F_OLD_EC_PRIV_DECODE 222 | ||
| 1045 | #define EC_F_PKEY_EC_CTRL 197 | ||
| 1046 | #define EC_F_PKEY_EC_CTRL_STR 198 | ||
| 1047 | #define EC_F_PKEY_EC_DERIVE 217 | ||
| 1048 | #define EC_F_PKEY_EC_KEYGEN 199 | ||
| 1049 | #define EC_F_PKEY_EC_PARAMGEN 219 | ||
| 1050 | #define EC_F_PKEY_EC_SIGN 218 | ||
| 482 | 1051 | ||
| 483 | /* Reason codes. */ | 1052 | /* Reason codes. */ |
| 484 | #define EC_R_ASN1_ERROR 115 | 1053 | #define EC_R_ASN1_ERROR 115 |
| 485 | #define EC_R_ASN1_UNKNOWN_FIELD 116 | 1054 | #define EC_R_ASN1_UNKNOWN_FIELD 116 |
| 486 | #define EC_R_BUFFER_TOO_SMALL 100 | 1055 | #define EC_R_BUFFER_TOO_SMALL 100 |
| 487 | #define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 | 1056 | #define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 |
| 1057 | #define EC_R_DECODE_ERROR 142 | ||
| 488 | #define EC_R_DISCRIMINANT_IS_ZERO 118 | 1058 | #define EC_R_DISCRIMINANT_IS_ZERO 118 |
| 489 | #define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 | 1059 | #define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 |
| 490 | #define EC_R_FIELD_TOO_LARGE 138 | 1060 | #define EC_R_FIELD_TOO_LARGE 143 |
| 491 | #define EC_R_GROUP2PKPARAMETERS_FAILURE 120 | 1061 | #define EC_R_GROUP2PKPARAMETERS_FAILURE 120 |
| 492 | #define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 | 1062 | #define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 |
| 493 | #define EC_R_INCOMPATIBLE_OBJECTS 101 | 1063 | #define EC_R_INCOMPATIBLE_OBJECTS 101 |
| 494 | #define EC_R_INVALID_ARGUMENT 112 | 1064 | #define EC_R_INVALID_ARGUMENT 112 |
| 495 | #define EC_R_INVALID_COMPRESSED_POINT 110 | 1065 | #define EC_R_INVALID_COMPRESSED_POINT 110 |
| 496 | #define EC_R_INVALID_COMPRESSION_BIT 109 | 1066 | #define EC_R_INVALID_COMPRESSION_BIT 109 |
| 1067 | #define EC_R_INVALID_CURVE 141 | ||
| 1068 | #define EC_R_INVALID_DIGEST_TYPE 138 | ||
| 497 | #define EC_R_INVALID_ENCODING 102 | 1069 | #define EC_R_INVALID_ENCODING 102 |
| 498 | #define EC_R_INVALID_FIELD 103 | 1070 | #define EC_R_INVALID_FIELD 103 |
| 499 | #define EC_R_INVALID_FORM 104 | 1071 | #define EC_R_INVALID_FORM 104 |
| @@ -501,6 +1073,7 @@ void ERR_load_EC_strings(void); | |||
| 501 | #define EC_R_INVALID_PENTANOMIAL_BASIS 132 | 1073 | #define EC_R_INVALID_PENTANOMIAL_BASIS 132 |
| 502 | #define EC_R_INVALID_PRIVATE_KEY 123 | 1074 | #define EC_R_INVALID_PRIVATE_KEY 123 |
| 503 | #define EC_R_INVALID_TRINOMIAL_BASIS 137 | 1075 | #define EC_R_INVALID_TRINOMIAL_BASIS 137 |
| 1076 | #define EC_R_KEYS_NOT_SET 140 | ||
| 504 | #define EC_R_MISSING_PARAMETERS 124 | 1077 | #define EC_R_MISSING_PARAMETERS 124 |
| 505 | #define EC_R_MISSING_PRIVATE_KEY 125 | 1078 | #define EC_R_MISSING_PRIVATE_KEY 125 |
| 506 | #define EC_R_NOT_A_NIST_PRIME 135 | 1079 | #define EC_R_NOT_A_NIST_PRIME 135 |
| @@ -508,6 +1081,7 @@ void ERR_load_EC_strings(void); | |||
| 508 | #define EC_R_NOT_IMPLEMENTED 126 | 1081 | #define EC_R_NOT_IMPLEMENTED 126 |
| 509 | #define EC_R_NOT_INITIALIZED 111 | 1082 | #define EC_R_NOT_INITIALIZED 111 |
| 510 | #define EC_R_NO_FIELD_MOD 133 | 1083 | #define EC_R_NO_FIELD_MOD 133 |
| 1084 | #define EC_R_NO_PARAMETERS_SET 139 | ||
| 511 | #define EC_R_PASSED_NULL_PARAMETER 134 | 1085 | #define EC_R_PASSED_NULL_PARAMETER 134 |
| 512 | #define EC_R_PKPARAMETERS2GROUP_FAILURE 127 | 1086 | #define EC_R_PKPARAMETERS2GROUP_FAILURE 127 |
| 513 | #define EC_R_POINT_AT_INFINITY 106 | 1087 | #define EC_R_POINT_AT_INFINITY 106 |
diff --git a/src/lib/libcrypto/ec/ec2_mult.c b/src/lib/libcrypto/ec/ec2_mult.c index ff368fd7d7..ab631a50a2 100644 --- a/src/lib/libcrypto/ec/ec2_mult.c +++ b/src/lib/libcrypto/ec/ec2_mult.c | |||
| @@ -76,7 +76,7 @@ | |||
| 76 | * coordinates. | 76 | * coordinates. |
| 77 | * Uses algorithm Mdouble in appendix of | 77 | * Uses algorithm Mdouble in appendix of |
| 78 | * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over | 78 | * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over |
| 79 | * GF(2^m) without precomputation". | 79 | * GF(2^m) without precomputation" (CHES '99, LNCS 1717). |
| 80 | * modified to not require precomputation of c=b^{2^{m-1}}. | 80 | * modified to not require precomputation of c=b^{2^{m-1}}. |
| 81 | */ | 81 | */ |
| 82 | static int gf2m_Mdouble(const EC_GROUP *group, BIGNUM *x, BIGNUM *z, BN_CTX *ctx) | 82 | static int gf2m_Mdouble(const EC_GROUP *group, BIGNUM *x, BIGNUM *z, BN_CTX *ctx) |
| @@ -107,8 +107,8 @@ static int gf2m_Mdouble(const EC_GROUP *group, BIGNUM *x, BIGNUM *z, BN_CTX *ctx | |||
| 107 | /* Compute the x-coordinate x1/z1 for the point (x1/z1)+(x2/x2) in Montgomery | 107 | /* Compute the x-coordinate x1/z1 for the point (x1/z1)+(x2/x2) in Montgomery |
| 108 | * projective coordinates. | 108 | * projective coordinates. |
| 109 | * Uses algorithm Madd in appendix of | 109 | * Uses algorithm Madd in appendix of |
| 110 | * Lopex, J. and Dahab, R. "Fast multiplication on elliptic curves over | 110 | * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over |
| 111 | * GF(2^m) without precomputation". | 111 | * GF(2^m) without precomputation" (CHES '99, LNCS 1717). |
| 112 | */ | 112 | */ |
| 113 | static int gf2m_Madd(const EC_GROUP *group, const BIGNUM *x, BIGNUM *x1, BIGNUM *z1, | 113 | static int gf2m_Madd(const EC_GROUP *group, const BIGNUM *x, BIGNUM *x1, BIGNUM *z1, |
| 114 | const BIGNUM *x2, const BIGNUM *z2, BN_CTX *ctx) | 114 | const BIGNUM *x2, const BIGNUM *z2, BN_CTX *ctx) |
| @@ -140,8 +140,8 @@ static int gf2m_Madd(const EC_GROUP *group, const BIGNUM *x, BIGNUM *x1, BIGNUM | |||
| 140 | 140 | ||
| 141 | /* Compute the x, y affine coordinates from the point (x1, z1) (x2, z2) | 141 | /* Compute the x, y affine coordinates from the point (x1, z1) (x2, z2) |
| 142 | * using Montgomery point multiplication algorithm Mxy() in appendix of | 142 | * using Montgomery point multiplication algorithm Mxy() in appendix of |
| 143 | * Lopex, J. and Dahab, R. "Fast multiplication on elliptic curves over | 143 | * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over |
| 144 | * GF(2^m) without precomputation". | 144 | * GF(2^m) without precomputation" (CHES '99, LNCS 1717). |
| 145 | * Returns: | 145 | * Returns: |
| 146 | * 0 on error | 146 | * 0 on error |
| 147 | * 1 if return value should be the point at infinity | 147 | * 1 if return value should be the point at infinity |
| @@ -209,15 +209,15 @@ static int gf2m_Mxy(const EC_GROUP *group, const BIGNUM *x, const BIGNUM *y, BIG | |||
| 209 | /* Computes scalar*point and stores the result in r. | 209 | /* Computes scalar*point and stores the result in r. |
| 210 | * point can not equal r. | 210 | * point can not equal r. |
| 211 | * Uses algorithm 2P of | 211 | * Uses algorithm 2P of |
| 212 | * Lopex, J. and Dahab, R. "Fast multiplication on elliptic curves over | 212 | * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over |
| 213 | * GF(2^m) without precomputation". | 213 | * GF(2^m) without precomputation" (CHES '99, LNCS 1717). |
| 214 | */ | 214 | */ |
| 215 | static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | 215 | static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, |
| 216 | const EC_POINT *point, BN_CTX *ctx) | 216 | const EC_POINT *point, BN_CTX *ctx) |
| 217 | { | 217 | { |
| 218 | BIGNUM *x1, *x2, *z1, *z2; | 218 | BIGNUM *x1, *x2, *z1, *z2; |
| 219 | int ret = 0, i, j; | 219 | int ret = 0, i; |
| 220 | BN_ULONG mask; | 220 | BN_ULONG mask,word; |
| 221 | 221 | ||
| 222 | if (r == point) | 222 | if (r == point) |
| 223 | { | 223 | { |
| @@ -251,22 +251,24 @@ static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r, | |||
| 251 | if (!BN_GF2m_add(x2, x2, &group->b)) goto err; /* x2 = x^4 + b */ | 251 | if (!BN_GF2m_add(x2, x2, &group->b)) goto err; /* x2 = x^4 + b */ |
| 252 | 252 | ||
| 253 | /* find top most bit and go one past it */ | 253 | /* find top most bit and go one past it */ |
| 254 | i = scalar->top - 1; j = BN_BITS2 - 1; | 254 | i = scalar->top - 1; |
| 255 | mask = BN_TBIT; | 255 | mask = BN_TBIT; |
| 256 | while (!(scalar->d[i] & mask)) { mask >>= 1; j--; } | 256 | word = scalar->d[i]; |
| 257 | mask >>= 1; j--; | 257 | while (!(word & mask)) mask >>= 1; |
| 258 | mask >>= 1; | ||
| 258 | /* if top most bit was at word break, go to next word */ | 259 | /* if top most bit was at word break, go to next word */ |
| 259 | if (!mask) | 260 | if (!mask) |
| 260 | { | 261 | { |
| 261 | i--; j = BN_BITS2 - 1; | 262 | i--; |
| 262 | mask = BN_TBIT; | 263 | mask = BN_TBIT; |
| 263 | } | 264 | } |
| 264 | 265 | ||
| 265 | for (; i >= 0; i--) | 266 | for (; i >= 0; i--) |
| 266 | { | 267 | { |
| 267 | for (; j >= 0; j--) | 268 | word = scalar->d[i]; |
| 269 | while (mask) | ||
| 268 | { | 270 | { |
| 269 | if (scalar->d[i] & mask) | 271 | if (word & mask) |
| 270 | { | 272 | { |
| 271 | if (!gf2m_Madd(group, &point->X, x1, z1, x2, z2, ctx)) goto err; | 273 | if (!gf2m_Madd(group, &point->X, x1, z1, x2, z2, ctx)) goto err; |
| 272 | if (!gf2m_Mdouble(group, x2, z2, ctx)) goto err; | 274 | if (!gf2m_Mdouble(group, x2, z2, ctx)) goto err; |
| @@ -278,7 +280,6 @@ static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r, | |||
| 278 | } | 280 | } |
| 279 | mask >>= 1; | 281 | mask >>= 1; |
| 280 | } | 282 | } |
| 281 | j = BN_BITS2 - 1; | ||
| 282 | mask = BN_TBIT; | 283 | mask = BN_TBIT; |
| 283 | } | 284 | } |
| 284 | 285 | ||
diff --git a/src/lib/libcrypto/ec/ec2_smpl.c b/src/lib/libcrypto/ec/ec2_smpl.c index 5cd1eac41f..cf357b462a 100644 --- a/src/lib/libcrypto/ec/ec2_smpl.c +++ b/src/lib/libcrypto/ec/ec2_smpl.c | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | * | 14 | * |
| 15 | */ | 15 | */ |
| 16 | /* ==================================================================== | 16 | /* ==================================================================== |
| 17 | * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. | 17 | * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. |
| 18 | * | 18 | * |
| 19 | * Redistribution and use in source and binary forms, with or without | 19 | * Redistribution and use in source and binary forms, with or without |
| 20 | * modification, are permitted provided that the following conditions | 20 | * modification, are permitted provided that the following conditions |
| @@ -157,6 +157,7 @@ void ec_GF2m_simple_group_clear_finish(EC_GROUP *group) | |||
| 157 | group->poly[2] = 0; | 157 | group->poly[2] = 0; |
| 158 | group->poly[3] = 0; | 158 | group->poly[3] = 0; |
| 159 | group->poly[4] = 0; | 159 | group->poly[4] = 0; |
| 160 | group->poly[5] = -1; | ||
| 160 | } | 161 | } |
| 161 | 162 | ||
| 162 | 163 | ||
| @@ -174,8 +175,9 @@ int ec_GF2m_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src) | |||
| 174 | dest->poly[2] = src->poly[2]; | 175 | dest->poly[2] = src->poly[2]; |
| 175 | dest->poly[3] = src->poly[3]; | 176 | dest->poly[3] = src->poly[3]; |
| 176 | dest->poly[4] = src->poly[4]; | 177 | dest->poly[4] = src->poly[4]; |
| 177 | bn_wexpand(&dest->a, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2); | 178 | dest->poly[5] = src->poly[5]; |
| 178 | bn_wexpand(&dest->b, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2); | 179 | if (bn_wexpand(&dest->a, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) return 0; |
| 180 | if (bn_wexpand(&dest->b, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) return 0; | ||
| 179 | for (i = dest->a.top; i < dest->a.dmax; i++) dest->a.d[i] = 0; | 181 | for (i = dest->a.top; i < dest->a.dmax; i++) dest->a.d[i] = 0; |
| 180 | for (i = dest->b.top; i < dest->b.dmax; i++) dest->b.d[i] = 0; | 182 | for (i = dest->b.top; i < dest->b.dmax; i++) dest->b.d[i] = 0; |
| 181 | return 1; | 183 | return 1; |
| @@ -190,7 +192,7 @@ int ec_GF2m_simple_group_set_curve(EC_GROUP *group, | |||
| 190 | 192 | ||
| 191 | /* group->field */ | 193 | /* group->field */ |
| 192 | if (!BN_copy(&group->field, p)) goto err; | 194 | if (!BN_copy(&group->field, p)) goto err; |
| 193 | i = BN_GF2m_poly2arr(&group->field, group->poly, 5); | 195 | i = BN_GF2m_poly2arr(&group->field, group->poly, 6) - 1; |
| 194 | if ((i != 5) && (i != 3)) | 196 | if ((i != 5) && (i != 3)) |
| 195 | { | 197 | { |
| 196 | ECerr(EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE, EC_R_UNSUPPORTED_FIELD); | 198 | ECerr(EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE, EC_R_UNSUPPORTED_FIELD); |
| @@ -199,12 +201,12 @@ int ec_GF2m_simple_group_set_curve(EC_GROUP *group, | |||
| 199 | 201 | ||
| 200 | /* group->a */ | 202 | /* group->a */ |
| 201 | if (!BN_GF2m_mod_arr(&group->a, a, group->poly)) goto err; | 203 | if (!BN_GF2m_mod_arr(&group->a, a, group->poly)) goto err; |
| 202 | bn_wexpand(&group->a, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2); | 204 | if(bn_wexpand(&group->a, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) goto err; |
| 203 | for (i = group->a.top; i < group->a.dmax; i++) group->a.d[i] = 0; | 205 | for (i = group->a.top; i < group->a.dmax; i++) group->a.d[i] = 0; |
| 204 | 206 | ||
| 205 | /* group->b */ | 207 | /* group->b */ |
| 206 | if (!BN_GF2m_mod_arr(&group->b, b, group->poly)) goto err; | 208 | if (!BN_GF2m_mod_arr(&group->b, b, group->poly)) goto err; |
| 207 | bn_wexpand(&group->b, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2); | 209 | if(bn_wexpand(&group->b, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) goto err; |
| 208 | for (i = group->b.top; i < group->b.dmax; i++) group->b.d[i] = 0; | 210 | for (i = group->b.top; i < group->b.dmax; i++) group->b.d[i] = 0; |
| 209 | 211 | ||
| 210 | ret = 1; | 212 | ret = 1; |
| @@ -404,18 +406,94 @@ int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_ | |||
| 404 | } | 406 | } |
| 405 | 407 | ||
| 406 | 408 | ||
| 407 | /* Include patented algorithms. */ | 409 | /* Calculates and sets the affine coordinates of an EC_POINT from the given |
| 408 | #include "ec2_smpt.c" | 410 | * compressed coordinates. Uses algorithm 2.3.4 of SEC 1. |
| 411 | * Note that the simple implementation only uses affine coordinates. | ||
| 412 | * | ||
| 413 | * The method is from the following publication: | ||
| 414 | * | ||
| 415 | * Harper, Menezes, Vanstone: | ||
| 416 | * "Public-Key Cryptosystems with Very Small Key Lengths", | ||
| 417 | * EUROCRYPT '92, Springer-Verlag LNCS 658, | ||
| 418 | * published February 1993 | ||
| 419 | * | ||
| 420 | * US Patents 6,141,420 and 6,618,483 (Vanstone, Mullin, Agnew) describe | ||
| 421 | * the same method, but claim no priority date earlier than July 29, 1994 | ||
| 422 | * (and additionally fail to cite the EUROCRYPT '92 publication as prior art). | ||
| 423 | */ | ||
| 424 | int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point, | ||
| 425 | const BIGNUM *x_, int y_bit, BN_CTX *ctx) | ||
| 426 | { | ||
| 427 | BN_CTX *new_ctx = NULL; | ||
| 428 | BIGNUM *tmp, *x, *y, *z; | ||
| 429 | int ret = 0, z0; | ||
| 430 | |||
| 431 | /* clear error queue */ | ||
| 432 | ERR_clear_error(); | ||
| 433 | |||
| 434 | if (ctx == NULL) | ||
| 435 | { | ||
| 436 | ctx = new_ctx = BN_CTX_new(); | ||
| 437 | if (ctx == NULL) | ||
| 438 | return 0; | ||
| 439 | } | ||
| 440 | |||
| 441 | y_bit = (y_bit != 0) ? 1 : 0; | ||
| 442 | |||
| 443 | BN_CTX_start(ctx); | ||
| 444 | tmp = BN_CTX_get(ctx); | ||
| 445 | x = BN_CTX_get(ctx); | ||
| 446 | y = BN_CTX_get(ctx); | ||
| 447 | z = BN_CTX_get(ctx); | ||
| 448 | if (z == NULL) goto err; | ||
| 449 | |||
| 450 | if (!BN_GF2m_mod_arr(x, x_, group->poly)) goto err; | ||
| 451 | if (BN_is_zero(x)) | ||
| 452 | { | ||
| 453 | if (!BN_GF2m_mod_sqrt_arr(y, &group->b, group->poly, ctx)) goto err; | ||
| 454 | } | ||
| 455 | else | ||
| 456 | { | ||
| 457 | if (!group->meth->field_sqr(group, tmp, x, ctx)) goto err; | ||
| 458 | if (!group->meth->field_div(group, tmp, &group->b, tmp, ctx)) goto err; | ||
| 459 | if (!BN_GF2m_add(tmp, &group->a, tmp)) goto err; | ||
| 460 | if (!BN_GF2m_add(tmp, x, tmp)) goto err; | ||
| 461 | if (!BN_GF2m_mod_solve_quad_arr(z, tmp, group->poly, ctx)) | ||
| 462 | { | ||
| 463 | unsigned long err = ERR_peek_last_error(); | ||
| 464 | |||
| 465 | if (ERR_GET_LIB(err) == ERR_LIB_BN && ERR_GET_REASON(err) == BN_R_NO_SOLUTION) | ||
| 466 | { | ||
| 467 | ERR_clear_error(); | ||
| 468 | ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES, EC_R_INVALID_COMPRESSED_POINT); | ||
| 469 | } | ||
| 470 | else | ||
| 471 | ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES, ERR_R_BN_LIB); | ||
| 472 | goto err; | ||
| 473 | } | ||
| 474 | z0 = (BN_is_odd(z)) ? 1 : 0; | ||
| 475 | if (!group->meth->field_mul(group, y, x, z, ctx)) goto err; | ||
| 476 | if (z0 != y_bit) | ||
| 477 | { | ||
| 478 | if (!BN_GF2m_add(y, y, x)) goto err; | ||
| 479 | } | ||
| 480 | } | ||
| 481 | |||
| 482 | if (!EC_POINT_set_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err; | ||
| 483 | |||
| 484 | ret = 1; | ||
| 485 | |||
| 486 | err: | ||
| 487 | BN_CTX_end(ctx); | ||
| 488 | if (new_ctx != NULL) | ||
| 489 | BN_CTX_free(new_ctx); | ||
| 490 | return ret; | ||
| 491 | } | ||
| 409 | 492 | ||
| 410 | 493 | ||
| 411 | /* Converts an EC_POINT to an octet string. | 494 | /* Converts an EC_POINT to an octet string. |
| 412 | * If buf is NULL, the encoded length will be returned. | 495 | * If buf is NULL, the encoded length will be returned. |
| 413 | * If the length len of buf is smaller than required an error will be returned. | 496 | * If the length len of buf is smaller than required an error will be returned. |
| 414 | * | ||
| 415 | * The point compression section of this function is patented by Certicom Corp. | ||
| 416 | * under US Patent 6,141,420. Point compression is disabled by default and can | ||
| 417 | * be enabled by defining the preprocessor macro OPENSSL_EC_BIN_PT_COMP at | ||
| 418 | * Configure-time. | ||
| 419 | */ | 497 | */ |
| 420 | size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form, | 498 | size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form, |
| 421 | unsigned char *buf, size_t len, BN_CTX *ctx) | 499 | unsigned char *buf, size_t len, BN_CTX *ctx) |
| @@ -426,14 +504,6 @@ size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, po | |||
| 426 | BIGNUM *x, *y, *yxi; | 504 | BIGNUM *x, *y, *yxi; |
| 427 | size_t field_len, i, skip; | 505 | size_t field_len, i, skip; |
| 428 | 506 | ||
| 429 | #ifndef OPENSSL_EC_BIN_PT_COMP | ||
| 430 | if ((form == POINT_CONVERSION_COMPRESSED) || (form == POINT_CONVERSION_HYBRID)) | ||
| 431 | { | ||
| 432 | ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_DISABLED); | ||
| 433 | goto err; | ||
| 434 | } | ||
| 435 | #endif | ||
| 436 | |||
| 437 | if ((form != POINT_CONVERSION_COMPRESSED) | 507 | if ((form != POINT_CONVERSION_COMPRESSED) |
| 438 | && (form != POINT_CONVERSION_UNCOMPRESSED) | 508 | && (form != POINT_CONVERSION_UNCOMPRESSED) |
| 439 | && (form != POINT_CONVERSION_HYBRID)) | 509 | && (form != POINT_CONVERSION_HYBRID)) |
| @@ -488,13 +558,11 @@ size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, po | |||
| 488 | if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err; | 558 | if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err; |
| 489 | 559 | ||
| 490 | buf[0] = form; | 560 | buf[0] = form; |
| 491 | #ifdef OPENSSL_EC_BIN_PT_COMP | ||
| 492 | if ((form != POINT_CONVERSION_UNCOMPRESSED) && !BN_is_zero(x)) | 561 | if ((form != POINT_CONVERSION_UNCOMPRESSED) && !BN_is_zero(x)) |
| 493 | { | 562 | { |
| 494 | if (!group->meth->field_div(group, yxi, y, x, ctx)) goto err; | 563 | if (!group->meth->field_div(group, yxi, y, x, ctx)) goto err; |
| 495 | if (BN_is_odd(yxi)) buf[0]++; | 564 | if (BN_is_odd(yxi)) buf[0]++; |
| 496 | } | 565 | } |
| 497 | #endif | ||
| 498 | 566 | ||
| 499 | i = 1; | 567 | i = 1; |
| 500 | 568 | ||
diff --git a/src/lib/libcrypto/ec/ec_ameth.c b/src/lib/libcrypto/ec/ec_ameth.c new file mode 100644 index 0000000000..c00f7d746c --- /dev/null +++ b/src/lib/libcrypto/ec/ec_ameth.c | |||
| @@ -0,0 +1,659 @@ | |||
| 1 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | ||
| 2 | * project 2006. | ||
| 3 | */ | ||
| 4 | /* ==================================================================== | ||
| 5 | * Copyright (c) 2006 The OpenSSL Project. All rights reserved. | ||
| 6 | * | ||
| 7 | * Redistribution and use in source and binary forms, with or without | ||
| 8 | * modification, are permitted provided that the following conditions | ||
| 9 | * are met: | ||
| 10 | * | ||
| 11 | * 1. Redistributions of source code must retain the above copyright | ||
| 12 | * notice, this list of conditions and the following disclaimer. | ||
| 13 | * | ||
| 14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 15 | * notice, this list of conditions and the following disclaimer in | ||
| 16 | * the documentation and/or other materials provided with the | ||
| 17 | * distribution. | ||
| 18 | * | ||
| 19 | * 3. All advertising materials mentioning features or use of this | ||
| 20 | * software must display the following acknowledgment: | ||
| 21 | * "This product includes software developed by the OpenSSL Project | ||
| 22 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 23 | * | ||
| 24 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 25 | * endorse or promote products derived from this software without | ||
| 26 | * prior written permission. For written permission, please contact | ||
| 27 | * licensing@OpenSSL.org. | ||
| 28 | * | ||
| 29 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 30 | * nor may "OpenSSL" appear in their names without prior written | ||
| 31 | * permission of the OpenSSL Project. | ||
| 32 | * | ||
| 33 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 34 | * acknowledgment: | ||
| 35 | * "This product includes software developed by the OpenSSL Project | ||
| 36 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 37 | * | ||
| 38 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 39 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 41 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 42 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 43 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 44 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 45 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 46 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 47 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 49 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 50 | * ==================================================================== | ||
| 51 | * | ||
| 52 | * This product includes cryptographic software written by Eric Young | ||
| 53 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 54 | * Hudson (tjh@cryptsoft.com). | ||
| 55 | * | ||
| 56 | */ | ||
| 57 | |||
| 58 | #include <stdio.h> | ||
| 59 | #include "cryptlib.h" | ||
| 60 | #include <openssl/x509.h> | ||
| 61 | #include <openssl/ec.h> | ||
| 62 | #include <openssl/bn.h> | ||
| 63 | #ifndef OPENSSL_NO_CMS | ||
| 64 | #include <openssl/cms.h> | ||
| 65 | #endif | ||
| 66 | #include "asn1_locl.h" | ||
| 67 | |||
| 68 | static int eckey_param2type(int *pptype, void **ppval, EC_KEY *ec_key) | ||
| 69 | { | ||
| 70 | const EC_GROUP *group; | ||
| 71 | int nid; | ||
| 72 | if (ec_key == NULL || (group = EC_KEY_get0_group(ec_key)) == NULL) | ||
| 73 | { | ||
| 74 | ECerr(EC_F_ECKEY_PARAM2TYPE, EC_R_MISSING_PARAMETERS); | ||
| 75 | return 0; | ||
| 76 | } | ||
| 77 | if (EC_GROUP_get_asn1_flag(group) | ||
| 78 | && (nid = EC_GROUP_get_curve_name(group))) | ||
| 79 | /* we have a 'named curve' => just set the OID */ | ||
| 80 | { | ||
| 81 | *ppval = OBJ_nid2obj(nid); | ||
| 82 | *pptype = V_ASN1_OBJECT; | ||
| 83 | } | ||
| 84 | else /* explicit parameters */ | ||
| 85 | { | ||
| 86 | ASN1_STRING *pstr = NULL; | ||
| 87 | pstr = ASN1_STRING_new(); | ||
| 88 | if (!pstr) | ||
| 89 | return 0; | ||
| 90 | pstr->length = i2d_ECParameters(ec_key, &pstr->data); | ||
| 91 | if (pstr->length < 0) | ||
| 92 | { | ||
| 93 | ASN1_STRING_free(pstr); | ||
| 94 | ECerr(EC_F_ECKEY_PARAM2TYPE, ERR_R_EC_LIB); | ||
| 95 | return 0; | ||
| 96 | } | ||
| 97 | *ppval = pstr; | ||
| 98 | *pptype = V_ASN1_SEQUENCE; | ||
| 99 | } | ||
| 100 | return 1; | ||
| 101 | } | ||
| 102 | |||
| 103 | static int eckey_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) | ||
| 104 | { | ||
| 105 | EC_KEY *ec_key = pkey->pkey.ec; | ||
| 106 | void *pval = NULL; | ||
| 107 | int ptype; | ||
| 108 | unsigned char *penc = NULL, *p; | ||
| 109 | int penclen; | ||
| 110 | |||
| 111 | if (!eckey_param2type(&ptype, &pval, ec_key)) | ||
| 112 | { | ||
| 113 | ECerr(EC_F_ECKEY_PUB_ENCODE, ERR_R_EC_LIB); | ||
| 114 | return 0; | ||
| 115 | } | ||
| 116 | penclen = i2o_ECPublicKey(ec_key, NULL); | ||
| 117 | if (penclen <= 0) | ||
| 118 | goto err; | ||
| 119 | penc = OPENSSL_malloc(penclen); | ||
| 120 | if (!penc) | ||
| 121 | goto err; | ||
| 122 | p = penc; | ||
| 123 | penclen = i2o_ECPublicKey(ec_key, &p); | ||
| 124 | if (penclen <= 0) | ||
| 125 | goto err; | ||
| 126 | if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_EC), | ||
| 127 | ptype, pval, penc, penclen)) | ||
| 128 | return 1; | ||
| 129 | err: | ||
| 130 | if (ptype == V_ASN1_OBJECT) | ||
| 131 | ASN1_OBJECT_free(pval); | ||
| 132 | else | ||
| 133 | ASN1_STRING_free(pval); | ||
| 134 | if (penc) | ||
| 135 | OPENSSL_free(penc); | ||
| 136 | return 0; | ||
| 137 | } | ||
| 138 | |||
| 139 | static EC_KEY *eckey_type2param(int ptype, void *pval) | ||
| 140 | { | ||
| 141 | EC_KEY *eckey = NULL; | ||
| 142 | if (ptype == V_ASN1_SEQUENCE) | ||
| 143 | { | ||
| 144 | ASN1_STRING *pstr = pval; | ||
| 145 | const unsigned char *pm = NULL; | ||
| 146 | int pmlen; | ||
| 147 | pm = pstr->data; | ||
| 148 | pmlen = pstr->length; | ||
| 149 | if (!(eckey = d2i_ECParameters(NULL, &pm, pmlen))) | ||
| 150 | { | ||
| 151 | ECerr(EC_F_ECKEY_TYPE2PARAM, EC_R_DECODE_ERROR); | ||
| 152 | goto ecerr; | ||
| 153 | } | ||
| 154 | } | ||
| 155 | else if (ptype == V_ASN1_OBJECT) | ||
| 156 | { | ||
| 157 | ASN1_OBJECT *poid = pval; | ||
| 158 | EC_GROUP *group; | ||
| 159 | |||
| 160 | /* type == V_ASN1_OBJECT => the parameters are given | ||
| 161 | * by an asn1 OID | ||
| 162 | */ | ||
| 163 | if ((eckey = EC_KEY_new()) == NULL) | ||
| 164 | { | ||
| 165 | ECerr(EC_F_ECKEY_TYPE2PARAM, ERR_R_MALLOC_FAILURE); | ||
| 166 | goto ecerr; | ||
| 167 | } | ||
| 168 | group = EC_GROUP_new_by_curve_name(OBJ_obj2nid(poid)); | ||
| 169 | if (group == NULL) | ||
| 170 | goto ecerr; | ||
| 171 | EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE); | ||
| 172 | if (EC_KEY_set_group(eckey, group) == 0) | ||
| 173 | goto ecerr; | ||
| 174 | EC_GROUP_free(group); | ||
| 175 | } | ||
| 176 | else | ||
| 177 | { | ||
| 178 | ECerr(EC_F_ECKEY_TYPE2PARAM, EC_R_DECODE_ERROR); | ||
| 179 | goto ecerr; | ||
| 180 | } | ||
| 181 | |||
| 182 | return eckey; | ||
| 183 | |||
| 184 | ecerr: | ||
| 185 | if (eckey) | ||
| 186 | EC_KEY_free(eckey); | ||
| 187 | return NULL; | ||
| 188 | } | ||
| 189 | |||
| 190 | static int eckey_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) | ||
| 191 | { | ||
| 192 | const unsigned char *p = NULL; | ||
| 193 | void *pval; | ||
| 194 | int ptype, pklen; | ||
| 195 | EC_KEY *eckey = NULL; | ||
| 196 | X509_ALGOR *palg; | ||
| 197 | |||
| 198 | if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, &palg, pubkey)) | ||
| 199 | return 0; | ||
| 200 | X509_ALGOR_get0(NULL, &ptype, &pval, palg); | ||
| 201 | |||
| 202 | eckey = eckey_type2param(ptype, pval); | ||
| 203 | |||
| 204 | if (!eckey) | ||
| 205 | { | ||
| 206 | ECerr(EC_F_ECKEY_PUB_DECODE, ERR_R_EC_LIB); | ||
| 207 | return 0; | ||
| 208 | } | ||
| 209 | |||
| 210 | /* We have parameters now set public key */ | ||
| 211 | if (!o2i_ECPublicKey(&eckey, &p, pklen)) | ||
| 212 | { | ||
| 213 | ECerr(EC_F_ECKEY_PUB_DECODE, EC_R_DECODE_ERROR); | ||
| 214 | goto ecerr; | ||
| 215 | } | ||
| 216 | |||
| 217 | EVP_PKEY_assign_EC_KEY(pkey, eckey); | ||
| 218 | return 1; | ||
| 219 | |||
| 220 | ecerr: | ||
| 221 | if (eckey) | ||
| 222 | EC_KEY_free(eckey); | ||
| 223 | return 0; | ||
| 224 | } | ||
| 225 | |||
| 226 | static int eckey_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) | ||
| 227 | { | ||
| 228 | int r; | ||
| 229 | const EC_GROUP *group = EC_KEY_get0_group(b->pkey.ec); | ||
| 230 | const EC_POINT *pa = EC_KEY_get0_public_key(a->pkey.ec), | ||
| 231 | *pb = EC_KEY_get0_public_key(b->pkey.ec); | ||
| 232 | r = EC_POINT_cmp(group, pa, pb, NULL); | ||
| 233 | if (r == 0) | ||
| 234 | return 1; | ||
| 235 | if (r == 1) | ||
| 236 | return 0; | ||
| 237 | return -2; | ||
| 238 | } | ||
| 239 | |||
| 240 | static int eckey_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) | ||
| 241 | { | ||
| 242 | const unsigned char *p = NULL; | ||
| 243 | void *pval; | ||
| 244 | int ptype, pklen; | ||
| 245 | EC_KEY *eckey = NULL; | ||
| 246 | X509_ALGOR *palg; | ||
| 247 | |||
| 248 | if (!PKCS8_pkey_get0(NULL, &p, &pklen, &palg, p8)) | ||
| 249 | return 0; | ||
| 250 | X509_ALGOR_get0(NULL, &ptype, &pval, palg); | ||
| 251 | |||
| 252 | eckey = eckey_type2param(ptype, pval); | ||
| 253 | |||
| 254 | if (!eckey) | ||
| 255 | goto ecliberr; | ||
| 256 | |||
| 257 | /* We have parameters now set private key */ | ||
| 258 | if (!d2i_ECPrivateKey(&eckey, &p, pklen)) | ||
| 259 | { | ||
| 260 | ECerr(EC_F_ECKEY_PRIV_DECODE, EC_R_DECODE_ERROR); | ||
| 261 | goto ecerr; | ||
| 262 | } | ||
| 263 | |||
| 264 | /* calculate public key (if necessary) */ | ||
| 265 | if (EC_KEY_get0_public_key(eckey) == NULL) | ||
| 266 | { | ||
| 267 | const BIGNUM *priv_key; | ||
| 268 | const EC_GROUP *group; | ||
| 269 | EC_POINT *pub_key; | ||
| 270 | /* the public key was not included in the SEC1 private | ||
| 271 | * key => calculate the public key */ | ||
| 272 | group = EC_KEY_get0_group(eckey); | ||
| 273 | pub_key = EC_POINT_new(group); | ||
| 274 | if (pub_key == NULL) | ||
| 275 | { | ||
| 276 | ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); | ||
| 277 | goto ecliberr; | ||
| 278 | } | ||
| 279 | if (!EC_POINT_copy(pub_key, EC_GROUP_get0_generator(group))) | ||
| 280 | { | ||
| 281 | EC_POINT_free(pub_key); | ||
| 282 | ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); | ||
| 283 | goto ecliberr; | ||
| 284 | } | ||
| 285 | priv_key = EC_KEY_get0_private_key(eckey); | ||
| 286 | if (!EC_POINT_mul(group, pub_key, priv_key, NULL, NULL, NULL)) | ||
| 287 | { | ||
| 288 | EC_POINT_free(pub_key); | ||
| 289 | ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); | ||
| 290 | goto ecliberr; | ||
| 291 | } | ||
| 292 | if (EC_KEY_set_public_key(eckey, pub_key) == 0) | ||
| 293 | { | ||
| 294 | EC_POINT_free(pub_key); | ||
| 295 | ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); | ||
| 296 | goto ecliberr; | ||
| 297 | } | ||
| 298 | EC_POINT_free(pub_key); | ||
| 299 | } | ||
| 300 | |||
| 301 | EVP_PKEY_assign_EC_KEY(pkey, eckey); | ||
| 302 | return 1; | ||
| 303 | |||
| 304 | ecliberr: | ||
| 305 | ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); | ||
| 306 | ecerr: | ||
| 307 | if (eckey) | ||
| 308 | EC_KEY_free(eckey); | ||
| 309 | return 0; | ||
| 310 | } | ||
| 311 | |||
| 312 | static int eckey_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) | ||
| 313 | { | ||
| 314 | EC_KEY *ec_key; | ||
| 315 | unsigned char *ep, *p; | ||
| 316 | int eplen, ptype; | ||
| 317 | void *pval; | ||
| 318 | unsigned int tmp_flags, old_flags; | ||
| 319 | |||
| 320 | ec_key = pkey->pkey.ec; | ||
| 321 | |||
| 322 | if (!eckey_param2type(&ptype, &pval, ec_key)) | ||
| 323 | { | ||
| 324 | ECerr(EC_F_ECKEY_PRIV_ENCODE, EC_R_DECODE_ERROR); | ||
| 325 | return 0; | ||
| 326 | } | ||
| 327 | |||
| 328 | /* set the private key */ | ||
| 329 | |||
| 330 | /* do not include the parameters in the SEC1 private key | ||
| 331 | * see PKCS#11 12.11 */ | ||
| 332 | old_flags = EC_KEY_get_enc_flags(ec_key); | ||
| 333 | tmp_flags = old_flags | EC_PKEY_NO_PARAMETERS; | ||
| 334 | EC_KEY_set_enc_flags(ec_key, tmp_flags); | ||
| 335 | eplen = i2d_ECPrivateKey(ec_key, NULL); | ||
| 336 | if (!eplen) | ||
| 337 | { | ||
| 338 | EC_KEY_set_enc_flags(ec_key, old_flags); | ||
| 339 | ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_EC_LIB); | ||
| 340 | return 0; | ||
| 341 | } | ||
| 342 | ep = (unsigned char *) OPENSSL_malloc(eplen); | ||
| 343 | if (!ep) | ||
| 344 | { | ||
| 345 | EC_KEY_set_enc_flags(ec_key, old_flags); | ||
| 346 | ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); | ||
| 347 | return 0; | ||
| 348 | } | ||
| 349 | p = ep; | ||
| 350 | if (!i2d_ECPrivateKey(ec_key, &p)) | ||
| 351 | { | ||
| 352 | EC_KEY_set_enc_flags(ec_key, old_flags); | ||
| 353 | OPENSSL_free(ep); | ||
| 354 | ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_EC_LIB); | ||
| 355 | } | ||
| 356 | /* restore old encoding flags */ | ||
| 357 | EC_KEY_set_enc_flags(ec_key, old_flags); | ||
| 358 | |||
| 359 | if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_X9_62_id_ecPublicKey), 0, | ||
| 360 | ptype, pval, ep, eplen)) | ||
| 361 | return 0; | ||
| 362 | |||
| 363 | return 1; | ||
| 364 | } | ||
| 365 | |||
| 366 | static int int_ec_size(const EVP_PKEY *pkey) | ||
| 367 | { | ||
| 368 | return ECDSA_size(pkey->pkey.ec); | ||
| 369 | } | ||
| 370 | |||
| 371 | static int ec_bits(const EVP_PKEY *pkey) | ||
| 372 | { | ||
| 373 | BIGNUM *order = BN_new(); | ||
| 374 | const EC_GROUP *group; | ||
| 375 | int ret; | ||
| 376 | |||
| 377 | if (!order) | ||
| 378 | { | ||
| 379 | ERR_clear_error(); | ||
| 380 | return 0; | ||
| 381 | } | ||
| 382 | group = EC_KEY_get0_group(pkey->pkey.ec); | ||
| 383 | if (!EC_GROUP_get_order(group, order, NULL)) | ||
| 384 | { | ||
| 385 | ERR_clear_error(); | ||
| 386 | return 0; | ||
| 387 | } | ||
| 388 | |||
| 389 | ret = BN_num_bits(order); | ||
| 390 | BN_free(order); | ||
| 391 | return ret; | ||
| 392 | } | ||
| 393 | |||
| 394 | static int ec_missing_parameters(const EVP_PKEY *pkey) | ||
| 395 | { | ||
| 396 | if (EC_KEY_get0_group(pkey->pkey.ec) == NULL) | ||
| 397 | return 1; | ||
| 398 | return 0; | ||
| 399 | } | ||
| 400 | |||
| 401 | static int ec_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) | ||
| 402 | { | ||
| 403 | EC_GROUP *group = EC_GROUP_dup(EC_KEY_get0_group(from->pkey.ec)); | ||
| 404 | if (group == NULL) | ||
| 405 | return 0; | ||
| 406 | if (EC_KEY_set_group(to->pkey.ec, group) == 0) | ||
| 407 | return 0; | ||
| 408 | EC_GROUP_free(group); | ||
| 409 | return 1; | ||
| 410 | } | ||
| 411 | |||
| 412 | static int ec_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b) | ||
| 413 | { | ||
| 414 | const EC_GROUP *group_a = EC_KEY_get0_group(a->pkey.ec), | ||
| 415 | *group_b = EC_KEY_get0_group(b->pkey.ec); | ||
| 416 | if (EC_GROUP_cmp(group_a, group_b, NULL)) | ||
| 417 | return 0; | ||
| 418 | else | ||
| 419 | return 1; | ||
| 420 | } | ||
| 421 | |||
| 422 | static void int_ec_free(EVP_PKEY *pkey) | ||
| 423 | { | ||
| 424 | EC_KEY_free(pkey->pkey.ec); | ||
| 425 | } | ||
| 426 | |||
| 427 | static int do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) | ||
| 428 | { | ||
| 429 | unsigned char *buffer=NULL; | ||
| 430 | const char *ecstr; | ||
| 431 | size_t buf_len=0, i; | ||
| 432 | int ret=0, reason=ERR_R_BIO_LIB; | ||
| 433 | BIGNUM *pub_key=NULL, *order=NULL; | ||
| 434 | BN_CTX *ctx=NULL; | ||
| 435 | const EC_GROUP *group; | ||
| 436 | const EC_POINT *public_key; | ||
| 437 | const BIGNUM *priv_key; | ||
| 438 | |||
| 439 | if (x == NULL || (group = EC_KEY_get0_group(x)) == NULL) | ||
| 440 | { | ||
| 441 | reason = ERR_R_PASSED_NULL_PARAMETER; | ||
| 442 | goto err; | ||
| 443 | } | ||
| 444 | |||
| 445 | ctx = BN_CTX_new(); | ||
| 446 | if (ctx == NULL) | ||
| 447 | { | ||
| 448 | reason = ERR_R_MALLOC_FAILURE; | ||
| 449 | goto err; | ||
| 450 | } | ||
| 451 | |||
| 452 | if (ktype > 0) | ||
| 453 | { | ||
| 454 | public_key = EC_KEY_get0_public_key(x); | ||
| 455 | if ((pub_key = EC_POINT_point2bn(group, public_key, | ||
| 456 | EC_KEY_get_conv_form(x), NULL, ctx)) == NULL) | ||
| 457 | { | ||
| 458 | reason = ERR_R_EC_LIB; | ||
| 459 | goto err; | ||
| 460 | } | ||
| 461 | if (pub_key) | ||
| 462 | buf_len = (size_t)BN_num_bytes(pub_key); | ||
| 463 | } | ||
| 464 | |||
| 465 | if (ktype == 2) | ||
| 466 | { | ||
| 467 | priv_key = EC_KEY_get0_private_key(x); | ||
| 468 | if (priv_key && (i = (size_t)BN_num_bytes(priv_key)) > buf_len) | ||
| 469 | buf_len = i; | ||
| 470 | } | ||
| 471 | else | ||
| 472 | priv_key = NULL; | ||
| 473 | |||
| 474 | if (ktype > 0) | ||
| 475 | { | ||
| 476 | buf_len += 10; | ||
| 477 | if ((buffer = OPENSSL_malloc(buf_len)) == NULL) | ||
| 478 | { | ||
| 479 | reason = ERR_R_MALLOC_FAILURE; | ||
| 480 | goto err; | ||
| 481 | } | ||
| 482 | } | ||
| 483 | if (ktype == 2) | ||
| 484 | ecstr = "Private-Key"; | ||
| 485 | else if (ktype == 1) | ||
| 486 | ecstr = "Public-Key"; | ||
| 487 | else | ||
| 488 | ecstr = "ECDSA-Parameters"; | ||
| 489 | |||
| 490 | if (!BIO_indent(bp, off, 128)) | ||
| 491 | goto err; | ||
| 492 | if ((order = BN_new()) == NULL) | ||
| 493 | goto err; | ||
| 494 | if (!EC_GROUP_get_order(group, order, NULL)) | ||
| 495 | goto err; | ||
| 496 | if (BIO_printf(bp, "%s: (%d bit)\n", ecstr, | ||
| 497 | BN_num_bits(order)) <= 0) goto err; | ||
| 498 | |||
| 499 | if ((priv_key != NULL) && !ASN1_bn_print(bp, "priv:", priv_key, | ||
| 500 | buffer, off)) | ||
| 501 | goto err; | ||
| 502 | if ((pub_key != NULL) && !ASN1_bn_print(bp, "pub: ", pub_key, | ||
| 503 | buffer, off)) | ||
| 504 | goto err; | ||
| 505 | if (!ECPKParameters_print(bp, group, off)) | ||
| 506 | goto err; | ||
| 507 | ret=1; | ||
| 508 | err: | ||
| 509 | if (!ret) | ||
| 510 | ECerr(EC_F_DO_EC_KEY_PRINT, reason); | ||
| 511 | if (pub_key) | ||
| 512 | BN_free(pub_key); | ||
| 513 | if (order) | ||
| 514 | BN_free(order); | ||
| 515 | if (ctx) | ||
| 516 | BN_CTX_free(ctx); | ||
| 517 | if (buffer != NULL) | ||
| 518 | OPENSSL_free(buffer); | ||
| 519 | return(ret); | ||
| 520 | } | ||
| 521 | |||
| 522 | static int eckey_param_decode(EVP_PKEY *pkey, | ||
| 523 | const unsigned char **pder, int derlen) | ||
| 524 | { | ||
| 525 | EC_KEY *eckey; | ||
| 526 | if (!(eckey = d2i_ECParameters(NULL, pder, derlen))) | ||
| 527 | { | ||
| 528 | ECerr(EC_F_ECKEY_PARAM_DECODE, ERR_R_EC_LIB); | ||
| 529 | return 0; | ||
| 530 | } | ||
| 531 | EVP_PKEY_assign_EC_KEY(pkey, eckey); | ||
| 532 | return 1; | ||
| 533 | } | ||
| 534 | |||
| 535 | static int eckey_param_encode(const EVP_PKEY *pkey, unsigned char **pder) | ||
| 536 | { | ||
| 537 | return i2d_ECParameters(pkey->pkey.ec, pder); | ||
| 538 | } | ||
| 539 | |||
| 540 | static int eckey_param_print(BIO *bp, const EVP_PKEY *pkey, int indent, | ||
| 541 | ASN1_PCTX *ctx) | ||
| 542 | { | ||
| 543 | return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 0); | ||
| 544 | } | ||
| 545 | |||
| 546 | static int eckey_pub_print(BIO *bp, const EVP_PKEY *pkey, int indent, | ||
| 547 | ASN1_PCTX *ctx) | ||
| 548 | { | ||
| 549 | return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 1); | ||
| 550 | } | ||
| 551 | |||
| 552 | |||
| 553 | static int eckey_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent, | ||
| 554 | ASN1_PCTX *ctx) | ||
| 555 | { | ||
| 556 | return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 2); | ||
| 557 | } | ||
| 558 | |||
| 559 | static int old_ec_priv_decode(EVP_PKEY *pkey, | ||
| 560 | const unsigned char **pder, int derlen) | ||
| 561 | { | ||
| 562 | EC_KEY *ec; | ||
| 563 | if (!(ec = d2i_ECPrivateKey (NULL, pder, derlen))) | ||
| 564 | { | ||
| 565 | ECerr(EC_F_OLD_EC_PRIV_DECODE, EC_R_DECODE_ERROR); | ||
| 566 | return 0; | ||
| 567 | } | ||
| 568 | EVP_PKEY_assign_EC_KEY(pkey, ec); | ||
| 569 | return 1; | ||
| 570 | } | ||
| 571 | |||
| 572 | static int old_ec_priv_encode(const EVP_PKEY *pkey, unsigned char **pder) | ||
| 573 | { | ||
| 574 | return i2d_ECPrivateKey(pkey->pkey.ec, pder); | ||
| 575 | } | ||
| 576 | |||
| 577 | static int ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) | ||
| 578 | { | ||
| 579 | switch (op) | ||
| 580 | { | ||
| 581 | case ASN1_PKEY_CTRL_PKCS7_SIGN: | ||
| 582 | if (arg1 == 0) | ||
| 583 | { | ||
| 584 | int snid, hnid; | ||
| 585 | X509_ALGOR *alg1, *alg2; | ||
| 586 | PKCS7_SIGNER_INFO_get0_algs(arg2, NULL, &alg1, &alg2); | ||
| 587 | if (alg1 == NULL || alg1->algorithm == NULL) | ||
| 588 | return -1; | ||
| 589 | hnid = OBJ_obj2nid(alg1->algorithm); | ||
| 590 | if (hnid == NID_undef) | ||
| 591 | return -1; | ||
| 592 | if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) | ||
| 593 | return -1; | ||
| 594 | X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); | ||
| 595 | } | ||
| 596 | return 1; | ||
| 597 | #ifndef OPENSSL_NO_CMS | ||
| 598 | case ASN1_PKEY_CTRL_CMS_SIGN: | ||
| 599 | if (arg1 == 0) | ||
| 600 | { | ||
| 601 | int snid, hnid; | ||
| 602 | X509_ALGOR *alg1, *alg2; | ||
| 603 | CMS_SignerInfo_get0_algs(arg2, NULL, NULL, | ||
| 604 | &alg1, &alg2); | ||
| 605 | if (alg1 == NULL || alg1->algorithm == NULL) | ||
| 606 | return -1; | ||
| 607 | hnid = OBJ_obj2nid(alg1->algorithm); | ||
| 608 | if (hnid == NID_undef) | ||
| 609 | return -1; | ||
| 610 | if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) | ||
| 611 | return -1; | ||
| 612 | X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); | ||
| 613 | } | ||
| 614 | return 1; | ||
| 615 | #endif | ||
| 616 | |||
| 617 | case ASN1_PKEY_CTRL_DEFAULT_MD_NID: | ||
| 618 | *(int *)arg2 = NID_sha1; | ||
| 619 | return 2; | ||
| 620 | |||
| 621 | default: | ||
| 622 | return -2; | ||
| 623 | |||
| 624 | } | ||
| 625 | |||
| 626 | } | ||
| 627 | |||
| 628 | const EVP_PKEY_ASN1_METHOD eckey_asn1_meth = | ||
| 629 | { | ||
| 630 | EVP_PKEY_EC, | ||
| 631 | EVP_PKEY_EC, | ||
| 632 | 0, | ||
| 633 | "EC", | ||
| 634 | "OpenSSL EC algorithm", | ||
| 635 | |||
| 636 | eckey_pub_decode, | ||
| 637 | eckey_pub_encode, | ||
| 638 | eckey_pub_cmp, | ||
| 639 | eckey_pub_print, | ||
| 640 | |||
| 641 | eckey_priv_decode, | ||
| 642 | eckey_priv_encode, | ||
| 643 | eckey_priv_print, | ||
| 644 | |||
| 645 | int_ec_size, | ||
| 646 | ec_bits, | ||
| 647 | |||
| 648 | eckey_param_decode, | ||
| 649 | eckey_param_encode, | ||
| 650 | ec_missing_parameters, | ||
| 651 | ec_copy_parameters, | ||
| 652 | ec_cmp_parameters, | ||
| 653 | eckey_param_print, | ||
| 654 | |||
| 655 | int_ec_free, | ||
| 656 | ec_pkey_ctrl, | ||
| 657 | old_ec_priv_decode, | ||
| 658 | old_ec_priv_encode | ||
| 659 | }; | ||
diff --git a/src/lib/libcrypto/ec/ec_curve.c b/src/lib/libcrypto/ec/ec_curve.c index beac20969b..23274e4031 100644 --- a/src/lib/libcrypto/ec/ec_curve.c +++ b/src/lib/libcrypto/ec/ec_curve.c | |||
| @@ -73,926 +73,1690 @@ | |||
| 73 | #include <openssl/err.h> | 73 | #include <openssl/err.h> |
| 74 | #include <openssl/obj_mac.h> | 74 | #include <openssl/obj_mac.h> |
| 75 | 75 | ||
| 76 | typedef struct ec_curve_data_st { | 76 | typedef struct { |
| 77 | int field_type; /* either NID_X9_62_prime_field or | 77 | int field_type, /* either NID_X9_62_prime_field or |
| 78 | * NID_X9_62_characteristic_two_field */ | 78 | * NID_X9_62_characteristic_two_field */ |
| 79 | const char *p; /* either a prime number or a polynomial */ | 79 | seed_len, |
| 80 | const char *a; | 80 | param_len; |
| 81 | const char *b; | 81 | unsigned int cofactor; /* promoted to BN_ULONG */ |
| 82 | const char *x; /* the x coordinate of the generator */ | ||
| 83 | const char *y; /* the y coordinate of the generator */ | ||
| 84 | const char *order; /* the order of the group generated by the | ||
| 85 | * generator */ | ||
| 86 | const BN_ULONG cofactor;/* the cofactor */ | ||
| 87 | const unsigned char *seed;/* the seed (optional) */ | ||
| 88 | size_t seed_len; | ||
| 89 | const char *comment; /* a short description of the curve */ | ||
| 90 | } EC_CURVE_DATA; | 82 | } EC_CURVE_DATA; |
| 91 | 83 | ||
| 92 | /* the nist prime curves */ | 84 | /* the nist prime curves */ |
| 93 | static const unsigned char _EC_NIST_PRIME_192_SEED[] = { | 85 | static const struct { EC_CURVE_DATA h; unsigned char data[20+24*6]; } |
| 94 | 0x30,0x45,0xAE,0x6F,0xC8,0x42,0x2F,0x64,0xED,0x57, | 86 | _EC_NIST_PRIME_192 = { |
| 95 | 0x95,0x28,0xD3,0x81,0x20,0xEA,0xE1,0x21,0x96,0xD5}; | 87 | { NID_X9_62_prime_field,20,24,1 }, |
| 96 | static const EC_CURVE_DATA _EC_NIST_PRIME_192 = { | 88 | { 0x30,0x45,0xAE,0x6F,0xC8,0x42,0x2F,0x64,0xED,0x57, /* seed */ |
| 97 | NID_X9_62_prime_field, | 89 | 0x95,0x28,0xD3,0x81,0x20,0xEA,0xE1,0x21,0x96,0xD5, |
| 98 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF", | 90 | |
| 99 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC", | 91 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 100 | "64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1", | 92 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, |
| 101 | "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012", | 93 | 0xFF,0xFF,0xFF,0xFF, |
| 102 | "07192b95ffc8da78631011ed6b24cdd573f977a11e794811", | 94 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ |
| 103 | "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831",1, | 95 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, |
| 104 | _EC_NIST_PRIME_192_SEED, 20, | 96 | 0xFF,0xFF,0xFF,0xFC, |
| 105 | "NIST/X9.62/SECG curve over a 192 bit prime field" | 97 | 0x64,0x21,0x05,0x19,0xE5,0x9C,0x80,0xE7,0x0F,0xA7, /* b */ |
| 98 | 0xE9,0xAB,0x72,0x24,0x30,0x49,0xFE,0xB8,0xDE,0xEC, | ||
| 99 | 0xC1,0x46,0xB9,0xB1, | ||
| 100 | 0x18,0x8D,0xA8,0x0E,0xB0,0x30,0x90,0xF6,0x7C,0xBF, /* x */ | ||
| 101 | 0x20,0xEB,0x43,0xA1,0x88,0x00,0xF4,0xFF,0x0A,0xFD, | ||
| 102 | 0x82,0xFF,0x10,0x12, | ||
| 103 | 0x07,0x19,0x2b,0x95,0xff,0xc8,0xda,0x78,0x63,0x10, /* y */ | ||
| 104 | 0x11,0xed,0x6b,0x24,0xcd,0xd5,0x73,0xf9,0x77,0xa1, | ||
| 105 | 0x1e,0x79,0x48,0x11, | ||
| 106 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 107 | 0xFF,0xFF,0x99,0xDE,0xF8,0x36,0x14,0x6B,0xC9,0xB1, | ||
| 108 | 0xB4,0xD2,0x28,0x31 } | ||
| 106 | }; | 109 | }; |
| 107 | 110 | ||
| 108 | static const unsigned char _EC_NIST_PRIME_224_SEED[] = { | 111 | static const struct { EC_CURVE_DATA h; unsigned char data[20+28*6]; } |
| 109 | 0xBD,0x71,0x34,0x47,0x99,0xD5,0xC7,0xFC,0xDC,0x45, | 112 | _EC_NIST_PRIME_224 = { |
| 110 | 0xB5,0x9F,0xA3,0xB9,0xAB,0x8F,0x6A,0x94,0x8B,0xC5}; | 113 | { NID_X9_62_prime_field,20,28,1 }, |
| 111 | static const EC_CURVE_DATA _EC_NIST_PRIME_224 = { | 114 | { 0xBD,0x71,0x34,0x47,0x99,0xD5,0xC7,0xFC,0xDC,0x45, /* seed */ |
| 112 | NID_X9_62_prime_field, | 115 | 0xB5,0x9F,0xA3,0xB9,0xAB,0x8F,0x6A,0x94,0x8B,0xC5, |
| 113 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001", | 116 | |
| 114 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE", | 117 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 115 | "B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4", | 118 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, |
| 116 | "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21", | 119 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, |
| 117 | "bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34", | 120 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ |
| 118 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D",1, | 121 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, |
| 119 | _EC_NIST_PRIME_224_SEED, 20, | 122 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, |
| 120 | "NIST/SECG curve over a 224 bit prime field" | 123 | 0xB4,0x05,0x0A,0x85,0x0C,0x04,0xB3,0xAB,0xF5,0x41, /* b */ |
| 124 | 0x32,0x56,0x50,0x44,0xB0,0xB7,0xD7,0xBF,0xD8,0xBA, | ||
| 125 | 0x27,0x0B,0x39,0x43,0x23,0x55,0xFF,0xB4, | ||
| 126 | 0xB7,0x0E,0x0C,0xBD,0x6B,0xB4,0xBF,0x7F,0x32,0x13, /* x */ | ||
| 127 | 0x90,0xB9,0x4A,0x03,0xC1,0xD3,0x56,0xC2,0x11,0x22, | ||
| 128 | 0x34,0x32,0x80,0xD6,0x11,0x5C,0x1D,0x21, | ||
| 129 | 0xbd,0x37,0x63,0x88,0xb5,0xf7,0x23,0xfb,0x4c,0x22, /* y */ | ||
| 130 | 0xdf,0xe6,0xcd,0x43,0x75,0xa0,0x5a,0x07,0x47,0x64, | ||
| 131 | 0x44,0xd5,0x81,0x99,0x85,0x00,0x7e,0x34, | ||
| 132 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 133 | 0xFF,0xFF,0xFF,0xFF,0x16,0xA2,0xE0,0xB8,0xF0,0x3E, | ||
| 134 | 0x13,0xDD,0x29,0x45,0x5C,0x5C,0x2A,0x3D } | ||
| 121 | }; | 135 | }; |
| 122 | 136 | ||
| 123 | static const unsigned char _EC_NIST_PRIME_384_SEED[] = { | 137 | static const struct { EC_CURVE_DATA h; unsigned char data[20+48*6]; } |
| 124 | 0xA3,0x35,0x92,0x6A,0xA3,0x19,0xA2,0x7A,0x1D,0x00, | 138 | _EC_NIST_PRIME_384 = { |
| 125 | 0x89,0x6A,0x67,0x73,0xA4,0x82,0x7A,0xCD,0xAC,0x73}; | 139 | { NID_X9_62_prime_field,20,48,1 }, |
| 126 | static const EC_CURVE_DATA _EC_NIST_PRIME_384 = { | 140 | { 0xA3,0x35,0x92,0x6A,0xA3,0x19,0xA2,0x7A,0x1D,0x00, /* seed */ |
| 127 | NID_X9_62_prime_field, | 141 | 0x89,0x6A,0x67,0x73,0xA4,0x82,0x7A,0xCD,0xAC,0x73, |
| 128 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFF" | 142 | |
| 129 | "FFF0000000000000000FFFFFFFF", | 143 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 130 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFF" | 144 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 131 | "FFF0000000000000000FFFFFFFC", | 145 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 132 | "B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC6563" | 146 | 0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, |
| 133 | "98D8A2ED19D2A85C8EDD3EC2AEF", | 147 | 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, |
| 134 | "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F" | 148 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ |
| 135 | "25DBF55296C3A545E3872760AB7", | 149 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 136 | "3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b" | 150 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 137 | "1ce1d7e819d7a431d7c90ea0e5f", | 151 | 0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, |
| 138 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0" | 152 | 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFC, |
| 139 | "DB248B0A77AECEC196ACCC52973",1, | 153 | 0xB3,0x31,0x2F,0xA7,0xE2,0x3E,0xE7,0xE4,0x98,0x8E, /* b */ |
| 140 | _EC_NIST_PRIME_384_SEED, 20, | 154 | 0x05,0x6B,0xE3,0xF8,0x2D,0x19,0x18,0x1D,0x9C,0x6E, |
| 141 | "NIST/SECG curve over a 384 bit prime field" | 155 | 0xFE,0x81,0x41,0x12,0x03,0x14,0x08,0x8F,0x50,0x13, |
| 156 | 0x87,0x5A,0xC6,0x56,0x39,0x8D,0x8A,0x2E,0xD1,0x9D, | ||
| 157 | 0x2A,0x85,0xC8,0xED,0xD3,0xEC,0x2A,0xEF, | ||
| 158 | 0xAA,0x87,0xCA,0x22,0xBE,0x8B,0x05,0x37,0x8E,0xB1, /* x */ | ||
| 159 | 0xC7,0x1E,0xF3,0x20,0xAD,0x74,0x6E,0x1D,0x3B,0x62, | ||
| 160 | 0x8B,0xA7,0x9B,0x98,0x59,0xF7,0x41,0xE0,0x82,0x54, | ||
| 161 | 0x2A,0x38,0x55,0x02,0xF2,0x5D,0xBF,0x55,0x29,0x6C, | ||
| 162 | 0x3A,0x54,0x5E,0x38,0x72,0x76,0x0A,0xB7, | ||
| 163 | 0x36,0x17,0xde,0x4a,0x96,0x26,0x2c,0x6f,0x5d,0x9e, /* y */ | ||
| 164 | 0x98,0xbf,0x92,0x92,0xdc,0x29,0xf8,0xf4,0x1d,0xbd, | ||
| 165 | 0x28,0x9a,0x14,0x7c,0xe9,0xda,0x31,0x13,0xb5,0xf0, | ||
| 166 | 0xb8,0xc0,0x0a,0x60,0xb1,0xce,0x1d,0x7e,0x81,0x9d, | ||
| 167 | 0x7a,0x43,0x1d,0x7c,0x90,0xea,0x0e,0x5f, | ||
| 168 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 169 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
| 170 | 0xFF,0xFF,0xFF,0xFF,0xC7,0x63,0x4D,0x81,0xF4,0x37, | ||
| 171 | 0x2D,0xDF,0x58,0x1A,0x0D,0xB2,0x48,0xB0,0xA7,0x7A, | ||
| 172 | 0xEC,0xEC,0x19,0x6A,0xCC,0xC5,0x29,0x73 } | ||
| 142 | }; | 173 | }; |
| 143 | 174 | ||
| 144 | static const unsigned char _EC_NIST_PRIME_521_SEED[] = { | 175 | static const struct { EC_CURVE_DATA h; unsigned char data[20+66*6]; } |
| 145 | 0xD0,0x9E,0x88,0x00,0x29,0x1C,0xB8,0x53,0x96,0xCC, | 176 | _EC_NIST_PRIME_521 = { |
| 146 | 0x67,0x17,0x39,0x32,0x84,0xAA,0xA0,0xDA,0x64,0xBA}; | 177 | { NID_X9_62_prime_field,20,66,1 }, |
| 147 | static const EC_CURVE_DATA _EC_NIST_PRIME_521 = { | 178 | { 0xD0,0x9E,0x88,0x00,0x29,0x1C,0xB8,0x53,0x96,0xCC, /* seed */ |
| 148 | NID_X9_62_prime_field, | 179 | 0x67,0x17,0x39,0x32,0x84,0xAA,0xA0,0xDA,0x64,0xBA, |
| 149 | "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" | 180 | |
| 150 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", | 181 | 0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 151 | "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" | 182 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 152 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC", | 183 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 153 | "051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156" | 184 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 154 | "193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00", | 185 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 155 | "C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14" | 186 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 156 | "B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66", | 187 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 157 | "011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c9" | 188 | 0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ |
| 158 | "7ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650", | 189 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 159 | "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51" | 190 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 160 | "868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409",1, | 191 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 161 | _EC_NIST_PRIME_521_SEED, 20, | 192 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 162 | "NIST/SECG curve over a 521 bit prime field" | 193 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 194 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFC, | ||
| 195 | 0x00,0x51,0x95,0x3E,0xB9,0x61,0x8E,0x1C,0x9A,0x1F, /* b */ | ||
| 196 | 0x92,0x9A,0x21,0xA0,0xB6,0x85,0x40,0xEE,0xA2,0xDA, | ||
| 197 | 0x72,0x5B,0x99,0xB3,0x15,0xF3,0xB8,0xB4,0x89,0x91, | ||
| 198 | 0x8E,0xF1,0x09,0xE1,0x56,0x19,0x39,0x51,0xEC,0x7E, | ||
| 199 | 0x93,0x7B,0x16,0x52,0xC0,0xBD,0x3B,0xB1,0xBF,0x07, | ||
| 200 | 0x35,0x73,0xDF,0x88,0x3D,0x2C,0x34,0xF1,0xEF,0x45, | ||
| 201 | 0x1F,0xD4,0x6B,0x50,0x3F,0x00, | ||
| 202 | 0x00,0xC6,0x85,0x8E,0x06,0xB7,0x04,0x04,0xE9,0xCD, /* x */ | ||
| 203 | 0x9E,0x3E,0xCB,0x66,0x23,0x95,0xB4,0x42,0x9C,0x64, | ||
| 204 | 0x81,0x39,0x05,0x3F,0xB5,0x21,0xF8,0x28,0xAF,0x60, | ||
| 205 | 0x6B,0x4D,0x3D,0xBA,0xA1,0x4B,0x5E,0x77,0xEF,0xE7, | ||
| 206 | 0x59,0x28,0xFE,0x1D,0xC1,0x27,0xA2,0xFF,0xA8,0xDE, | ||
| 207 | 0x33,0x48,0xB3,0xC1,0x85,0x6A,0x42,0x9B,0xF9,0x7E, | ||
| 208 | 0x7E,0x31,0xC2,0xE5,0xBD,0x66, | ||
| 209 | 0x01,0x18,0x39,0x29,0x6a,0x78,0x9a,0x3b,0xc0,0x04, /* y */ | ||
| 210 | 0x5c,0x8a,0x5f,0xb4,0x2c,0x7d,0x1b,0xd9,0x98,0xf5, | ||
| 211 | 0x44,0x49,0x57,0x9b,0x44,0x68,0x17,0xaf,0xbd,0x17, | ||
| 212 | 0x27,0x3e,0x66,0x2c,0x97,0xee,0x72,0x99,0x5e,0xf4, | ||
| 213 | 0x26,0x40,0xc5,0x50,0xb9,0x01,0x3f,0xad,0x07,0x61, | ||
| 214 | 0x35,0x3c,0x70,0x86,0xa2,0x72,0xc2,0x40,0x88,0xbe, | ||
| 215 | 0x94,0x76,0x9f,0xd1,0x66,0x50, | ||
| 216 | 0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 217 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
| 218 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
| 219 | 0xFF,0xFF,0xFF,0xFA,0x51,0x86,0x87,0x83,0xBF,0x2F, | ||
| 220 | 0x96,0x6B,0x7F,0xCC,0x01,0x48,0xF7,0x09,0xA5,0xD0, | ||
| 221 | 0x3B,0xB5,0xC9,0xB8,0x89,0x9C,0x47,0xAE,0xBB,0x6F, | ||
| 222 | 0xB7,0x1E,0x91,0x38,0x64,0x09 } | ||
| 163 | }; | 223 | }; |
| 224 | |||
| 164 | /* the x9.62 prime curves (minus the nist prime curves) */ | 225 | /* the x9.62 prime curves (minus the nist prime curves) */ |
| 165 | static const unsigned char _EC_X9_62_PRIME_192V2_SEED[] = { | 226 | static const struct { EC_CURVE_DATA h; unsigned char data[20+24*6]; } |
| 166 | 0x31,0xA9,0x2E,0xE2,0x02,0x9F,0xD1,0x0D,0x90,0x1B, | 227 | _EC_X9_62_PRIME_192V2 = { |
| 167 | 0x11,0x3E,0x99,0x07,0x10,0xF0,0xD2,0x1A,0xC6,0xB6}; | 228 | { NID_X9_62_prime_field,20,24,1 }, |
| 168 | static const EC_CURVE_DATA _EC_X9_62_PRIME_192V2 = { | 229 | { 0x31,0xA9,0x2E,0xE2,0x02,0x9F,0xD1,0x0D,0x90,0x1B, /* seed */ |
| 169 | NID_X9_62_prime_field, | 230 | 0x11,0x3E,0x99,0x07,0x10,0xF0,0xD2,0x1A,0xC6,0xB6, |
| 170 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF", | 231 | |
| 171 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC", | 232 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 172 | "CC22D6DFB95C6B25E49C0D6364A4E5980C393AA21668D953", | 233 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, |
| 173 | "EEA2BAE7E1497842F2DE7769CFE9C989C072AD696F48034A", | 234 | 0xFF,0xFF,0xFF,0xFF, |
| 174 | "6574d11d69b6ec7a672bb82a083df2f2b0847de970b2de15", | 235 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ |
| 175 | "FFFFFFFFFFFFFFFFFFFFFFFE5FB1A724DC80418648D8DD31",1, | 236 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, |
| 176 | _EC_X9_62_PRIME_192V2_SEED, 20, | 237 | 0xFF,0xFF,0xFF,0xFC, |
| 177 | "X9.62 curve over a 192 bit prime field" | 238 | 0xCC,0x22,0xD6,0xDF,0xB9,0x5C,0x6B,0x25,0xE4,0x9C, /* b */ |
| 239 | 0x0D,0x63,0x64,0xA4,0xE5,0x98,0x0C,0x39,0x3A,0xA2, | ||
| 240 | 0x16,0x68,0xD9,0x53, | ||
| 241 | 0xEE,0xA2,0xBA,0xE7,0xE1,0x49,0x78,0x42,0xF2,0xDE, /* x */ | ||
| 242 | 0x77,0x69,0xCF,0xE9,0xC9,0x89,0xC0,0x72,0xAD,0x69, | ||
| 243 | 0x6F,0x48,0x03,0x4A, | ||
| 244 | 0x65,0x74,0xd1,0x1d,0x69,0xb6,0xec,0x7a,0x67,0x2b, /* y */ | ||
| 245 | 0xb8,0x2a,0x08,0x3d,0xf2,0xf2,0xb0,0x84,0x7d,0xe9, | ||
| 246 | 0x70,0xb2,0xde,0x15, | ||
| 247 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 248 | 0xFF,0xFE,0x5F,0xB1,0xA7,0x24,0xDC,0x80,0x41,0x86, | ||
| 249 | 0x48,0xD8,0xDD,0x31 } | ||
| 178 | }; | 250 | }; |
| 179 | 251 | ||
| 180 | static const unsigned char _EC_X9_62_PRIME_192V3_SEED[] = { | 252 | static const struct { EC_CURVE_DATA h; unsigned char data[20+24*6]; } |
| 181 | 0xC4,0x69,0x68,0x44,0x35,0xDE,0xB3,0x78,0xC4,0xB6, | 253 | _EC_X9_62_PRIME_192V3 = { |
| 182 | 0x5C,0xA9,0x59,0x1E,0x2A,0x57,0x63,0x05,0x9A,0x2E}; | 254 | { NID_X9_62_prime_field,20,24,1 }, |
| 183 | static const EC_CURVE_DATA _EC_X9_62_PRIME_192V3 = { | 255 | { 0xC4,0x69,0x68,0x44,0x35,0xDE,0xB3,0x78,0xC4,0xB6, /* seed */ |
| 184 | NID_X9_62_prime_field, | 256 | 0x5C,0xA9,0x59,0x1E,0x2A,0x57,0x63,0x05,0x9A,0x2E, |
| 185 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF", | 257 | |
| 186 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC", | 258 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 187 | "22123DC2395A05CAA7423DAECCC94760A7D462256BD56916", | 259 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, |
| 188 | "7D29778100C65A1DA1783716588DCE2B8B4AEE8E228F1896", | 260 | 0xFF,0xFF,0xFF,0xFF, |
| 189 | "38a90f22637337334b49dcb66a6dc8f9978aca7648a943b0", | 261 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ |
| 190 | "FFFFFFFFFFFFFFFFFFFFFFFF7A62D031C83F4294F640EC13",1, | 262 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, |
| 191 | _EC_X9_62_PRIME_192V3_SEED, 20, | 263 | 0xFF,0xFF,0xFF,0xFC, |
| 192 | "X9.62 curve over a 192 bit prime field" | 264 | 0x22,0x12,0x3D,0xC2,0x39,0x5A,0x05,0xCA,0xA7,0x42, /* b */ |
| 265 | 0x3D,0xAE,0xCC,0xC9,0x47,0x60,0xA7,0xD4,0x62,0x25, | ||
| 266 | 0x6B,0xD5,0x69,0x16, | ||
| 267 | 0x7D,0x29,0x77,0x81,0x00,0xC6,0x5A,0x1D,0xA1,0x78, /* x */ | ||
| 268 | 0x37,0x16,0x58,0x8D,0xCE,0x2B,0x8B,0x4A,0xEE,0x8E, | ||
| 269 | 0x22,0x8F,0x18,0x96, | ||
| 270 | 0x38,0xa9,0x0f,0x22,0x63,0x73,0x37,0x33,0x4b,0x49, /* y */ | ||
| 271 | 0xdc,0xb6,0x6a,0x6d,0xc8,0xf9,0x97,0x8a,0xca,0x76, | ||
| 272 | 0x48,0xa9,0x43,0xb0, | ||
| 273 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 274 | 0xFF,0xFF,0x7A,0x62,0xD0,0x31,0xC8,0x3F,0x42,0x94, | ||
| 275 | 0xF6,0x40,0xEC,0x13 } | ||
| 193 | }; | 276 | }; |
| 194 | 277 | ||
| 195 | static const unsigned char _EC_X9_62_PRIME_239V1_SEED[] = { | 278 | static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } |
| 196 | 0xE4,0x3B,0xB4,0x60,0xF0,0xB8,0x0C,0xC0,0xC0,0xB0, | 279 | _EC_X9_62_PRIME_239V1 = { |
| 197 | 0x75,0x79,0x8E,0x94,0x80,0x60,0xF8,0x32,0x1B,0x7D}; | 280 | { NID_X9_62_prime_field,20,30,1 }, |
| 198 | static const EC_CURVE_DATA _EC_X9_62_PRIME_239V1 = { | 281 | { 0xE4,0x3B,0xB4,0x60,0xF0,0xB8,0x0C,0xC0,0xC0,0xB0, /* seed */ |
| 199 | NID_X9_62_prime_field, | 282 | 0x75,0x79,0x8E,0x94,0x80,0x60,0xF8,0x32,0x1B,0x7D, |
| 200 | "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFF", | 283 | |
| 201 | "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFC", | 284 | 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 202 | "6B016C3BDCF18941D0D654921475CA71A9DB2FB27D1D37796185C2942C0A", | 285 | 0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00, |
| 203 | "0FFA963CDCA8816CCC33B8642BEDF905C3D358573D3F27FBBD3B3CB9AAAF", | 286 | 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 204 | "7debe8e4e90a5dae6e4054ca530ba04654b36818ce226b39fccb7b02f1ae", | 287 | |
| 205 | "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFF9E5E9A9F5D9071FBD1522688909D0B",1, | 288 | 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ |
| 206 | _EC_X9_62_PRIME_239V1_SEED, 20, | 289 | 0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00, |
| 207 | "X9.62 curve over a 239 bit prime field" | 290 | 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFC, |
| 291 | |||
| 292 | 0x6B,0x01,0x6C,0x3B,0xDC,0xF1,0x89,0x41,0xD0,0xD6, /* b */ | ||
| 293 | 0x54,0x92,0x14,0x75,0xCA,0x71,0xA9,0xDB,0x2F,0xB2, | ||
| 294 | 0x7D,0x1D,0x37,0x79,0x61,0x85,0xC2,0x94,0x2C,0x0A, | ||
| 295 | |||
| 296 | 0x0F,0xFA,0x96,0x3C,0xDC,0xA8,0x81,0x6C,0xCC,0x33, /* x */ | ||
| 297 | 0xB8,0x64,0x2B,0xED,0xF9,0x05,0xC3,0xD3,0x58,0x57, | ||
| 298 | 0x3D,0x3F,0x27,0xFB,0xBD,0x3B,0x3C,0xB9,0xAA,0xAF, | ||
| 299 | |||
| 300 | 0x7d,0xeb,0xe8,0xe4,0xe9,0x0a,0x5d,0xae,0x6e,0x40, /* y */ | ||
| 301 | 0x54,0xca,0x53,0x0b,0xa0,0x46,0x54,0xb3,0x68,0x18, | ||
| 302 | 0xce,0x22,0x6b,0x39,0xfc,0xcb,0x7b,0x02,0xf1,0xae, | ||
| 303 | |||
| 304 | 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 305 | 0xFF,0xFF,0x7F,0xFF,0xFF,0x9E,0x5E,0x9A,0x9F,0x5D, | ||
| 306 | 0x90,0x71,0xFB,0xD1,0x52,0x26,0x88,0x90,0x9D,0x0B } | ||
| 208 | }; | 307 | }; |
| 209 | 308 | ||
| 210 | static const unsigned char _EC_X9_62_PRIME_239V2_SEED[] = { | 309 | static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } |
| 211 | 0xE8,0xB4,0x01,0x16,0x04,0x09,0x53,0x03,0xCA,0x3B, | 310 | _EC_X9_62_PRIME_239V2 = { |
| 212 | 0x80,0x99,0x98,0x2B,0xE0,0x9F,0xCB,0x9A,0xE6,0x16}; | 311 | { NID_X9_62_prime_field,20,30,1 }, |
| 213 | static const EC_CURVE_DATA _EC_X9_62_PRIME_239V2 = { | 312 | { 0xE8,0xB4,0x01,0x16,0x04,0x09,0x53,0x03,0xCA,0x3B, /* seed */ |
| 214 | NID_X9_62_prime_field, | 313 | 0x80,0x99,0x98,0x2B,0xE0,0x9F,0xCB,0x9A,0xE6,0x16, |
| 215 | "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFF", | 314 | |
| 216 | "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFC", | 315 | 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 217 | "617FAB6832576CBBFED50D99F0249C3FEE58B94BA0038C7AE84C8C832F2C", | 316 | 0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00, |
| 218 | "38AF09D98727705120C921BB5E9E26296A3CDCF2F35757A0EAFD87B830E7", | 317 | 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 219 | "5b0125e4dbea0ec7206da0fc01d9b081329fb555de6ef460237dff8be4ba", | 318 | |
| 220 | "7FFFFFFFFFFFFFFFFFFFFFFF800000CFA7E8594377D414C03821BC582063",1, | 319 | 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ |
| 221 | _EC_X9_62_PRIME_239V2_SEED, 20, | 320 | 0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00, |
| 222 | "X9.62 curve over a 239 bit prime field" | 321 | 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFC, |
| 322 | |||
| 323 | 0x61,0x7F,0xAB,0x68,0x32,0x57,0x6C,0xBB,0xFE,0xD5, /* b */ | ||
| 324 | 0x0D,0x99,0xF0,0x24,0x9C,0x3F,0xEE,0x58,0xB9,0x4B, | ||
| 325 | 0xA0,0x03,0x8C,0x7A,0xE8,0x4C,0x8C,0x83,0x2F,0x2C, | ||
| 326 | |||
| 327 | 0x38,0xAF,0x09,0xD9,0x87,0x27,0x70,0x51,0x20,0xC9, /* x */ | ||
| 328 | 0x21,0xBB,0x5E,0x9E,0x26,0x29,0x6A,0x3C,0xDC,0xF2, | ||
| 329 | 0xF3,0x57,0x57,0xA0,0xEA,0xFD,0x87,0xB8,0x30,0xE7, | ||
| 330 | |||
| 331 | 0x5b,0x01,0x25,0xe4,0xdb,0xea,0x0e,0xc7,0x20,0x6d, /* y */ | ||
| 332 | 0xa0,0xfc,0x01,0xd9,0xb0,0x81,0x32,0x9f,0xb5,0x55, | ||
| 333 | 0xde,0x6e,0xf4,0x60,0x23,0x7d,0xff,0x8b,0xe4,0xba, | ||
| 334 | |||
| 335 | 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 336 | 0xFF,0xFF,0x80,0x00,0x00,0xCF,0xA7,0xE8,0x59,0x43, | ||
| 337 | 0x77,0xD4,0x14,0xC0,0x38,0x21,0xBC,0x58,0x20,0x63 } | ||
| 223 | }; | 338 | }; |
| 224 | 339 | ||
| 225 | static const unsigned char _EC_X9_62_PRIME_239V3_SEED[] = { | 340 | static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } |
| 226 | 0x7D,0x73,0x74,0x16,0x8F,0xFE,0x34,0x71,0xB6,0x0A, | 341 | _EC_X9_62_PRIME_239V3 = { |
| 227 | 0x85,0x76,0x86,0xA1,0x94,0x75,0xD3,0xBF,0xA2,0xFF}; | 342 | { NID_X9_62_prime_field,20,30,1 }, |
| 228 | static const EC_CURVE_DATA _EC_X9_62_PRIME_239V3 = { | 343 | { 0x7D,0x73,0x74,0x16,0x8F,0xFE,0x34,0x71,0xB6,0x0A, /* seed */ |
| 229 | NID_X9_62_prime_field, | 344 | 0x85,0x76,0x86,0xA1,0x94,0x75,0xD3,0xBF,0xA2,0xFF, |
| 230 | "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFF", | 345 | |
| 231 | "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFC", | 346 | 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 232 | "255705FA2A306654B1F4CB03D6A750A30C250102D4988717D9BA15AB6D3E", | 347 | 0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00, |
| 233 | "6768AE8E18BB92CFCF005C949AA2C6D94853D0E660BBF854B1C9505FE95A", | 348 | 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 234 | "1607e6898f390c06bc1d552bad226f3b6fcfe48b6e818499af18e3ed6cf3", | 349 | |
| 235 | "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFF975DEB41B3A6057C3C432146526551",1, | 350 | 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ |
| 236 | _EC_X9_62_PRIME_239V3_SEED, 20, | 351 | 0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00, |
| 237 | "X9.62 curve over a 239 bit prime field" | 352 | 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFC, |
| 353 | |||
| 354 | 0x25,0x57,0x05,0xFA,0x2A,0x30,0x66,0x54,0xB1,0xF4, /* b */ | ||
| 355 | 0xCB,0x03,0xD6,0xA7,0x50,0xA3,0x0C,0x25,0x01,0x02, | ||
| 356 | 0xD4,0x98,0x87,0x17,0xD9,0xBA,0x15,0xAB,0x6D,0x3E, | ||
| 357 | |||
| 358 | 0x67,0x68,0xAE,0x8E,0x18,0xBB,0x92,0xCF,0xCF,0x00, /* x */ | ||
| 359 | 0x5C,0x94,0x9A,0xA2,0xC6,0xD9,0x48,0x53,0xD0,0xE6, | ||
| 360 | 0x60,0xBB,0xF8,0x54,0xB1,0xC9,0x50,0x5F,0xE9,0x5A, | ||
| 361 | |||
| 362 | 0x16,0x07,0xe6,0x89,0x8f,0x39,0x0c,0x06,0xbc,0x1d, /* y */ | ||
| 363 | 0x55,0x2b,0xad,0x22,0x6f,0x3b,0x6f,0xcf,0xe4,0x8b, | ||
| 364 | 0x6e,0x81,0x84,0x99,0xaf,0x18,0xe3,0xed,0x6c,0xf3, | ||
| 365 | |||
| 366 | 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 367 | 0xFF,0xFF,0x7F,0xFF,0xFF,0x97,0x5D,0xEB,0x41,0xB3, | ||
| 368 | 0xA6,0x05,0x7C,0x3C,0x43,0x21,0x46,0x52,0x65,0x51 } | ||
| 238 | }; | 369 | }; |
| 239 | 370 | ||
| 240 | static const unsigned char _EC_X9_62_PRIME_256V1_SEED[] = { | 371 | |
| 241 | 0xC4,0x9D,0x36,0x08,0x86,0xE7,0x04,0x93,0x6A,0x66, | 372 | static const struct { EC_CURVE_DATA h; unsigned char data[20+32*6]; } |
| 242 | 0x78,0xE1,0x13,0x9D,0x26,0xB7,0x81,0x9F,0x7E,0x90}; | 373 | _EC_X9_62_PRIME_256V1 = { |
| 243 | static const EC_CURVE_DATA _EC_X9_62_PRIME_256V1 = { | 374 | { NID_X9_62_prime_field,20,32,1 }, |
| 244 | NID_X9_62_prime_field, | 375 | { 0xC4,0x9D,0x36,0x08,0x86,0xE7,0x04,0x93,0x6A,0x66, /* seed */ |
| 245 | "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", | 376 | 0x78,0xE1,0x13,0x9D,0x26,0xB7,0x81,0x9F,0x7E,0x90, |
| 246 | "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC", | 377 | |
| 247 | "5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B", | 378 | 0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x01,0x00,0x00, /* p */ |
| 248 | "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", | 379 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 249 | "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5", | 380 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 250 | "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551",1, | 381 | 0xFF,0xFF, |
| 251 | _EC_X9_62_PRIME_256V1_SEED, 20, | 382 | 0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x01,0x00,0x00, /* a */ |
| 252 | "X9.62/SECG curve over a 256 bit prime field" | 383 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 384 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
| 385 | 0xFF,0xFC, | ||
| 386 | 0x5A,0xC6,0x35,0xD8,0xAA,0x3A,0x93,0xE7,0xB3,0xEB, /* b */ | ||
| 387 | 0xBD,0x55,0x76,0x98,0x86,0xBC,0x65,0x1D,0x06,0xB0, | ||
| 388 | 0xCC,0x53,0xB0,0xF6,0x3B,0xCE,0x3C,0x3E,0x27,0xD2, | ||
| 389 | 0x60,0x4B, | ||
| 390 | 0x6B,0x17,0xD1,0xF2,0xE1,0x2C,0x42,0x47,0xF8,0xBC, /* x */ | ||
| 391 | 0xE6,0xE5,0x63,0xA4,0x40,0xF2,0x77,0x03,0x7D,0x81, | ||
| 392 | 0x2D,0xEB,0x33,0xA0,0xF4,0xA1,0x39,0x45,0xD8,0x98, | ||
| 393 | 0xC2,0x96, | ||
| 394 | 0x4f,0xe3,0x42,0xe2,0xfe,0x1a,0x7f,0x9b,0x8e,0xe7, /* y */ | ||
| 395 | 0xeb,0x4a,0x7c,0x0f,0x9e,0x16,0x2b,0xce,0x33,0x57, | ||
| 396 | 0x6b,0x31,0x5e,0xce,0xcb,0xb6,0x40,0x68,0x37,0xbf, | ||
| 397 | 0x51,0xf5, | ||
| 398 | 0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0xFF,0xFF, /* order */ | ||
| 399 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBC,0xE6,0xFA,0xAD, | ||
| 400 | 0xA7,0x17,0x9E,0x84,0xF3,0xB9,0xCA,0xC2,0xFC,0x63, | ||
| 401 | 0x25,0x51 } | ||
| 253 | }; | 402 | }; |
| 403 | |||
| 254 | /* the secg prime curves (minus the nist and x9.62 prime curves) */ | 404 | /* the secg prime curves (minus the nist and x9.62 prime curves) */ |
| 255 | static const unsigned char _EC_SECG_PRIME_112R1_SEED[] = { | 405 | static const struct { EC_CURVE_DATA h; unsigned char data[20+14*6]; } |
| 256 | 0x00,0xF5,0x0B,0x02,0x8E,0x4D,0x69,0x6E,0x67,0x68, | 406 | _EC_SECG_PRIME_112R1 = { |
| 257 | 0x75,0x61,0x51,0x75,0x29,0x04,0x72,0x78,0x3F,0xB1}; | 407 | { NID_X9_62_prime_field,20,14,1 }, |
| 258 | static const EC_CURVE_DATA _EC_SECG_PRIME_112R1 = { | 408 | { 0x00,0xF5,0x0B,0x02,0x8E,0x4D,0x69,0x6E,0x67,0x68, /* seed */ |
| 259 | NID_X9_62_prime_field, | 409 | 0x75,0x61,0x51,0x75,0x29,0x04,0x72,0x78,0x3F,0xB1, |
| 260 | "DB7C2ABF62E35E668076BEAD208B", | 410 | |
| 261 | "DB7C2ABF62E35E668076BEAD2088", | 411 | 0xDB,0x7C,0x2A,0xBF,0x62,0xE3,0x5E,0x66,0x80,0x76, /* p */ |
| 262 | "659EF8BA043916EEDE8911702B22", | 412 | 0xBE,0xAD,0x20,0x8B, |
| 263 | "09487239995A5EE76B55F9C2F098", | 413 | 0xDB,0x7C,0x2A,0xBF,0x62,0xE3,0x5E,0x66,0x80,0x76, /* a */ |
| 264 | "a89ce5af8724c0a23e0e0ff77500", | 414 | 0xBE,0xAD,0x20,0x88, |
| 265 | "DB7C2ABF62E35E7628DFAC6561C5",1, | 415 | 0x65,0x9E,0xF8,0xBA,0x04,0x39,0x16,0xEE,0xDE,0x89, /* b */ |
| 266 | _EC_SECG_PRIME_112R1_SEED, 20, | 416 | 0x11,0x70,0x2B,0x22, |
| 267 | "SECG/WTLS curve over a 112 bit prime field" | 417 | 0x09,0x48,0x72,0x39,0x99,0x5A,0x5E,0xE7,0x6B,0x55, /* x */ |
| 418 | 0xF9,0xC2,0xF0,0x98, | ||
| 419 | 0xa8,0x9c,0xe5,0xaf,0x87,0x24,0xc0,0xa2,0x3e,0x0e, /* y */ | ||
| 420 | 0x0f,0xf7,0x75,0x00, | ||
| 421 | 0xDB,0x7C,0x2A,0xBF,0x62,0xE3,0x5E,0x76,0x28,0xDF, /* order */ | ||
| 422 | 0xAC,0x65,0x61,0xC5 } | ||
| 268 | }; | 423 | }; |
| 269 | 424 | ||
| 270 | static const unsigned char _EC_SECG_PRIME_112R2_SEED[] = { | 425 | static const struct { EC_CURVE_DATA h; unsigned char data[20+14*6]; } |
| 271 | 0x00,0x27,0x57,0xA1,0x11,0x4D,0x69,0x6E,0x67,0x68, | 426 | _EC_SECG_PRIME_112R2 = { |
| 272 | 0x75,0x61,0x51,0x75,0x53,0x16,0xC0,0x5E,0x0B,0xD4}; | 427 | { NID_X9_62_prime_field,20,14,4 }, |
| 273 | static const EC_CURVE_DATA _EC_SECG_PRIME_112R2 = { | 428 | { 0x00,0x27,0x57,0xA1,0x11,0x4D,0x69,0x6E,0x67,0x68, /* seed */ |
| 274 | NID_X9_62_prime_field, | 429 | 0x75,0x61,0x51,0x75,0x53,0x16,0xC0,0x5E,0x0B,0xD4, |
| 275 | "DB7C2ABF62E35E668076BEAD208B", | 430 | |
| 276 | "6127C24C05F38A0AAAF65C0EF02C", | 431 | 0xDB,0x7C,0x2A,0xBF,0x62,0xE3,0x5E,0x66,0x80,0x76, /* p */ |
| 277 | "51DEF1815DB5ED74FCC34C85D709", | 432 | 0xBE,0xAD,0x20,0x8B, |
| 278 | "4BA30AB5E892B4E1649DD0928643", | 433 | 0x61,0x27,0xC2,0x4C,0x05,0xF3,0x8A,0x0A,0xAA,0xF6, /* a */ |
| 279 | "adcd46f5882e3747def36e956e97", | 434 | 0x5C,0x0E,0xF0,0x2C, |
| 280 | "36DF0AAFD8B8D7597CA10520D04B",4, | 435 | 0x51,0xDE,0xF1,0x81,0x5D,0xB5,0xED,0x74,0xFC,0xC3, /* b */ |
| 281 | _EC_SECG_PRIME_112R2_SEED, 20, | 436 | 0x4C,0x85,0xD7,0x09, |
| 282 | "SECG curve over a 112 bit prime field" | 437 | 0x4B,0xA3,0x0A,0xB5,0xE8,0x92,0xB4,0xE1,0x64,0x9D, /* x */ |
| 438 | 0xD0,0x92,0x86,0x43, | ||
| 439 | 0xad,0xcd,0x46,0xf5,0x88,0x2e,0x37,0x47,0xde,0xf3, /* y */ | ||
| 440 | 0x6e,0x95,0x6e,0x97, | ||
| 441 | 0x36,0xDF,0x0A,0xAF,0xD8,0xB8,0xD7,0x59,0x7C,0xA1, /* order */ | ||
| 442 | 0x05,0x20,0xD0,0x4B } | ||
| 283 | }; | 443 | }; |
| 284 | 444 | ||
| 285 | static const unsigned char _EC_SECG_PRIME_128R1_SEED[] = { | 445 | static const struct { EC_CURVE_DATA h; unsigned char data[20+16*6]; } |
| 286 | 0x00,0x0E,0x0D,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61, | 446 | _EC_SECG_PRIME_128R1 = { |
| 287 | 0x51,0x75,0x0C,0xC0,0x3A,0x44,0x73,0xD0,0x36,0x79}; | 447 | { NID_X9_62_prime_field,20,16,1 }, |
| 288 | static const EC_CURVE_DATA _EC_SECG_PRIME_128R1 = { | 448 | { 0x00,0x0E,0x0D,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61, /* seed */ |
| 289 | NID_X9_62_prime_field, | 449 | 0x51,0x75,0x0C,0xC0,0x3A,0x44,0x73,0xD0,0x36,0x79, |
| 290 | "FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF", | 450 | |
| 291 | "FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC", | 451 | 0xFF,0xFF,0xFF,0xFD,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 292 | "E87579C11079F43DD824993C2CEE5ED3", | 452 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 293 | "161FF7528B899B2D0C28607CA52C5B86", | 453 | 0xFF,0xFF,0xFF,0xFD,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ |
| 294 | "cf5ac8395bafeb13c02da292dded7a83", | 454 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFC, |
| 295 | "FFFFFFFE0000000075A30D1B9038A115",1, | 455 | 0xE8,0x75,0x79,0xC1,0x10,0x79,0xF4,0x3D,0xD8,0x24, /* b */ |
| 296 | _EC_SECG_PRIME_128R1_SEED, 20, | 456 | 0x99,0x3C,0x2C,0xEE,0x5E,0xD3, |
| 297 | "SECG curve over a 128 bit prime field" | 457 | 0x16,0x1F,0xF7,0x52,0x8B,0x89,0x9B,0x2D,0x0C,0x28, /* x */ |
| 458 | 0x60,0x7C,0xA5,0x2C,0x5B,0x86, | ||
| 459 | 0xcf,0x5a,0xc8,0x39,0x5b,0xaf,0xeb,0x13,0xc0,0x2d, /* y */ | ||
| 460 | 0xa2,0x92,0xdd,0xed,0x7a,0x83, | ||
| 461 | 0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x75,0xA3, /* order */ | ||
| 462 | 0x0D,0x1B,0x90,0x38,0xA1,0x15 } | ||
| 298 | }; | 463 | }; |
| 299 | 464 | ||
| 300 | static const unsigned char _EC_SECG_PRIME_128R2_SEED[] = { | 465 | static const struct { EC_CURVE_DATA h; unsigned char data[20+16*6]; } |
| 301 | 0x00,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61,0x51,0x75, | 466 | _EC_SECG_PRIME_128R2 = { |
| 302 | 0x12,0xD8,0xF0,0x34,0x31,0xFC,0xE6,0x3B,0x88,0xF4}; | 467 | { NID_X9_62_prime_field,20,16,4 }, |
| 303 | static const EC_CURVE_DATA _EC_SECG_PRIME_128R2 = { | 468 | { 0x00,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61,0x51,0x75, /* seed */ |
| 304 | NID_X9_62_prime_field, | 469 | 0x12,0xD8,0xF0,0x34,0x31,0xFC,0xE6,0x3B,0x88,0xF4, |
| 305 | "FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF", | 470 | |
| 306 | "D6031998D1B3BBFEBF59CC9BBFF9AEE1", | 471 | 0xFF,0xFF,0xFF,0xFD,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 307 | "5EEEFCA380D02919DC2C6558BB6D8A5D", | 472 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 308 | "7B6AA5D85E572983E6FB32A7CDEBC140", | 473 | 0xD6,0x03,0x19,0x98,0xD1,0xB3,0xBB,0xFE,0xBF,0x59, /* a */ |
| 309 | "27b6916a894d3aee7106fe805fc34b44", | 474 | 0xCC,0x9B,0xBF,0xF9,0xAE,0xE1, |
| 310 | "3FFFFFFF7FFFFFFFBE0024720613B5A3",4, | 475 | 0x5E,0xEE,0xFC,0xA3,0x80,0xD0,0x29,0x19,0xDC,0x2C, /* b */ |
| 311 | _EC_SECG_PRIME_128R2_SEED, 20, | 476 | 0x65,0x58,0xBB,0x6D,0x8A,0x5D, |
| 312 | "SECG curve over a 128 bit prime field" | 477 | 0x7B,0x6A,0xA5,0xD8,0x5E,0x57,0x29,0x83,0xE6,0xFB, /* x */ |
| 478 | 0x32,0xA7,0xCD,0xEB,0xC1,0x40, | ||
| 479 | 0x27,0xb6,0x91,0x6a,0x89,0x4d,0x3a,0xee,0x71,0x06, /* y */ | ||
| 480 | 0xfe,0x80,0x5f,0xc3,0x4b,0x44, | ||
| 481 | 0x3F,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xBE,0x00, /* order */ | ||
| 482 | 0x24,0x72,0x06,0x13,0xB5,0xA3 } | ||
| 313 | }; | 483 | }; |
| 314 | 484 | ||
| 315 | static const EC_CURVE_DATA _EC_SECG_PRIME_160K1 = { | 485 | static const struct { EC_CURVE_DATA h; unsigned char data[0+21*6]; } |
| 316 | NID_X9_62_prime_field, | 486 | _EC_SECG_PRIME_160K1 = { |
| 317 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73", | 487 | { NID_X9_62_prime_field,0,21,1 }, |
| 318 | "0", | 488 | { /* no seed */ |
| 319 | "7", | 489 | 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 320 | "3B4C382CE37AA192A4019E763036F4F5DD4D7EBB", | 490 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xAC, |
| 321 | "938cf935318fdced6bc28286531733c3f03c4fee", | 491 | 0x73, |
| 322 | "0100000000000000000001B8FA16DFAB9ACA16B6B3",1, | 492 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 323 | NULL, 0, | 493 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 324 | "SECG curve over a 160 bit prime field" | 494 | 0x00, |
| 495 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ | ||
| 496 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 497 | 0x07, | ||
| 498 | 0x00,0x3B,0x4C,0x38,0x2C,0xE3,0x7A,0xA1,0x92,0xA4, /* x */ | ||
| 499 | 0x01,0x9E,0x76,0x30,0x36,0xF4,0xF5,0xDD,0x4D,0x7E, | ||
| 500 | 0xBB, | ||
| 501 | 0x00,0x93,0x8c,0xf9,0x35,0x31,0x8f,0xdc,0xed,0x6b, /* y */ | ||
| 502 | 0xc2,0x82,0x86,0x53,0x17,0x33,0xc3,0xf0,0x3c,0x4f, | ||
| 503 | 0xee, | ||
| 504 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 505 | 0x01,0xB8,0xFA,0x16,0xDF,0xAB,0x9A,0xCA,0x16,0xB6, | ||
| 506 | 0xB3 } | ||
| 325 | }; | 507 | }; |
| 326 | 508 | ||
| 327 | static const unsigned char _EC_SECG_PRIME_160R1_SEED[] = { | 509 | static const struct { EC_CURVE_DATA h; unsigned char data[20+21*6]; } |
| 328 | 0x10,0x53,0xCD,0xE4,0x2C,0x14,0xD6,0x96,0xE6,0x76, | 510 | _EC_SECG_PRIME_160R1 = { |
| 329 | 0x87,0x56,0x15,0x17,0x53,0x3B,0xF3,0xF8,0x33,0x45}; | 511 | { NID_X9_62_prime_field,20,21,1 }, |
| 330 | static const EC_CURVE_DATA _EC_SECG_PRIME_160R1 = { | 512 | { 0x10,0x53,0xCD,0xE4,0x2C,0x14,0xD6,0x96,0xE6,0x76, /* seed */ |
| 331 | NID_X9_62_prime_field, | 513 | 0x87,0x56,0x15,0x17,0x53,0x3B,0xF3,0xF8,0x33,0x45, |
| 332 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF", | 514 | |
| 333 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC", | 515 | 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 334 | "1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45", | 516 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF, |
| 335 | "4A96B5688EF573284664698968C38BB913CBFC82", | 517 | 0xFF, |
| 336 | "23a628553168947d59dcc912042351377ac5fb32", | 518 | 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ |
| 337 | "0100000000000000000001F4C8F927AED3CA752257",1, | 519 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF, |
| 338 | _EC_SECG_PRIME_160R1_SEED, 20, | 520 | 0xFC, |
| 339 | "SECG curve over a 160 bit prime field" | 521 | 0x00,0x1C,0x97,0xBE,0xFC,0x54,0xBD,0x7A,0x8B,0x65, /* b */ |
| 522 | 0xAC,0xF8,0x9F,0x81,0xD4,0xD4,0xAD,0xC5,0x65,0xFA, | ||
| 523 | 0x45, | ||
| 524 | 0x00,0x4A,0x96,0xB5,0x68,0x8E,0xF5,0x73,0x28,0x46, /* x */ | ||
| 525 | 0x64,0x69,0x89,0x68,0xC3,0x8B,0xB9,0x13,0xCB,0xFC, | ||
| 526 | 0x82, | ||
| 527 | 0x00,0x23,0xa6,0x28,0x55,0x31,0x68,0x94,0x7d,0x59, /* y */ | ||
| 528 | 0xdc,0xc9,0x12,0x04,0x23,0x51,0x37,0x7a,0xc5,0xfb, | ||
| 529 | 0x32, | ||
| 530 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 531 | 0x01,0xF4,0xC8,0xF9,0x27,0xAE,0xD3,0xCA,0x75,0x22, | ||
| 532 | 0x57 } | ||
| 340 | }; | 533 | }; |
| 341 | 534 | ||
| 342 | static const unsigned char _EC_SECG_PRIME_160R2_SEED[] = { | 535 | static const struct { EC_CURVE_DATA h; unsigned char data[20+21*6]; } |
| 343 | 0xB9,0x9B,0x99,0xB0,0x99,0xB3,0x23,0xE0,0x27,0x09, | 536 | _EC_SECG_PRIME_160R2 = { |
| 344 | 0xA4,0xD6,0x96,0xE6,0x76,0x87,0x56,0x15,0x17,0x51}; | 537 | { NID_X9_62_prime_field,20,21,1 }, |
| 345 | static const EC_CURVE_DATA _EC_SECG_PRIME_160R2 = { | 538 | { 0xB9,0x9B,0x99,0xB0,0x99,0xB3,0x23,0xE0,0x27,0x09, /* seed */ |
| 346 | NID_X9_62_prime_field, | 539 | 0xA4,0xD6,0x96,0xE6,0x76,0x87,0x56,0x15,0x17,0x51, |
| 347 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73", | 540 | |
| 348 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC70", | 541 | 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 349 | "B4E134D3FB59EB8BAB57274904664D5AF50388BA", | 542 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xAC, |
| 350 | "52DCB034293A117E1F4FF11B30F7199D3144CE6D", | 543 | 0x73, |
| 351 | "feaffef2e331f296e071fa0df9982cfea7d43f2e", | 544 | 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ |
| 352 | "0100000000000000000000351EE786A818F3A1A16B",1, | 545 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xAC, |
| 353 | _EC_SECG_PRIME_160R2_SEED, 20, | 546 | 0x70, |
| 354 | "SECG/WTLS curve over a 160 bit prime field" | 547 | 0x00,0xB4,0xE1,0x34,0xD3,0xFB,0x59,0xEB,0x8B,0xAB, /* b */ |
| 548 | 0x57,0x27,0x49,0x04,0x66,0x4D,0x5A,0xF5,0x03,0x88, | ||
| 549 | 0xBA, | ||
| 550 | 0x00,0x52,0xDC,0xB0,0x34,0x29,0x3A,0x11,0x7E,0x1F, /* x */ | ||
| 551 | 0x4F,0xF1,0x1B,0x30,0xF7,0x19,0x9D,0x31,0x44,0xCE, | ||
| 552 | 0x6D, | ||
| 553 | 0x00,0xfe,0xaf,0xfe,0xf2,0xe3,0x31,0xf2,0x96,0xe0, /* y */ | ||
| 554 | 0x71,0xfa,0x0d,0xf9,0x98,0x2c,0xfe,0xa7,0xd4,0x3f, | ||
| 555 | 0x2e, | ||
| 556 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 557 | 0x00,0x35,0x1E,0xE7,0x86,0xA8,0x18,0xF3,0xA1,0xA1, | ||
| 558 | 0x6B } | ||
| 355 | }; | 559 | }; |
| 356 | 560 | ||
| 357 | static const EC_CURVE_DATA _EC_SECG_PRIME_192K1 = { | 561 | static const struct { EC_CURVE_DATA h; unsigned char data[0+24*6]; } |
| 358 | NID_X9_62_prime_field, | 562 | _EC_SECG_PRIME_192K1 = { |
| 359 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37", | 563 | { NID_X9_62_prime_field,0,24,1 }, |
| 360 | "0", | 564 | { /* no seed */ |
| 361 | "3", | 565 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 362 | "DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D", | 566 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, |
| 363 | "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d", | 567 | 0xFF,0xFF,0xEE,0x37, |
| 364 | "FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D",1, | 568 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 365 | NULL, 20, | 569 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 366 | "SECG curve over a 192 bit prime field" | 570 | 0x00,0x00,0x00,0x00, |
| 571 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ | ||
| 572 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 573 | 0x00,0x00,0x00,0x03, | ||
| 574 | 0xDB,0x4F,0xF1,0x0E,0xC0,0x57,0xE9,0xAE,0x26,0xB0, /* x */ | ||
| 575 | 0x7D,0x02,0x80,0xB7,0xF4,0x34,0x1D,0xA5,0xD1,0xB1, | ||
| 576 | 0xEA,0xE0,0x6C,0x7D, | ||
| 577 | 0x9b,0x2f,0x2f,0x6d,0x9c,0x56,0x28,0xa7,0x84,0x41, /* y */ | ||
| 578 | 0x63,0xd0,0x15,0xbe,0x86,0x34,0x40,0x82,0xaa,0x88, | ||
| 579 | 0xd9,0x5e,0x2f,0x9d, | ||
| 580 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 581 | 0xFF,0xFE,0x26,0xF2,0xFC,0x17,0x0F,0x69,0x46,0x6A, | ||
| 582 | 0x74,0xDE,0xFD,0x8D } | ||
| 367 | }; | 583 | }; |
| 368 | 584 | ||
| 369 | static const EC_CURVE_DATA _EC_SECG_PRIME_224K1 = { | 585 | static const struct { EC_CURVE_DATA h; unsigned char data[0+29*6]; } |
| 370 | NID_X9_62_prime_field, | 586 | _EC_SECG_PRIME_224K1 = { |
| 371 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFE56D", | 587 | { NID_X9_62_prime_field,0,29,1 }, |
| 372 | "0", | 588 | { /* no seed */ |
| 373 | "5", | 589 | 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 374 | "A1455B334DF099DF30FC28A169A467E9E47075A90F7E650EB6B7A45C", | 590 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 375 | "7e089fed7fba344282cafbd6f7e319f7c0b0bd59e2ca4bdb556d61a5", | 591 | 0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xE5,0x6D, |
| 376 | "010000000000000000000000000001DCE8D2EC6184CAF0A971769FB1F7",1, | 592 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 377 | NULL, 20, | 593 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 378 | "SECG curve over a 224 bit prime field" | 594 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 595 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ | ||
| 596 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 597 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05, | ||
| 598 | 0x00,0xA1,0x45,0x5B,0x33,0x4D,0xF0,0x99,0xDF,0x30, /* x */ | ||
| 599 | 0xFC,0x28,0xA1,0x69,0xA4,0x67,0xE9,0xE4,0x70,0x75, | ||
| 600 | 0xA9,0x0F,0x7E,0x65,0x0E,0xB6,0xB7,0xA4,0x5C, | ||
| 601 | 0x00,0x7e,0x08,0x9f,0xed,0x7f,0xba,0x34,0x42,0x82, /* y */ | ||
| 602 | 0xca,0xfb,0xd6,0xf7,0xe3,0x19,0xf7,0xc0,0xb0,0xbd, | ||
| 603 | 0x59,0xe2,0xca,0x4b,0xdb,0x55,0x6d,0x61,0xa5, | ||
| 604 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 605 | 0x00,0x00,0x00,0x00,0x01,0xDC,0xE8,0xD2,0xEC,0x61, | ||
| 606 | 0x84,0xCA,0xF0,0xA9,0x71,0x76,0x9F,0xB1,0xF7 } | ||
| 379 | }; | 607 | }; |
| 380 | 608 | ||
| 381 | static const EC_CURVE_DATA _EC_SECG_PRIME_256K1 = { | 609 | static const struct { EC_CURVE_DATA h; unsigned char data[0+32*6]; } |
| 382 | NID_X9_62_prime_field, | 610 | _EC_SECG_PRIME_256K1 = { |
| 383 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", | 611 | { NID_X9_62_prime_field,0,32,1 }, |
| 384 | "0", | 612 | { /* no seed */ |
| 385 | "7", | 613 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 386 | "79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798", | 614 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
| 387 | "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", | 615 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF, |
| 388 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141",1, | 616 | 0xFC,0x2F, |
| 389 | NULL, 20, | 617 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 390 | "SECG curve over a 256 bit prime field" | 618 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 619 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 620 | 0x00,0x00, | ||
| 621 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ | ||
| 622 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 623 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 624 | 0x00,0x07, | ||
| 625 | 0x79,0xBE,0x66,0x7E,0xF9,0xDC,0xBB,0xAC,0x55,0xA0, /* x */ | ||
| 626 | 0x62,0x95,0xCE,0x87,0x0B,0x07,0x02,0x9B,0xFC,0xDB, | ||
| 627 | 0x2D,0xCE,0x28,0xD9,0x59,0xF2,0x81,0x5B,0x16,0xF8, | ||
| 628 | 0x17,0x98, | ||
| 629 | 0x48,0x3a,0xda,0x77,0x26,0xa3,0xc4,0x65,0x5d,0xa4, /* y */ | ||
| 630 | 0xfb,0xfc,0x0e,0x11,0x08,0xa8,0xfd,0x17,0xb4,0x48, | ||
| 631 | 0xa6,0x85,0x54,0x19,0x9c,0x47,0xd0,0x8f,0xfb,0x10, | ||
| 632 | 0xd4,0xb8, | ||
| 633 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 634 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xBA,0xAE,0xDC,0xE6, | ||
| 635 | 0xAF,0x48,0xA0,0x3B,0xBF,0xD2,0x5E,0x8C,0xD0,0x36, | ||
| 636 | 0x41,0x41 } | ||
| 391 | }; | 637 | }; |
| 392 | 638 | ||
| 393 | /* some wap/wtls curves */ | 639 | /* some wap/wtls curves */ |
| 394 | static const EC_CURVE_DATA _EC_WTLS_8 = { | 640 | static const struct { EC_CURVE_DATA h; unsigned char data[0+15*6]; } |
| 395 | NID_X9_62_prime_field, | 641 | _EC_WTLS_8 = { |
| 396 | "FFFFFFFFFFFFFFFFFFFFFFFFFDE7", | 642 | { NID_X9_62_prime_field,0,15,1 }, |
| 397 | "0", | 643 | { /* no seed */ |
| 398 | "3", | 644 | 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 399 | "1", | 645 | 0xFF,0xFF,0xFF,0xFD,0xE7, |
| 400 | "2", | 646 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 401 | "0100000000000001ECEA551AD837E9",1, | 647 | 0x00,0x00,0x00,0x00,0x00, |
| 402 | NULL, 20, | 648 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ |
| 403 | "WTLS curve over a 112 bit prime field" | 649 | 0x00,0x00,0x00,0x00,0x03, |
| 650 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* x */ | ||
| 651 | 0x00,0x00,0x00,0x00,0x01, | ||
| 652 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* y */ | ||
| 653 | 0x00,0x00,0x00,0x00,0x02, | ||
| 654 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xEC,0xEA, /* order */ | ||
| 655 | 0x55,0x1A,0xD8,0x37,0xE9 } | ||
| 404 | }; | 656 | }; |
| 405 | 657 | ||
| 406 | static const EC_CURVE_DATA _EC_WTLS_9 = { | 658 | static const struct { EC_CURVE_DATA h; unsigned char data[0+21*6]; } |
| 407 | NID_X9_62_prime_field, | 659 | _EC_WTLS_9 = { |
| 408 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC808F", | 660 | { NID_X9_62_prime_field,0,21,1 }, |
| 409 | "0", | 661 | { /* no seed */ |
| 410 | "3", | 662 | 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 411 | "1", | 663 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x80, |
| 412 | "2", | 664 | 0x8F, |
| 413 | "0100000000000000000001CDC98AE0E2DE574ABF33",1, | 665 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 414 | NULL, 20, | 666 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 415 | "WTLS curve over a 160 bit prime field" | 667 | 0x00, |
| 668 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ | ||
| 669 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 670 | 0x03, | ||
| 671 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* x */ | ||
| 672 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 673 | 0x01, | ||
| 674 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* y */ | ||
| 675 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 676 | 0x02, | ||
| 677 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 678 | 0x01,0xCD,0xC9,0x8A,0xE0,0xE2,0xDE,0x57,0x4A,0xBF, | ||
| 679 | 0x33 } | ||
| 416 | }; | 680 | }; |
| 417 | 681 | ||
| 418 | static const EC_CURVE_DATA _EC_WTLS_12 = { | 682 | static const struct { EC_CURVE_DATA h; unsigned char data[0+28*6]; } |
| 419 | NID_X9_62_prime_field, | 683 | _EC_WTLS_12 = { |
| 420 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001", | 684 | { NID_X9_62_prime_field,0,28,1 }, |
| 421 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE", | 685 | { /* no seed */ |
| 422 | "B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4", | 686 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* p */ |
| 423 | "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21", | 687 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, |
| 424 | "bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34", | 688 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, |
| 425 | "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D", 1, | 689 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* a */ |
| 426 | NULL, 0, | 690 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF, |
| 427 | "WTLS curvs over a 224 bit prime field" | 691 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, |
| 692 | 0xB4,0x05,0x0A,0x85,0x0C,0x04,0xB3,0xAB,0xF5,0x41, /* b */ | ||
| 693 | 0x32,0x56,0x50,0x44,0xB0,0xB7,0xD7,0xBF,0xD8,0xBA, | ||
| 694 | 0x27,0x0B,0x39,0x43,0x23,0x55,0xFF,0xB4, | ||
| 695 | 0xB7,0x0E,0x0C,0xBD,0x6B,0xB4,0xBF,0x7F,0x32,0x13, /* x */ | ||
| 696 | 0x90,0xB9,0x4A,0x03,0xC1,0xD3,0x56,0xC2,0x11,0x22, | ||
| 697 | 0x34,0x32,0x80,0xD6,0x11,0x5C,0x1D,0x21, | ||
| 698 | 0xbd,0x37,0x63,0x88,0xb5,0xf7,0x23,0xfb,0x4c,0x22, /* y */ | ||
| 699 | 0xdf,0xe6,0xcd,0x43,0x75,0xa0,0x5a,0x07,0x47,0x64, | ||
| 700 | 0x44,0xd5,0x81,0x99,0x85,0x00,0x7e,0x34, | ||
| 701 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 702 | 0xFF,0xFF,0xFF,0xFF,0x16,0xA2,0xE0,0xB8,0xF0,0x3E, | ||
| 703 | 0x13,0xDD,0x29,0x45,0x5C,0x5C,0x2A,0x3D } | ||
| 428 | }; | 704 | }; |
| 429 | 705 | ||
| 430 | /* characteristic two curves */ | 706 | /* characteristic two curves */ |
| 431 | static const unsigned char _EC_SECG_CHAR2_113R1_SEED[] = { | 707 | static const struct { EC_CURVE_DATA h; unsigned char data[20+15*6]; } |
| 432 | 0x10,0xE7,0x23,0xAB,0x14,0xD6,0x96,0xE6,0x76,0x87, | 708 | _EC_SECG_CHAR2_113R1 = { |
| 433 | 0x56,0x15,0x17,0x56,0xFE,0xBF,0x8F,0xCB,0x49,0xA9}; | 709 | { NID_X9_62_characteristic_two_field,20,15,2 }, |
| 434 | static const EC_CURVE_DATA _EC_SECG_CHAR2_113R1 = { | 710 | { 0x10,0xE7,0x23,0xAB,0x14,0xD6,0x96,0xE6,0x76,0x87, /* seed */ |
| 435 | NID_X9_62_characteristic_two_field, | 711 | 0x56,0x15,0x17,0x56,0xFE,0xBF,0x8F,0xCB,0x49,0xA9, |
| 436 | "020000000000000000000000000201", | 712 | |
| 437 | "003088250CA6E7C7FE649CE85820F7", | 713 | 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 438 | "00E8BEE4D3E2260744188BE0E9C723", | 714 | 0x00,0x00,0x00,0x02,0x01, |
| 439 | "009D73616F35F4AB1407D73562C10F", | 715 | 0x00,0x30,0x88,0x25,0x0C,0xA6,0xE7,0xC7,0xFE,0x64, /* a */ |
| 440 | "00A52830277958EE84D1315ED31886", | 716 | 0x9C,0xE8,0x58,0x20,0xF7, |
| 441 | "0100000000000000D9CCEC8A39E56F", 2, | 717 | 0x00,0xE8,0xBE,0xE4,0xD3,0xE2,0x26,0x07,0x44,0x18, /* b */ |
| 442 | _EC_SECG_CHAR2_113R1_SEED, 20, | 718 | 0x8B,0xE0,0xE9,0xC7,0x23, |
| 443 | "SECG curve over a 113 bit binary field" | 719 | 0x00,0x9D,0x73,0x61,0x6F,0x35,0xF4,0xAB,0x14,0x07, /* x */ |
| 720 | 0xD7,0x35,0x62,0xC1,0x0F, | ||
| 721 | 0x00,0xA5,0x28,0x30,0x27,0x79,0x58,0xEE,0x84,0xD1, /* y */ | ||
| 722 | 0x31,0x5E,0xD3,0x18,0x86, | ||
| 723 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD9,0xCC, /* order */ | ||
| 724 | 0xEC,0x8A,0x39,0xE5,0x6F } | ||
| 444 | }; | 725 | }; |
| 445 | 726 | ||
| 446 | static const unsigned char _EC_SECG_CHAR2_113R2_SEED[] = { | 727 | static const struct { EC_CURVE_DATA h; unsigned char data[20+15*6]; } |
| 447 | 0x10,0xC0,0xFB,0x15,0x76,0x08,0x60,0xDE,0xF1,0xEE, | 728 | _EC_SECG_CHAR2_113R2 = { |
| 448 | 0xF4,0xD6,0x96,0xE6,0x76,0x87,0x56,0x15,0x17,0x5D}; | 729 | { NID_X9_62_characteristic_two_field,20,15,2 }, |
| 449 | static const EC_CURVE_DATA _EC_SECG_CHAR2_113R2 = { | 730 | { 0x10,0xC0,0xFB,0x15,0x76,0x08,0x60,0xDE,0xF1,0xEE, /* seed */ |
| 450 | NID_X9_62_characteristic_two_field, | 731 | 0xF4,0xD6,0x96,0xE6,0x76,0x87,0x56,0x15,0x17,0x5D, |
| 451 | "020000000000000000000000000201", | 732 | |
| 452 | "00689918DBEC7E5A0DD6DFC0AA55C7", | 733 | 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 453 | "0095E9A9EC9B297BD4BF36E059184F", | 734 | 0x00,0x00,0x00,0x02,0x01, |
| 454 | "01A57A6A7B26CA5EF52FCDB8164797", | 735 | 0x00,0x68,0x99,0x18,0xDB,0xEC,0x7E,0x5A,0x0D,0xD6, /* a */ |
| 455 | "00B3ADC94ED1FE674C06E695BABA1D", | 736 | 0xDF,0xC0,0xAA,0x55,0xC7, |
| 456 | "010000000000000108789B2496AF93", 2, | 737 | 0x00,0x95,0xE9,0xA9,0xEC,0x9B,0x29,0x7B,0xD4,0xBF, /* b */ |
| 457 | _EC_SECG_CHAR2_113R2_SEED, 20, | 738 | 0x36,0xE0,0x59,0x18,0x4F, |
| 458 | "SECG curve over a 113 bit binary field" | 739 | 0x01,0xA5,0x7A,0x6A,0x7B,0x26,0xCA,0x5E,0xF5,0x2F, /* x */ |
| 740 | 0xCD,0xB8,0x16,0x47,0x97, | ||
| 741 | 0x00,0xB3,0xAD,0xC9,0x4E,0xD1,0xFE,0x67,0x4C,0x06, /* y */ | ||
| 742 | 0xE6,0x95,0xBA,0xBA,0x1D, | ||
| 743 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x08,0x78, /* order */ | ||
| 744 | 0x9B,0x24,0x96,0xAF,0x93 } | ||
| 459 | }; | 745 | }; |
| 460 | 746 | ||
| 461 | static const unsigned char _EC_SECG_CHAR2_131R1_SEED[] = { | 747 | static const struct { EC_CURVE_DATA h; unsigned char data[20+17*6]; } |
| 462 | 0x4D,0x69,0x6E,0x67,0x68,0x75,0x61,0x51,0x75,0x98, | 748 | _EC_SECG_CHAR2_131R1 = { |
| 463 | 0x5B,0xD3,0xAD,0xBA,0xDA,0x21,0xB4,0x3A,0x97,0xE2}; | 749 | { NID_X9_62_characteristic_two_field,20,17,2 }, |
| 464 | static const EC_CURVE_DATA _EC_SECG_CHAR2_131R1 = { | 750 | { 0x4D,0x69,0x6E,0x67,0x68,0x75,0x61,0x51,0x75,0x98, /* seed */ |
| 465 | NID_X9_62_characteristic_two_field, | 751 | 0x5B,0xD3,0xAD,0xBA,0xDA,0x21,0xB4,0x3A,0x97,0xE2, |
| 466 | "080000000000000000000000000000010D", | 752 | |
| 467 | "07A11B09A76B562144418FF3FF8C2570B8", | 753 | 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 468 | "0217C05610884B63B9C6C7291678F9D341", | 754 | 0x00,0x00,0x00,0x00,0x00,0x01,0x0D, |
| 469 | "0081BAF91FDF9833C40F9C181343638399", | 755 | 0x07,0xA1,0x1B,0x09,0xA7,0x6B,0x56,0x21,0x44,0x41, /* a */ |
| 470 | "078C6E7EA38C001F73C8134B1B4EF9E150", | 756 | 0x8F,0xF3,0xFF,0x8C,0x25,0x70,0xB8, |
| 471 | "0400000000000000023123953A9464B54D", 2, | 757 | 0x02,0x17,0xC0,0x56,0x10,0x88,0x4B,0x63,0xB9,0xC6, /* b */ |
| 472 | _EC_SECG_CHAR2_131R1_SEED, 20, | 758 | 0xC7,0x29,0x16,0x78,0xF9,0xD3,0x41, |
| 473 | "SECG/WTLS curve over a 131 bit binary field" | 759 | 0x00,0x81,0xBA,0xF9,0x1F,0xDF,0x98,0x33,0xC4,0x0F, /* x */ |
| 760 | 0x9C,0x18,0x13,0x43,0x63,0x83,0x99, | ||
| 761 | 0x07,0x8C,0x6E,0x7E,0xA3,0x8C,0x00,0x1F,0x73,0xC8, /* y */ | ||
| 762 | 0x13,0x4B,0x1B,0x4E,0xF9,0xE1,0x50, | ||
| 763 | 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x31, /* order */ | ||
| 764 | 0x23,0x95,0x3A,0x94,0x64,0xB5,0x4D } | ||
| 474 | }; | 765 | }; |
| 475 | 766 | ||
| 476 | static const unsigned char _EC_SECG_CHAR2_131R2_SEED[] = { | 767 | static const struct { EC_CURVE_DATA h; unsigned char data[20+17*6]; } |
| 477 | 0x98,0x5B,0xD3,0xAD,0xBA,0xD4,0xD6,0x96,0xE6,0x76, | 768 | _EC_SECG_CHAR2_131R2 = { |
| 478 | 0x87,0x56,0x15,0x17,0x5A,0x21,0xB4,0x3A,0x97,0xE3}; | 769 | { NID_X9_62_characteristic_two_field,20,17,2 }, |
| 479 | static const EC_CURVE_DATA _EC_SECG_CHAR2_131R2 = { | 770 | { 0x98,0x5B,0xD3,0xAD,0xBA,0xD4,0xD6,0x96,0xE6,0x76, /* seed */ |
| 480 | NID_X9_62_characteristic_two_field, | 771 | 0x87,0x56,0x15,0x17,0x5A,0x21,0xB4,0x3A,0x97,0xE3, |
| 481 | "080000000000000000000000000000010D", | 772 | |
| 482 | "03E5A88919D7CAFCBF415F07C2176573B2", | 773 | 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 483 | "04B8266A46C55657AC734CE38F018F2192", | 774 | 0x00,0x00,0x00,0x00,0x00,0x01,0x0D, |
| 484 | "0356DCD8F2F95031AD652D23951BB366A8", | 775 | 0x03,0xE5,0xA8,0x89,0x19,0xD7,0xCA,0xFC,0xBF,0x41, /* a */ |
| 485 | "0648F06D867940A5366D9E265DE9EB240F", | 776 | 0x5F,0x07,0xC2,0x17,0x65,0x73,0xB2, |
| 486 | "0400000000000000016954A233049BA98F", 2, | 777 | 0x04,0xB8,0x26,0x6A,0x46,0xC5,0x56,0x57,0xAC,0x73, /* b */ |
| 487 | _EC_SECG_CHAR2_131R2_SEED, 20, | 778 | 0x4C,0xE3,0x8F,0x01,0x8F,0x21,0x92, |
| 488 | "SECG curve over a 131 bit binary field" | 779 | 0x03,0x56,0xDC,0xD8,0xF2,0xF9,0x50,0x31,0xAD,0x65, /* x */ |
| 780 | 0x2D,0x23,0x95,0x1B,0xB3,0x66,0xA8, | ||
| 781 | 0x06,0x48,0xF0,0x6D,0x86,0x79,0x40,0xA5,0x36,0x6D, /* y */ | ||
| 782 | 0x9E,0x26,0x5D,0xE9,0xEB,0x24,0x0F, | ||
| 783 | 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x69, /* order */ | ||
| 784 | 0x54,0xA2,0x33,0x04,0x9B,0xA9,0x8F } | ||
| 489 | }; | 785 | }; |
| 490 | 786 | ||
| 491 | static const EC_CURVE_DATA _EC_NIST_CHAR2_163K = { | 787 | static const struct { EC_CURVE_DATA h; unsigned char data[0+21*6]; } |
| 492 | NID_X9_62_characteristic_two_field, | 788 | _EC_NIST_CHAR2_163K = { |
| 493 | "0800000000000000000000000000000000000000C9", | 789 | { NID_X9_62_characteristic_two_field,0,21,2 }, |
| 494 | "1", | 790 | { /* no seed */ |
| 495 | "1", | 791 | 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 496 | "02FE13C0537BBC11ACAA07D793DE4E6D5E5C94EEE8", | 792 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 497 | "0289070FB05D38FF58321F2E800536D538CCDAA3D9", | 793 | 0xC9, |
| 498 | "04000000000000000000020108A2E0CC0D99F8A5EF", 2, | 794 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 499 | NULL, 0, | 795 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 500 | "NIST/SECG/WTLS curve over a 163 bit binary field" | 796 | 0x01, |
| 797 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ | ||
| 798 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 799 | 0x01, | ||
| 800 | 0x02,0xFE,0x13,0xC0,0x53,0x7B,0xBC,0x11,0xAC,0xAA, /* x */ | ||
| 801 | 0x07,0xD7,0x93,0xDE,0x4E,0x6D,0x5E,0x5C,0x94,0xEE, | ||
| 802 | 0xE8, | ||
| 803 | 0x02,0x89,0x07,0x0F,0xB0,0x5D,0x38,0xFF,0x58,0x32, /* y */ | ||
| 804 | 0x1F,0x2E,0x80,0x05,0x36,0xD5,0x38,0xCC,0xDA,0xA3, | ||
| 805 | 0xD9, | ||
| 806 | 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 807 | 0x02,0x01,0x08,0xA2,0xE0,0xCC,0x0D,0x99,0xF8,0xA5, | ||
| 808 | 0xEF } | ||
| 501 | }; | 809 | }; |
| 502 | 810 | ||
| 503 | static const unsigned char _EC_SECG_CHAR2_163R1_SEED[] = { | 811 | static const struct { EC_CURVE_DATA h; unsigned char data[0+21*6]; } |
| 504 | 0x24,0xB7,0xB1,0x37,0xC8,0xA1,0x4D,0x69,0x6E,0x67, | 812 | _EC_SECG_CHAR2_163R1 = { |
| 505 | 0x68,0x75,0x61,0x51,0x75,0x6F,0xD0,0xDA,0x2E,0x5C}; | 813 | { NID_X9_62_characteristic_two_field,0,21,2 }, |
| 506 | static const EC_CURVE_DATA _EC_SECG_CHAR2_163R1 = { | 814 | { /* no seed */ |
| 507 | NID_X9_62_characteristic_two_field, | 815 | #if 0 |
| 508 | "0800000000000000000000000000000000000000C9", | ||
| 509 | "07B6882CAAEFA84F9554FF8428BD88E246D2782AE2", | ||
| 510 | "0713612DCDDCB40AAB946BDA29CA91F73AF958AFD9", | ||
| 511 | "0369979697AB43897789566789567F787A7876A654", | ||
| 512 | "00435EDB42EFAFB2989D51FEFCE3C80988F41FF883", | ||
| 513 | "03FFFFFFFFFFFFFFFFFFFF48AAB689C29CA710279B", 2, | ||
| 514 | /* The algorithm used to derive the curve parameters from | 816 | /* The algorithm used to derive the curve parameters from |
| 515 | * the seed used here is slightly different than the | 817 | * the seed used here is slightly different than the |
| 516 | * algorithm described in X9.62 . | 818 | * algorithm described in X9.62 . */ |
| 517 | */ | 819 | 0x24,0xB7,0xB1,0x37,0xC8,0xA1,0x4D,0x69,0x6E,0x67, |
| 518 | #if 0 | 820 | 0x68,0x75,0x61,0x51,0x75,0x6F,0xD0,0xDA,0x2E,0x5C, |
| 519 | _EC_SECG_CHAR2_163R1_SEED, 20, | ||
| 520 | #else | ||
| 521 | NULL, 0, | ||
| 522 | #endif | 821 | #endif |
| 523 | "SECG curve over a 163 bit binary field" | 822 | 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 823 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 824 | 0xC9, | ||
| 825 | 0x07,0xB6,0x88,0x2C,0xAA,0xEF,0xA8,0x4F,0x95,0x54, /* a */ | ||
| 826 | 0xFF,0x84,0x28,0xBD,0x88,0xE2,0x46,0xD2,0x78,0x2A, | ||
| 827 | 0xE2, | ||
| 828 | 0x07,0x13,0x61,0x2D,0xCD,0xDC,0xB4,0x0A,0xAB,0x94, /* b */ | ||
| 829 | 0x6B,0xDA,0x29,0xCA,0x91,0xF7,0x3A,0xF9,0x58,0xAF, | ||
| 830 | 0xD9, | ||
| 831 | 0x03,0x69,0x97,0x96,0x97,0xAB,0x43,0x89,0x77,0x89, /* x */ | ||
| 832 | 0x56,0x67,0x89,0x56,0x7F,0x78,0x7A,0x78,0x76,0xA6, | ||
| 833 | 0x54, | ||
| 834 | 0x00,0x43,0x5E,0xDB,0x42,0xEF,0xAF,0xB2,0x98,0x9D, /* y */ | ||
| 835 | 0x51,0xFE,0xFC,0xE3,0xC8,0x09,0x88,0xF4,0x1F,0xF8, | ||
| 836 | 0x83, | ||
| 837 | 0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 838 | 0xFF,0x48,0xAA,0xB6,0x89,0xC2,0x9C,0xA7,0x10,0x27, | ||
| 839 | 0x9B } | ||
| 524 | }; | 840 | }; |
| 525 | 841 | ||
| 526 | static const unsigned char _EC_NIST_CHAR2_163B_SEED[] = { | 842 | static const struct { EC_CURVE_DATA h; unsigned char data[0+21*6]; } |
| 527 | 0x85,0xE2,0x5B,0xFE,0x5C,0x86,0x22,0x6C,0xDB,0x12, | 843 | _EC_NIST_CHAR2_163B = { |
| 528 | 0x01,0x6F,0x75,0x53,0xF9,0xD0,0xE6,0x93,0xA2,0x68}; | 844 | { NID_X9_62_characteristic_two_field,0,21,2 }, |
| 529 | static const EC_CURVE_DATA _EC_NIST_CHAR2_163B ={ | 845 | { /* no seed */ |
| 530 | NID_X9_62_characteristic_two_field, | ||
| 531 | "0800000000000000000000000000000000000000C9", | ||
| 532 | "1", | ||
| 533 | "020A601907B8C953CA1481EB10512F78744A3205FD", | ||
| 534 | "03F0EBA16286A2D57EA0991168D4994637E8343E36", | ||
| 535 | "00D51FBC6C71A0094FA2CDD545B11C5C0C797324F1", | ||
| 536 | "040000000000000000000292FE77E70C12A4234C33", 2, | ||
| 537 | /* The seed here was used to created the curve parameters in normal | ||
| 538 | * basis representation (and not the polynomial representation used here) | ||
| 539 | */ | ||
| 540 | #if 0 | 846 | #if 0 |
| 541 | _EC_NIST_CHAR2_163B_SEED, 20, | 847 | /* The seed here was used to created the curve parameters in normal |
| 542 | #else | 848 | * basis representation (and not the polynomial representation used here) */ |
| 543 | NULL, 0, | 849 | 0x85,0xE2,0x5B,0xFE,0x5C,0x86,0x22,0x6C,0xDB,0x12, |
| 850 | 0x01,0x6F,0x75,0x53,0xF9,0xD0,0xE6,0x93,0xA2,0x68, | ||
| 544 | #endif | 851 | #endif |
| 545 | "NIST/SECG curve over a 163 bit binary field" | 852 | 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 853 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 854 | 0xC9, | ||
| 855 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ | ||
| 856 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 857 | 0x01, | ||
| 858 | 0x02,0x0A,0x60,0x19,0x07,0xB8,0xC9,0x53,0xCA,0x14, /* b */ | ||
| 859 | 0x81,0xEB,0x10,0x51,0x2F,0x78,0x74,0x4A,0x32,0x05, | ||
| 860 | 0xFD, | ||
| 861 | 0x03,0xF0,0xEB,0xA1,0x62,0x86,0xA2,0xD5,0x7E,0xA0, /* x */ | ||
| 862 | 0x99,0x11,0x68,0xD4,0x99,0x46,0x37,0xE8,0x34,0x3E, | ||
| 863 | 0x36, | ||
| 864 | 0x00,0xD5,0x1F,0xBC,0x6C,0x71,0xA0,0x09,0x4F,0xA2, /* y */ | ||
| 865 | 0xCD,0xD5,0x45,0xB1,0x1C,0x5C,0x0C,0x79,0x73,0x24, | ||
| 866 | 0xF1, | ||
| 867 | 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 868 | 0x02,0x92,0xFE,0x77,0xE7,0x0C,0x12,0xA4,0x23,0x4C, | ||
| 869 | 0x33 } | ||
| 546 | }; | 870 | }; |
| 547 | 871 | ||
| 548 | static const unsigned char _EC_SECG_CHAR2_193R1_SEED[] = { | 872 | static const struct { EC_CURVE_DATA h; unsigned char data[20+25*6]; } |
| 549 | 0x10,0x3F,0xAE,0xC7,0x4D,0x69,0x6E,0x67,0x68,0x75, | 873 | _EC_SECG_CHAR2_193R1 = { |
| 550 | 0x61,0x51,0x75,0x77,0x7F,0xC5,0xB1,0x91,0xEF,0x30}; | 874 | { NID_X9_62_characteristic_two_field,20,25,2 }, |
| 551 | static const EC_CURVE_DATA _EC_SECG_CHAR2_193R1 = { | 875 | { 0x10,0x3F,0xAE,0xC7,0x4D,0x69,0x6E,0x67,0x68,0x75, /* seed */ |
| 552 | NID_X9_62_characteristic_two_field, | 876 | 0x61,0x51,0x75,0x77,0x7F,0xC5,0xB1,0x91,0xEF,0x30, |
| 553 | "02000000000000000000000000000000000000000000008001", | 877 | |
| 554 | "0017858FEB7A98975169E171F77B4087DE098AC8A911DF7B01", | 878 | 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 555 | "00FDFB49BFE6C3A89FACADAA7A1E5BBC7CC1C2E5D831478814", | 879 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 556 | "01F481BC5F0FF84A74AD6CDF6FDEF4BF6179625372D8C0C5E1", | 880 | 0x00,0x00,0x00,0x80,0x01, |
| 557 | "0025E399F2903712CCF3EA9E3A1AD17FB0B3201B6AF7CE1B05", | 881 | 0x00,0x17,0x85,0x8F,0xEB,0x7A,0x98,0x97,0x51,0x69, /* a */ |
| 558 | "01000000000000000000000000C7F34A778F443ACC920EBA49", 2, | 882 | 0xE1,0x71,0xF7,0x7B,0x40,0x87,0xDE,0x09,0x8A,0xC8, |
| 559 | _EC_SECG_CHAR2_193R1_SEED, 20, | 883 | 0xA9,0x11,0xDF,0x7B,0x01, |
| 560 | "SECG curve over a 193 bit binary field" | 884 | 0x00,0xFD,0xFB,0x49,0xBF,0xE6,0xC3,0xA8,0x9F,0xAC, /* b */ |
| 885 | 0xAD,0xAA,0x7A,0x1E,0x5B,0xBC,0x7C,0xC1,0xC2,0xE5, | ||
| 886 | 0xD8,0x31,0x47,0x88,0x14, | ||
| 887 | 0x01,0xF4,0x81,0xBC,0x5F,0x0F,0xF8,0x4A,0x74,0xAD, /* x */ | ||
| 888 | 0x6C,0xDF,0x6F,0xDE,0xF4,0xBF,0x61,0x79,0x62,0x53, | ||
| 889 | 0x72,0xD8,0xC0,0xC5,0xE1, | ||
| 890 | 0x00,0x25,0xE3,0x99,0xF2,0x90,0x37,0x12,0xCC,0xF3, /* y */ | ||
| 891 | 0xEA,0x9E,0x3A,0x1A,0xD1,0x7F,0xB0,0xB3,0x20,0x1B, | ||
| 892 | 0x6A,0xF7,0xCE,0x1B,0x05, | ||
| 893 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 894 | 0x00,0x00,0x00,0xC7,0xF3,0x4A,0x77,0x8F,0x44,0x3A, | ||
| 895 | 0xCC,0x92,0x0E,0xBA,0x49 } | ||
| 561 | }; | 896 | }; |
| 562 | 897 | ||
| 563 | static const unsigned char _EC_SECG_CHAR2_193R2_SEED[] = { | 898 | static const struct { EC_CURVE_DATA h; unsigned char data[20+25*6]; } |
| 564 | 0x10,0xB7,0xB4,0xD6,0x96,0xE6,0x76,0x87,0x56,0x15, | 899 | _EC_SECG_CHAR2_193R2 = { |
| 565 | 0x17,0x51,0x37,0xC8,0xA1,0x6F,0xD0,0xDA,0x22,0x11}; | 900 | { NID_X9_62_characteristic_two_field,20,25,2 }, |
| 566 | static const EC_CURVE_DATA _EC_SECG_CHAR2_193R2 = { | 901 | { 0x10,0xB7,0xB4,0xD6,0x96,0xE6,0x76,0x87,0x56,0x15, /* seed */ |
| 567 | NID_X9_62_characteristic_two_field, | 902 | 0x17,0x51,0x37,0xC8,0xA1,0x6F,0xD0,0xDA,0x22,0x11, |
| 568 | "02000000000000000000000000000000000000000000008001", | 903 | |
| 569 | "0163F35A5137C2CE3EA6ED8667190B0BC43ECD69977702709B", | 904 | 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 570 | "00C9BB9E8927D4D64C377E2AB2856A5B16E3EFB7F61D4316AE", | 905 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 571 | "00D9B67D192E0367C803F39E1A7E82CA14A651350AAE617E8F", | 906 | 0x00,0x00,0x00,0x80,0x01, |
| 572 | "01CE94335607C304AC29E7DEFBD9CA01F596F927224CDECF6C", | 907 | 0x01,0x63,0xF3,0x5A,0x51,0x37,0xC2,0xCE,0x3E,0xA6, /* a */ |
| 573 | "010000000000000000000000015AAB561B005413CCD4EE99D5", 2, | 908 | 0xED,0x86,0x67,0x19,0x0B,0x0B,0xC4,0x3E,0xCD,0x69, |
| 574 | _EC_SECG_CHAR2_193R2_SEED, 20, | 909 | 0x97,0x77,0x02,0x70,0x9B, |
| 575 | "SECG curve over a 193 bit binary field" | 910 | 0x00,0xC9,0xBB,0x9E,0x89,0x27,0xD4,0xD6,0x4C,0x37, /* b */ |
| 911 | 0x7E,0x2A,0xB2,0x85,0x6A,0x5B,0x16,0xE3,0xEF,0xB7, | ||
| 912 | 0xF6,0x1D,0x43,0x16,0xAE, | ||
| 913 | 0x00,0xD9,0xB6,0x7D,0x19,0x2E,0x03,0x67,0xC8,0x03, /* x */ | ||
| 914 | 0xF3,0x9E,0x1A,0x7E,0x82,0xCA,0x14,0xA6,0x51,0x35, | ||
| 915 | 0x0A,0xAE,0x61,0x7E,0x8F, | ||
| 916 | 0x01,0xCE,0x94,0x33,0x56,0x07,0xC3,0x04,0xAC,0x29, /* y */ | ||
| 917 | 0xE7,0xDE,0xFB,0xD9,0xCA,0x01,0xF5,0x96,0xF9,0x27, | ||
| 918 | 0x22,0x4C,0xDE,0xCF,0x6C, | ||
| 919 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 920 | 0x00,0x00,0x01,0x5A,0xAB,0x56,0x1B,0x00,0x54,0x13, | ||
| 921 | 0xCC,0xD4,0xEE,0x99,0xD5 } | ||
| 576 | }; | 922 | }; |
| 577 | 923 | ||
| 578 | static const EC_CURVE_DATA _EC_NIST_CHAR2_233K = { | 924 | static const struct { EC_CURVE_DATA h; unsigned char data[0+30*6]; } |
| 579 | NID_X9_62_characteristic_two_field, | 925 | _EC_NIST_CHAR2_233K = { |
| 580 | "020000000000000000000000000000000000000004000000000000000001", | 926 | { NID_X9_62_characteristic_two_field,0,30,4 }, |
| 581 | "0", | 927 | { /* no seed */ |
| 582 | "1", | 928 | 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 583 | "017232BA853A7E731AF129F22FF4149563A419C26BF50A4C9D6EEFAD6126", | 929 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 584 | "01DB537DECE819B7F70F555A67C427A8CD9BF18AEB9B56E0C11056FAE6A3", | 930 | 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, |
| 585 | "008000000000000000000000000000069D5BB915BCD46EFB1AD5F173ABDF", 4, | 931 | |
| 586 | NULL, 0, | 932 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 587 | "NIST/SECG/WTLS curve over a 233 bit binary field" | 933 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 934 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 935 | |||
| 936 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ | ||
| 937 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 938 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, | ||
| 939 | |||
| 940 | 0x01,0x72,0x32,0xBA,0x85,0x3A,0x7E,0x73,0x1A,0xF1, /* x */ | ||
| 941 | 0x29,0xF2,0x2F,0xF4,0x14,0x95,0x63,0xA4,0x19,0xC2, | ||
| 942 | 0x6B,0xF5,0x0A,0x4C,0x9D,0x6E,0xEF,0xAD,0x61,0x26, | ||
| 943 | |||
| 944 | 0x01,0xDB,0x53,0x7D,0xEC,0xE8,0x19,0xB7,0xF7,0x0F, /* y */ | ||
| 945 | 0x55,0x5A,0x67,0xC4,0x27,0xA8,0xCD,0x9B,0xF1,0x8A, | ||
| 946 | 0xEB,0x9B,0x56,0xE0,0xC1,0x10,0x56,0xFA,0xE6,0xA3, | ||
| 947 | |||
| 948 | 0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 949 | 0x00,0x00,0x00,0x00,0x00,0x06,0x9D,0x5B,0xB9,0x15, | ||
| 950 | 0xBC,0xD4,0x6E,0xFB,0x1A,0xD5,0xF1,0x73,0xAB,0xDF } | ||
| 588 | }; | 951 | }; |
| 589 | 952 | ||
| 590 | static const unsigned char _EC_NIST_CHAR2_233B_SEED[] = { | 953 | static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } |
| 591 | 0x74,0xD5,0x9F,0xF0,0x7F,0x6B,0x41,0x3D,0x0E,0xA1, | 954 | _EC_NIST_CHAR2_233B = { |
| 592 | 0x4B,0x34,0x4B,0x20,0xA2,0xDB,0x04,0x9B,0x50,0xC3}; | 955 | { NID_X9_62_characteristic_two_field,20,30,2 }, |
| 593 | static const EC_CURVE_DATA _EC_NIST_CHAR2_233B = { | 956 | { 0x74,0xD5,0x9F,0xF0,0x7F,0x6B,0x41,0x3D,0x0E,0xA1, /* seed */ |
| 594 | NID_X9_62_characteristic_two_field, | 957 | 0x4B,0x34,0x4B,0x20,0xA2,0xDB,0x04,0x9B,0x50,0xC3, |
| 595 | "020000000000000000000000000000000000000004000000000000000001", | 958 | |
| 596 | "000000000000000000000000000000000000000000000000000000000001", | 959 | 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 597 | "0066647EDE6C332C7F8C0923BB58213B333B20E9CE4281FE115F7D8F90AD", | 960 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 598 | "00FAC9DFCBAC8313BB2139F1BB755FEF65BC391F8B36F8F8EB7371FD558B", | 961 | 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, |
| 599 | "01006A08A41903350678E58528BEBF8A0BEFF867A7CA36716F7E01F81052", | 962 | |
| 600 | "01000000000000000000000000000013E974E72F8A6922031D2603CFE0D7", 2, | 963 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 601 | _EC_NIST_CHAR2_233B_SEED, 20, | 964 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 602 | "NIST/SECG/WTLS curve over a 233 bit binary field" | 965 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, |
| 966 | |||
| 967 | 0x00,0x66,0x64,0x7E,0xDE,0x6C,0x33,0x2C,0x7F,0x8C, /* b */ | ||
| 968 | 0x09,0x23,0xBB,0x58,0x21,0x3B,0x33,0x3B,0x20,0xE9, | ||
| 969 | 0xCE,0x42,0x81,0xFE,0x11,0x5F,0x7D,0x8F,0x90,0xAD, | ||
| 970 | |||
| 971 | 0x00,0xFA,0xC9,0xDF,0xCB,0xAC,0x83,0x13,0xBB,0x21, /* x */ | ||
| 972 | 0x39,0xF1,0xBB,0x75,0x5F,0xEF,0x65,0xBC,0x39,0x1F, | ||
| 973 | 0x8B,0x36,0xF8,0xF8,0xEB,0x73,0x71,0xFD,0x55,0x8B, | ||
| 974 | |||
| 975 | 0x01,0x00,0x6A,0x08,0xA4,0x19,0x03,0x35,0x06,0x78, /* y */ | ||
| 976 | 0xE5,0x85,0x28,0xBE,0xBF,0x8A,0x0B,0xEF,0xF8,0x67, | ||
| 977 | 0xA7,0xCA,0x36,0x71,0x6F,0x7E,0x01,0xF8,0x10,0x52, | ||
| 978 | |||
| 979 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 980 | 0x00,0x00,0x00,0x00,0x00,0x13,0xE9,0x74,0xE7,0x2F, | ||
| 981 | 0x8A,0x69,0x22,0x03,0x1D,0x26,0x03,0xCF,0xE0,0xD7 } | ||
| 603 | }; | 982 | }; |
| 604 | 983 | ||
| 605 | static const EC_CURVE_DATA _EC_SECG_CHAR2_239K1 = { | 984 | static const struct { EC_CURVE_DATA h; unsigned char data[0+30*6]; } |
| 606 | NID_X9_62_characteristic_two_field, | 985 | _EC_SECG_CHAR2_239K1 = { |
| 607 | "800000000000000000004000000000000000000000000000000000000001", | 986 | { NID_X9_62_characteristic_two_field,0,30,4 }, |
| 608 | "0", | 987 | { /* no seed */ |
| 609 | "1", | 988 | 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 610 | "29A0B6A887A983E9730988A68727A8B2D126C44CC2CC7B2A6555193035DC", | 989 | 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 611 | "76310804F12E549BDB011C103089E73510ACB275FC312A5DC6B76553F0CA", | 990 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, |
| 612 | "2000000000000000000000000000005A79FEC67CB6E91F1C1DA800E478A5", 4, | 991 | |
| 613 | NULL, 0, | 992 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 614 | "SECG curve over a 239 bit binary field" | 993 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 994 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 995 | |||
| 996 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ | ||
| 997 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 998 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, | ||
| 999 | |||
| 1000 | 0x29,0xA0,0xB6,0xA8,0x87,0xA9,0x83,0xE9,0x73,0x09, /* x */ | ||
| 1001 | 0x88,0xA6,0x87,0x27,0xA8,0xB2,0xD1,0x26,0xC4,0x4C, | ||
| 1002 | 0xC2,0xCC,0x7B,0x2A,0x65,0x55,0x19,0x30,0x35,0xDC, | ||
| 1003 | |||
| 1004 | 0x76,0x31,0x08,0x04,0xF1,0x2E,0x54,0x9B,0xDB,0x01, /* y */ | ||
| 1005 | 0x1C,0x10,0x30,0x89,0xE7,0x35,0x10,0xAC,0xB2,0x75, | ||
| 1006 | 0xFC,0x31,0x2A,0x5D,0xC6,0xB7,0x65,0x53,0xF0,0xCA, | ||
| 1007 | |||
| 1008 | 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 1009 | 0x00,0x00,0x00,0x00,0x00,0x5A,0x79,0xFE,0xC6,0x7C, | ||
| 1010 | 0xB6,0xE9,0x1F,0x1C,0x1D,0xA8,0x00,0xE4,0x78,0xA5 } | ||
| 615 | }; | 1011 | }; |
| 616 | 1012 | ||
| 617 | static const EC_CURVE_DATA _EC_NIST_CHAR2_283K = { | 1013 | static const struct { EC_CURVE_DATA h; unsigned char data[0+36*6]; } |
| 618 | NID_X9_62_characteristic_two_field, | 1014 | _EC_NIST_CHAR2_283K = { |
| 619 | "080000000000000000000000000000000000000000000000000000000000000000001" | 1015 | { NID_X9_62_characteristic_two_field,0,36,4 }, |
| 620 | "0A1", | 1016 | { /* no seed */ |
| 621 | "0", | 1017 | 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 622 | "1", | 1018 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 623 | "0503213F78CA44883F1A3B8162F188E553CD265F23C1567A16876913B0C2AC2458492" | 1019 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 624 | "836", | 1020 | 0x00,0x00,0x00,0x00,0x10,0xA1, |
| 625 | "01CCDA380F1C9E318D90F95D07E5426FE87E45C0E8184698E45962364E34116177DD2" | 1021 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 626 | "259", | 1022 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 627 | "01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE9AE2ED07577265DFF7F94451E061E163" | 1023 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 628 | "C61", 4, | 1024 | 0x00,0x00,0x00,0x00,0x00,0x00, |
| 629 | NULL, 20, | 1025 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ |
| 630 | "NIST/SECG curve over a 283 bit binary field" | 1026 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 1027 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1028 | 0x00,0x00,0x00,0x00,0x00,0x01, | ||
| 1029 | 0x05,0x03,0x21,0x3F,0x78,0xCA,0x44,0x88,0x3F,0x1A, /* x */ | ||
| 1030 | 0x3B,0x81,0x62,0xF1,0x88,0xE5,0x53,0xCD,0x26,0x5F, | ||
| 1031 | 0x23,0xC1,0x56,0x7A,0x16,0x87,0x69,0x13,0xB0,0xC2, | ||
| 1032 | 0xAC,0x24,0x58,0x49,0x28,0x36, | ||
| 1033 | 0x01,0xCC,0xDA,0x38,0x0F,0x1C,0x9E,0x31,0x8D,0x90, /* y */ | ||
| 1034 | 0xF9,0x5D,0x07,0xE5,0x42,0x6F,0xE8,0x7E,0x45,0xC0, | ||
| 1035 | 0xE8,0x18,0x46,0x98,0xE4,0x59,0x62,0x36,0x4E,0x34, | ||
| 1036 | 0x11,0x61,0x77,0xDD,0x22,0x59, | ||
| 1037 | 0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 1038 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE9,0xAE, | ||
| 1039 | 0x2E,0xD0,0x75,0x77,0x26,0x5D,0xFF,0x7F,0x94,0x45, | ||
| 1040 | 0x1E,0x06,0x1E,0x16,0x3C,0x61 } | ||
| 631 | }; | 1041 | }; |
| 632 | 1042 | ||
| 633 | static const unsigned char _EC_NIST_CHAR2_283B_SEED[] = { | 1043 | static const struct { EC_CURVE_DATA h; unsigned char data[20+36*6]; } |
| 634 | 0x77,0xE2,0xB0,0x73,0x70,0xEB,0x0F,0x83,0x2A,0x6D, | 1044 | _EC_NIST_CHAR2_283B = { |
| 635 | 0xD5,0xB6,0x2D,0xFC,0x88,0xCD,0x06,0xBB,0x84,0xBE}; | 1045 | { NID_X9_62_characteristic_two_field,20,36,2 }, |
| 636 | static const EC_CURVE_DATA _EC_NIST_CHAR2_283B = { | 1046 | { 0x77,0xE2,0xB0,0x73,0x70,0xEB,0x0F,0x83,0x2A,0x6D, /* no seed */ |
| 637 | NID_X9_62_characteristic_two_field, | 1047 | 0xD5,0xB6,0x2D,0xFC,0x88,0xCD,0x06,0xBB,0x84,0xBE, |
| 638 | "080000000000000000000000000000000000000000000000000000000000000000001" | 1048 | |
| 639 | "0A1", | 1049 | 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 640 | "000000000000000000000000000000000000000000000000000000000000000000000" | 1050 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 641 | "001", | 1051 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 642 | "027B680AC8B8596DA5A4AF8A19A0303FCA97FD7645309FA2A581485AF6263E313B79A" | 1052 | 0x00,0x00,0x00,0x00,0x10,0xA1, |
| 643 | "2F5", | 1053 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 644 | "05F939258DB7DD90E1934F8C70B0DFEC2EED25B8557EAC9C80E2E198F8CDBECD86B12" | 1054 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 645 | "053", | 1055 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 646 | "03676854FE24141CB98FE6D4B20D02B4516FF702350EDDB0826779C813F0DF45BE811" | 1056 | 0x00,0x00,0x00,0x00,0x00,0x01, |
| 647 | "2F4", | 1057 | 0x02,0x7B,0x68,0x0A,0xC8,0xB8,0x59,0x6D,0xA5,0xA4, /* b */ |
| 648 | "03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF90399660FC938A90165B042A7CEFADB" | 1058 | 0xAF,0x8A,0x19,0xA0,0x30,0x3F,0xCA,0x97,0xFD,0x76, |
| 649 | "307", 2, | 1059 | 0x45,0x30,0x9F,0xA2,0xA5,0x81,0x48,0x5A,0xF6,0x26, |
| 650 | _EC_NIST_CHAR2_283B_SEED, 20, | 1060 | 0x3E,0x31,0x3B,0x79,0xA2,0xF5, |
| 651 | "NIST/SECG curve over a 283 bit binary field" | 1061 | 0x05,0xF9,0x39,0x25,0x8D,0xB7,0xDD,0x90,0xE1,0x93, /* x */ |
| 1062 | 0x4F,0x8C,0x70,0xB0,0xDF,0xEC,0x2E,0xED,0x25,0xB8, | ||
| 1063 | 0x55,0x7E,0xAC,0x9C,0x80,0xE2,0xE1,0x98,0xF8,0xCD, | ||
| 1064 | 0xBE,0xCD,0x86,0xB1,0x20,0x53, | ||
| 1065 | 0x03,0x67,0x68,0x54,0xFE,0x24,0x14,0x1C,0xB9,0x8F, /* y */ | ||
| 1066 | 0xE6,0xD4,0xB2,0x0D,0x02,0xB4,0x51,0x6F,0xF7,0x02, | ||
| 1067 | 0x35,0x0E,0xDD,0xB0,0x82,0x67,0x79,0xC8,0x13,0xF0, | ||
| 1068 | 0xDF,0x45,0xBE,0x81,0x12,0xF4, | ||
| 1069 | 0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 1070 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEF,0x90, | ||
| 1071 | 0x39,0x96,0x60,0xFC,0x93,0x8A,0x90,0x16,0x5B,0x04, | ||
| 1072 | 0x2A,0x7C,0xEF,0xAD,0xB3,0x07 } | ||
| 652 | }; | 1073 | }; |
| 653 | 1074 | ||
| 654 | static const EC_CURVE_DATA _EC_NIST_CHAR2_409K = { | 1075 | static const struct { EC_CURVE_DATA h; unsigned char data[0+52*6]; } |
| 655 | NID_X9_62_characteristic_two_field, | 1076 | _EC_NIST_CHAR2_409K = { |
| 656 | "020000000000000000000000000000000000000000000000000000000000000000000" | 1077 | { NID_X9_62_characteristic_two_field,0,52,4 }, |
| 657 | "00000000000008000000000000000000001", | 1078 | { /* no seed */ |
| 658 | "0", | 1079 | 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 659 | "1", | 1080 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 660 | "0060F05F658F49C1AD3AB1890F7184210EFD0987E307C84C27ACCFB8F9F67CC2C4601" | 1081 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 661 | "89EB5AAAA62EE222EB1B35540CFE9023746", | 1082 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 662 | "01E369050B7C4E42ACBA1DACBF04299C3460782F918EA427E6325165E9EA10E3DA5F6" | 1083 | 0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 663 | "C42E9C55215AA9CA27A5863EC48D8E0286B", | 1084 | 0x00,0x01, |
| 664 | "007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE5F83B2D4EA20400" | 1085 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 665 | "EC4557D5ED3E3E7CA5B4B5C83B8E01E5FCF", 4, | 1086 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 666 | NULL, 0, | 1087 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 667 | "NIST/SECG curve over a 409 bit binary field" | 1088 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 1089 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1090 | 0x00,0x00, | ||
| 1091 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ | ||
| 1092 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1093 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1094 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1095 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1096 | 0x00,0x01, | ||
| 1097 | 0x00,0x60,0xF0,0x5F,0x65,0x8F,0x49,0xC1,0xAD,0x3A, /* x */ | ||
| 1098 | 0xB1,0x89,0x0F,0x71,0x84,0x21,0x0E,0xFD,0x09,0x87, | ||
| 1099 | 0xE3,0x07,0xC8,0x4C,0x27,0xAC,0xCF,0xB8,0xF9,0xF6, | ||
| 1100 | 0x7C,0xC2,0xC4,0x60,0x18,0x9E,0xB5,0xAA,0xAA,0x62, | ||
| 1101 | 0xEE,0x22,0x2E,0xB1,0xB3,0x55,0x40,0xCF,0xE9,0x02, | ||
| 1102 | 0x37,0x46, | ||
| 1103 | 0x01,0xE3,0x69,0x05,0x0B,0x7C,0x4E,0x42,0xAC,0xBA, /* y */ | ||
| 1104 | 0x1D,0xAC,0xBF,0x04,0x29,0x9C,0x34,0x60,0x78,0x2F, | ||
| 1105 | 0x91,0x8E,0xA4,0x27,0xE6,0x32,0x51,0x65,0xE9,0xEA, | ||
| 1106 | 0x10,0xE3,0xDA,0x5F,0x6C,0x42,0xE9,0xC5,0x52,0x15, | ||
| 1107 | 0xAA,0x9C,0xA2,0x7A,0x58,0x63,0xEC,0x48,0xD8,0xE0, | ||
| 1108 | 0x28,0x6B, | ||
| 1109 | 0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 1110 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
| 1111 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x5F,0x83,0xB2, | ||
| 1112 | 0xD4,0xEA,0x20,0x40,0x0E,0xC4,0x55,0x7D,0x5E,0xD3, | ||
| 1113 | 0xE3,0xE7,0xCA,0x5B,0x4B,0x5C,0x83,0xB8,0xE0,0x1E, | ||
| 1114 | 0x5F,0xCF } | ||
| 668 | }; | 1115 | }; |
| 669 | 1116 | ||
| 670 | static const unsigned char _EC_NIST_CHAR2_409B_SEED[] = { | 1117 | static const struct { EC_CURVE_DATA h; unsigned char data[20+52*6]; } |
| 671 | 0x40,0x99,0xB5,0xA4,0x57,0xF9,0xD6,0x9F,0x79,0x21, | 1118 | _EC_NIST_CHAR2_409B = { |
| 672 | 0x3D,0x09,0x4C,0x4B,0xCD,0x4D,0x42,0x62,0x21,0x0B}; | 1119 | { NID_X9_62_characteristic_two_field,20,52,2 }, |
| 673 | static const EC_CURVE_DATA _EC_NIST_CHAR2_409B = { | 1120 | { 0x40,0x99,0xB5,0xA4,0x57,0xF9,0xD6,0x9F,0x79,0x21, /* seed */ |
| 674 | NID_X9_62_characteristic_two_field, | 1121 | 0x3D,0x09,0x4C,0x4B,0xCD,0x4D,0x42,0x62,0x21,0x0B, |
| 675 | "020000000000000000000000000000000000000000000000000000000000000000000" | 1122 | |
| 676 | "00000000000008000000000000000000001", | 1123 | 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 677 | "000000000000000000000000000000000000000000000000000000000000000000000" | 1124 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 678 | "00000000000000000000000000000000001", | 1125 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 679 | "0021A5C2C8EE9FEB5C4B9A753B7B476B7FD6422EF1F3DD674761FA99D6AC27C8A9A19" | 1126 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 680 | "7B272822F6CD57A55AA4F50AE317B13545F", | 1127 | 0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 681 | "015D4860D088DDB3496B0C6064756260441CDE4AF1771D4DB01FFE5B34E59703DC255" | 1128 | 0x00,0x01, |
| 682 | "A868A1180515603AEAB60794E54BB7996A7", | 1129 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 683 | "0061B1CFAB6BE5F32BBFA78324ED106A7636B9C5A7BD198D0158AA4F5488D08F38514" | 1130 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 684 | "F1FDF4B4F40D2181B3681C364BA0273C706", | 1131 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 685 | "010000000000000000000000000000000000000000000000000001E2AAD6A612F3330" | 1132 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 686 | "7BE5FA47C3C9E052F838164CD37D9A21173", 2, | 1133 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 687 | _EC_NIST_CHAR2_409B_SEED, 20, | 1134 | 0x00,0x01, |
| 688 | "NIST/SECG curve over a 409 bit binary field" | 1135 | 0x00,0x21,0xA5,0xC2,0xC8,0xEE,0x9F,0xEB,0x5C,0x4B, /* b */ |
| 1136 | 0x9A,0x75,0x3B,0x7B,0x47,0x6B,0x7F,0xD6,0x42,0x2E, | ||
| 1137 | 0xF1,0xF3,0xDD,0x67,0x47,0x61,0xFA,0x99,0xD6,0xAC, | ||
| 1138 | 0x27,0xC8,0xA9,0xA1,0x97,0xB2,0x72,0x82,0x2F,0x6C, | ||
| 1139 | 0xD5,0x7A,0x55,0xAA,0x4F,0x50,0xAE,0x31,0x7B,0x13, | ||
| 1140 | 0x54,0x5F, | ||
| 1141 | 0x01,0x5D,0x48,0x60,0xD0,0x88,0xDD,0xB3,0x49,0x6B, /* x */ | ||
| 1142 | 0x0C,0x60,0x64,0x75,0x62,0x60,0x44,0x1C,0xDE,0x4A, | ||
| 1143 | 0xF1,0x77,0x1D,0x4D,0xB0,0x1F,0xFE,0x5B,0x34,0xE5, | ||
| 1144 | 0x97,0x03,0xDC,0x25,0x5A,0x86,0x8A,0x11,0x80,0x51, | ||
| 1145 | 0x56,0x03,0xAE,0xAB,0x60,0x79,0x4E,0x54,0xBB,0x79, | ||
| 1146 | 0x96,0xA7, | ||
| 1147 | 0x00,0x61,0xB1,0xCF,0xAB,0x6B,0xE5,0xF3,0x2B,0xBF, /* y */ | ||
| 1148 | 0xA7,0x83,0x24,0xED,0x10,0x6A,0x76,0x36,0xB9,0xC5, | ||
| 1149 | 0xA7,0xBD,0x19,0x8D,0x01,0x58,0xAA,0x4F,0x54,0x88, | ||
| 1150 | 0xD0,0x8F,0x38,0x51,0x4F,0x1F,0xDF,0x4B,0x4F,0x40, | ||
| 1151 | 0xD2,0x18,0x1B,0x36,0x81,0xC3,0x64,0xBA,0x02,0x73, | ||
| 1152 | 0xC7,0x06, | ||
| 1153 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 1154 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1155 | 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xE2,0xAA,0xD6, | ||
| 1156 | 0xA6,0x12,0xF3,0x33,0x07,0xBE,0x5F,0xA4,0x7C,0x3C, | ||
| 1157 | 0x9E,0x05,0x2F,0x83,0x81,0x64,0xCD,0x37,0xD9,0xA2, | ||
| 1158 | 0x11,0x73 } | ||
| 689 | }; | 1159 | }; |
| 690 | 1160 | ||
| 691 | static const EC_CURVE_DATA _EC_NIST_CHAR2_571K = { | 1161 | static const struct { EC_CURVE_DATA h; unsigned char data[0+72*6]; } |
| 692 | NID_X9_62_characteristic_two_field, | 1162 | _EC_NIST_CHAR2_571K = { |
| 693 | "800000000000000000000000000000000000000000000000000000000000000000000" | 1163 | { NID_X9_62_characteristic_two_field,0,72,4 }, |
| 694 | "000000000000000000000000000000000000000000000000000000000000000000000" | 1164 | { /* no seed */ |
| 695 | "00425", | 1165 | 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 696 | "0", | 1166 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 697 | "1", | 1167 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 698 | "026EB7A859923FBC82189631F8103FE4AC9CA2970012D5D46024804801841CA443709" | 1168 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 699 | "58493B205E647DA304DB4CEB08CBBD1BA39494776FB988B47174DCA88C7E2945283A0" | 1169 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 700 | "1C8972", | 1170 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 701 | "0349DC807F4FBF374F4AEADE3BCA95314DD58CEC9F307A54FFC61EFC006D8A2C9D497" | 1171 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 702 | "9C0AC44AEA74FBEBBB9F772AEDCB620B01A7BA7AF1B320430C8591984F601CD4C143E" | 1172 | 0x04,0x25, |
| 703 | "F1C7A3", | 1173 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 704 | "020000000000000000000000000000000000000000000000000000000000000000000" | 1174 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 705 | "000131850E1F19A63E4B391A8DB917F4138B630D84BE5D639381E91DEB45CFE778F63" | 1175 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 706 | "7C1001", 4, | 1176 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 707 | NULL, 0, | 1177 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 708 | "NIST/SECG curve over a 571 bit binary field" | 1178 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 1179 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1180 | 0x00,0x00, | ||
| 1181 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ | ||
| 1182 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1183 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1184 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1185 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1186 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1187 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1188 | 0x00,0x01, | ||
| 1189 | 0x02,0x6E,0xB7,0xA8,0x59,0x92,0x3F,0xBC,0x82,0x18, /* x */ | ||
| 1190 | 0x96,0x31,0xF8,0x10,0x3F,0xE4,0xAC,0x9C,0xA2,0x97, | ||
| 1191 | 0x00,0x12,0xD5,0xD4,0x60,0x24,0x80,0x48,0x01,0x84, | ||
| 1192 | 0x1C,0xA4,0x43,0x70,0x95,0x84,0x93,0xB2,0x05,0xE6, | ||
| 1193 | 0x47,0xDA,0x30,0x4D,0xB4,0xCE,0xB0,0x8C,0xBB,0xD1, | ||
| 1194 | 0xBA,0x39,0x49,0x47,0x76,0xFB,0x98,0x8B,0x47,0x17, | ||
| 1195 | 0x4D,0xCA,0x88,0xC7,0xE2,0x94,0x52,0x83,0xA0,0x1C, | ||
| 1196 | 0x89,0x72, | ||
| 1197 | 0x03,0x49,0xDC,0x80,0x7F,0x4F,0xBF,0x37,0x4F,0x4A, /* y */ | ||
| 1198 | 0xEA,0xDE,0x3B,0xCA,0x95,0x31,0x4D,0xD5,0x8C,0xEC, | ||
| 1199 | 0x9F,0x30,0x7A,0x54,0xFF,0xC6,0x1E,0xFC,0x00,0x6D, | ||
| 1200 | 0x8A,0x2C,0x9D,0x49,0x79,0xC0,0xAC,0x44,0xAE,0xA7, | ||
| 1201 | 0x4F,0xBE,0xBB,0xB9,0xF7,0x72,0xAE,0xDC,0xB6,0x20, | ||
| 1202 | 0xB0,0x1A,0x7B,0xA7,0xAF,0x1B,0x32,0x04,0x30,0xC8, | ||
| 1203 | 0x59,0x19,0x84,0xF6,0x01,0xCD,0x4C,0x14,0x3E,0xF1, | ||
| 1204 | 0xC7,0xA3, | ||
| 1205 | 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 1206 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1207 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1208 | 0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x18,0x50,0xE1, | ||
| 1209 | 0xF1,0x9A,0x63,0xE4,0xB3,0x91,0xA8,0xDB,0x91,0x7F, | ||
| 1210 | 0x41,0x38,0xB6,0x30,0xD8,0x4B,0xE5,0xD6,0x39,0x38, | ||
| 1211 | 0x1E,0x91,0xDE,0xB4,0x5C,0xFE,0x77,0x8F,0x63,0x7C, | ||
| 1212 | 0x10,0x01 } | ||
| 709 | }; | 1213 | }; |
| 710 | 1214 | ||
| 711 | static const unsigned char _EC_NIST_CHAR2_571B_SEED[] = { | 1215 | static const struct { EC_CURVE_DATA h; unsigned char data[20+72*6]; } |
| 712 | 0x2A,0xA0,0x58,0xF7,0x3A,0x0E,0x33,0xAB,0x48,0x6B, | 1216 | _EC_NIST_CHAR2_571B = { |
| 713 | 0x0F,0x61,0x04,0x10,0xC5,0x3A,0x7F,0x13,0x23,0x10}; | 1217 | { NID_X9_62_characteristic_two_field,20,72,2 }, |
| 714 | static const EC_CURVE_DATA _EC_NIST_CHAR2_571B = { | 1218 | { 0x2A,0xA0,0x58,0xF7,0x3A,0x0E,0x33,0xAB,0x48,0x6B, /* seed */ |
| 715 | NID_X9_62_characteristic_two_field, | 1219 | 0x0F,0x61,0x04,0x10,0xC5,0x3A,0x7F,0x13,0x23,0x10, |
| 716 | "800000000000000000000000000000000000000000000000000000000000000000000" | 1220 | |
| 717 | "000000000000000000000000000000000000000000000000000000000000000000000" | 1221 | 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 718 | "00425", | 1222 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 719 | "000000000000000000000000000000000000000000000000000000000000000000000" | 1223 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 720 | "000000000000000000000000000000000000000000000000000000000000000000000" | 1224 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 721 | "000001", | 1225 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 722 | "02F40E7E2221F295DE297117B7F3D62F5C6A97FFCB8CEFF1CD6BA8CE4A9A18AD84FFA" | 1226 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 723 | "BBD8EFA59332BE7AD6756A66E294AFD185A78FF12AA520E4DE739BACA0C7FFEFF7F29" | 1227 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 724 | "55727A", | 1228 | 0x04,0x25, |
| 725 | "0303001D34B856296C16C0D40D3CD7750A93D1D2955FA80AA5F40FC8DB7B2ABDBDE53" | 1229 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 726 | "950F4C0D293CDD711A35B67FB1499AE60038614F1394ABFA3B4C850D927E1E7769C8E" | 1230 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 727 | "EC2D19", | 1231 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 728 | "037BF27342DA639B6DCCFFFEB73D69D78C6C27A6009CBBCA1980F8533921E8A684423" | 1232 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 729 | "E43BAB08A576291AF8F461BB2A8B3531D2F0485C19B16E2F1516E23DD3C1A4827AF1B" | 1233 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 730 | "8AC15B", | 1234 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 731 | "03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" | 1235 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 732 | "FFFE661CE18FF55987308059B186823851EC7DD9CA1161DE93D5174D66E8382E9BB2F" | 1236 | 0x00,0x01, |
| 733 | "E84E47", 2, | 1237 | 0x02,0xF4,0x0E,0x7E,0x22,0x21,0xF2,0x95,0xDE,0x29, /* b */ |
| 734 | _EC_NIST_CHAR2_571B_SEED, 20, | 1238 | 0x71,0x17,0xB7,0xF3,0xD6,0x2F,0x5C,0x6A,0x97,0xFF, |
| 735 | "NIST/SECG curve over a 571 bit binary field" | 1239 | 0xCB,0x8C,0xEF,0xF1,0xCD,0x6B,0xA8,0xCE,0x4A,0x9A, |
| 1240 | 0x18,0xAD,0x84,0xFF,0xAB,0xBD,0x8E,0xFA,0x59,0x33, | ||
| 1241 | 0x2B,0xE7,0xAD,0x67,0x56,0xA6,0x6E,0x29,0x4A,0xFD, | ||
| 1242 | 0x18,0x5A,0x78,0xFF,0x12,0xAA,0x52,0x0E,0x4D,0xE7, | ||
| 1243 | 0x39,0xBA,0xCA,0x0C,0x7F,0xFE,0xFF,0x7F,0x29,0x55, | ||
| 1244 | 0x72,0x7A, | ||
| 1245 | 0x03,0x03,0x00,0x1D,0x34,0xB8,0x56,0x29,0x6C,0x16, /* x */ | ||
| 1246 | 0xC0,0xD4,0x0D,0x3C,0xD7,0x75,0x0A,0x93,0xD1,0xD2, | ||
| 1247 | 0x95,0x5F,0xA8,0x0A,0xA5,0xF4,0x0F,0xC8,0xDB,0x7B, | ||
| 1248 | 0x2A,0xBD,0xBD,0xE5,0x39,0x50,0xF4,0xC0,0xD2,0x93, | ||
| 1249 | 0xCD,0xD7,0x11,0xA3,0x5B,0x67,0xFB,0x14,0x99,0xAE, | ||
| 1250 | 0x60,0x03,0x86,0x14,0xF1,0x39,0x4A,0xBF,0xA3,0xB4, | ||
| 1251 | 0xC8,0x50,0xD9,0x27,0xE1,0xE7,0x76,0x9C,0x8E,0xEC, | ||
| 1252 | 0x2D,0x19, | ||
| 1253 | 0x03,0x7B,0xF2,0x73,0x42,0xDA,0x63,0x9B,0x6D,0xCC, /* y */ | ||
| 1254 | 0xFF,0xFE,0xB7,0x3D,0x69,0xD7,0x8C,0x6C,0x27,0xA6, | ||
| 1255 | 0x00,0x9C,0xBB,0xCA,0x19,0x80,0xF8,0x53,0x39,0x21, | ||
| 1256 | 0xE8,0xA6,0x84,0x42,0x3E,0x43,0xBA,0xB0,0x8A,0x57, | ||
| 1257 | 0x62,0x91,0xAF,0x8F,0x46,0x1B,0xB2,0xA8,0xB3,0x53, | ||
| 1258 | 0x1D,0x2F,0x04,0x85,0xC1,0x9B,0x16,0xE2,0xF1,0x51, | ||
| 1259 | 0x6E,0x23,0xDD,0x3C,0x1A,0x48,0x27,0xAF,0x1B,0x8A, | ||
| 1260 | 0xC1,0x5B, | ||
| 1261 | 0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 1262 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
| 1263 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
| 1264 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE6,0x61,0xCE,0x18, | ||
| 1265 | 0xFF,0x55,0x98,0x73,0x08,0x05,0x9B,0x18,0x68,0x23, | ||
| 1266 | 0x85,0x1E,0xC7,0xDD,0x9C,0xA1,0x16,0x1D,0xE9,0x3D, | ||
| 1267 | 0x51,0x74,0xD6,0x6E,0x83,0x82,0xE9,0xBB,0x2F,0xE8, | ||
| 1268 | 0x4E,0x47 } | ||
| 736 | }; | 1269 | }; |
| 737 | 1270 | ||
| 738 | static const unsigned char _EC_X9_62_CHAR2_163V1_SEED[] = { | 1271 | static const struct { EC_CURVE_DATA h; unsigned char data[20+21*6]; } |
| 739 | 0xD2,0xC0,0xFB,0x15,0x76,0x08,0x60,0xDE,0xF1,0xEE, | 1272 | _EC_X9_62_CHAR2_163V1 = { |
| 740 | 0xF4,0xD6,0x96,0xE6,0x76,0x87,0x56,0x15,0x17,0x54}; | 1273 | { NID_X9_62_characteristic_two_field,20,21,2 }, |
| 741 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_163V1 = { | 1274 | { 0xD2,0xC0,0xFB,0x15,0x76,0x08,0x60,0xDE,0xF1,0xEE, |
| 742 | NID_X9_62_characteristic_two_field, | 1275 | 0xF4,0xD6,0x96,0xE6,0x76,0x87,0x56,0x15,0x17,0x54, /* seed */ |
| 743 | "080000000000000000000000000000000000000107", | 1276 | |
| 744 | "072546B5435234A422E0789675F432C89435DE5242", | 1277 | 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 745 | "00C9517D06D5240D3CFF38C74B20B6CD4D6F9DD4D9", | 1278 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, |
| 746 | "07AF69989546103D79329FCC3D74880F33BBE803CB", | 1279 | 0x07, |
| 747 | "01EC23211B5966ADEA1D3F87F7EA5848AEF0B7CA9F", | 1280 | 0x07,0x25,0x46,0xB5,0x43,0x52,0x34,0xA4,0x22,0xE0, /* a */ |
| 748 | "0400000000000000000001E60FC8821CC74DAEAFC1", 2, | 1281 | 0x78,0x96,0x75,0xF4,0x32,0xC8,0x94,0x35,0xDE,0x52, |
| 749 | _EC_X9_62_CHAR2_163V1_SEED, 20, | 1282 | 0x42, |
| 750 | "X9.62 curve over a 163 bit binary field" | 1283 | 0x00,0xC9,0x51,0x7D,0x06,0xD5,0x24,0x0D,0x3C,0xFF, /* b */ |
| 1284 | 0x38,0xC7,0x4B,0x20,0xB6,0xCD,0x4D,0x6F,0x9D,0xD4, | ||
| 1285 | 0xD9, | ||
| 1286 | 0x07,0xAF,0x69,0x98,0x95,0x46,0x10,0x3D,0x79,0x32, /* x */ | ||
| 1287 | 0x9F,0xCC,0x3D,0x74,0x88,0x0F,0x33,0xBB,0xE8,0x03, | ||
| 1288 | 0xCB, | ||
| 1289 | 0x01,0xEC,0x23,0x21,0x1B,0x59,0x66,0xAD,0xEA,0x1D, /* y */ | ||
| 1290 | 0x3F,0x87,0xF7,0xEA,0x58,0x48,0xAE,0xF0,0xB7,0xCA, | ||
| 1291 | 0x9F, | ||
| 1292 | 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 1293 | 0x01,0xE6,0x0F,0xC8,0x82,0x1C,0xC7,0x4D,0xAE,0xAF, | ||
| 1294 | 0xC1 } | ||
| 751 | }; | 1295 | }; |
| 752 | 1296 | ||
| 753 | static const unsigned char _EC_X9_62_CHAR2_163V2_SEED[] = { | 1297 | static const struct { EC_CURVE_DATA h; unsigned char data[20+21*6]; } |
| 754 | 0x53,0x81,0x4C,0x05,0x0D,0x44,0xD6,0x96,0xE6,0x76, | 1298 | _EC_X9_62_CHAR2_163V2 = { |
| 755 | 0x87,0x56,0x15,0x17,0x58,0x0C,0xA4,0xE2,0x9F,0xFD}; | 1299 | { NID_X9_62_characteristic_two_field,20,21,2 }, |
| 756 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_163V2 = { | 1300 | { 0x53,0x81,0x4C,0x05,0x0D,0x44,0xD6,0x96,0xE6,0x76, /* seed */ |
| 757 | NID_X9_62_characteristic_two_field, | 1301 | 0x87,0x56,0x15,0x17,0x58,0x0C,0xA4,0xE2,0x9F,0xFD, |
| 758 | "080000000000000000000000000000000000000107", | 1302 | |
| 759 | "0108B39E77C4B108BED981ED0E890E117C511CF072", | 1303 | 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 760 | "0667ACEB38AF4E488C407433FFAE4F1C811638DF20", | 1304 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, |
| 761 | "0024266E4EB5106D0A964D92C4860E2671DB9B6CC5", | 1305 | 0x07, |
| 762 | "079F684DDF6684C5CD258B3890021B2386DFD19FC5", | 1306 | 0x01,0x08,0xB3,0x9E,0x77,0xC4,0xB1,0x08,0xBE,0xD9, /* a */ |
| 763 | "03FFFFFFFFFFFFFFFFFFFDF64DE1151ADBB78F10A7", 2, | 1307 | 0x81,0xED,0x0E,0x89,0x0E,0x11,0x7C,0x51,0x1C,0xF0, |
| 764 | _EC_X9_62_CHAR2_163V2_SEED, 20, | 1308 | 0x72, |
| 765 | "X9.62 curve over a 163 bit binary field" | 1309 | 0x06,0x67,0xAC,0xEB,0x38,0xAF,0x4E,0x48,0x8C,0x40, /* b */ |
| 1310 | 0x74,0x33,0xFF,0xAE,0x4F,0x1C,0x81,0x16,0x38,0xDF, | ||
| 1311 | 0x20, | ||
| 1312 | 0x00,0x24,0x26,0x6E,0x4E,0xB5,0x10,0x6D,0x0A,0x96, /* x */ | ||
| 1313 | 0x4D,0x92,0xC4,0x86,0x0E,0x26,0x71,0xDB,0x9B,0x6C, | ||
| 1314 | 0xC5, | ||
| 1315 | 0x07,0x9F,0x68,0x4D,0xDF,0x66,0x84,0xC5,0xCD,0x25, /* y */ | ||
| 1316 | 0x8B,0x38,0x90,0x02,0x1B,0x23,0x86,0xDF,0xD1,0x9F, | ||
| 1317 | 0xC5, | ||
| 1318 | 0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 1319 | 0xFD,0xF6,0x4D,0xE1,0x15,0x1A,0xDB,0xB7,0x8F,0x10, | ||
| 1320 | 0xA7 } | ||
| 766 | }; | 1321 | }; |
| 767 | 1322 | ||
| 768 | static const unsigned char _EC_X9_62_CHAR2_163V3_SEED[] = { | 1323 | static const struct { EC_CURVE_DATA h; unsigned char data[20+21*6]; } |
| 769 | 0x50,0xCB,0xF1,0xD9,0x5C,0xA9,0x4D,0x69,0x6E,0x67, | 1324 | _EC_X9_62_CHAR2_163V3 = { |
| 770 | 0x68,0x75,0x61,0x51,0x75,0xF1,0x6A,0x36,0xA3,0xB8}; | 1325 | { NID_X9_62_characteristic_two_field,20,21,2 }, |
| 771 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_163V3 = { | 1326 | { 0x50,0xCB,0xF1,0xD9,0x5C,0xA9,0x4D,0x69,0x6E,0x67, /* seed */ |
| 772 | NID_X9_62_characteristic_two_field, | 1327 | 0x68,0x75,0x61,0x51,0x75,0xF1,0x6A,0x36,0xA3,0xB8, |
| 773 | "080000000000000000000000000000000000000107", | 1328 | |
| 774 | "07A526C63D3E25A256A007699F5447E32AE456B50E", | 1329 | 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 775 | "03F7061798EB99E238FD6F1BF95B48FEEB4854252B", | 1330 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, |
| 776 | "02F9F87B7C574D0BDECF8A22E6524775F98CDEBDCB", | 1331 | 0x07, |
| 777 | "05B935590C155E17EA48EB3FF3718B893DF59A05D0", | 1332 | 0x07,0xA5,0x26,0xC6,0x3D,0x3E,0x25,0xA2,0x56,0xA0, /* a */ |
| 778 | "03FFFFFFFFFFFFFFFFFFFE1AEE140F110AFF961309", 2, | 1333 | 0x07,0x69,0x9F,0x54,0x47,0xE3,0x2A,0xE4,0x56,0xB5, |
| 779 | _EC_X9_62_CHAR2_163V3_SEED, 20, | 1334 | 0x0E, |
| 780 | "X9.62 curve over a 163 bit binary field" | 1335 | 0x03,0xF7,0x06,0x17,0x98,0xEB,0x99,0xE2,0x38,0xFD, /* b */ |
| 1336 | 0x6F,0x1B,0xF9,0x5B,0x48,0xFE,0xEB,0x48,0x54,0x25, | ||
| 1337 | 0x2B, | ||
| 1338 | 0x02,0xF9,0xF8,0x7B,0x7C,0x57,0x4D,0x0B,0xDE,0xCF, /* x */ | ||
| 1339 | 0x8A,0x22,0xE6,0x52,0x47,0x75,0xF9,0x8C,0xDE,0xBD, | ||
| 1340 | 0xCB, | ||
| 1341 | 0x05,0xB9,0x35,0x59,0x0C,0x15,0x5E,0x17,0xEA,0x48, /* y */ | ||
| 1342 | 0xEB,0x3F,0xF3,0x71,0x8B,0x89,0x3D,0xF5,0x9A,0x05, | ||
| 1343 | 0xD0, | ||
| 1344 | 0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 1345 | 0xFE,0x1A,0xEE,0x14,0x0F,0x11,0x0A,0xFF,0x96,0x13, | ||
| 1346 | 0x09 } | ||
| 781 | }; | 1347 | }; |
| 782 | 1348 | ||
| 783 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_176V1 = { | 1349 | static const struct { EC_CURVE_DATA h; unsigned char data[0+23*6]; } |
| 784 | NID_X9_62_characteristic_two_field, | 1350 | _EC_X9_62_CHAR2_176V1 = { |
| 785 | "0100000000000000000000000000000000080000000007", | 1351 | { NID_X9_62_characteristic_two_field,0,23,0xFF6E }, |
| 786 | "E4E6DB2995065C407D9D39B8D0967B96704BA8E9C90B", | 1352 | { /* no seed */ |
| 787 | "5DDA470ABE6414DE8EC133AE28E9BBD7FCEC0AE0FFF2", | 1353 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 788 | "8D16C2866798B600F9F08BB4A8E860F3298CE04A5798", | 1354 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00, |
| 789 | "6FA4539C2DADDDD6BAB5167D61B436E1D92BB16A562C", | 1355 | 0x00,0x00,0x07, |
| 790 | "00010092537397ECA4F6145799D62B0A19CE06FE26AD", 0xFF6E, | 1356 | 0x00,0xE4,0xE6,0xDB,0x29,0x95,0x06,0x5C,0x40,0x7D, /* a */ |
| 791 | NULL, 0, | 1357 | 0x9D,0x39,0xB8,0xD0,0x96,0x7B,0x96,0x70,0x4B,0xA8, |
| 792 | "X9.62 curve over a 176 bit binary field" | 1358 | 0xE9,0xC9,0x0B, |
| 1359 | 0x00,0x5D,0xDA,0x47,0x0A,0xBE,0x64,0x14,0xDE,0x8E, /* b */ | ||
| 1360 | 0xC1,0x33,0xAE,0x28,0xE9,0xBB,0xD7,0xFC,0xEC,0x0A, | ||
| 1361 | 0xE0,0xFF,0xF2, | ||
| 1362 | 0x00,0x8D,0x16,0xC2,0x86,0x67,0x98,0xB6,0x00,0xF9, /* x */ | ||
| 1363 | 0xF0,0x8B,0xB4,0xA8,0xE8,0x60,0xF3,0x29,0x8C,0xE0, | ||
| 1364 | 0x4A,0x57,0x98, | ||
| 1365 | 0x00,0x6F,0xA4,0x53,0x9C,0x2D,0xAD,0xDD,0xD6,0xBA, /* y */ | ||
| 1366 | 0xB5,0x16,0x7D,0x61,0xB4,0x36,0xE1,0xD9,0x2B,0xB1, | ||
| 1367 | 0x6A,0x56,0x2C, | ||
| 1368 | 0x00,0x00,0x01,0x00,0x92,0x53,0x73,0x97,0xEC,0xA4, /* order */ | ||
| 1369 | 0xF6,0x14,0x57,0x99,0xD6,0x2B,0x0A,0x19,0xCE,0x06, | ||
| 1370 | 0xFE,0x26,0xAD } | ||
| 793 | }; | 1371 | }; |
| 794 | 1372 | ||
| 795 | static const unsigned char _EC_X9_62_CHAR2_191V1_SEED[] = { | 1373 | static const struct { EC_CURVE_DATA h; unsigned char data[20+24*6]; } |
| 796 | 0x4E,0x13,0xCA,0x54,0x27,0x44,0xD6,0x96,0xE6,0x76, | 1374 | _EC_X9_62_CHAR2_191V1 = { |
| 797 | 0x87,0x56,0x15,0x17,0x55,0x2F,0x27,0x9A,0x8C,0x84}; | 1375 | { NID_X9_62_characteristic_two_field,20,24,2 }, |
| 798 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_191V1 = { | 1376 | { 0x4E,0x13,0xCA,0x54,0x27,0x44,0xD6,0x96,0xE6,0x76, /* seed */ |
| 799 | NID_X9_62_characteristic_two_field, | 1377 | 0x87,0x56,0x15,0x17,0x55,0x2F,0x27,0x9A,0x8C,0x84, |
| 800 | "800000000000000000000000000000000000000000000201", | 1378 | |
| 801 | "2866537B676752636A68F56554E12640276B649EF7526267", | 1379 | 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 802 | "2E45EF571F00786F67B0081B9495A3D95462F5DE0AA185EC", | 1380 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 803 | "36B3DAF8A23206F9C4F299D7B21A9C369137F2C84AE1AA0D", | 1381 | 0x00,0x00,0x02,0x01, |
| 804 | "765BE73433B3F95E332932E70EA245CA2418EA0EF98018FB", | 1382 | 0x28,0x66,0x53,0x7B,0x67,0x67,0x52,0x63,0x6A,0x68, /* a */ |
| 805 | "40000000000000000000000004A20E90C39067C893BBB9A5", 2, | 1383 | 0xF5,0x65,0x54,0xE1,0x26,0x40,0x27,0x6B,0x64,0x9E, |
| 806 | _EC_X9_62_CHAR2_191V1_SEED, 20, | 1384 | 0xF7,0x52,0x62,0x67, |
| 807 | "X9.62 curve over a 191 bit binary field" | 1385 | 0x2E,0x45,0xEF,0x57,0x1F,0x00,0x78,0x6F,0x67,0xB0, /* b */ |
| 1386 | 0x08,0x1B,0x94,0x95,0xA3,0xD9,0x54,0x62,0xF5,0xDE, | ||
| 1387 | 0x0A,0xA1,0x85,0xEC, | ||
| 1388 | 0x36,0xB3,0xDA,0xF8,0xA2,0x32,0x06,0xF9,0xC4,0xF2, /* x */ | ||
| 1389 | 0x99,0xD7,0xB2,0x1A,0x9C,0x36,0x91,0x37,0xF2,0xC8, | ||
| 1390 | 0x4A,0xE1,0xAA,0x0D, | ||
| 1391 | 0x76,0x5B,0xE7,0x34,0x33,0xB3,0xF9,0x5E,0x33,0x29, /* y */ | ||
| 1392 | 0x32,0xE7,0x0E,0xA2,0x45,0xCA,0x24,0x18,0xEA,0x0E, | ||
| 1393 | 0xF9,0x80,0x18,0xFB, | ||
| 1394 | 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 1395 | 0x00,0x00,0x04,0xA2,0x0E,0x90,0xC3,0x90,0x67,0xC8, | ||
| 1396 | 0x93,0xBB,0xB9,0xA5 } | ||
| 808 | }; | 1397 | }; |
| 809 | 1398 | ||
| 810 | static const unsigned char _EC_X9_62_CHAR2_191V2_SEED[] = { | 1399 | static const struct { EC_CURVE_DATA h; unsigned char data[20+24*6]; } |
| 811 | 0x08,0x71,0xEF,0x2F,0xEF,0x24,0xD6,0x96,0xE6,0x76, | 1400 | _EC_X9_62_CHAR2_191V2 = { |
| 812 | 0x87,0x56,0x15,0x17,0x58,0xBE,0xE0,0xD9,0x5C,0x15}; | 1401 | { NID_X9_62_characteristic_two_field,20,24,4 }, |
| 813 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_191V2 = { | 1402 | { 0x08,0x71,0xEF,0x2F,0xEF,0x24,0xD6,0x96,0xE6,0x76, /* seed */ |
| 814 | NID_X9_62_characteristic_two_field, | 1403 | 0x87,0x56,0x15,0x17,0x58,0xBE,0xE0,0xD9,0x5C,0x15, |
| 815 | "800000000000000000000000000000000000000000000201", | 1404 | |
| 816 | "401028774D7777C7B7666D1366EA432071274F89FF01E718", | 1405 | 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 817 | "0620048D28BCBD03B6249C99182B7C8CD19700C362C46A01", | 1406 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 818 | "3809B2B7CC1B28CC5A87926AAD83FD28789E81E2C9E3BF10", | 1407 | 0x00,0x00,0x02,0x01, |
| 819 | "17434386626D14F3DBF01760D9213A3E1CF37AEC437D668A", | 1408 | 0x40,0x10,0x28,0x77,0x4D,0x77,0x77,0xC7,0xB7,0x66, /* a */ |
| 820 | "20000000000000000000000050508CB89F652824E06B8173", 4, | 1409 | 0x6D,0x13,0x66,0xEA,0x43,0x20,0x71,0x27,0x4F,0x89, |
| 821 | _EC_X9_62_CHAR2_191V2_SEED, 20, | 1410 | 0xFF,0x01,0xE7,0x18, |
| 822 | "X9.62 curve over a 191 bit binary field" | 1411 | 0x06,0x20,0x04,0x8D,0x28,0xBC,0xBD,0x03,0xB6,0x24, /* b */ |
| 1412 | 0x9C,0x99,0x18,0x2B,0x7C,0x8C,0xD1,0x97,0x00,0xC3, | ||
| 1413 | 0x62,0xC4,0x6A,0x01, | ||
| 1414 | 0x38,0x09,0xB2,0xB7,0xCC,0x1B,0x28,0xCC,0x5A,0x87, /* x */ | ||
| 1415 | 0x92,0x6A,0xAD,0x83,0xFD,0x28,0x78,0x9E,0x81,0xE2, | ||
| 1416 | 0xC9,0xE3,0xBF,0x10, | ||
| 1417 | 0x17,0x43,0x43,0x86,0x62,0x6D,0x14,0xF3,0xDB,0xF0, /* y */ | ||
| 1418 | 0x17,0x60,0xD9,0x21,0x3A,0x3E,0x1C,0xF3,0x7A,0xEC, | ||
| 1419 | 0x43,0x7D,0x66,0x8A, | ||
| 1420 | 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 1421 | 0x00,0x00,0x50,0x50,0x8C,0xB8,0x9F,0x65,0x28,0x24, | ||
| 1422 | 0xE0,0x6B,0x81,0x73 } | ||
| 823 | }; | 1423 | }; |
| 824 | 1424 | ||
| 825 | static const unsigned char _EC_X9_62_CHAR2_191V3_SEED[] = { | 1425 | static const struct { EC_CURVE_DATA h; unsigned char data[20+24*6]; } |
| 826 | 0xE0,0x53,0x51,0x2D,0xC6,0x84,0xD6,0x96,0xE6,0x76, | 1426 | _EC_X9_62_CHAR2_191V3 = { |
| 827 | 0x87,0x56,0x15,0x17,0x50,0x67,0xAE,0x78,0x6D,0x1F}; | 1427 | { NID_X9_62_characteristic_two_field,20,24,6 }, |
| 828 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_191V3 = { | 1428 | { 0xE0,0x53,0x51,0x2D,0xC6,0x84,0xD6,0x96,0xE6,0x76, /* seed */ |
| 829 | NID_X9_62_characteristic_two_field, | 1429 | 0x87,0x56,0x15,0x17,0x50,0x67,0xAE,0x78,0x6D,0x1F, |
| 830 | "800000000000000000000000000000000000000000000201", | 1430 | |
| 831 | "6C01074756099122221056911C77D77E77A777E7E7E77FCB", | 1431 | 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 832 | "71FE1AF926CF847989EFEF8DB459F66394D90F32AD3F15E8", | 1432 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 833 | "375D4CE24FDE434489DE8746E71786015009E66E38A926DD", | 1433 | 0x00,0x00,0x02,0x01, |
| 834 | "545A39176196575D985999366E6AD34CE0A77CD7127B06BE", | 1434 | 0x6C,0x01,0x07,0x47,0x56,0x09,0x91,0x22,0x22,0x10, /* a */ |
| 835 | "155555555555555555555555610C0B196812BFB6288A3EA3", 6, | 1435 | 0x56,0x91,0x1C,0x77,0xD7,0x7E,0x77,0xA7,0x77,0xE7, |
| 836 | _EC_X9_62_CHAR2_191V3_SEED, 20, | 1436 | 0xE7,0xE7,0x7F,0xCB, |
| 837 | "X9.62 curve over a 191 bit binary field" | 1437 | 0x71,0xFE,0x1A,0xF9,0x26,0xCF,0x84,0x79,0x89,0xEF, /* b */ |
| 1438 | 0xEF,0x8D,0xB4,0x59,0xF6,0x63,0x94,0xD9,0x0F,0x32, | ||
| 1439 | 0xAD,0x3F,0x15,0xE8, | ||
| 1440 | 0x37,0x5D,0x4C,0xE2,0x4F,0xDE,0x43,0x44,0x89,0xDE, /* x */ | ||
| 1441 | 0x87,0x46,0xE7,0x17,0x86,0x01,0x50,0x09,0xE6,0x6E, | ||
| 1442 | 0x38,0xA9,0x26,0xDD, | ||
| 1443 | 0x54,0x5A,0x39,0x17,0x61,0x96,0x57,0x5D,0x98,0x59, /* y */ | ||
| 1444 | 0x99,0x36,0x6E,0x6A,0xD3,0x4C,0xE0,0xA7,0x7C,0xD7, | ||
| 1445 | 0x12,0x7B,0x06,0xBE, | ||
| 1446 | 0x15,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55, /* order */ | ||
| 1447 | 0x55,0x55,0x61,0x0C,0x0B,0x19,0x68,0x12,0xBF,0xB6, | ||
| 1448 | 0x28,0x8A,0x3E,0xA3 } | ||
| 838 | }; | 1449 | }; |
| 839 | 1450 | ||
| 840 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_208W1 = { | 1451 | static const struct { EC_CURVE_DATA h; unsigned char data[0+27*6]; } |
| 841 | NID_X9_62_characteristic_two_field, | 1452 | _EC_X9_62_CHAR2_208W1 = { |
| 842 | "010000000000000000000000000000000800000000000000000007", | 1453 | { NID_X9_62_characteristic_two_field,0,27,0xFE48 }, |
| 843 | "0000000000000000000000000000000000000000000000000000", | 1454 | { /* no seed */ |
| 844 | "C8619ED45A62E6212E1160349E2BFA844439FAFC2A3FD1638F9E", | 1455 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 845 | "89FDFBE4ABE193DF9559ECF07AC0CE78554E2784EB8C1ED1A57A", | 1456 | 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00, |
| 846 | "0F55B51A06E78E9AC38A035FF520D8B01781BEB1A6BB08617DE3", | 1457 | 0x00,0x00,0x00,0x00,0x00,0x00,0x07, |
| 847 | "000101BAF95C9723C57B6C21DA2EFF2D5ED588BDD5717E212F9D", 0xFE48, | 1458 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 848 | NULL, 0, | 1459 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 849 | "X9.62 curve over a 208 bit binary field" | 1460 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 1461 | 0x00,0xC8,0x61,0x9E,0xD4,0x5A,0x62,0xE6,0x21,0x2E, /* b */ | ||
| 1462 | 0x11,0x60,0x34,0x9E,0x2B,0xFA,0x84,0x44,0x39,0xFA, | ||
| 1463 | 0xFC,0x2A,0x3F,0xD1,0x63,0x8F,0x9E, | ||
| 1464 | 0x00,0x89,0xFD,0xFB,0xE4,0xAB,0xE1,0x93,0xDF,0x95, /* x */ | ||
| 1465 | 0x59,0xEC,0xF0,0x7A,0xC0,0xCE,0x78,0x55,0x4E,0x27, | ||
| 1466 | 0x84,0xEB,0x8C,0x1E,0xD1,0xA5,0x7A, | ||
| 1467 | 0x00,0x0F,0x55,0xB5,0x1A,0x06,0xE7,0x8E,0x9A,0xC3, /* y */ | ||
| 1468 | 0x8A,0x03,0x5F,0xF5,0x20,0xD8,0xB0,0x17,0x81,0xBE, | ||
| 1469 | 0xB1,0xA6,0xBB,0x08,0x61,0x7D,0xE3, | ||
| 1470 | 0x00,0x00,0x01,0x01,0xBA,0xF9,0x5C,0x97,0x23,0xC5, /* order */ | ||
| 1471 | 0x7B,0x6C,0x21,0xDA,0x2E,0xFF,0x2D,0x5E,0xD5,0x88, | ||
| 1472 | 0xBD,0xD5,0x71,0x7E,0x21,0x2F,0x9D } | ||
| 850 | }; | 1473 | }; |
| 851 | 1474 | ||
| 852 | static const unsigned char _EC_X9_62_CHAR2_239V1_SEED[] = { | 1475 | static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } |
| 853 | 0xD3,0x4B,0x9A,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61, | 1476 | _EC_X9_62_CHAR2_239V1 = { |
| 854 | 0x51,0x75,0xCA,0x71,0xB9,0x20,0xBF,0xEF,0xB0,0x5D}; | 1477 | { NID_X9_62_characteristic_two_field,20,30,4 }, |
| 855 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_239V1 = { | 1478 | { 0xD3,0x4B,0x9A,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61, /* seed */ |
| 856 | NID_X9_62_characteristic_two_field, | 1479 | 0x51,0x75,0xCA,0x71,0xB9,0x20,0xBF,0xEF,0xB0,0x5D, |
| 857 | "800000000000000000000000000000000000000000000000001000000001", | 1480 | |
| 858 | "32010857077C5431123A46B808906756F543423E8D27877578125778AC76", | 1481 | 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 859 | "790408F2EEDAF392B012EDEFB3392F30F4327C0CA3F31FC383C422AA8C16", | 1482 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 860 | "57927098FA932E7C0A96D3FD5B706EF7E5F5C156E16B7E7C86038552E91D", | 1483 | 0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x01, |
| 861 | "61D8EE5077C33FECF6F1A16B268DE469C3C7744EA9A971649FC7A9616305", | 1484 | |
| 862 | "2000000000000000000000000000000F4D42FFE1492A4993F1CAD666E447", 4, | 1485 | 0x32,0x01,0x08,0x57,0x07,0x7C,0x54,0x31,0x12,0x3A, /* a */ |
| 863 | _EC_X9_62_CHAR2_239V1_SEED, 20, | 1486 | 0x46,0xB8,0x08,0x90,0x67,0x56,0xF5,0x43,0x42,0x3E, |
| 864 | "X9.62 curve over a 239 bit binary field" | 1487 | 0x8D,0x27,0x87,0x75,0x78,0x12,0x57,0x78,0xAC,0x76, |
| 1488 | |||
| 1489 | 0x79,0x04,0x08,0xF2,0xEE,0xDA,0xF3,0x92,0xB0,0x12, /* b */ | ||
| 1490 | 0xED,0xEF,0xB3,0x39,0x2F,0x30,0xF4,0x32,0x7C,0x0C, | ||
| 1491 | 0xA3,0xF3,0x1F,0xC3,0x83,0xC4,0x22,0xAA,0x8C,0x16, | ||
| 1492 | |||
| 1493 | 0x57,0x92,0x70,0x98,0xFA,0x93,0x2E,0x7C,0x0A,0x96, /* x */ | ||
| 1494 | 0xD3,0xFD,0x5B,0x70,0x6E,0xF7,0xE5,0xF5,0xC1,0x56, | ||
| 1495 | 0xE1,0x6B,0x7E,0x7C,0x86,0x03,0x85,0x52,0xE9,0x1D, | ||
| 1496 | |||
| 1497 | 0x61,0xD8,0xEE,0x50,0x77,0xC3,0x3F,0xEC,0xF6,0xF1, /* y */ | ||
| 1498 | 0xA1,0x6B,0x26,0x8D,0xE4,0x69,0xC3,0xC7,0x74,0x4E, | ||
| 1499 | 0xA9,0xA9,0x71,0x64,0x9F,0xC7,0xA9,0x61,0x63,0x05, | ||
| 1500 | |||
| 1501 | 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* order */ | ||
| 1502 | 0x00,0x00,0x00,0x00,0x00,0x0F,0x4D,0x42,0xFF,0xE1, | ||
| 1503 | 0x49,0x2A,0x49,0x93,0xF1,0xCA,0xD6,0x66,0xE4,0x47 } | ||
| 865 | }; | 1504 | }; |
| 866 | 1505 | ||
| 867 | static const unsigned char _EC_X9_62_CHAR2_239V2_SEED[] = { | 1506 | static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } |
| 868 | 0x2A,0xA6,0x98,0x2F,0xDF,0xA4,0xD6,0x96,0xE6,0x76, | 1507 | _EC_X9_62_CHAR2_239V2 = { |
| 869 | 0x87,0x56,0x15,0x17,0x5D,0x26,0x67,0x27,0x27,0x7D}; | 1508 | { NID_X9_62_characteristic_two_field,20,30,6 }, |
| 870 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_239V2 = { | 1509 | { 0x2A,0xA6,0x98,0x2F,0xDF,0xA4,0xD6,0x96,0xE6,0x76, /* seed */ |
| 871 | NID_X9_62_characteristic_two_field, | 1510 | 0x87,0x56,0x15,0x17,0x5D,0x26,0x67,0x27,0x27,0x7D, |
| 872 | "800000000000000000000000000000000000000000000000001000000001", | 1511 | |
| 873 | "4230017757A767FAE42398569B746325D45313AF0766266479B75654E65F", | 1512 | 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 874 | "5037EA654196CFF0CD82B2C14A2FCF2E3FF8775285B545722F03EACDB74B", | 1513 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 875 | "28F9D04E900069C8DC47A08534FE76D2B900B7D7EF31F5709F200C4CA205", | 1514 | 0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x01, |
| 876 | "5667334C45AFF3B5A03BAD9DD75E2C71A99362567D5453F7FA6E227EC833", | 1515 | |
| 877 | "1555555555555555555555555555553C6F2885259C31E3FCDF154624522D", 6, | 1516 | 0x42,0x30,0x01,0x77,0x57,0xA7,0x67,0xFA,0xE4,0x23, /* a */ |
| 878 | _EC_X9_62_CHAR2_239V2_SEED, 20, | 1517 | 0x98,0x56,0x9B,0x74,0x63,0x25,0xD4,0x53,0x13,0xAF, |
| 879 | "X9.62 curve over a 239 bit binary field" | 1518 | 0x07,0x66,0x26,0x64,0x79,0xB7,0x56,0x54,0xE6,0x5F, |
| 1519 | |||
| 1520 | 0x50,0x37,0xEA,0x65,0x41,0x96,0xCF,0xF0,0xCD,0x82, /* b */ | ||
| 1521 | 0xB2,0xC1,0x4A,0x2F,0xCF,0x2E,0x3F,0xF8,0x77,0x52, | ||
| 1522 | 0x85,0xB5,0x45,0x72,0x2F,0x03,0xEA,0xCD,0xB7,0x4B, | ||
| 1523 | |||
| 1524 | 0x28,0xF9,0xD0,0x4E,0x90,0x00,0x69,0xC8,0xDC,0x47, /* x */ | ||
| 1525 | 0xA0,0x85,0x34,0xFE,0x76,0xD2,0xB9,0x00,0xB7,0xD7, | ||
| 1526 | 0xEF,0x31,0xF5,0x70,0x9F,0x20,0x0C,0x4C,0xA2,0x05, | ||
| 1527 | |||
| 1528 | 0x56,0x67,0x33,0x4C,0x45,0xAF,0xF3,0xB5,0xA0,0x3B, /* y */ | ||
| 1529 | 0xAD,0x9D,0xD7,0x5E,0x2C,0x71,0xA9,0x93,0x62,0x56, | ||
| 1530 | 0x7D,0x54,0x53,0xF7,0xFA,0x6E,0x22,0x7E,0xC8,0x33, | ||
| 1531 | |||
| 1532 | 0x15,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55, /* order */ | ||
| 1533 | 0x55,0x55,0x55,0x55,0x55,0x3C,0x6F,0x28,0x85,0x25, | ||
| 1534 | 0x9C,0x31,0xE3,0xFC,0xDF,0x15,0x46,0x24,0x52,0x2D } | ||
| 880 | }; | 1535 | }; |
| 881 | 1536 | ||
| 882 | static const unsigned char _EC_X9_62_CHAR2_239V3_SEED[] = { | 1537 | static const struct { EC_CURVE_DATA h; unsigned char data[20+30*6]; } |
| 883 | 0x9E,0x07,0x6F,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61, | 1538 | _EC_X9_62_CHAR2_239V3 = { |
| 884 | 0x51,0x75,0xE1,0x1E,0x9F,0xDD,0x77,0xF9,0x20,0x41}; | 1539 | { NID_X9_62_characteristic_two_field,20,30,0xA }, |
| 885 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_239V3 = { | 1540 | { 0x9E,0x07,0x6F,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61, /* seed */ |
| 886 | NID_X9_62_characteristic_two_field, | 1541 | 0x51,0x75,0xE1,0x1E,0x9F,0xDD,0x77,0xF9,0x20,0x41, |
| 887 | "800000000000000000000000000000000000000000000000001000000001", | 1542 | |
| 888 | "01238774666A67766D6676F778E676B66999176666E687666D8766C66A9F", | 1543 | 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 889 | "6A941977BA9F6A435199ACFC51067ED587F519C5ECB541B8E44111DE1D40", | 1544 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 890 | "70F6E9D04D289C4E89913CE3530BFDE903977D42B146D539BF1BDE4E9C92", | 1545 | 0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x01, |
| 891 | "2E5A0EAF6E5E1305B9004DCE5C0ED7FE59A35608F33837C816D80B79F461", | 1546 | |
| 892 | "0CCCCCCCCCCCCCCCCCCCCCCCCCCCCCAC4912D2D9DF903EF9888B8A0E4CFF", 0xA, | 1547 | 0x01,0x23,0x87,0x74,0x66,0x6A,0x67,0x76,0x6D,0x66, /* a */ |
| 893 | _EC_X9_62_CHAR2_239V3_SEED, 20, | 1548 | 0x76,0xF7,0x78,0xE6,0x76,0xB6,0x69,0x99,0x17,0x66, |
| 894 | "X9.62 curve over a 239 bit binary field" | 1549 | 0x66,0xE6,0x87,0x66,0x6D,0x87,0x66,0xC6,0x6A,0x9F, |
| 1550 | |||
| 1551 | 0x6A,0x94,0x19,0x77,0xBA,0x9F,0x6A,0x43,0x51,0x99, /* b */ | ||
| 1552 | 0xAC,0xFC,0x51,0x06,0x7E,0xD5,0x87,0xF5,0x19,0xC5, | ||
| 1553 | 0xEC,0xB5,0x41,0xB8,0xE4,0x41,0x11,0xDE,0x1D,0x40, | ||
| 1554 | |||
| 1555 | 0x70,0xF6,0xE9,0xD0,0x4D,0x28,0x9C,0x4E,0x89,0x91, /* x */ | ||
| 1556 | 0x3C,0xE3,0x53,0x0B,0xFD,0xE9,0x03,0x97,0x7D,0x42, | ||
| 1557 | 0xB1,0x46,0xD5,0x39,0xBF,0x1B,0xDE,0x4E,0x9C,0x92, | ||
| 1558 | |||
| 1559 | 0x2E,0x5A,0x0E,0xAF,0x6E,0x5E,0x13,0x05,0xB9,0x00, /* y */ | ||
| 1560 | 0x4D,0xCE,0x5C,0x0E,0xD7,0xFE,0x59,0xA3,0x56,0x08, | ||
| 1561 | 0xF3,0x38,0x37,0xC8,0x16,0xD8,0x0B,0x79,0xF4,0x61, | ||
| 1562 | |||
| 1563 | 0x0C,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC, /* order */ | ||
| 1564 | 0xCC,0xCC,0xCC,0xCC,0xCC,0xAC,0x49,0x12,0xD2,0xD9, | ||
| 1565 | 0xDF,0x90,0x3E,0xF9,0x88,0x8B,0x8A,0x0E,0x4C,0xFF } | ||
| 895 | }; | 1566 | }; |
| 896 | 1567 | ||
| 897 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_272W1 = { | 1568 | static const struct { EC_CURVE_DATA h; unsigned char data[0+35*6]; } |
| 898 | NID_X9_62_characteristic_two_field, | 1569 | _EC_X9_62_CHAR2_272W1 = { |
| 899 | "010000000000000000000000000000000000000000000000000000010000000000000" | 1570 | { NID_X9_62_characteristic_two_field,0,35,0xFF06 }, |
| 900 | "B", | 1571 | { /* no seed */ |
| 901 | "91A091F03B5FBA4AB2CCF49C4EDD220FB028712D42BE752B2C40094DBACDB586FB20", | 1572 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 902 | "7167EFC92BB2E3CE7C8AAAFF34E12A9C557003D7C73A6FAF003F99F6CC8482E540F7", | 1573 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 903 | "6108BABB2CEEBCF787058A056CBE0CFE622D7723A289E08A07AE13EF0D10D171DD8D", | 1574 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, |
| 904 | "10C7695716851EEF6BA7F6872E6142FBD241B830FF5EFCACECCAB05E02005DDE9D23", | 1575 | 0x00,0x00,0x00,0x00,0x0B, |
| 905 | "000100FAF51354E0E39E4892DF6E319C72C8161603FA45AA7B998A167B8F1E629521", | 1576 | 0x00,0x91,0xA0,0x91,0xF0,0x3B,0x5F,0xBA,0x4A,0xB2, /* a */ |
| 906 | 0xFF06, | 1577 | 0xCC,0xF4,0x9C,0x4E,0xDD,0x22,0x0F,0xB0,0x28,0x71, |
| 907 | NULL, 0, | 1578 | 0x2D,0x42,0xBE,0x75,0x2B,0x2C,0x40,0x09,0x4D,0xBA, |
| 908 | "X9.62 curve over a 272 bit binary field" | 1579 | 0xCD,0xB5,0x86,0xFB,0x20, |
| 1580 | 0x00,0x71,0x67,0xEF,0xC9,0x2B,0xB2,0xE3,0xCE,0x7C, /* b */ | ||
| 1581 | 0x8A,0xAA,0xFF,0x34,0xE1,0x2A,0x9C,0x55,0x70,0x03, | ||
| 1582 | 0xD7,0xC7,0x3A,0x6F,0xAF,0x00,0x3F,0x99,0xF6,0xCC, | ||
| 1583 | 0x84,0x82,0xE5,0x40,0xF7, | ||
| 1584 | 0x00,0x61,0x08,0xBA,0xBB,0x2C,0xEE,0xBC,0xF7,0x87, /* x */ | ||
| 1585 | 0x05,0x8A,0x05,0x6C,0xBE,0x0C,0xFE,0x62,0x2D,0x77, | ||
| 1586 | 0x23,0xA2,0x89,0xE0,0x8A,0x07,0xAE,0x13,0xEF,0x0D, | ||
| 1587 | 0x10,0xD1,0x71,0xDD,0x8D, | ||
| 1588 | 0x00,0x10,0xC7,0x69,0x57,0x16,0x85,0x1E,0xEF,0x6B, /* y */ | ||
| 1589 | 0xA7,0xF6,0x87,0x2E,0x61,0x42,0xFB,0xD2,0x41,0xB8, | ||
| 1590 | 0x30,0xFF,0x5E,0xFC,0xAC,0xEC,0xCA,0xB0,0x5E,0x02, | ||
| 1591 | 0x00,0x5D,0xDE,0x9D,0x23, | ||
| 1592 | 0x00,0x00,0x01,0x00,0xFA,0xF5,0x13,0x54,0xE0,0xE3, /* order */ | ||
| 1593 | 0x9E,0x48,0x92,0xDF,0x6E,0x31,0x9C,0x72,0xC8,0x16, | ||
| 1594 | 0x16,0x03,0xFA,0x45,0xAA,0x7B,0x99,0x8A,0x16,0x7B, | ||
| 1595 | 0x8F,0x1E,0x62,0x95,0x21 } | ||
| 909 | }; | 1596 | }; |
| 910 | 1597 | ||
| 911 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_304W1 = { | 1598 | static const struct { EC_CURVE_DATA h; unsigned char data[0+39*6]; } |
| 912 | NID_X9_62_characteristic_two_field, | 1599 | _EC_X9_62_CHAR2_304W1 = { |
| 913 | "010000000000000000000000000000000000000000000000000000000000000000000" | 1600 | { NID_X9_62_characteristic_two_field,0,39,0xFE2E }, |
| 914 | "000000807", | 1601 | { /* no seed */ |
| 915 | "FD0D693149A118F651E6DCE6802085377E5F882D1B510B44160074C1288078365A039" | 1602 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 916 | "6C8E681", | 1603 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 917 | "BDDB97E555A50A908E43B01C798EA5DAA6788F1EA2794EFCF57166B8C14039601E558" | 1604 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 918 | "27340BE", | 1605 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x07, |
| 919 | "197B07845E9BE2D96ADB0F5F3C7F2CFFBD7A3EB8B6FEC35C7FD67F26DDF6285A644F7" | 1606 | 0x00,0xFD,0x0D,0x69,0x31,0x49,0xA1,0x18,0xF6,0x51, /* a */ |
| 920 | "40A2614", | 1607 | 0xE6,0xDC,0xE6,0x80,0x20,0x85,0x37,0x7E,0x5F,0x88, |
| 921 | "E19FBEB76E0DA171517ECF401B50289BF014103288527A9B416A105E80260B549FDC1" | 1608 | 0x2D,0x1B,0x51,0x0B,0x44,0x16,0x00,0x74,0xC1,0x28, |
| 922 | "B92C03B", | 1609 | 0x80,0x78,0x36,0x5A,0x03,0x96,0xC8,0xE6,0x81, |
| 923 | "000101D556572AABAC800101D556572AABAC8001022D5C91DD173F8FB561DA6899164" | 1610 | 0x00,0xBD,0xDB,0x97,0xE5,0x55,0xA5,0x0A,0x90,0x8E, /* b */ |
| 924 | "443051D", 0xFE2E, | 1611 | 0x43,0xB0,0x1C,0x79,0x8E,0xA5,0xDA,0xA6,0x78,0x8F, |
| 925 | NULL, 0, | 1612 | 0x1E,0xA2,0x79,0x4E,0xFC,0xF5,0x71,0x66,0xB8,0xC1, |
| 926 | "X9.62 curve over a 304 bit binary field" | 1613 | 0x40,0x39,0x60,0x1E,0x55,0x82,0x73,0x40,0xBE, |
| 1614 | 0x00,0x19,0x7B,0x07,0x84,0x5E,0x9B,0xE2,0xD9,0x6A, /* x */ | ||
| 1615 | 0xDB,0x0F,0x5F,0x3C,0x7F,0x2C,0xFF,0xBD,0x7A,0x3E, | ||
| 1616 | 0xB8,0xB6,0xFE,0xC3,0x5C,0x7F,0xD6,0x7F,0x26,0xDD, | ||
| 1617 | 0xF6,0x28,0x5A,0x64,0x4F,0x74,0x0A,0x26,0x14, | ||
| 1618 | 0x00,0xE1,0x9F,0xBE,0xB7,0x6E,0x0D,0xA1,0x71,0x51, /* y */ | ||
| 1619 | 0x7E,0xCF,0x40,0x1B,0x50,0x28,0x9B,0xF0,0x14,0x10, | ||
| 1620 | 0x32,0x88,0x52,0x7A,0x9B,0x41,0x6A,0x10,0x5E,0x80, | ||
| 1621 | 0x26,0x0B,0x54,0x9F,0xDC,0x1B,0x92,0xC0,0x3B, | ||
| 1622 | 0x00,0x00,0x01,0x01,0xD5,0x56,0x57,0x2A,0xAB,0xAC, /* order */ | ||
| 1623 | 0x80,0x01,0x01,0xD5,0x56,0x57,0x2A,0xAB,0xAC,0x80, | ||
| 1624 | 0x01,0x02,0x2D,0x5C,0x91,0xDD,0x17,0x3F,0x8F,0xB5, | ||
| 1625 | 0x61,0xDA,0x68,0x99,0x16,0x44,0x43,0x05,0x1D } | ||
| 927 | }; | 1626 | }; |
| 928 | 1627 | ||
| 929 | static const unsigned char _EC_X9_62_CHAR2_359V1_SEED[] = { | 1628 | static const struct { EC_CURVE_DATA h; unsigned char data[20+45*6]; } |
| 930 | 0x2B,0x35,0x49,0x20,0xB7,0x24,0xD6,0x96,0xE6,0x76, | 1629 | _EC_X9_62_CHAR2_359V1 = { |
| 931 | 0x87,0x56,0x15,0x17,0x58,0x5B,0xA1,0x33,0x2D,0xC6}; | 1630 | { NID_X9_62_characteristic_two_field,20,45,0x4C }, |
| 932 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_359V1 = { | 1631 | { 0x2B,0x35,0x49,0x20,0xB7,0x24,0xD6,0x96,0xE6,0x76, /* seed */ |
| 933 | NID_X9_62_characteristic_two_field, | 1632 | 0x87,0x56,0x15,0x17,0x58,0x5B,0xA1,0x33,0x2D,0xC6, |
| 934 | "800000000000000000000000000000000000000000000000000000000000000000000" | 1633 | |
| 935 | "000100000000000000001", | 1634 | 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 936 | "5667676A654B20754F356EA92017D946567C46675556F19556A04616B567D223A5E05" | 1635 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 937 | "656FB549016A96656A557", | 1636 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 938 | "2472E2D0197C49363F1FE7F5B6DB075D52B6947D135D8CA445805D39BC34562608968" | 1637 | 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00, |
| 939 | "7742B6329E70680231988", | 1638 | 0x00,0x00,0x00,0x00,0x01, |
| 940 | "3C258EF3047767E7EDE0F1FDAA79DAEE3841366A132E163ACED4ED2401DF9C6BDCDE9" | 1639 | 0x56,0x67,0x67,0x6A,0x65,0x4B,0x20,0x75,0x4F,0x35, /* a */ |
| 941 | "8E8E707C07A2239B1B097", | 1640 | 0x6E,0xA9,0x20,0x17,0xD9,0x46,0x56,0x7C,0x46,0x67, |
| 942 | "53D7E08529547048121E9C95F3791DD804963948F34FAE7BF44EA82365DC7868FE57E" | 1641 | 0x55,0x56,0xF1,0x95,0x56,0xA0,0x46,0x16,0xB5,0x67, |
| 943 | "4AE2DE211305A407104BD", | 1642 | 0xD2,0x23,0xA5,0xE0,0x56,0x56,0xFB,0x54,0x90,0x16, |
| 944 | "01AF286BCA1AF286BCA1AF286BCA1AF286BCA1AF286BC9FB8F6B85C556892C20A7EB9" | 1643 | 0xA9,0x66,0x56,0xA5,0x57, |
| 945 | "64FE7719E74F490758D3B", 0x4C, | 1644 | 0x24,0x72,0xE2,0xD0,0x19,0x7C,0x49,0x36,0x3F,0x1F, /* b */ |
| 946 | _EC_X9_62_CHAR2_359V1_SEED, 20, | 1645 | 0xE7,0xF5,0xB6,0xDB,0x07,0x5D,0x52,0xB6,0x94,0x7D, |
| 947 | "X9.62 curve over a 359 bit binary field" | 1646 | 0x13,0x5D,0x8C,0xA4,0x45,0x80,0x5D,0x39,0xBC,0x34, |
| 1647 | 0x56,0x26,0x08,0x96,0x87,0x74,0x2B,0x63,0x29,0xE7, | ||
| 1648 | 0x06,0x80,0x23,0x19,0x88, | ||
| 1649 | 0x3C,0x25,0x8E,0xF3,0x04,0x77,0x67,0xE7,0xED,0xE0, /* x */ | ||
| 1650 | 0xF1,0xFD,0xAA,0x79,0xDA,0xEE,0x38,0x41,0x36,0x6A, | ||
| 1651 | 0x13,0x2E,0x16,0x3A,0xCE,0xD4,0xED,0x24,0x01,0xDF, | ||
| 1652 | 0x9C,0x6B,0xDC,0xDE,0x98,0xE8,0xE7,0x07,0xC0,0x7A, | ||
| 1653 | 0x22,0x39,0xB1,0xB0,0x97, | ||
| 1654 | 0x53,0xD7,0xE0,0x85,0x29,0x54,0x70,0x48,0x12,0x1E, /* y */ | ||
| 1655 | 0x9C,0x95,0xF3,0x79,0x1D,0xD8,0x04,0x96,0x39,0x48, | ||
| 1656 | 0xF3,0x4F,0xAE,0x7B,0xF4,0x4E,0xA8,0x23,0x65,0xDC, | ||
| 1657 | 0x78,0x68,0xFE,0x57,0xE4,0xAE,0x2D,0xE2,0x11,0x30, | ||
| 1658 | 0x5A,0x40,0x71,0x04,0xBD, | ||
| 1659 | 0x01,0xAF,0x28,0x6B,0xCA,0x1A,0xF2,0x86,0xBC,0xA1, /* order */ | ||
| 1660 | 0xAF,0x28,0x6B,0xCA,0x1A,0xF2,0x86,0xBC,0xA1,0xAF, | ||
| 1661 | 0x28,0x6B,0xC9,0xFB,0x8F,0x6B,0x85,0xC5,0x56,0x89, | ||
| 1662 | 0x2C,0x20,0xA7,0xEB,0x96,0x4F,0xE7,0x71,0x9E,0x74, | ||
| 1663 | 0xF4,0x90,0x75,0x8D,0x3B } | ||
| 948 | }; | 1664 | }; |
| 949 | 1665 | ||
| 950 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_368W1 = { | 1666 | static const struct { EC_CURVE_DATA h; unsigned char data[0+47*6]; } |
| 951 | NID_X9_62_characteristic_two_field, | 1667 | _EC_X9_62_CHAR2_368W1 = { |
| 952 | "010000000000000000000000000000000000000000000000000000000000000000000" | 1668 | { NID_X9_62_characteristic_two_field,0,47,0xFF70 }, |
| 953 | "0002000000000000000000007", | 1669 | { /* no seed */ |
| 954 | "E0D2EE25095206F5E2A4F9ED229F1F256E79A0E2B455970D8D0D865BD94778C576D62" | 1670 | 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 955 | "F0AB7519CCD2A1A906AE30D", | 1671 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 956 | "FC1217D4320A90452C760A58EDCD30C8DD069B3C34453837A34ED50CB54917E1C2112" | 1672 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 957 | "D84D164F444F8F74786046A", | 1673 | 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, |
| 958 | "1085E2755381DCCCE3C1557AFA10C2F0C0C2825646C5B34A394CBCFA8BC16B22E7E78" | 1674 | 0x00,0x00,0x00,0x00,0x00,0x00,0x07, |
| 959 | "9E927BE216F02E1FB136A5F", | 1675 | 0x00,0xE0,0xD2,0xEE,0x25,0x09,0x52,0x06,0xF5,0xE2, /* a */ |
| 960 | "7B3EB1BDDCBA62D5D8B2059B525797FC73822C59059C623A45FF3843CEE8F87CD1855" | 1676 | 0xA4,0xF9,0xED,0x22,0x9F,0x1F,0x25,0x6E,0x79,0xA0, |
| 961 | "ADAA81E2A0750B80FDA2310", | 1677 | 0xE2,0xB4,0x55,0x97,0x0D,0x8D,0x0D,0x86,0x5B,0xD9, |
| 962 | "00010090512DA9AF72B08349D98A5DD4C7B0532ECA51CE03E2D10F3B7AC579BD87E90" | 1678 | 0x47,0x78,0xC5,0x76,0xD6,0x2F,0x0A,0xB7,0x51,0x9C, |
| 963 | "9AE40A6F131E9CFCE5BD967", 0xFF70, | 1679 | 0xCD,0x2A,0x1A,0x90,0x6A,0xE3,0x0D, |
| 964 | NULL, 0, | 1680 | 0x00,0xFC,0x12,0x17,0xD4,0x32,0x0A,0x90,0x45,0x2C, /* b */ |
| 965 | "X9.62 curve over a 368 bit binary field" | 1681 | 0x76,0x0A,0x58,0xED,0xCD,0x30,0xC8,0xDD,0x06,0x9B, |
| 1682 | 0x3C,0x34,0x45,0x38,0x37,0xA3,0x4E,0xD5,0x0C,0xB5, | ||
| 1683 | 0x49,0x17,0xE1,0xC2,0x11,0x2D,0x84,0xD1,0x64,0xF4, | ||
| 1684 | 0x44,0xF8,0xF7,0x47,0x86,0x04,0x6A, | ||
| 1685 | 0x00,0x10,0x85,0xE2,0x75,0x53,0x81,0xDC,0xCC,0xE3, /* x */ | ||
| 1686 | 0xC1,0x55,0x7A,0xFA,0x10,0xC2,0xF0,0xC0,0xC2,0x82, | ||
| 1687 | 0x56,0x46,0xC5,0xB3,0x4A,0x39,0x4C,0xBC,0xFA,0x8B, | ||
| 1688 | 0xC1,0x6B,0x22,0xE7,0xE7,0x89,0xE9,0x27,0xBE,0x21, | ||
| 1689 | 0x6F,0x02,0xE1,0xFB,0x13,0x6A,0x5F, | ||
| 1690 | 0x00,0x7B,0x3E,0xB1,0xBD,0xDC,0xBA,0x62,0xD5,0xD8, /* y */ | ||
| 1691 | 0xB2,0x05,0x9B,0x52,0x57,0x97,0xFC,0x73,0x82,0x2C, | ||
| 1692 | 0x59,0x05,0x9C,0x62,0x3A,0x45,0xFF,0x38,0x43,0xCE, | ||
| 1693 | 0xE8,0xF8,0x7C,0xD1,0x85,0x5A,0xDA,0xA8,0x1E,0x2A, | ||
| 1694 | 0x07,0x50,0xB8,0x0F,0xDA,0x23,0x10, | ||
| 1695 | 0x00,0x00,0x01,0x00,0x90,0x51,0x2D,0xA9,0xAF,0x72, /* order */ | ||
| 1696 | 0xB0,0x83,0x49,0xD9,0x8A,0x5D,0xD4,0xC7,0xB0,0x53, | ||
| 1697 | 0x2E,0xCA,0x51,0xCE,0x03,0xE2,0xD1,0x0F,0x3B,0x7A, | ||
| 1698 | 0xC5,0x79,0xBD,0x87,0xE9,0x09,0xAE,0x40,0xA6,0xF1, | ||
| 1699 | 0x31,0xE9,0xCF,0xCE,0x5B,0xD9,0x67 } | ||
| 966 | }; | 1700 | }; |
| 967 | 1701 | ||
| 968 | static const EC_CURVE_DATA _EC_X9_62_CHAR2_431R1 = { | 1702 | static const struct { EC_CURVE_DATA h; unsigned char data[0+54*6]; } |
| 969 | NID_X9_62_characteristic_two_field, | 1703 | _EC_X9_62_CHAR2_431R1 = { |
| 970 | "800000000000000000000000000000000000000000000000000000000000000000000" | 1704 | { NID_X9_62_characteristic_two_field,0,54,0x2760 }, |
| 971 | "000000001000000000000000000000000000001", | 1705 | { /* no seed */ |
| 972 | "1A827EF00DD6FC0E234CAF046C6A5D8A85395B236CC4AD2CF32A0CADBDC9DDF620B0E" | 1706 | 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 973 | "B9906D0957F6C6FEACD615468DF104DE296CD8F", | 1707 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 974 | "10D9B4A3D9047D8B154359ABFB1B7F5485B04CEB868237DDC9DEDA982A679A5A919B6" | 1708 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 975 | "26D4E50A8DD731B107A9962381FB5D807BF2618", | 1709 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00, |
| 976 | "120FC05D3C67A99DE161D2F4092622FECA701BE4F50F4758714E8A87BBF2A658EF8C2" | 1710 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 977 | "1E7C5EFE965361F6C2999C0C247B0DBD70CE6B7", | 1711 | 0x00,0x00,0x00,0x01, |
| 978 | "20D0AF8903A96F8D5FA2C255745D3C451B302C9346D9B7E485E7BCE41F6B591F3E8F6" | 1712 | 0x1A,0x82,0x7E,0xF0,0x0D,0xD6,0xFC,0x0E,0x23,0x4C, /* a */ |
| 979 | "ADDCBB0BC4C2F947A7DE1A89B625D6A598B3760", | 1713 | 0xAF,0x04,0x6C,0x6A,0x5D,0x8A,0x85,0x39,0x5B,0x23, |
| 980 | "0340340340340340340340340340340340340340340340340340340323C313FAB5058" | 1714 | 0x6C,0xC4,0xAD,0x2C,0xF3,0x2A,0x0C,0xAD,0xBD,0xC9, |
| 981 | "9703B5EC68D3587FEC60D161CC149C1AD4A91", 0x2760, | 1715 | 0xDD,0xF6,0x20,0xB0,0xEB,0x99,0x06,0xD0,0x95,0x7F, |
| 982 | NULL, 0, | 1716 | 0x6C,0x6F,0xEA,0xCD,0x61,0x54,0x68,0xDF,0x10,0x4D, |
| 983 | "X9.62 curve over a 431 bit binary field" | 1717 | 0xE2,0x96,0xCD,0x8F, |
| 1718 | 0x10,0xD9,0xB4,0xA3,0xD9,0x04,0x7D,0x8B,0x15,0x43, /* b */ | ||
| 1719 | 0x59,0xAB,0xFB,0x1B,0x7F,0x54,0x85,0xB0,0x4C,0xEB, | ||
| 1720 | 0x86,0x82,0x37,0xDD,0xC9,0xDE,0xDA,0x98,0x2A,0x67, | ||
| 1721 | 0x9A,0x5A,0x91,0x9B,0x62,0x6D,0x4E,0x50,0xA8,0xDD, | ||
| 1722 | 0x73,0x1B,0x10,0x7A,0x99,0x62,0x38,0x1F,0xB5,0xD8, | ||
| 1723 | 0x07,0xBF,0x26,0x18, | ||
| 1724 | 0x12,0x0F,0xC0,0x5D,0x3C,0x67,0xA9,0x9D,0xE1,0x61, /* x */ | ||
| 1725 | 0xD2,0xF4,0x09,0x26,0x22,0xFE,0xCA,0x70,0x1B,0xE4, | ||
| 1726 | 0xF5,0x0F,0x47,0x58,0x71,0x4E,0x8A,0x87,0xBB,0xF2, | ||
| 1727 | 0xA6,0x58,0xEF,0x8C,0x21,0xE7,0xC5,0xEF,0xE9,0x65, | ||
| 1728 | 0x36,0x1F,0x6C,0x29,0x99,0xC0,0xC2,0x47,0xB0,0xDB, | ||
| 1729 | 0xD7,0x0C,0xE6,0xB7, | ||
| 1730 | 0x20,0xD0,0xAF,0x89,0x03,0xA9,0x6F,0x8D,0x5F,0xA2, /* y */ | ||
| 1731 | 0xC2,0x55,0x74,0x5D,0x3C,0x45,0x1B,0x30,0x2C,0x93, | ||
| 1732 | 0x46,0xD9,0xB7,0xE4,0x85,0xE7,0xBC,0xE4,0x1F,0x6B, | ||
| 1733 | 0x59,0x1F,0x3E,0x8F,0x6A,0xDD,0xCB,0xB0,0xBC,0x4C, | ||
| 1734 | 0x2F,0x94,0x7A,0x7D,0xE1,0xA8,0x9B,0x62,0x5D,0x6A, | ||
| 1735 | 0x59,0x8B,0x37,0x60, | ||
| 1736 | 0x00,0x03,0x40,0x34,0x03,0x40,0x34,0x03,0x40,0x34, /* order */ | ||
| 1737 | 0x03,0x40,0x34,0x03,0x40,0x34,0x03,0x40,0x34,0x03, | ||
| 1738 | 0x40,0x34,0x03,0x40,0x34,0x03,0x40,0x34,0x03,0x23, | ||
| 1739 | 0xC3,0x13,0xFA,0xB5,0x05,0x89,0x70,0x3B,0x5E,0xC6, | ||
| 1740 | 0x8D,0x35,0x87,0xFE,0xC6,0x0D,0x16,0x1C,0xC1,0x49, | ||
| 1741 | 0xC1,0xAD,0x4A,0x91 } | ||
| 984 | }; | 1742 | }; |
| 985 | 1743 | ||
| 986 | static const EC_CURVE_DATA _EC_WTLS_1 = { | 1744 | static const struct { EC_CURVE_DATA h; unsigned char data[0+15*6]; } |
| 987 | NID_X9_62_characteristic_two_field, | 1745 | _EC_WTLS_1 = { |
| 988 | "020000000000000000000000000201", | 1746 | { NID_X9_62_characteristic_two_field,0,15,2 }, |
| 989 | "1", | 1747 | { /* no seed */ |
| 990 | "1", | 1748 | 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 991 | "01667979A40BA497E5D5C270780617", | 1749 | 0x00,0x00,0x00,0x02,0x01, |
| 992 | "00F44B4AF1ECC2630E08785CEBCC15", | 1750 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 993 | "00FFFFFFFFFFFFFFFDBF91AF6DEA73", 2, | 1751 | 0x00,0x00,0x00,0x00,0x01, |
| 994 | NULL, 0, | 1752 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ |
| 995 | "WTLS curve over a 113 bit binary field" | 1753 | 0x00,0x00,0x00,0x00,0x01, |
| 1754 | 0x01,0x66,0x79,0x79,0xA4,0x0B,0xA4,0x97,0xE5,0xD5, /* x */ | ||
| 1755 | 0xC2,0x70,0x78,0x06,0x17, | ||
| 1756 | 0x00,0xF4,0x4B,0x4A,0xF1,0xEC,0xC2,0x63,0x0E,0x08, /* y */ | ||
| 1757 | 0x78,0x5C,0xEB,0xCC,0x15, | ||
| 1758 | 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD,0xBF, /* order */ | ||
| 1759 | 0x91,0xAF,0x6D,0xEA,0x73 } | ||
| 996 | }; | 1760 | }; |
| 997 | 1761 | ||
| 998 | /* IPSec curves */ | 1762 | /* IPSec curves */ |
| @@ -1001,17 +1765,27 @@ static const EC_CURVE_DATA _EC_WTLS_1 = { | |||
| 1001 | * As the group order is not a prime this curve is not suitable | 1765 | * As the group order is not a prime this curve is not suitable |
| 1002 | * for ECDSA. | 1766 | * for ECDSA. |
| 1003 | */ | 1767 | */ |
| 1004 | static const EC_CURVE_DATA _EC_IPSEC_155_ID3 = { | 1768 | static const struct { EC_CURVE_DATA h; unsigned char data[0+20*6]; } |
| 1005 | NID_X9_62_characteristic_two_field, | 1769 | _EC_IPSEC_155_ID3 = { |
| 1006 | "0800000000000000000000004000000000000001", | 1770 | { NID_X9_62_characteristic_two_field,0,20,3 }, |
| 1007 | "0", | 1771 | { /* no seed */ |
| 1008 | "07338f", | 1772 | 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 1009 | "7b", | 1773 | 0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x01, |
| 1010 | "1c8", | 1774 | |
| 1011 | "2AAAAAAAAAAAAAAAAAAC7F3C7881BD0868FA86C",3, | 1775 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 1012 | NULL, 0, | 1776 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 1013 | "\n\tIPSec/IKE/Oakley curve #3 over a 155 bit binary field.\n" | 1777 | |
| 1014 | "\tNot suitable for ECDSA.\n\tQuestionable extension field!" | 1778 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ |
| 1779 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x33,0x8f, | ||
| 1780 | |||
| 1781 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* x */ | ||
| 1782 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7b, | ||
| 1783 | |||
| 1784 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* y */ | ||
| 1785 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xc8, | ||
| 1786 | |||
| 1787 | 0x02,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA, /* order */ | ||
| 1788 | 0xC7,0xF3,0xC7,0x88,0x1B,0xD0,0x86,0x8F,0xA8,0x6C } | ||
| 1015 | }; | 1789 | }; |
| 1016 | 1790 | ||
| 1017 | /* NOTE: The of curves over a extension field of non prime degree | 1791 | /* NOTE: The of curves over a extension field of non prime degree |
| @@ -1019,106 +1793,118 @@ static const EC_CURVE_DATA _EC_IPSEC_155_ID3 = { | |||
| 1019 | * As the group order is not a prime this curve is not suitable | 1793 | * As the group order is not a prime this curve is not suitable |
| 1020 | * for ECDSA. | 1794 | * for ECDSA. |
| 1021 | */ | 1795 | */ |
| 1022 | static const EC_CURVE_DATA _EC_IPSEC_185_ID4 = { | 1796 | static const struct { EC_CURVE_DATA h; unsigned char data[0+24*6]; } |
| 1023 | NID_X9_62_characteristic_two_field, | 1797 | _EC_IPSEC_185_ID4 = { |
| 1024 | "020000000000000000000000000000200000000000000001", | 1798 | { NID_X9_62_characteristic_two_field,0,24,2 }, |
| 1025 | "0", | 1799 | { /* no seed */ |
| 1026 | "1ee9", | 1800 | 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p */ |
| 1027 | "18", | 1801 | 0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00, |
| 1028 | "0d", | 1802 | 0x00,0x00,0x00,0x01, |
| 1029 | "FFFFFFFFFFFFFFFFFFFFFFEDF97C44DB9F2420BAFCA75E",2, | 1803 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* a */ |
| 1030 | NULL, 0, | 1804 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 1031 | "\n\tIPSec/IKE/Oakley curve #4 over a 185 bit binary field.\n" | 1805 | 0x00,0x00,0x00,0x00, |
| 1032 | "\tNot suitable for ECDSA.\n\tQuestionable extension field!" | 1806 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* b */ |
| 1807 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1808 | 0x00,0x00,0x1e,0xe9, | ||
| 1809 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* x */ | ||
| 1810 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1811 | 0x00,0x00,0x00,0x18, | ||
| 1812 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* y */ | ||
| 1813 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||
| 1814 | 0x00,0x00,0x00,0x0d, | ||
| 1815 | 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, /* order */ | ||
| 1816 | 0xFF,0xFF,0xED,0xF9,0x7C,0x44,0xDB,0x9F,0x24,0x20, | ||
| 1817 | 0xBA,0xFC,0xA7,0x5E } | ||
| 1033 | }; | 1818 | }; |
| 1034 | 1819 | ||
| 1035 | typedef struct _ec_list_element_st { | 1820 | typedef struct _ec_list_element_st { |
| 1036 | int nid; | 1821 | int nid; |
| 1037 | const EC_CURVE_DATA *data; | 1822 | const EC_CURVE_DATA *data; |
| 1823 | const char *comment; | ||
| 1038 | } ec_list_element; | 1824 | } ec_list_element; |
| 1039 | 1825 | ||
| 1040 | static const ec_list_element curve_list[] = { | 1826 | static const ec_list_element curve_list[] = { |
| 1041 | /* prime field curves */ | 1827 | /* prime field curves */ |
| 1042 | /* secg curves */ | 1828 | /* secg curves */ |
| 1043 | { NID_secp112r1, &_EC_SECG_PRIME_112R1}, | 1829 | { NID_secp112r1, &_EC_SECG_PRIME_112R1.h, "SECG/WTLS curve over a 112 bit prime field"}, |
| 1044 | { NID_secp112r2, &_EC_SECG_PRIME_112R2}, | 1830 | { NID_secp112r2, &_EC_SECG_PRIME_112R2.h, "SECG curve over a 112 bit prime field"}, |
| 1045 | { NID_secp128r1, &_EC_SECG_PRIME_128R1}, | 1831 | { NID_secp128r1, &_EC_SECG_PRIME_128R1.h, "SECG curve over a 128 bit prime field"}, |
| 1046 | { NID_secp128r2, &_EC_SECG_PRIME_128R2}, | 1832 | { NID_secp128r2, &_EC_SECG_PRIME_128R2.h, "SECG curve over a 128 bit prime field"}, |
| 1047 | { NID_secp160k1, &_EC_SECG_PRIME_160K1}, | 1833 | { NID_secp160k1, &_EC_SECG_PRIME_160K1.h, "SECG curve over a 160 bit prime field"}, |
| 1048 | { NID_secp160r1, &_EC_SECG_PRIME_160R1}, | 1834 | { NID_secp160r1, &_EC_SECG_PRIME_160R1.h, "SECG curve over a 160 bit prime field"}, |
| 1049 | { NID_secp160r2, &_EC_SECG_PRIME_160R2}, | 1835 | { NID_secp160r2, &_EC_SECG_PRIME_160R2.h, "SECG/WTLS curve over a 160 bit prime field"}, |
| 1050 | /* SECG secp192r1 is the same as X9.62 prime192v1 and hence omitted */ | 1836 | /* SECG secp192r1 is the same as X9.62 prime192v1 and hence omitted */ |
| 1051 | { NID_secp192k1, &_EC_SECG_PRIME_192K1}, | 1837 | { NID_secp192k1, &_EC_SECG_PRIME_192K1.h, "SECG curve over a 192 bit prime field"}, |
| 1052 | { NID_secp224k1, &_EC_SECG_PRIME_224K1}, | 1838 | { NID_secp224k1, &_EC_SECG_PRIME_224K1.h, "SECG curve over a 224 bit prime field"}, |
| 1053 | { NID_secp224r1, &_EC_NIST_PRIME_224}, | 1839 | { NID_secp224r1, &_EC_NIST_PRIME_224.h, "NIST/SECG curve over a 224 bit prime field"}, |
| 1054 | { NID_secp256k1, &_EC_SECG_PRIME_256K1}, | 1840 | { NID_secp256k1, &_EC_SECG_PRIME_256K1.h, "SECG curve over a 256 bit prime field"}, |
| 1055 | /* SECG secp256r1 is the same as X9.62 prime256v1 and hence omitted */ | 1841 | /* SECG secp256r1 is the same as X9.62 prime256v1 and hence omitted */ |
| 1056 | { NID_secp384r1, &_EC_NIST_PRIME_384}, | 1842 | { NID_secp384r1, &_EC_NIST_PRIME_384.h, "NIST/SECG curve over a 384 bit prime field"}, |
| 1057 | { NID_secp521r1, &_EC_NIST_PRIME_521}, | 1843 | { NID_secp521r1, &_EC_NIST_PRIME_521.h, "NIST/SECG curve over a 521 bit prime field"}, |
| 1058 | /* X9.62 curves */ | 1844 | /* X9.62 curves */ |
| 1059 | { NID_X9_62_prime192v1, &_EC_NIST_PRIME_192}, | 1845 | { NID_X9_62_prime192v1, &_EC_NIST_PRIME_192.h, "NIST/X9.62/SECG curve over a 192 bit prime field"}, |
| 1060 | { NID_X9_62_prime192v2, &_EC_X9_62_PRIME_192V2}, | 1846 | { NID_X9_62_prime192v2, &_EC_X9_62_PRIME_192V2.h, "X9.62 curve over a 192 bit prime field"}, |
| 1061 | { NID_X9_62_prime192v3, &_EC_X9_62_PRIME_192V3}, | 1847 | { NID_X9_62_prime192v3, &_EC_X9_62_PRIME_192V3.h, "X9.62 curve over a 192 bit prime field"}, |
| 1062 | { NID_X9_62_prime239v1, &_EC_X9_62_PRIME_239V1}, | 1848 | { NID_X9_62_prime239v1, &_EC_X9_62_PRIME_239V1.h, "X9.62 curve over a 239 bit prime field"}, |
| 1063 | { NID_X9_62_prime239v2, &_EC_X9_62_PRIME_239V2}, | 1849 | { NID_X9_62_prime239v2, &_EC_X9_62_PRIME_239V2.h, "X9.62 curve over a 239 bit prime field"}, |
| 1064 | { NID_X9_62_prime239v3, &_EC_X9_62_PRIME_239V3}, | 1850 | { NID_X9_62_prime239v3, &_EC_X9_62_PRIME_239V3.h, "X9.62 curve over a 239 bit prime field"}, |
| 1065 | { NID_X9_62_prime256v1, &_EC_X9_62_PRIME_256V1}, | 1851 | { NID_X9_62_prime256v1, &_EC_X9_62_PRIME_256V1.h, "X9.62/SECG curve over a 256 bit prime field"}, |
| 1066 | /* characteristic two field curves */ | 1852 | /* characteristic two field curves */ |
| 1067 | /* NIST/SECG curves */ | 1853 | /* NIST/SECG curves */ |
| 1068 | { NID_sect113r1, &_EC_SECG_CHAR2_113R1}, | 1854 | { NID_sect113r1, &_EC_SECG_CHAR2_113R1.h, "SECG curve over a 113 bit binary field"}, |
| 1069 | { NID_sect113r2, &_EC_SECG_CHAR2_113R2}, | 1855 | { NID_sect113r2, &_EC_SECG_CHAR2_113R2.h, "SECG curve over a 113 bit binary field"}, |
| 1070 | { NID_sect131r1, &_EC_SECG_CHAR2_131R1}, | 1856 | { NID_sect131r1, &_EC_SECG_CHAR2_131R1.h, "SECG/WTLS curve over a 131 bit binary field"}, |
| 1071 | { NID_sect131r2, &_EC_SECG_CHAR2_131R2}, | 1857 | { NID_sect131r2, &_EC_SECG_CHAR2_131R2.h, "SECG curve over a 131 bit binary field"}, |
| 1072 | { NID_sect163k1, &_EC_NIST_CHAR2_163K }, | 1858 | { NID_sect163k1, &_EC_NIST_CHAR2_163K.h, "NIST/SECG/WTLS curve over a 163 bit binary field" }, |
| 1073 | { NID_sect163r1, &_EC_SECG_CHAR2_163R1}, | 1859 | { NID_sect163r1, &_EC_SECG_CHAR2_163R1.h, "SECG curve over a 163 bit binary field"}, |
| 1074 | { NID_sect163r2, &_EC_NIST_CHAR2_163B }, | 1860 | { NID_sect163r2, &_EC_NIST_CHAR2_163B.h, "NIST/SECG curve over a 163 bit binary field" }, |
| 1075 | { NID_sect193r1, &_EC_SECG_CHAR2_193R1}, | 1861 | { NID_sect193r1, &_EC_SECG_CHAR2_193R1.h, "SECG curve over a 193 bit binary field"}, |
| 1076 | { NID_sect193r2, &_EC_SECG_CHAR2_193R2}, | 1862 | { NID_sect193r2, &_EC_SECG_CHAR2_193R2.h, "SECG curve over a 193 bit binary field"}, |
| 1077 | { NID_sect233k1, &_EC_NIST_CHAR2_233K }, | 1863 | { NID_sect233k1, &_EC_NIST_CHAR2_233K.h, "NIST/SECG/WTLS curve over a 233 bit binary field" }, |
| 1078 | { NID_sect233r1, &_EC_NIST_CHAR2_233B }, | 1864 | { NID_sect233r1, &_EC_NIST_CHAR2_233B.h, "NIST/SECG/WTLS curve over a 233 bit binary field" }, |
| 1079 | { NID_sect239k1, &_EC_SECG_CHAR2_239K1}, | 1865 | { NID_sect239k1, &_EC_SECG_CHAR2_239K1.h, "SECG curve over a 239 bit binary field"}, |
| 1080 | { NID_sect283k1, &_EC_NIST_CHAR2_283K }, | 1866 | { NID_sect283k1, &_EC_NIST_CHAR2_283K.h, "NIST/SECG curve over a 283 bit binary field" }, |
| 1081 | { NID_sect283r1, &_EC_NIST_CHAR2_283B }, | 1867 | { NID_sect283r1, &_EC_NIST_CHAR2_283B.h, "NIST/SECG curve over a 283 bit binary field" }, |
| 1082 | { NID_sect409k1, &_EC_NIST_CHAR2_409K }, | 1868 | { NID_sect409k1, &_EC_NIST_CHAR2_409K.h, "NIST/SECG curve over a 409 bit binary field" }, |
| 1083 | { NID_sect409r1, &_EC_NIST_CHAR2_409B }, | 1869 | { NID_sect409r1, &_EC_NIST_CHAR2_409B.h, "NIST/SECG curve over a 409 bit binary field" }, |
| 1084 | { NID_sect571k1, &_EC_NIST_CHAR2_571K }, | 1870 | { NID_sect571k1, &_EC_NIST_CHAR2_571K.h, "NIST/SECG curve over a 571 bit binary field" }, |
| 1085 | { NID_sect571r1, &_EC_NIST_CHAR2_571B }, | 1871 | { NID_sect571r1, &_EC_NIST_CHAR2_571B.h, "NIST/SECG curve over a 571 bit binary field" }, |
| 1086 | /* X9.62 curves */ | 1872 | /* X9.62 curves */ |
| 1087 | { NID_X9_62_c2pnb163v1, &_EC_X9_62_CHAR2_163V1}, | 1873 | { NID_X9_62_c2pnb163v1, &_EC_X9_62_CHAR2_163V1.h, "X9.62 curve over a 163 bit binary field"}, |
| 1088 | { NID_X9_62_c2pnb163v2, &_EC_X9_62_CHAR2_163V2}, | 1874 | { NID_X9_62_c2pnb163v2, &_EC_X9_62_CHAR2_163V2.h, "X9.62 curve over a 163 bit binary field"}, |
| 1089 | { NID_X9_62_c2pnb163v3, &_EC_X9_62_CHAR2_163V3}, | 1875 | { NID_X9_62_c2pnb163v3, &_EC_X9_62_CHAR2_163V3.h, "X9.62 curve over a 163 bit binary field"}, |
| 1090 | { NID_X9_62_c2pnb176v1, &_EC_X9_62_CHAR2_176V1}, | 1876 | { NID_X9_62_c2pnb176v1, &_EC_X9_62_CHAR2_176V1.h, "X9.62 curve over a 176 bit binary field"}, |
| 1091 | { NID_X9_62_c2tnb191v1, &_EC_X9_62_CHAR2_191V1}, | 1877 | { NID_X9_62_c2tnb191v1, &_EC_X9_62_CHAR2_191V1.h, "X9.62 curve over a 191 bit binary field"}, |
| 1092 | { NID_X9_62_c2tnb191v2, &_EC_X9_62_CHAR2_191V2}, | 1878 | { NID_X9_62_c2tnb191v2, &_EC_X9_62_CHAR2_191V2.h, "X9.62 curve over a 191 bit binary field"}, |
| 1093 | { NID_X9_62_c2tnb191v3, &_EC_X9_62_CHAR2_191V3}, | 1879 | { NID_X9_62_c2tnb191v3, &_EC_X9_62_CHAR2_191V3.h, "X9.62 curve over a 191 bit binary field"}, |
| 1094 | { NID_X9_62_c2pnb208w1, &_EC_X9_62_CHAR2_208W1}, | 1880 | { NID_X9_62_c2pnb208w1, &_EC_X9_62_CHAR2_208W1.h, "X9.62 curve over a 208 bit binary field"}, |
| 1095 | { NID_X9_62_c2tnb239v1, &_EC_X9_62_CHAR2_239V1}, | 1881 | { NID_X9_62_c2tnb239v1, &_EC_X9_62_CHAR2_239V1.h, "X9.62 curve over a 239 bit binary field"}, |
| 1096 | { NID_X9_62_c2tnb239v2, &_EC_X9_62_CHAR2_239V2}, | 1882 | { NID_X9_62_c2tnb239v2, &_EC_X9_62_CHAR2_239V2.h, "X9.62 curve over a 239 bit binary field"}, |
| 1097 | { NID_X9_62_c2tnb239v3, &_EC_X9_62_CHAR2_239V3}, | 1883 | { NID_X9_62_c2tnb239v3, &_EC_X9_62_CHAR2_239V3.h, "X9.62 curve over a 239 bit binary field"}, |
| 1098 | { NID_X9_62_c2pnb272w1, &_EC_X9_62_CHAR2_272W1}, | 1884 | { NID_X9_62_c2pnb272w1, &_EC_X9_62_CHAR2_272W1.h, "X9.62 curve over a 272 bit binary field"}, |
| 1099 | { NID_X9_62_c2pnb304w1, &_EC_X9_62_CHAR2_304W1}, | 1885 | { NID_X9_62_c2pnb304w1, &_EC_X9_62_CHAR2_304W1.h, "X9.62 curve over a 304 bit binary field"}, |
| 1100 | { NID_X9_62_c2tnb359v1, &_EC_X9_62_CHAR2_359V1}, | 1886 | { NID_X9_62_c2tnb359v1, &_EC_X9_62_CHAR2_359V1.h, "X9.62 curve over a 359 bit binary field"}, |
| 1101 | { NID_X9_62_c2pnb368w1, &_EC_X9_62_CHAR2_368W1}, | 1887 | { NID_X9_62_c2pnb368w1, &_EC_X9_62_CHAR2_368W1.h, "X9.62 curve over a 368 bit binary field"}, |
| 1102 | { NID_X9_62_c2tnb431r1, &_EC_X9_62_CHAR2_431R1}, | 1888 | { NID_X9_62_c2tnb431r1, &_EC_X9_62_CHAR2_431R1.h, "X9.62 curve over a 431 bit binary field"}, |
| 1103 | /* the WAP/WTLS curves | 1889 | /* the WAP/WTLS curves |
| 1104 | * [unlike SECG, spec has its own OIDs for curves from X9.62] */ | 1890 | * [unlike SECG, spec has its own OIDs for curves from X9.62] */ |
| 1105 | { NID_wap_wsg_idm_ecid_wtls1, &_EC_WTLS_1}, | 1891 | { NID_wap_wsg_idm_ecid_wtls1, &_EC_WTLS_1.h, "WTLS curve over a 113 bit binary field"}, |
| 1106 | { NID_wap_wsg_idm_ecid_wtls3, &_EC_NIST_CHAR2_163K}, | 1892 | { NID_wap_wsg_idm_ecid_wtls3, &_EC_NIST_CHAR2_163K.h, "NIST/SECG/WTLS curve over a 163 bit binary field"}, |
| 1107 | { NID_wap_wsg_idm_ecid_wtls4, &_EC_SECG_CHAR2_113R1}, | 1893 | { NID_wap_wsg_idm_ecid_wtls4, &_EC_SECG_CHAR2_113R1.h, "SECG curve over a 113 bit binary field"}, |
| 1108 | { NID_wap_wsg_idm_ecid_wtls5, &_EC_X9_62_CHAR2_163V1}, | 1894 | { NID_wap_wsg_idm_ecid_wtls5, &_EC_X9_62_CHAR2_163V1.h, "X9.62 curve over a 163 bit binary field"}, |
| 1109 | { NID_wap_wsg_idm_ecid_wtls6, &_EC_SECG_PRIME_112R1}, | 1895 | { NID_wap_wsg_idm_ecid_wtls6, &_EC_SECG_PRIME_112R1.h, "SECG/WTLS curve over a 112 bit prime field"}, |
| 1110 | { NID_wap_wsg_idm_ecid_wtls7, &_EC_SECG_PRIME_160R2}, | 1896 | { NID_wap_wsg_idm_ecid_wtls7, &_EC_SECG_PRIME_160R2.h, "SECG/WTLS curve over a 160 bit prime field"}, |
| 1111 | { NID_wap_wsg_idm_ecid_wtls8, &_EC_WTLS_8}, | 1897 | { NID_wap_wsg_idm_ecid_wtls8, &_EC_WTLS_8.h, "WTLS curve over a 112 bit prime field"}, |
| 1112 | { NID_wap_wsg_idm_ecid_wtls9, &_EC_WTLS_9 }, | 1898 | { NID_wap_wsg_idm_ecid_wtls9, &_EC_WTLS_9.h, "WTLS curve over a 160 bit prime field" }, |
| 1113 | { NID_wap_wsg_idm_ecid_wtls10, &_EC_NIST_CHAR2_233K}, | 1899 | { NID_wap_wsg_idm_ecid_wtls10, &_EC_NIST_CHAR2_233K.h, "NIST/SECG/WTLS curve over a 233 bit binary field"}, |
| 1114 | { NID_wap_wsg_idm_ecid_wtls11, &_EC_NIST_CHAR2_233B}, | 1900 | { NID_wap_wsg_idm_ecid_wtls11, &_EC_NIST_CHAR2_233B.h, "NIST/SECG/WTLS curve over a 233 bit binary field"}, |
| 1115 | { NID_wap_wsg_idm_ecid_wtls12, &_EC_WTLS_12}, | 1901 | { NID_wap_wsg_idm_ecid_wtls12, &_EC_WTLS_12.h, "WTLS curvs over a 224 bit prime field"}, |
| 1116 | /* IPSec curves */ | 1902 | /* IPSec curves */ |
| 1117 | { NID_ipsec3, &_EC_IPSEC_155_ID3}, | 1903 | { NID_ipsec3, &_EC_IPSEC_155_ID3.h, "\n\tIPSec/IKE/Oakley curve #3 over a 155 bit binary field.\n""\tNot suitable for ECDSA.\n\tQuestionable extension field!"}, |
| 1118 | { NID_ipsec4, &_EC_IPSEC_185_ID4}, | 1904 | { NID_ipsec4, &_EC_IPSEC_185_ID4.h, "\n\tIPSec/IKE/Oakley curve #4 over a 185 bit binary field.\n""\tNot suitable for ECDSA.\n\tQuestionable extension field!"}, |
| 1119 | }; | 1905 | }; |
| 1120 | 1906 | ||
| 1121 | static size_t curve_list_length = sizeof(curve_list)/sizeof(ec_list_element); | 1907 | #define curve_list_length (sizeof(curve_list)/sizeof(ec_list_element)) |
| 1122 | 1908 | ||
| 1123 | static EC_GROUP *ec_group_new_from_data(const EC_CURVE_DATA *data) | 1909 | static EC_GROUP *ec_group_new_from_data(const EC_CURVE_DATA *data) |
| 1124 | { | 1910 | { |
| @@ -1127,22 +1913,23 @@ static EC_GROUP *ec_group_new_from_data(const EC_CURVE_DATA *data) | |||
| 1127 | BN_CTX *ctx=NULL; | 1913 | BN_CTX *ctx=NULL; |
| 1128 | BIGNUM *p=NULL, *a=NULL, *b=NULL, *x=NULL, *y=NULL, *order=NULL; | 1914 | BIGNUM *p=NULL, *a=NULL, *b=NULL, *x=NULL, *y=NULL, *order=NULL; |
| 1129 | int ok=0; | 1915 | int ok=0; |
| 1916 | int seed_len,param_len; | ||
| 1917 | const unsigned char *params; | ||
| 1130 | 1918 | ||
| 1131 | if ((ctx = BN_CTX_new()) == NULL) | 1919 | if ((ctx = BN_CTX_new()) == NULL) |
| 1132 | { | 1920 | { |
| 1133 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_MALLOC_FAILURE); | 1921 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_MALLOC_FAILURE); |
| 1134 | goto err; | 1922 | goto err; |
| 1135 | } | 1923 | } |
| 1136 | if ((p = BN_new()) == NULL || (a = BN_new()) == NULL || | 1924 | |
| 1137 | (b = BN_new()) == NULL || (x = BN_new()) == NULL || | 1925 | seed_len = data->seed_len; |
| 1138 | (y = BN_new()) == NULL || (order = BN_new()) == NULL) | 1926 | param_len = data->param_len; |
| 1139 | { | 1927 | params = (const unsigned char *)(data+1); /* skip header */ |
| 1140 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_MALLOC_FAILURE); | 1928 | params += seed_len; /* skip seed */ |
| 1141 | goto err; | 1929 | |
| 1142 | } | 1930 | if (!(p = BN_bin2bn(params+0*param_len, param_len, NULL)) |
| 1143 | 1931 | || !(a = BN_bin2bn(params+1*param_len, param_len, NULL)) | |
| 1144 | if (!BN_hex2bn(&p, data->p) || !BN_hex2bn(&a, data->a) | 1932 | || !(b = BN_bin2bn(params+2*param_len, param_len, NULL))) |
| 1145 | || !BN_hex2bn(&b, data->b)) | ||
| 1146 | { | 1933 | { |
| 1147 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); | 1934 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); |
| 1148 | goto err; | 1935 | goto err; |
| @@ -1156,8 +1943,8 @@ static EC_GROUP *ec_group_new_from_data(const EC_CURVE_DATA *data) | |||
| 1156 | goto err; | 1943 | goto err; |
| 1157 | } | 1944 | } |
| 1158 | } | 1945 | } |
| 1159 | else | 1946 | else /* field_type == NID_X9_62_characteristic_two_field */ |
| 1160 | { /* field_type == NID_X9_62_characteristic_two_field */ | 1947 | { |
| 1161 | if ((group = EC_GROUP_new_curve_GF2m(p, a, b, ctx)) == NULL) | 1948 | if ((group = EC_GROUP_new_curve_GF2m(p, a, b, ctx)) == NULL) |
| 1162 | { | 1949 | { |
| 1163 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); | 1950 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); |
| @@ -1171,7 +1958,8 @@ static EC_GROUP *ec_group_new_from_data(const EC_CURVE_DATA *data) | |||
| 1171 | goto err; | 1958 | goto err; |
| 1172 | } | 1959 | } |
| 1173 | 1960 | ||
| 1174 | if (!BN_hex2bn(&x, data->x) || !BN_hex2bn(&y, data->y)) | 1961 | if (!(x = BN_bin2bn(params+3*param_len, param_len, NULL)) |
| 1962 | || !(y = BN_bin2bn(params+4*param_len, param_len, NULL))) | ||
| 1175 | { | 1963 | { |
| 1176 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); | 1964 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); |
| 1177 | goto err; | 1965 | goto err; |
| @@ -1181,7 +1969,8 @@ static EC_GROUP *ec_group_new_from_data(const EC_CURVE_DATA *data) | |||
| 1181 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); | 1969 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); |
| 1182 | goto err; | 1970 | goto err; |
| 1183 | } | 1971 | } |
| 1184 | if (!BN_hex2bn(&order, data->order) || !BN_set_word(x, data->cofactor)) | 1972 | if (!(order = BN_bin2bn(params+5*param_len, param_len, NULL)) |
| 1973 | || !BN_set_word(x, (BN_ULONG)data->cofactor)) | ||
| 1185 | { | 1974 | { |
| 1186 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); | 1975 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); |
| 1187 | goto err; | 1976 | goto err; |
| @@ -1191,9 +1980,9 @@ static EC_GROUP *ec_group_new_from_data(const EC_CURVE_DATA *data) | |||
| 1191 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); | 1980 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); |
| 1192 | goto err; | 1981 | goto err; |
| 1193 | } | 1982 | } |
| 1194 | if (data->seed) | 1983 | if (seed_len) |
| 1195 | { | 1984 | { |
| 1196 | if (!EC_GROUP_set_seed(group, data->seed, data->seed_len)) | 1985 | if (!EC_GROUP_set_seed(group, params-seed_len, seed_len)) |
| 1197 | { | 1986 | { |
| 1198 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); | 1987 | ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); |
| 1199 | goto err; | 1988 | goto err; |
| @@ -1263,7 +2052,7 @@ size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems) | |||
| 1263 | for (i = 0; i < min; i++) | 2052 | for (i = 0; i < min; i++) |
| 1264 | { | 2053 | { |
| 1265 | r[i].nid = curve_list[i].nid; | 2054 | r[i].nid = curve_list[i].nid; |
| 1266 | r[i].comment = curve_list[i].data->comment; | 2055 | r[i].comment = curve_list[i].comment; |
| 1267 | } | 2056 | } |
| 1268 | 2057 | ||
| 1269 | return curve_list_length; | 2058 | return curve_list_length; |
diff --git a/src/lib/libcrypto/ec/ec_err.c b/src/lib/libcrypto/ec/ec_err.c index d04c895560..84b4833371 100644 --- a/src/lib/libcrypto/ec/ec_err.c +++ b/src/lib/libcrypto/ec/ec_err.c | |||
| @@ -74,6 +74,14 @@ static ERR_STRING_DATA EC_str_functs[]= | |||
| 74 | {ERR_FUNC(EC_F_D2I_ECPARAMETERS), "d2i_ECParameters"}, | 74 | {ERR_FUNC(EC_F_D2I_ECPARAMETERS), "d2i_ECParameters"}, |
| 75 | {ERR_FUNC(EC_F_D2I_ECPKPARAMETERS), "d2i_ECPKParameters"}, | 75 | {ERR_FUNC(EC_F_D2I_ECPKPARAMETERS), "d2i_ECPKParameters"}, |
| 76 | {ERR_FUNC(EC_F_D2I_ECPRIVATEKEY), "d2i_ECPrivateKey"}, | 76 | {ERR_FUNC(EC_F_D2I_ECPRIVATEKEY), "d2i_ECPrivateKey"}, |
| 77 | {ERR_FUNC(EC_F_DO_EC_KEY_PRINT), "DO_EC_KEY_PRINT"}, | ||
| 78 | {ERR_FUNC(EC_F_ECKEY_PARAM2TYPE), "ECKEY_PARAM2TYPE"}, | ||
| 79 | {ERR_FUNC(EC_F_ECKEY_PARAM_DECODE), "ECKEY_PARAM_DECODE"}, | ||
| 80 | {ERR_FUNC(EC_F_ECKEY_PRIV_DECODE), "ECKEY_PRIV_DECODE"}, | ||
| 81 | {ERR_FUNC(EC_F_ECKEY_PRIV_ENCODE), "ECKEY_PRIV_ENCODE"}, | ||
| 82 | {ERR_FUNC(EC_F_ECKEY_PUB_DECODE), "ECKEY_PUB_DECODE"}, | ||
| 83 | {ERR_FUNC(EC_F_ECKEY_PUB_ENCODE), "ECKEY_PUB_ENCODE"}, | ||
| 84 | {ERR_FUNC(EC_F_ECKEY_TYPE2PARAM), "ECKEY_TYPE2PARAM"}, | ||
| 77 | {ERR_FUNC(EC_F_ECPARAMETERS_PRINT), "ECParameters_print"}, | 85 | {ERR_FUNC(EC_F_ECPARAMETERS_PRINT), "ECParameters_print"}, |
| 78 | {ERR_FUNC(EC_F_ECPARAMETERS_PRINT_FP), "ECParameters_print_fp"}, | 86 | {ERR_FUNC(EC_F_ECPARAMETERS_PRINT_FP), "ECParameters_print_fp"}, |
| 79 | {ERR_FUNC(EC_F_ECPKPARAMETERS_PRINT), "ECPKParameters_print"}, | 87 | {ERR_FUNC(EC_F_ECPKPARAMETERS_PRINT), "ECPKParameters_print"}, |
| @@ -147,7 +155,6 @@ static ERR_STRING_DATA EC_str_functs[]= | |||
| 147 | {ERR_FUNC(EC_F_EC_KEY_PRINT), "EC_KEY_print"}, | 155 | {ERR_FUNC(EC_F_EC_KEY_PRINT), "EC_KEY_print"}, |
| 148 | {ERR_FUNC(EC_F_EC_KEY_PRINT_FP), "EC_KEY_print_fp"}, | 156 | {ERR_FUNC(EC_F_EC_KEY_PRINT_FP), "EC_KEY_print_fp"}, |
| 149 | {ERR_FUNC(EC_F_EC_POINTS_MAKE_AFFINE), "EC_POINTs_make_affine"}, | 157 | {ERR_FUNC(EC_F_EC_POINTS_MAKE_AFFINE), "EC_POINTs_make_affine"}, |
| 150 | {ERR_FUNC(EC_F_EC_POINTS_MUL), "EC_POINTs_mul"}, | ||
| 151 | {ERR_FUNC(EC_F_EC_POINT_ADD), "EC_POINT_add"}, | 158 | {ERR_FUNC(EC_F_EC_POINT_ADD), "EC_POINT_add"}, |
| 152 | {ERR_FUNC(EC_F_EC_POINT_CMP), "EC_POINT_cmp"}, | 159 | {ERR_FUNC(EC_F_EC_POINT_CMP), "EC_POINT_cmp"}, |
| 153 | {ERR_FUNC(EC_F_EC_POINT_COPY), "EC_POINT_copy"}, | 160 | {ERR_FUNC(EC_F_EC_POINT_COPY), "EC_POINT_copy"}, |
| @@ -178,6 +185,13 @@ static ERR_STRING_DATA EC_str_functs[]= | |||
| 178 | {ERR_FUNC(EC_F_I2D_ECPRIVATEKEY), "i2d_ECPrivateKey"}, | 185 | {ERR_FUNC(EC_F_I2D_ECPRIVATEKEY), "i2d_ECPrivateKey"}, |
| 179 | {ERR_FUNC(EC_F_I2O_ECPUBLICKEY), "i2o_ECPublicKey"}, | 186 | {ERR_FUNC(EC_F_I2O_ECPUBLICKEY), "i2o_ECPublicKey"}, |
| 180 | {ERR_FUNC(EC_F_O2I_ECPUBLICKEY), "o2i_ECPublicKey"}, | 187 | {ERR_FUNC(EC_F_O2I_ECPUBLICKEY), "o2i_ECPublicKey"}, |
| 188 | {ERR_FUNC(EC_F_OLD_EC_PRIV_DECODE), "OLD_EC_PRIV_DECODE"}, | ||
| 189 | {ERR_FUNC(EC_F_PKEY_EC_CTRL), "PKEY_EC_CTRL"}, | ||
| 190 | {ERR_FUNC(EC_F_PKEY_EC_CTRL_STR), "PKEY_EC_CTRL_STR"}, | ||
| 191 | {ERR_FUNC(EC_F_PKEY_EC_DERIVE), "PKEY_EC_DERIVE"}, | ||
| 192 | {ERR_FUNC(EC_F_PKEY_EC_KEYGEN), "PKEY_EC_KEYGEN"}, | ||
| 193 | {ERR_FUNC(EC_F_PKEY_EC_PARAMGEN), "PKEY_EC_PARAMGEN"}, | ||
| 194 | {ERR_FUNC(EC_F_PKEY_EC_SIGN), "PKEY_EC_SIGN"}, | ||
| 181 | {0,NULL} | 195 | {0,NULL} |
| 182 | }; | 196 | }; |
| 183 | 197 | ||
| @@ -187,6 +201,7 @@ static ERR_STRING_DATA EC_str_reasons[]= | |||
| 187 | {ERR_REASON(EC_R_ASN1_UNKNOWN_FIELD) ,"asn1 unknown field"}, | 201 | {ERR_REASON(EC_R_ASN1_UNKNOWN_FIELD) ,"asn1 unknown field"}, |
| 188 | {ERR_REASON(EC_R_BUFFER_TOO_SMALL) ,"buffer too small"}, | 202 | {ERR_REASON(EC_R_BUFFER_TOO_SMALL) ,"buffer too small"}, |
| 189 | {ERR_REASON(EC_R_D2I_ECPKPARAMETERS_FAILURE),"d2i ecpkparameters failure"}, | 203 | {ERR_REASON(EC_R_D2I_ECPKPARAMETERS_FAILURE),"d2i ecpkparameters failure"}, |
| 204 | {ERR_REASON(EC_R_DECODE_ERROR) ,"decode error"}, | ||
| 190 | {ERR_REASON(EC_R_DISCRIMINANT_IS_ZERO) ,"discriminant is zero"}, | 205 | {ERR_REASON(EC_R_DISCRIMINANT_IS_ZERO) ,"discriminant is zero"}, |
| 191 | {ERR_REASON(EC_R_EC_GROUP_NEW_BY_NAME_FAILURE),"ec group new by name failure"}, | 206 | {ERR_REASON(EC_R_EC_GROUP_NEW_BY_NAME_FAILURE),"ec group new by name failure"}, |
| 192 | {ERR_REASON(EC_R_FIELD_TOO_LARGE) ,"field too large"}, | 207 | {ERR_REASON(EC_R_FIELD_TOO_LARGE) ,"field too large"}, |
| @@ -196,6 +211,8 @@ static ERR_STRING_DATA EC_str_reasons[]= | |||
| 196 | {ERR_REASON(EC_R_INVALID_ARGUMENT) ,"invalid argument"}, | 211 | {ERR_REASON(EC_R_INVALID_ARGUMENT) ,"invalid argument"}, |
| 197 | {ERR_REASON(EC_R_INVALID_COMPRESSED_POINT),"invalid compressed point"}, | 212 | {ERR_REASON(EC_R_INVALID_COMPRESSED_POINT),"invalid compressed point"}, |
| 198 | {ERR_REASON(EC_R_INVALID_COMPRESSION_BIT),"invalid compression bit"}, | 213 | {ERR_REASON(EC_R_INVALID_COMPRESSION_BIT),"invalid compression bit"}, |
| 214 | {ERR_REASON(EC_R_INVALID_CURVE) ,"invalid curve"}, | ||
| 215 | {ERR_REASON(EC_R_INVALID_DIGEST_TYPE) ,"invalid digest type"}, | ||
| 199 | {ERR_REASON(EC_R_INVALID_ENCODING) ,"invalid encoding"}, | 216 | {ERR_REASON(EC_R_INVALID_ENCODING) ,"invalid encoding"}, |
| 200 | {ERR_REASON(EC_R_INVALID_FIELD) ,"invalid field"}, | 217 | {ERR_REASON(EC_R_INVALID_FIELD) ,"invalid field"}, |
| 201 | {ERR_REASON(EC_R_INVALID_FORM) ,"invalid form"}, | 218 | {ERR_REASON(EC_R_INVALID_FORM) ,"invalid form"}, |
| @@ -203,6 +220,7 @@ static ERR_STRING_DATA EC_str_reasons[]= | |||
| 203 | {ERR_REASON(EC_R_INVALID_PENTANOMIAL_BASIS),"invalid pentanomial basis"}, | 220 | {ERR_REASON(EC_R_INVALID_PENTANOMIAL_BASIS),"invalid pentanomial basis"}, |
| 204 | {ERR_REASON(EC_R_INVALID_PRIVATE_KEY) ,"invalid private key"}, | 221 | {ERR_REASON(EC_R_INVALID_PRIVATE_KEY) ,"invalid private key"}, |
| 205 | {ERR_REASON(EC_R_INVALID_TRINOMIAL_BASIS),"invalid trinomial basis"}, | 222 | {ERR_REASON(EC_R_INVALID_TRINOMIAL_BASIS),"invalid trinomial basis"}, |
| 223 | {ERR_REASON(EC_R_KEYS_NOT_SET) ,"keys not set"}, | ||
| 206 | {ERR_REASON(EC_R_MISSING_PARAMETERS) ,"missing parameters"}, | 224 | {ERR_REASON(EC_R_MISSING_PARAMETERS) ,"missing parameters"}, |
| 207 | {ERR_REASON(EC_R_MISSING_PRIVATE_KEY) ,"missing private key"}, | 225 | {ERR_REASON(EC_R_MISSING_PRIVATE_KEY) ,"missing private key"}, |
| 208 | {ERR_REASON(EC_R_NOT_A_NIST_PRIME) ,"not a NIST prime"}, | 226 | {ERR_REASON(EC_R_NOT_A_NIST_PRIME) ,"not a NIST prime"}, |
| @@ -210,6 +228,7 @@ static ERR_STRING_DATA EC_str_reasons[]= | |||
| 210 | {ERR_REASON(EC_R_NOT_IMPLEMENTED) ,"not implemented"}, | 228 | {ERR_REASON(EC_R_NOT_IMPLEMENTED) ,"not implemented"}, |
| 211 | {ERR_REASON(EC_R_NOT_INITIALIZED) ,"not initialized"}, | 229 | {ERR_REASON(EC_R_NOT_INITIALIZED) ,"not initialized"}, |
| 212 | {ERR_REASON(EC_R_NO_FIELD_MOD) ,"no field mod"}, | 230 | {ERR_REASON(EC_R_NO_FIELD_MOD) ,"no field mod"}, |
| 231 | {ERR_REASON(EC_R_NO_PARAMETERS_SET) ,"no parameters set"}, | ||
| 213 | {ERR_REASON(EC_R_PASSED_NULL_PARAMETER) ,"passed null parameter"}, | 232 | {ERR_REASON(EC_R_PASSED_NULL_PARAMETER) ,"passed null parameter"}, |
| 214 | {ERR_REASON(EC_R_PKPARAMETERS2GROUP_FAILURE),"pkparameters2group failure"}, | 233 | {ERR_REASON(EC_R_PKPARAMETERS2GROUP_FAILURE),"pkparameters2group failure"}, |
| 215 | {ERR_REASON(EC_R_POINT_AT_INFINITY) ,"point at infinity"}, | 234 | {ERR_REASON(EC_R_POINT_AT_INFINITY) ,"point at infinity"}, |
diff --git a/src/lib/libcrypto/ec/ec_lcl.h b/src/lib/libcrypto/ec/ec_lcl.h index fdd7aa2755..3e2c34b0bc 100644 --- a/src/lib/libcrypto/ec/ec_lcl.h +++ b/src/lib/libcrypto/ec/ec_lcl.h | |||
| @@ -205,11 +205,14 @@ struct ec_group_st { | |||
| 205 | * irreducible polynomial defining the field. | 205 | * irreducible polynomial defining the field. |
| 206 | */ | 206 | */ |
| 207 | 207 | ||
| 208 | unsigned int poly[5]; /* Field specification for curves over GF(2^m). | 208 | int poly[6]; /* Field specification for curves over GF(2^m). |
| 209 | * The irreducible f(t) is then of the form: | 209 | * The irreducible f(t) is then of the form: |
| 210 | * t^poly[0] + t^poly[1] + ... + t^poly[k] | 210 | * t^poly[0] + t^poly[1] + ... + t^poly[k] |
| 211 | * where m = poly[0] > poly[1] > ... > poly[k] = 0. | 211 | * where m = poly[0] > poly[1] > ... > poly[k] = 0. |
| 212 | */ | 212 | * The array is terminated with poly[k+1]=-1. |
| 213 | * All elliptic curve irreducibles have at most 5 | ||
| 214 | * non-zero terms. | ||
| 215 | */ | ||
| 213 | 216 | ||
| 214 | BIGNUM a, b; /* Curve coefficients. | 217 | BIGNUM a, b; /* Curve coefficients. |
| 215 | * (Here the assumption is that BIGNUMs can be used | 218 | * (Here the assumption is that BIGNUMs can be used |
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index 5af84376c6..dd7da0fcf9 100644 --- a/src/lib/libcrypto/ec/ec_lib.c +++ b/src/lib/libcrypto/ec/ec_lib.c | |||
| @@ -79,7 +79,7 @@ EC_GROUP *EC_GROUP_new(const EC_METHOD *meth) | |||
| 79 | 79 | ||
| 80 | if (meth == NULL) | 80 | if (meth == NULL) |
| 81 | { | 81 | { |
| 82 | ECerr(EC_F_EC_GROUP_NEW, ERR_R_PASSED_NULL_PARAMETER); | 82 | ECerr(EC_F_EC_GROUP_NEW, EC_R_SLOT_FULL); |
| 83 | return NULL; | 83 | return NULL; |
| 84 | } | 84 | } |
| 85 | if (meth->group_init == 0) | 85 | if (meth->group_init == 0) |
| @@ -740,7 +740,7 @@ void EC_POINT_clear_free(EC_POINT *point) | |||
| 740 | 740 | ||
| 741 | if (point->meth->point_clear_finish != 0) | 741 | if (point->meth->point_clear_finish != 0) |
| 742 | point->meth->point_clear_finish(point); | 742 | point->meth->point_clear_finish(point); |
| 743 | else if (point->meth != NULL && point->meth->point_finish != 0) | 743 | else if (point->meth->point_finish != 0) |
| 744 | point->meth->point_finish(point); | 744 | point->meth->point_finish(point); |
| 745 | OPENSSL_cleanse(point, sizeof *point); | 745 | OPENSSL_cleanse(point, sizeof *point); |
| 746 | OPENSSL_free(point); | 746 | OPENSSL_free(point); |
diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c index 2ba173ef36..f05df5332e 100644 --- a/src/lib/libcrypto/ec/ec_mult.c +++ b/src/lib/libcrypto/ec/ec_mult.c | |||
| @@ -224,6 +224,12 @@ static signed char *compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len) | |||
| 224 | sign = -1; | 224 | sign = -1; |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | if (scalar->d == NULL || scalar->top == 0) | ||
| 228 | { | ||
| 229 | ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); | ||
| 230 | goto err; | ||
| 231 | } | ||
| 232 | |||
| 227 | len = BN_num_bits(scalar); | 233 | len = BN_num_bits(scalar); |
| 228 | r = OPENSSL_malloc(len + 1); /* modified wNAF may be one digit longer than binary representation | 234 | r = OPENSSL_malloc(len + 1); /* modified wNAF may be one digit longer than binary representation |
| 229 | * (*ret_len will be set to the actual length, i.e. at most | 235 | * (*ret_len will be set to the actual length, i.e. at most |
| @@ -233,12 +239,6 @@ static signed char *compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len) | |||
| 233 | ECerr(EC_F_COMPUTE_WNAF, ERR_R_MALLOC_FAILURE); | 239 | ECerr(EC_F_COMPUTE_WNAF, ERR_R_MALLOC_FAILURE); |
| 234 | goto err; | 240 | goto err; |
| 235 | } | 241 | } |
| 236 | |||
| 237 | if (scalar->d == NULL || scalar->top == 0) | ||
| 238 | { | ||
| 239 | ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); | ||
| 240 | goto err; | ||
| 241 | } | ||
| 242 | window_val = scalar->d[0] & mask; | 242 | window_val = scalar->d[0] & mask; |
| 243 | j = 0; | 243 | j = 0; |
| 244 | while ((window_val != 0) || (j + w + 1 < len)) /* if j+w+1 >= len, window_val will not increase */ | 244 | while ((window_val != 0) || (j + w + 1 < len)) /* if j+w+1 >= len, window_val will not increase */ |
| @@ -419,7 +419,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
| 419 | if (numblocks > pre_comp->numblocks) | 419 | if (numblocks > pre_comp->numblocks) |
| 420 | numblocks = pre_comp->numblocks; | 420 | numblocks = pre_comp->numblocks; |
| 421 | 421 | ||
| 422 | pre_points_per_block = 1u << (pre_comp->w - 1); | 422 | pre_points_per_block = (size_t)1 << (pre_comp->w - 1); |
| 423 | 423 | ||
| 424 | /* check that pre_comp looks sane */ | 424 | /* check that pre_comp looks sane */ |
| 425 | if (pre_comp->num != (pre_comp->numblocks * pre_points_per_block)) | 425 | if (pre_comp->num != (pre_comp->numblocks * pre_points_per_block)) |
| @@ -461,7 +461,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
| 461 | 461 | ||
| 462 | bits = i < num ? BN_num_bits(scalars[i]) : BN_num_bits(scalar); | 462 | bits = i < num ? BN_num_bits(scalars[i]) : BN_num_bits(scalar); |
| 463 | wsize[i] = EC_window_bits_for_scalar_size(bits); | 463 | wsize[i] = EC_window_bits_for_scalar_size(bits); |
| 464 | num_val += 1u << (wsize[i] - 1); | 464 | num_val += (size_t)1 << (wsize[i] - 1); |
| 465 | wNAF[i + 1] = NULL; /* make sure we always have a pivot */ | 465 | wNAF[i + 1] = NULL; /* make sure we always have a pivot */ |
| 466 | wNAF[i] = compute_wNAF((i < num ? scalars[i] : scalar), wsize[i], &wNAF_len[i]); | 466 | wNAF[i] = compute_wNAF((i < num ? scalars[i] : scalar), wsize[i], &wNAF_len[i]); |
| 467 | if (wNAF[i] == NULL) | 467 | if (wNAF[i] == NULL) |
| @@ -600,7 +600,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
| 600 | for (i = 0; i < num + num_scalar; i++) | 600 | for (i = 0; i < num + num_scalar; i++) |
| 601 | { | 601 | { |
| 602 | val_sub[i] = v; | 602 | val_sub[i] = v; |
| 603 | for (j = 0; j < (1u << (wsize[i] - 1)); j++) | 603 | for (j = 0; j < ((size_t)1 << (wsize[i] - 1)); j++) |
| 604 | { | 604 | { |
| 605 | *v = EC_POINT_new(group); | 605 | *v = EC_POINT_new(group); |
| 606 | if (*v == NULL) goto err; | 606 | if (*v == NULL) goto err; |
| @@ -636,7 +636,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
| 636 | if (wsize[i] > 1) | 636 | if (wsize[i] > 1) |
| 637 | { | 637 | { |
| 638 | if (!EC_POINT_dbl(group, tmp, val_sub[i][0], ctx)) goto err; | 638 | if (!EC_POINT_dbl(group, tmp, val_sub[i][0], ctx)) goto err; |
| 639 | for (j = 1; j < (1u << (wsize[i] - 1)); j++) | 639 | for (j = 1; j < ((size_t)1 << (wsize[i] - 1)); j++) |
| 640 | { | 640 | { |
| 641 | if (!EC_POINT_add(group, val_sub[i][j], val_sub[i][j - 1], tmp, ctx)) goto err; | 641 | if (!EC_POINT_add(group, val_sub[i][j], val_sub[i][j - 1], tmp, ctx)) goto err; |
| 642 | } | 642 | } |
| @@ -820,7 +820,7 @@ int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx) | |||
| 820 | 820 | ||
| 821 | numblocks = (bits + blocksize - 1) / blocksize; /* max. number of blocks to use for wNAF splitting */ | 821 | numblocks = (bits + blocksize - 1) / blocksize; /* max. number of blocks to use for wNAF splitting */ |
| 822 | 822 | ||
| 823 | pre_points_per_block = 1u << (w - 1); | 823 | pre_points_per_block = (size_t)1 << (w - 1); |
| 824 | num = pre_points_per_block * numblocks; /* number of points to compute and store */ | 824 | num = pre_points_per_block * numblocks; /* number of points to compute and store */ |
| 825 | 825 | ||
| 826 | points = OPENSSL_malloc(sizeof (EC_POINT*)*(num + 1)); | 826 | points = OPENSSL_malloc(sizeof (EC_POINT*)*(num + 1)); |
diff --git a/src/lib/libcrypto/ec/ec_pmeth.c b/src/lib/libcrypto/ec/ec_pmeth.c new file mode 100644 index 0000000000..f433076ca1 --- /dev/null +++ b/src/lib/libcrypto/ec/ec_pmeth.c | |||
| @@ -0,0 +1,340 @@ | |||
| 1 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | ||
| 2 | * project 2006. | ||
| 3 | */ | ||
| 4 | /* ==================================================================== | ||
| 5 | * Copyright (c) 2006 The OpenSSL Project. All rights reserved. | ||
| 6 | * | ||
| 7 | * Redistribution and use in source and binary forms, with or without | ||
| 8 | * modification, are permitted provided that the following conditions | ||
| 9 | * are met: | ||
| 10 | * | ||
| 11 | * 1. Redistributions of source code must retain the above copyright | ||
| 12 | * notice, this list of conditions and the following disclaimer. | ||
| 13 | * | ||
| 14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 15 | * notice, this list of conditions and the following disclaimer in | ||
| 16 | * the documentation and/or other materials provided with the | ||
| 17 | * distribution. | ||
| 18 | * | ||
| 19 | * 3. All advertising materials mentioning features or use of this | ||
| 20 | * software must display the following acknowledgment: | ||
| 21 | * "This product includes software developed by the OpenSSL Project | ||
| 22 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 23 | * | ||
| 24 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 25 | * endorse or promote products derived from this software without | ||
| 26 | * prior written permission. For written permission, please contact | ||
| 27 | * licensing@OpenSSL.org. | ||
| 28 | * | ||
| 29 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 30 | * nor may "OpenSSL" appear in their names without prior written | ||
| 31 | * permission of the OpenSSL Project. | ||
| 32 | * | ||
| 33 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 34 | * acknowledgment: | ||
| 35 | * "This product includes software developed by the OpenSSL Project | ||
| 36 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 37 | * | ||
| 38 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 39 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 41 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 42 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 43 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 44 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 45 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 46 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 47 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 48 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 49 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 50 | * ==================================================================== | ||
| 51 | * | ||
| 52 | * This product includes cryptographic software written by Eric Young | ||
| 53 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 54 | * Hudson (tjh@cryptsoft.com). | ||
| 55 | * | ||
| 56 | */ | ||
| 57 | |||
| 58 | #include <stdio.h> | ||
| 59 | #include "cryptlib.h" | ||
| 60 | #include <openssl/asn1t.h> | ||
| 61 | #include <openssl/x509.h> | ||
| 62 | #include <openssl/ec.h> | ||
| 63 | #include <openssl/ecdsa.h> | ||
| 64 | #include <openssl/evp.h> | ||
| 65 | #include "evp_locl.h" | ||
| 66 | |||
| 67 | /* EC pkey context structure */ | ||
| 68 | |||
| 69 | typedef struct | ||
| 70 | { | ||
| 71 | /* Key and paramgen group */ | ||
| 72 | EC_GROUP *gen_group; | ||
| 73 | /* message digest */ | ||
| 74 | const EVP_MD *md; | ||
| 75 | } EC_PKEY_CTX; | ||
| 76 | |||
| 77 | static int pkey_ec_init(EVP_PKEY_CTX *ctx) | ||
| 78 | { | ||
| 79 | EC_PKEY_CTX *dctx; | ||
| 80 | dctx = OPENSSL_malloc(sizeof(EC_PKEY_CTX)); | ||
| 81 | if (!dctx) | ||
| 82 | return 0; | ||
| 83 | dctx->gen_group = NULL; | ||
| 84 | dctx->md = NULL; | ||
| 85 | |||
| 86 | ctx->data = dctx; | ||
| 87 | |||
| 88 | return 1; | ||
| 89 | } | ||
| 90 | |||
| 91 | static int pkey_ec_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) | ||
| 92 | { | ||
| 93 | EC_PKEY_CTX *dctx, *sctx; | ||
| 94 | if (!pkey_ec_init(dst)) | ||
| 95 | return 0; | ||
| 96 | sctx = src->data; | ||
| 97 | dctx = dst->data; | ||
| 98 | if (sctx->gen_group) | ||
| 99 | { | ||
| 100 | dctx->gen_group = EC_GROUP_dup(sctx->gen_group); | ||
| 101 | if (!dctx->gen_group) | ||
| 102 | return 0; | ||
| 103 | } | ||
| 104 | dctx->md = sctx->md; | ||
| 105 | return 1; | ||
| 106 | } | ||
| 107 | |||
| 108 | static void pkey_ec_cleanup(EVP_PKEY_CTX *ctx) | ||
| 109 | { | ||
| 110 | EC_PKEY_CTX *dctx = ctx->data; | ||
| 111 | if (dctx) | ||
| 112 | { | ||
| 113 | if (dctx->gen_group) | ||
| 114 | EC_GROUP_free(dctx->gen_group); | ||
| 115 | OPENSSL_free(dctx); | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | static int pkey_ec_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, | ||
| 120 | const unsigned char *tbs, size_t tbslen) | ||
| 121 | { | ||
| 122 | int ret, type; | ||
| 123 | unsigned int sltmp; | ||
| 124 | EC_PKEY_CTX *dctx = ctx->data; | ||
| 125 | EC_KEY *ec = ctx->pkey->pkey.ec; | ||
| 126 | |||
| 127 | if (!sig) | ||
| 128 | { | ||
| 129 | *siglen = ECDSA_size(ec); | ||
| 130 | return 1; | ||
| 131 | } | ||
| 132 | else if(*siglen < (size_t)ECDSA_size(ec)) | ||
| 133 | { | ||
| 134 | ECerr(EC_F_PKEY_EC_SIGN, EC_R_BUFFER_TOO_SMALL); | ||
| 135 | return 0; | ||
| 136 | } | ||
| 137 | |||
| 138 | if (dctx->md) | ||
| 139 | type = EVP_MD_type(dctx->md); | ||
| 140 | else | ||
| 141 | type = NID_sha1; | ||
| 142 | |||
| 143 | |||
| 144 | ret = ECDSA_sign(type, tbs, tbslen, sig, &sltmp, ec); | ||
| 145 | |||
| 146 | if (ret <= 0) | ||
| 147 | return ret; | ||
| 148 | *siglen = (size_t)sltmp; | ||
| 149 | return 1; | ||
| 150 | } | ||
| 151 | |||
| 152 | static int pkey_ec_verify(EVP_PKEY_CTX *ctx, | ||
| 153 | const unsigned char *sig, size_t siglen, | ||
| 154 | const unsigned char *tbs, size_t tbslen) | ||
| 155 | { | ||
| 156 | int ret, type; | ||
| 157 | EC_PKEY_CTX *dctx = ctx->data; | ||
| 158 | EC_KEY *ec = ctx->pkey->pkey.ec; | ||
| 159 | |||
| 160 | if (dctx->md) | ||
| 161 | type = EVP_MD_type(dctx->md); | ||
| 162 | else | ||
| 163 | type = NID_sha1; | ||
| 164 | |||
| 165 | ret = ECDSA_verify(type, tbs, tbslen, sig, siglen, ec); | ||
| 166 | |||
| 167 | return ret; | ||
| 168 | } | ||
| 169 | |||
| 170 | static int pkey_ec_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen) | ||
| 171 | { | ||
| 172 | int ret; | ||
| 173 | size_t outlen; | ||
| 174 | const EC_POINT *pubkey = NULL; | ||
| 175 | if (!ctx->pkey || !ctx->peerkey) | ||
| 176 | { | ||
| 177 | ECerr(EC_F_PKEY_EC_DERIVE, EC_R_KEYS_NOT_SET); | ||
| 178 | return 0; | ||
| 179 | } | ||
| 180 | |||
| 181 | if (!key) | ||
| 182 | { | ||
| 183 | const EC_GROUP *group; | ||
| 184 | group = EC_KEY_get0_group(ctx->pkey->pkey.ec); | ||
| 185 | *keylen = (EC_GROUP_get_degree(group) + 7)/8; | ||
| 186 | return 1; | ||
| 187 | } | ||
| 188 | |||
| 189 | pubkey = EC_KEY_get0_public_key(ctx->peerkey->pkey.ec); | ||
| 190 | |||
| 191 | /* NB: unlike PKS#3 DH, if *outlen is less than maximum size this is | ||
| 192 | * not an error, the result is truncated. | ||
| 193 | */ | ||
| 194 | |||
| 195 | outlen = *keylen; | ||
| 196 | |||
| 197 | ret = ECDH_compute_key(key, outlen, pubkey, ctx->pkey->pkey.ec, 0); | ||
| 198 | if (ret < 0) | ||
| 199 | return ret; | ||
| 200 | *keylen = ret; | ||
| 201 | return 1; | ||
| 202 | } | ||
| 203 | |||
| 204 | static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) | ||
| 205 | { | ||
| 206 | EC_PKEY_CTX *dctx = ctx->data; | ||
| 207 | EC_GROUP *group; | ||
| 208 | switch (type) | ||
| 209 | { | ||
| 210 | case EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID: | ||
| 211 | group = EC_GROUP_new_by_curve_name(p1); | ||
| 212 | if (group == NULL) | ||
| 213 | { | ||
| 214 | ECerr(EC_F_PKEY_EC_CTRL, EC_R_INVALID_CURVE); | ||
| 215 | return 0; | ||
| 216 | } | ||
| 217 | if (dctx->gen_group) | ||
| 218 | EC_GROUP_free(dctx->gen_group); | ||
| 219 | dctx->gen_group = group; | ||
| 220 | return 1; | ||
| 221 | |||
| 222 | case EVP_PKEY_CTRL_MD: | ||
| 223 | if (EVP_MD_type((const EVP_MD *)p2) != NID_sha1 && | ||
| 224 | EVP_MD_type((const EVP_MD *)p2) != NID_sha224 && | ||
| 225 | EVP_MD_type((const EVP_MD *)p2) != NID_sha256 && | ||
| 226 | EVP_MD_type((const EVP_MD *)p2) != NID_sha384 && | ||
| 227 | EVP_MD_type((const EVP_MD *)p2) != NID_sha512) | ||
| 228 | { | ||
| 229 | ECerr(EC_F_PKEY_EC_CTRL, EC_R_INVALID_DIGEST_TYPE); | ||
| 230 | return 0; | ||
| 231 | } | ||
| 232 | dctx->md = p2; | ||
| 233 | return 1; | ||
| 234 | |||
| 235 | case EVP_PKEY_CTRL_PEER_KEY: | ||
| 236 | /* Default behaviour is OK */ | ||
| 237 | case EVP_PKEY_CTRL_DIGESTINIT: | ||
| 238 | case EVP_PKEY_CTRL_PKCS7_SIGN: | ||
| 239 | case EVP_PKEY_CTRL_CMS_SIGN: | ||
| 240 | return 1; | ||
| 241 | |||
| 242 | default: | ||
| 243 | return -2; | ||
| 244 | |||
| 245 | } | ||
| 246 | } | ||
| 247 | |||
| 248 | static int pkey_ec_ctrl_str(EVP_PKEY_CTX *ctx, | ||
| 249 | const char *type, const char *value) | ||
| 250 | { | ||
| 251 | if (!strcmp(type, "ec_paramgen_curve")) | ||
| 252 | { | ||
| 253 | int nid; | ||
| 254 | nid = OBJ_sn2nid(value); | ||
| 255 | if (nid == NID_undef) | ||
| 256 | nid = OBJ_ln2nid(value); | ||
| 257 | if (nid == NID_undef) | ||
| 258 | { | ||
| 259 | ECerr(EC_F_PKEY_EC_CTRL_STR, EC_R_INVALID_CURVE); | ||
| 260 | return 0; | ||
| 261 | } | ||
| 262 | return EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid); | ||
| 263 | } | ||
| 264 | return -2; | ||
| 265 | } | ||
| 266 | |||
| 267 | static int pkey_ec_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) | ||
| 268 | { | ||
| 269 | EC_KEY *ec = NULL; | ||
| 270 | EC_PKEY_CTX *dctx = ctx->data; | ||
| 271 | int ret = 0; | ||
| 272 | if (dctx->gen_group == NULL) | ||
| 273 | { | ||
| 274 | ECerr(EC_F_PKEY_EC_PARAMGEN, EC_R_NO_PARAMETERS_SET); | ||
| 275 | return 0; | ||
| 276 | } | ||
| 277 | ec = EC_KEY_new(); | ||
| 278 | if (!ec) | ||
| 279 | return 0; | ||
| 280 | ret = EC_KEY_set_group(ec, dctx->gen_group); | ||
| 281 | if (ret) | ||
| 282 | EVP_PKEY_assign_EC_KEY(pkey, ec); | ||
| 283 | else | ||
| 284 | EC_KEY_free(ec); | ||
| 285 | return ret; | ||
| 286 | } | ||
| 287 | |||
| 288 | static int pkey_ec_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) | ||
| 289 | { | ||
| 290 | EC_KEY *ec = NULL; | ||
| 291 | if (ctx->pkey == NULL) | ||
| 292 | { | ||
| 293 | ECerr(EC_F_PKEY_EC_KEYGEN, EC_R_NO_PARAMETERS_SET); | ||
| 294 | return 0; | ||
| 295 | } | ||
| 296 | ec = EC_KEY_new(); | ||
| 297 | if (!ec) | ||
| 298 | return 0; | ||
| 299 | EVP_PKEY_assign_EC_KEY(pkey, ec); | ||
| 300 | /* Note: if error return, pkey is freed by parent routine */ | ||
| 301 | if (!EVP_PKEY_copy_parameters(pkey, ctx->pkey)) | ||
| 302 | return 0; | ||
| 303 | return EC_KEY_generate_key(pkey->pkey.ec); | ||
| 304 | } | ||
| 305 | |||
| 306 | const EVP_PKEY_METHOD ec_pkey_meth = | ||
| 307 | { | ||
| 308 | EVP_PKEY_EC, | ||
| 309 | 0, | ||
| 310 | pkey_ec_init, | ||
| 311 | pkey_ec_copy, | ||
| 312 | pkey_ec_cleanup, | ||
| 313 | |||
| 314 | 0, | ||
| 315 | pkey_ec_paramgen, | ||
| 316 | |||
| 317 | 0, | ||
| 318 | pkey_ec_keygen, | ||
| 319 | |||
| 320 | 0, | ||
| 321 | pkey_ec_sign, | ||
| 322 | |||
| 323 | 0, | ||
| 324 | pkey_ec_verify, | ||
| 325 | |||
| 326 | 0,0, | ||
| 327 | |||
| 328 | 0,0,0,0, | ||
| 329 | |||
| 330 | 0,0, | ||
| 331 | |||
| 332 | 0,0, | ||
| 333 | |||
| 334 | 0, | ||
| 335 | pkey_ec_derive, | ||
| 336 | |||
| 337 | pkey_ec_ctrl, | ||
| 338 | pkey_ec_ctrl_str | ||
| 339 | |||
| 340 | }; | ||
diff --git a/src/lib/libcrypto/ec/eck_prn.c b/src/lib/libcrypto/ec/eck_prn.c new file mode 100644 index 0000000000..7d3e175ae7 --- /dev/null +++ b/src/lib/libcrypto/ec/eck_prn.c | |||
| @@ -0,0 +1,391 @@ | |||
| 1 | /* crypto/ec/eck_prn.c */ | ||
| 2 | /* | ||
| 3 | * Written by Nils Larsch for the OpenSSL project. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * openssl-core@openssl.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | /* ==================================================================== | ||
| 59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | ||
| 60 | * Portions originally developed by SUN MICROSYSTEMS, INC., and | ||
| 61 | * contributed to the OpenSSL project. | ||
| 62 | */ | ||
| 63 | |||
| 64 | #include <stdio.h> | ||
| 65 | #include "cryptlib.h" | ||
| 66 | #include <openssl/evp.h> | ||
| 67 | #include <openssl/ec.h> | ||
| 68 | #include <openssl/bn.h> | ||
| 69 | |||
| 70 | #ifndef OPENSSL_NO_FP_API | ||
| 71 | int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off) | ||
| 72 | { | ||
| 73 | BIO *b; | ||
| 74 | int ret; | ||
| 75 | |||
| 76 | if ((b=BIO_new(BIO_s_file())) == NULL) | ||
| 77 | { | ||
| 78 | ECerr(EC_F_ECPKPARAMETERS_PRINT_FP,ERR_R_BUF_LIB); | ||
| 79 | return(0); | ||
| 80 | } | ||
| 81 | BIO_set_fp(b, fp, BIO_NOCLOSE); | ||
| 82 | ret = ECPKParameters_print(b, x, off); | ||
| 83 | BIO_free(b); | ||
| 84 | return(ret); | ||
| 85 | } | ||
| 86 | |||
| 87 | int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off) | ||
| 88 | { | ||
| 89 | BIO *b; | ||
| 90 | int ret; | ||
| 91 | |||
| 92 | if ((b=BIO_new(BIO_s_file())) == NULL) | ||
| 93 | { | ||
| 94 | ECerr(EC_F_EC_KEY_PRINT_FP, ERR_R_BIO_LIB); | ||
| 95 | return(0); | ||
| 96 | } | ||
| 97 | BIO_set_fp(b, fp, BIO_NOCLOSE); | ||
| 98 | ret = EC_KEY_print(b, x, off); | ||
| 99 | BIO_free(b); | ||
| 100 | return(ret); | ||
| 101 | } | ||
| 102 | |||
| 103 | int ECParameters_print_fp(FILE *fp, const EC_KEY *x) | ||
| 104 | { | ||
| 105 | BIO *b; | ||
| 106 | int ret; | ||
| 107 | |||
| 108 | if ((b=BIO_new(BIO_s_file())) == NULL) | ||
| 109 | { | ||
| 110 | ECerr(EC_F_ECPARAMETERS_PRINT_FP, ERR_R_BIO_LIB); | ||
| 111 | return(0); | ||
| 112 | } | ||
| 113 | BIO_set_fp(b, fp, BIO_NOCLOSE); | ||
| 114 | ret = ECParameters_print(b, x); | ||
| 115 | BIO_free(b); | ||
| 116 | return(ret); | ||
| 117 | } | ||
| 118 | #endif | ||
| 119 | |||
| 120 | int EC_KEY_print(BIO *bp, const EC_KEY *x, int off) | ||
| 121 | { | ||
| 122 | EVP_PKEY *pk; | ||
| 123 | int ret; | ||
| 124 | pk = EVP_PKEY_new(); | ||
| 125 | if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *)x)) | ||
| 126 | return 0; | ||
| 127 | ret = EVP_PKEY_print_private(bp, pk, off, NULL); | ||
| 128 | EVP_PKEY_free(pk); | ||
| 129 | return ret; | ||
| 130 | } | ||
| 131 | |||
| 132 | int ECParameters_print(BIO *bp, const EC_KEY *x) | ||
| 133 | { | ||
| 134 | EVP_PKEY *pk; | ||
| 135 | int ret; | ||
| 136 | pk = EVP_PKEY_new(); | ||
| 137 | if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *)x)) | ||
| 138 | return 0; | ||
| 139 | ret = EVP_PKEY_print_params(bp, pk, 4, NULL); | ||
| 140 | EVP_PKEY_free(pk); | ||
| 141 | return ret; | ||
| 142 | } | ||
| 143 | |||
| 144 | static int print_bin(BIO *fp, const char *str, const unsigned char *num, | ||
| 145 | size_t len, int off); | ||
| 146 | |||
| 147 | int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off) | ||
| 148 | { | ||
| 149 | unsigned char *buffer=NULL; | ||
| 150 | size_t buf_len=0, i; | ||
| 151 | int ret=0, reason=ERR_R_BIO_LIB; | ||
| 152 | BN_CTX *ctx=NULL; | ||
| 153 | const EC_POINT *point=NULL; | ||
| 154 | BIGNUM *p=NULL, *a=NULL, *b=NULL, *gen=NULL, | ||
| 155 | *order=NULL, *cofactor=NULL; | ||
| 156 | const unsigned char *seed; | ||
| 157 | size_t seed_len=0; | ||
| 158 | |||
| 159 | static const char *gen_compressed = "Generator (compressed):"; | ||
| 160 | static const char *gen_uncompressed = "Generator (uncompressed):"; | ||
| 161 | static const char *gen_hybrid = "Generator (hybrid):"; | ||
| 162 | |||
| 163 | if (!x) | ||
| 164 | { | ||
| 165 | reason = ERR_R_PASSED_NULL_PARAMETER; | ||
| 166 | goto err; | ||
| 167 | } | ||
| 168 | |||
| 169 | ctx = BN_CTX_new(); | ||
| 170 | if (ctx == NULL) | ||
| 171 | { | ||
| 172 | reason = ERR_R_MALLOC_FAILURE; | ||
| 173 | goto err; | ||
| 174 | } | ||
| 175 | |||
| 176 | if (EC_GROUP_get_asn1_flag(x)) | ||
| 177 | { | ||
| 178 | /* the curve parameter are given by an asn1 OID */ | ||
| 179 | int nid; | ||
| 180 | |||
| 181 | if (!BIO_indent(bp, off, 128)) | ||
| 182 | goto err; | ||
| 183 | |||
| 184 | nid = EC_GROUP_get_curve_name(x); | ||
| 185 | if (nid == 0) | ||
| 186 | goto err; | ||
| 187 | |||
| 188 | if (BIO_printf(bp, "ASN1 OID: %s", OBJ_nid2sn(nid)) <= 0) | ||
| 189 | goto err; | ||
| 190 | if (BIO_printf(bp, "\n") <= 0) | ||
| 191 | goto err; | ||
| 192 | } | ||
| 193 | else | ||
| 194 | { | ||
| 195 | /* explicit parameters */ | ||
| 196 | int is_char_two = 0; | ||
| 197 | point_conversion_form_t form; | ||
| 198 | int tmp_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(x)); | ||
| 199 | |||
| 200 | if (tmp_nid == NID_X9_62_characteristic_two_field) | ||
| 201 | is_char_two = 1; | ||
| 202 | |||
| 203 | if ((p = BN_new()) == NULL || (a = BN_new()) == NULL || | ||
| 204 | (b = BN_new()) == NULL || (order = BN_new()) == NULL || | ||
| 205 | (cofactor = BN_new()) == NULL) | ||
| 206 | { | ||
| 207 | reason = ERR_R_MALLOC_FAILURE; | ||
| 208 | goto err; | ||
| 209 | } | ||
| 210 | |||
| 211 | if (is_char_two) | ||
| 212 | { | ||
| 213 | if (!EC_GROUP_get_curve_GF2m(x, p, a, b, ctx)) | ||
| 214 | { | ||
| 215 | reason = ERR_R_EC_LIB; | ||
| 216 | goto err; | ||
| 217 | } | ||
| 218 | } | ||
| 219 | else /* prime field */ | ||
| 220 | { | ||
| 221 | if (!EC_GROUP_get_curve_GFp(x, p, a, b, ctx)) | ||
| 222 | { | ||
| 223 | reason = ERR_R_EC_LIB; | ||
| 224 | goto err; | ||
| 225 | } | ||
| 226 | } | ||
| 227 | |||
| 228 | if ((point = EC_GROUP_get0_generator(x)) == NULL) | ||
| 229 | { | ||
| 230 | reason = ERR_R_EC_LIB; | ||
| 231 | goto err; | ||
| 232 | } | ||
| 233 | if (!EC_GROUP_get_order(x, order, NULL) || | ||
| 234 | !EC_GROUP_get_cofactor(x, cofactor, NULL)) | ||
| 235 | { | ||
| 236 | reason = ERR_R_EC_LIB; | ||
| 237 | goto err; | ||
| 238 | } | ||
| 239 | |||
| 240 | form = EC_GROUP_get_point_conversion_form(x); | ||
| 241 | |||
| 242 | if ((gen = EC_POINT_point2bn(x, point, | ||
| 243 | form, NULL, ctx)) == NULL) | ||
| 244 | { | ||
| 245 | reason = ERR_R_EC_LIB; | ||
| 246 | goto err; | ||
| 247 | } | ||
| 248 | |||
| 249 | buf_len = (size_t)BN_num_bytes(p); | ||
| 250 | if (buf_len < (i = (size_t)BN_num_bytes(a))) | ||
| 251 | buf_len = i; | ||
| 252 | if (buf_len < (i = (size_t)BN_num_bytes(b))) | ||
| 253 | buf_len = i; | ||
| 254 | if (buf_len < (i = (size_t)BN_num_bytes(gen))) | ||
| 255 | buf_len = i; | ||
| 256 | if (buf_len < (i = (size_t)BN_num_bytes(order))) | ||
| 257 | buf_len = i; | ||
| 258 | if (buf_len < (i = (size_t)BN_num_bytes(cofactor))) | ||
| 259 | buf_len = i; | ||
| 260 | |||
| 261 | if ((seed = EC_GROUP_get0_seed(x)) != NULL) | ||
| 262 | seed_len = EC_GROUP_get_seed_len(x); | ||
| 263 | |||
| 264 | buf_len += 10; | ||
| 265 | if ((buffer = OPENSSL_malloc(buf_len)) == NULL) | ||
| 266 | { | ||
| 267 | reason = ERR_R_MALLOC_FAILURE; | ||
| 268 | goto err; | ||
| 269 | } | ||
| 270 | |||
| 271 | if (!BIO_indent(bp, off, 128)) | ||
| 272 | goto err; | ||
| 273 | |||
| 274 | /* print the 'short name' of the field type */ | ||
| 275 | if (BIO_printf(bp, "Field Type: %s\n", OBJ_nid2sn(tmp_nid)) | ||
| 276 | <= 0) | ||
| 277 | goto err; | ||
| 278 | |||
| 279 | if (is_char_two) | ||
| 280 | { | ||
| 281 | /* print the 'short name' of the base type OID */ | ||
| 282 | int basis_type = EC_GROUP_get_basis_type(x); | ||
| 283 | if (basis_type == 0) | ||
| 284 | goto err; | ||
| 285 | |||
| 286 | if (!BIO_indent(bp, off, 128)) | ||
| 287 | goto err; | ||
| 288 | |||
| 289 | if (BIO_printf(bp, "Basis Type: %s\n", | ||
| 290 | OBJ_nid2sn(basis_type)) <= 0) | ||
| 291 | goto err; | ||
| 292 | |||
| 293 | /* print the polynomial */ | ||
| 294 | if ((p != NULL) && !ASN1_bn_print(bp, "Polynomial:", p, buffer, | ||
| 295 | off)) | ||
| 296 | goto err; | ||
| 297 | } | ||
| 298 | else | ||
| 299 | { | ||
| 300 | if ((p != NULL) && !ASN1_bn_print(bp, "Prime:", p, buffer,off)) | ||
| 301 | goto err; | ||
| 302 | } | ||
| 303 | if ((a != NULL) && !ASN1_bn_print(bp, "A: ", a, buffer, off)) | ||
| 304 | goto err; | ||
| 305 | if ((b != NULL) && !ASN1_bn_print(bp, "B: ", b, buffer, off)) | ||
| 306 | goto err; | ||
| 307 | if (form == POINT_CONVERSION_COMPRESSED) | ||
| 308 | { | ||
| 309 | if ((gen != NULL) && !ASN1_bn_print(bp, gen_compressed, gen, | ||
| 310 | buffer, off)) | ||
| 311 | goto err; | ||
| 312 | } | ||
| 313 | else if (form == POINT_CONVERSION_UNCOMPRESSED) | ||
| 314 | { | ||
| 315 | if ((gen != NULL) && !ASN1_bn_print(bp, gen_uncompressed, gen, | ||
| 316 | buffer, off)) | ||
| 317 | goto err; | ||
| 318 | } | ||
| 319 | else /* form == POINT_CONVERSION_HYBRID */ | ||
| 320 | { | ||
| 321 | if ((gen != NULL) && !ASN1_bn_print(bp, gen_hybrid, gen, | ||
| 322 | buffer, off)) | ||
| 323 | goto err; | ||
| 324 | } | ||
| 325 | if ((order != NULL) && !ASN1_bn_print(bp, "Order: ", order, | ||
| 326 | buffer, off)) goto err; | ||
| 327 | if ((cofactor != NULL) && !ASN1_bn_print(bp, "Cofactor: ", cofactor, | ||
| 328 | buffer, off)) goto err; | ||
| 329 | if (seed && !print_bin(bp, "Seed:", seed, seed_len, off)) | ||
| 330 | goto err; | ||
| 331 | } | ||
| 332 | ret=1; | ||
| 333 | err: | ||
| 334 | if (!ret) | ||
| 335 | ECerr(EC_F_ECPKPARAMETERS_PRINT, reason); | ||
| 336 | if (p) | ||
| 337 | BN_free(p); | ||
| 338 | if (a) | ||
| 339 | BN_free(a); | ||
| 340 | if (b) | ||
| 341 | BN_free(b); | ||
| 342 | if (gen) | ||
| 343 | BN_free(gen); | ||
| 344 | if (order) | ||
| 345 | BN_free(order); | ||
| 346 | if (cofactor) | ||
| 347 | BN_free(cofactor); | ||
| 348 | if (ctx) | ||
| 349 | BN_CTX_free(ctx); | ||
| 350 | if (buffer != NULL) | ||
| 351 | OPENSSL_free(buffer); | ||
| 352 | return(ret); | ||
| 353 | } | ||
| 354 | |||
| 355 | static int print_bin(BIO *fp, const char *name, const unsigned char *buf, | ||
| 356 | size_t len, int off) | ||
| 357 | { | ||
| 358 | size_t i; | ||
| 359 | char str[128]; | ||
| 360 | |||
| 361 | if (buf == NULL) | ||
| 362 | return 1; | ||
| 363 | if (off) | ||
| 364 | { | ||
| 365 | if (off > 128) | ||
| 366 | off=128; | ||
| 367 | memset(str,' ',off); | ||
| 368 | if (BIO_write(fp, str, off) <= 0) | ||
| 369 | return 0; | ||
| 370 | } | ||
| 371 | |||
| 372 | if (BIO_printf(fp,"%s", name) <= 0) | ||
| 373 | return 0; | ||
| 374 | |||
| 375 | for (i=0; i<len; i++) | ||
| 376 | { | ||
| 377 | if ((i%15) == 0) | ||
| 378 | { | ||
| 379 | str[0]='\n'; | ||
| 380 | memset(&(str[1]),' ',off+4); | ||
| 381 | if (BIO_write(fp, str, off+1+4) <= 0) | ||
| 382 | return 0; | ||
| 383 | } | ||
| 384 | if (BIO_printf(fp,"%02x%s",buf[i],((i+1) == len)?"":":") <= 0) | ||
| 385 | return 0; | ||
| 386 | } | ||
| 387 | if (BIO_write(fp,"\n",1) <= 0) | ||
| 388 | return 0; | ||
| 389 | |||
| 390 | return 1; | ||
| 391 | } | ||
diff --git a/src/lib/libcrypto/ec/ecp_nist.c b/src/lib/libcrypto/ec/ecp_nist.c index 71893d5eab..2a5682ea41 100644 --- a/src/lib/libcrypto/ec/ecp_nist.c +++ b/src/lib/libcrypto/ec/ecp_nist.c | |||
| @@ -112,10 +112,6 @@ const EC_METHOD *EC_GFp_nist_method(void) | |||
| 112 | return &ret; | 112 | return &ret; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | #if BN_BITS2 == 64 | ||
| 116 | #define NO_32_BIT_TYPE | ||
| 117 | #endif | ||
| 118 | |||
| 119 | int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src) | 115 | int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src) |
| 120 | { | 116 | { |
| 121 | dest->field_mod_func = src->field_mod_func; | 117 | dest->field_mod_func = src->field_mod_func; |
| @@ -139,34 +135,12 @@ int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p, | |||
| 139 | if (BN_ucmp(BN_get0_nist_prime_192(), p) == 0) | 135 | if (BN_ucmp(BN_get0_nist_prime_192(), p) == 0) |
| 140 | group->field_mod_func = BN_nist_mod_192; | 136 | group->field_mod_func = BN_nist_mod_192; |
| 141 | else if (BN_ucmp(BN_get0_nist_prime_224(), p) == 0) | 137 | else if (BN_ucmp(BN_get0_nist_prime_224(), p) == 0) |
| 142 | { | ||
| 143 | #ifndef NO_32_BIT_TYPE | ||
| 144 | group->field_mod_func = BN_nist_mod_224; | 138 | group->field_mod_func = BN_nist_mod_224; |
| 145 | #else | ||
| 146 | ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE, EC_R_NOT_A_SUPPORTED_NIST_PRIME); | ||
| 147 | goto err; | ||
| 148 | #endif | ||
| 149 | } | ||
| 150 | else if (BN_ucmp(BN_get0_nist_prime_256(), p) == 0) | 139 | else if (BN_ucmp(BN_get0_nist_prime_256(), p) == 0) |
| 151 | { | ||
| 152 | #ifndef NO_32_BIT_TYPE | ||
| 153 | group->field_mod_func = BN_nist_mod_256; | 140 | group->field_mod_func = BN_nist_mod_256; |
| 154 | #else | ||
| 155 | ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE, EC_R_NOT_A_SUPPORTED_NIST_PRIME); | ||
| 156 | goto err; | ||
| 157 | #endif | ||
| 158 | } | ||
| 159 | else if (BN_ucmp(BN_get0_nist_prime_384(), p) == 0) | 141 | else if (BN_ucmp(BN_get0_nist_prime_384(), p) == 0) |
| 160 | { | ||
| 161 | #ifndef NO_32_BIT_TYPE | ||
| 162 | group->field_mod_func = BN_nist_mod_384; | 142 | group->field_mod_func = BN_nist_mod_384; |
| 163 | #else | ||
| 164 | ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE, EC_R_NOT_A_SUPPORTED_NIST_PRIME); | ||
| 165 | goto err; | ||
| 166 | #endif | ||
| 167 | } | ||
| 168 | else if (BN_ucmp(BN_get0_nist_prime_521(), p) == 0) | 143 | else if (BN_ucmp(BN_get0_nist_prime_521(), p) == 0) |
| 169 | /* this one works in the NO_32_BIT_TYPE case */ | ||
| 170 | group->field_mod_func = BN_nist_mod_521; | 144 | group->field_mod_func = BN_nist_mod_521; |
| 171 | else | 145 | else |
| 172 | { | 146 | { |
