diff options
author | Bodo Möller <bodo@openssl.org> | 2002-08-15 09:21:31 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 2002-08-15 09:21:31 +0000 |
commit | 7eb18f1237f517d7072c6d5d4602b68c8e0a1a21 (patch) | |
tree | 540d2a01ec526fdc3429275b87b95678661da158 /crypto | |
parent | 265e892fede07013088e383bc630b8186c8b6e7c (diff) |
Simplify handling of named curves: get rid of EC_GROUP_new_by_name(),
EC_GROUP_new_by_nid() should be enough. This avoids a lot of
redundancy.
Submitted by: Nils Larsch
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/ec/Makefile.ssl | 11 | ||||
-rw-r--r-- | crypto/ec/ec.h | 234 | ||||
-rw-r--r-- | crypto/ec/ec_asn1.c | 2 | ||||
-rw-r--r-- | crypto/ec/ec_curve.c | 1849 | ||||
-rw-r--r-- | crypto/ec/ec_err.c | 17 | ||||
-rw-r--r-- | crypto/ecdh/ecdhtest.c | 32 | ||||
-rw-r--r-- | crypto/ecdsa/ecdsatest.c | 36 |
7 files changed, 1221 insertions, 960 deletions
diff --git a/crypto/ec/Makefile.ssl b/crypto/ec/Makefile.ssl index d183f679c4..431a14c8a6 100644 --- a/crypto/ec/Makefile.ssl +++ b/crypto/ec/Makefile.ssl @@ -118,12 +118,11 @@ ec_check.o: ../../include/openssl/obj_mac.h ../../include/openssl/opensslconf.h ec_check.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h ec_check.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h ec_check.o: ../../include/openssl/symhacks.h ec_check.c ec_lcl.h -ec_curve.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h -ec_curve.o: ../../include/openssl/bio.h ../../include/openssl/bn.h -ec_curve.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h -ec_curve.o: ../../include/openssl/ec.h ../../include/openssl/err.h -ec_curve.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h -ec_curve.o: ../../include/openssl/opensslconf.h +ec_curve.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +ec_curve.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h +ec_curve.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h +ec_curve.o: ../../include/openssl/err.h ../../include/openssl/lhash.h +ec_curve.o: ../../include/openssl/obj_mac.h ../../include/openssl/opensslconf.h ec_curve.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h ec_curve.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h ec_curve.o: ../../include/openssl/symhacks.h ec_curve.c ec_lcl.h diff --git a/crypto/ec/ec.h b/crypto/ec/ec.h index 17083f23a2..4eb4ad678c 100644 --- a/crypto/ec/ec.h +++ b/crypto/ec/ec.h @@ -182,94 +182,15 @@ int EC_GROUP_check_discriminant(const EC_GROUP *, BN_CTX *); EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); -/* EC_GROUP_new_by_nid() and EC_GROUP_new_by_name() also set - * generator and order */ +/* EC_GROUP_new_by_nid() creates a EC_GROUP structure specified by a NID */ EC_GROUP *EC_GROUP_new_by_nid(int nid); -EC_GROUP *EC_GROUP_new_by_name(int name); -/* Currently valid arguments to EC_GROUP_new_by_name() */ -#define EC_GROUP_NO_CURVE 0 -#define EC_GROUP_NIST_PRIME_192 NID_X9_62_prime192v1 -#define EC_GROUP_NIST_PRIME_224 NID_secp224r1 -#define EC_GROUP_NIST_PRIME_256 NID_X9_62_prime256v1 -#define EC_GROUP_NIST_PRIME_384 NID_secp384r1 -#define EC_GROUP_NIST_PRIME_521 NID_secp521r1 -#define EC_GROUP_X9_62_PRIME_192V1 NID_X9_62_prime192v1 -#define EC_GROUP_X9_62_PRIME_192V2 NID_X9_62_prime192v2 -#define EC_GROUP_X9_62_PRIME_192V3 NID_X9_62_prime192v3 -#define EC_GROUP_X9_62_PRIME_239V1 NID_X9_62_prime239v1 -#define EC_GROUP_X9_62_PRIME_239V2 NID_X9_62_prime239v2 -#define EC_GROUP_X9_62_PRIME_239V3 NID_X9_62_prime239v3 -#define EC_GROUP_X9_62_PRIME_256V1 NID_X9_62_prime256v1 -#define EC_GROUP_SECG_PRIME_112R1 NID_secp112r1 -#define EC_GROUP_SECG_PRIME_112R2 NID_secp112r2 -#define EC_GROUP_SECG_PRIME_128R1 NID_secp128r1 -#define EC_GROUP_SECG_PRIME_128R2 NID_secp128r2 -#define EC_GROUP_SECG_PRIME_160K1 NID_secp160k1 -#define EC_GROUP_SECG_PRIME_160R1 NID_secp160r1 -#define EC_GROUP_SECG_PRIME_160R2 NID_secp160r2 -#define EC_GROUP_SECG_PRIME_192K1 NID_secp192k1 -#define EC_GROUP_SECG_PRIME_192R1 NID_X9_62_prime192v1 -#define EC_GROUP_SECG_PRIME_224K1 NID_secp224k1 -#define EC_GROUP_SECG_PRIME_224R1 NID_secp224r1 -#define EC_GROUP_SECG_PRIME_256K1 NID_secp256k1 -#define EC_GROUP_SECG_PRIME_256R1 NID_X9_62_prime256v1 -#define EC_GROUP_SECG_PRIME_384R1 NID_secp384r1 -#define EC_GROUP_SECG_PRIME_521R1 NID_secp521r1 -#define EC_GROUP_WTLS_6 NID_wap_wsg_idm_ecid_wtls6 -#define EC_GROUP_WTLS_7 NID_wap_wsg_idm_ecid_wtls7 -#define EC_GROUP_WTLS_8 NID_wap_wsg_idm_ecid_wtls8 -#define EC_GROUP_WTLS_9 NID_wap_wsg_idm_ecid_wtls9 -#define EC_GROUP_WTLS_12 NID_wap_wsg_idm_ecid_wtls12 -#define EC_GROUP_NIST_CHAR2_K163 NID_sect163k1 -#define EC_GROUP_NIST_CHAR2_B163 NID_sect163r2 -#define EC_GROUP_NIST_CHAR2_K233 NID_sect233k1 -#define EC_GROUP_NIST_CHAR2_B233 NID_sect233r1 -#define EC_GROUP_NIST_CHAR2_K283 NID_sect283k1 -#define EC_GROUP_NIST_CHAR2_B283 NID_sect283r1 -#define EC_GROUP_NIST_CHAR2_K409 NID_sect409k1 -#define EC_GROUP_NIST_CHAR2_B409 NID_sect409r1 -#define EC_GROUP_NIST_CHAR2_K571 NID_sect571k1 -#define EC_GROUP_NIST_CHAR2_B571 NID_sect571r1 -#define EC_GROUP_X9_62_CHAR2_163V1 NID_X9_62_c2pnb163v1 -#define EC_GROUP_X9_62_CHAR2_163V2 NID_X9_62_c2pnb163v2 -#define EC_GROUP_X9_62_CHAR2_163V3 NID_X9_62_c2pnb163v3 -#define EC_GROUP_X9_62_CHAR2_176V1 NID_X9_62_c2pnb176v1 -#define EC_GROUP_X9_62_CHAR2_191V1 NID_X9_62_c2tnb191v1 -#define EC_GROUP_X9_62_CHAR2_191V2 NID_X9_62_c2tnb191v2 -#define EC_GROUP_X9_62_CHAR2_191V3 NID_X9_62_c2tnb191v3 -#define EC_GROUP_X9_62_CHAR2_208W1 NID_X9_62_c2pnb208w1 -#define EC_GROUP_X9_62_CHAR2_239V1 NID_X9_62_c2tnb239v1 -#define EC_GROUP_X9_62_CHAR2_239V2 NID_X9_62_c2tnb239v2 -#define EC_GROUP_X9_62_CHAR2_239V3 NID_X9_62_c2tnb239v3 -#define EC_GROUP_X9_62_CHAR2_272W1 NID_X9_62_c2pnb272w1 -#define EC_GROUP_X9_62_CHAR2_304W1 NID_X9_62_c2pnb304w1 -#define EC_GROUP_X9_62_CHAR2_359V1 NID_X9_62_c2tnb359v1 -#define EC_GROUP_X9_62_CHAR2_368W1 NID_X9_62_c2pnb368w1 -#define EC_GROUP_X9_62_CHAR2_431R1 NID_X9_62_c2tnb431r1 -#define EC_GROUP_SECG_CHAR2_113R1 NID_sect113r1 -#define EC_GROUP_SECG_CHAR2_113R2 NID_sect113r2 -#define EC_GROUP_SECG_CHAR2_131R1 NID_sect131r1 -#define EC_GROUP_SECG_CHAR2_131R2 NID_sect131r2 -#define EC_GROUP_SECG_CHAR2_163K1 NID_sect163k1 -#define EC_GROUP_SECG_CHAR2_163R1 NID_sect163r1 -#define EC_GROUP_SECG_CHAR2_163R2 NID_sect163r2 -#define EC_GROUP_SECG_CHAR2_193R1 NID_sect193r1 -#define EC_GROUP_SECG_CHAR2_193R2 NID_sect193r2 -#define EC_GROUP_SECG_CHAR2_233K1 NID_sect233k1 -#define EC_GROUP_SECG_CHAR2_233R1 NID_sect233r1 -#define EC_GROUP_SECG_CHAR2_239K1 NID_sect239k1 -#define EC_GROUP_SECG_CHAR2_283K1 NID_sect283k1 -#define EC_GROUP_SECG_CHAR2_283R1 NID_sect283r1 -#define EC_GROUP_SECG_CHAR2_409K1 NID_sect409k1 -#define EC_GROUP_SECG_CHAR2_409R1 NID_sect409r1 -#define EC_GROUP_SECG_CHAR2_571K1 NID_sect571k1 -#define EC_GROUP_SECG_CHAR2_571R1 NID_sect571r1 -#define EC_GROUP_WTLS_1 NID_wap_wsg_idm_ecid_wtls1 -#define EC_GROUP_WTLS_3 NID_wap_wsg_idm_ecid_wtls3 -#define EC_GROUP_WTLS_4 NID_wap_wsg_idm_ecid_wtls4 -#define EC_GROUP_WTLS_5 NID_wap_wsg_idm_ecid_wtls5 -#define EC_GROUP_WTLS_10 NID_wap_wsg_idm_ecid_wtls10 -#define EC_GROUP_WTLS_11 NID_wap_wsg_idm_ecid_wtls11 +/* EC_GROUP_get0_comment() returns a pointer to the 'comment' field of + * ec_curve_data_st structure */ +const char *EC_GROUP_get0_comment(int nid); +/* internal function : ec_group_index2nid() returns the NID of curve + * with the given index i from the internal curve list */ +int ec_group_index2nid(int i); + EC_POINT *EC_POINT_new(const EC_GROUP *); void EC_POINT_free(EC_POINT *); @@ -426,111 +347,109 @@ void ERR_load_EC_strings(void); /* Function codes. */ #define EC_F_COMPUTE_WNAF 143 -#define EC_F_D2I_ECPARAMETERS 155 -#define EC_F_D2I_ECPKPARAMETERS 161 -#define EC_F_D2I_ECPRIVATEKEY 168 -#define EC_F_ECPARAMETERS_PRINT 173 -#define EC_F_ECPARAMETERS_PRINT_FP 174 -#define EC_F_ECPKPARAMETERS_PRINT 166 -#define EC_F_ECPKPARAMETERS_PRINT_FP 167 -#define EC_F_ECPUBLICKEY_GET_OCTET 170 -#define EC_F_ECPUBLICKEY_SET_OCTET 171 -#define EC_F_EC_ASN1_GROUP2CURVE 159 -#define EC_F_EC_ASN1_GROUP2FIELDID 156 -#define EC_F_EC_ASN1_GROUP2PARAMETERS 160 -#define EC_F_EC_ASN1_GROUP2PKPARAMETERS 162 +#define EC_F_D2I_ECPARAMETERS 144 +#define EC_F_D2I_ECPKPARAMETERS 145 +#define EC_F_D2I_ECPRIVATEKEY 146 +#define EC_F_ECPARAMETERS_PRINT 147 +#define EC_F_ECPARAMETERS_PRINT_FP 148 +#define EC_F_ECPKPARAMETERS_PRINT 149 +#define EC_F_ECPKPARAMETERS_PRINT_FP 150 +#define EC_F_ECPUBLICKEY_GET_OCTET 151 +#define EC_F_ECPUBLICKEY_SET_OCTET 152 +#define EC_F_EC_ASN1_GROUP2CURVE 153 +#define EC_F_EC_ASN1_GROUP2FIELDID 154 +#define EC_F_EC_ASN1_GROUP2PARAMETERS 155 +#define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156 #define EC_F_EC_ASN1_PARAMETERS2GROUP 157 -#define EC_F_EC_ASN1_PKPARAMETERS2GROUP 163 -#define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 168 -#define EC_F_EC_GF2M_SIMPLE_OCT2POINT 169 -#define EC_F_EC_GF2M_SIMPLE_POINT2OCT 170 -#define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 171 -#define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 172 -#define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 182 +#define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158 +#define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159 +#define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160 +#define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161 +#define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162 +#define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163 +#define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164 #define EC_F_EC_GFP_MONT_FIELD_DECODE 133 #define EC_F_EC_GFP_MONT_FIELD_ENCODE 134 #define EC_F_EC_GFP_MONT_FIELD_MUL 131 #define EC_F_EC_GFP_MONT_FIELD_SQR 132 -#define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 152 -#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 100 +#define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100 #define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101 #define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102 #define EC_F_EC_GFP_SIMPLE_OCT2POINT 103 #define EC_F_EC_GFP_SIMPLE_POINT2OCT 104 #define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137 -#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 105 -#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 128 -#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 129 -#define EC_F_EC_GROUP_CHECK 150 -#define EC_F_EC_GROUP_CHECK_DISCRIMINANT 153 +#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167 +#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105 +#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168 +#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128 +#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169 +#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129 +#define EC_F_EC_GROUP_CHECK 170 +#define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171 #define EC_F_EC_GROUP_COPY 106 #define EC_F_EC_GROUP_GET0_GENERATOR 139 #define EC_F_EC_GROUP_GET_COFACTOR 140 -#define EC_F_EC_GROUP_GET_CURVE_GF2M 173 +#define EC_F_EC_GROUP_GET_CURVE_GF2M 172 #define EC_F_EC_GROUP_GET_CURVE_GFP 130 -#define EC_F_EC_GROUP_GET_DEGREE 174 +#define EC_F_EC_GROUP_GET_DEGREE 173 #define EC_F_EC_GROUP_GET_EXTRA_DATA 107 #define EC_F_EC_GROUP_GET_ORDER 141 #define EC_F_EC_GROUP_GROUP2NID 147 #define EC_F_EC_GROUP_NEW 108 -#define EC_F_EC_GROUP_NEW_BY_NAME 144 -#define EC_F_EC_GROUP_NEW_BY_NID 146 -#define EC_F_EC_GROUP_NEW_GF2M_FROM_HEX 175 -#define EC_F_EC_GROUP_NEW_GFP_FROM_HEX 148 +#define EC_F_EC_GROUP_NEW_BY_NID 174 +#define EC_F_EC_GROUP_NEW_FROM_DATA 175 #define EC_F_EC_GROUP_PRECOMPUTE_MULT 142 #define EC_F_EC_GROUP_SET_CURVE_GF2M 176 #define EC_F_EC_GROUP_SET_CURVE_GFP 109 #define EC_F_EC_GROUP_SET_EXTRA_DATA 110 #define EC_F_EC_GROUP_SET_GENERATOR 111 -#define EC_F_EC_KEY_CHECK_KEY 184 -#define EC_F_EC_KEY_COPY 186 -#define EC_F_EC_KEY_GENERATE_KEY 185 -#define EC_F_EC_KEY_PRINT 175 -#define EC_F_EC_KEY_PRINT_FP 176 -#define EC_F_EC_NEW 172 +#define EC_F_EC_KEY_CHECK_KEY 177 +#define EC_F_EC_KEY_COPY 178 +#define EC_F_EC_KEY_GENERATE_KEY 179 +#define EC_F_EC_KEY_PRINT 180 +#define EC_F_EC_KEY_PRINT_FP 181 +#define EC_F_EC_NEW 182 #define EC_F_EC_POINTS_MAKE_AFFINE 136 #define EC_F_EC_POINTS_MUL 138 #define EC_F_EC_POINT_ADD 112 #define EC_F_EC_POINT_CMP 113 #define EC_F_EC_POINT_COPY 114 #define EC_F_EC_POINT_DBL 115 -#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 177 +#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183 #define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116 #define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117 #define EC_F_EC_POINT_IS_AT_INFINITY 118 #define EC_F_EC_POINT_IS_ON_CURVE 119 #define EC_F_EC_POINT_MAKE_AFFINE 120 -#define EC_F_EC_POINT_MUL 179 +#define EC_F_EC_POINT_MUL 184 #define EC_F_EC_POINT_NEW 121 #define EC_F_EC_POINT_OCT2POINT 122 #define EC_F_EC_POINT_POINT2OCT 123 -#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 180 +#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185 #define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124 -#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 181 +#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186 #define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125 #define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126 #define EC_F_EC_POINT_SET_TO_INFINITY 127 -#define EC_F_EC_WNAF_MUL 183 -#define EC_F_EC_WNAF_PRECOMPUTE_MULT 178 -#define EC_F_GFP_MONT_GROUP_SET_CURVE 135 -#define EC_F_I2D_ECDSAPARAMETERS 158 -#define EC_F_I2D_ECPARAMETERS 164 -#define EC_F_I2D_ECPKPARAMETERS 165 -#define EC_F_I2D_ECPRIVATEKEY 169 +#define EC_F_EC_WNAF_MUL 187 +#define EC_F_EC_WNAF_PRECOMPUTE_MULT 188 +#define EC_F_GFP_MONT_GROUP_SET_CURVE 189 +#define EC_F_GFP_MONT_GROUP_SET_CURVE_GFP 135 +#define EC_F_I2D_ECPARAMETERS 190 +#define EC_F_I2D_ECPKPARAMETERS 191 +#define EC_F_I2D_ECPRIVATEKEY 192 /* Reason codes. */ -#define EC_R_ASN1_ERROR 130 -#define EC_R_ASN1_UNKNOWN_FIELD 131 +#define EC_R_ASN1_ERROR 115 +#define EC_R_ASN1_UNKNOWN_FIELD 116 #define EC_R_BUFFER_TOO_SMALL 100 -#define EC_R_D2I_ECPARAMETERS_FAILURE 132 -#define EC_R_D2I_ECPKPARAMETERS_FAILURE 133 -#define EC_R_D2I_EC_PARAMETERS_FAILURE 123 +#define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 #define EC_R_DISCRIMINANT_IS_ZERO 118 -#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 124 -#define EC_R_GROUP2PARAMETERS_FAILURE 125 -#define EC_R_GROUP2PKPARAMETERS_FAILURE 134 -#define EC_R_I2D_ECPKPARAMETERS_FAILURE 135 -#define EC_R_I2D_EC_PARAMETERS_FAILURE 126 +#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 +#define EC_R_GROUP2PKPARAMETERS_FAILURE 120 +#define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 #define EC_R_INCOMPATIBLE_OBJECTS 101 #define EC_R_INVALID_ARGUMENT 112 #define EC_R_INVALID_COMPRESSED_POINT 110 @@ -538,25 +457,22 @@ void ERR_load_EC_strings(void); #define EC_R_INVALID_ENCODING 102 #define EC_R_INVALID_FIELD 103 #define EC_R_INVALID_FORM 104 -#define EC_R_INVALID_GROUP_ORDER 119 -#define EC_R_INVALID_PRIVATE_KEY 139 -#define EC_R_MISSING_PARAMETERS 127 -#define EC_R_MISSING_PRIVATE_KEY 138 -#define EC_R_NOT_IMPLEMENTED 136 +#define EC_R_INVALID_GROUP_ORDER 122 +#define EC_R_INVALID_PRIVATE_KEY 123 +#define EC_R_MISSING_PARAMETERS 124 +#define EC_R_MISSING_PRIVATE_KEY 125 +#define EC_R_NOT_IMPLEMENTED 126 #define EC_R_NOT_INITIALIZED 111 #define EC_R_NO_SUCH_EXTRA_DATA 105 -#define EC_R_PARAMETERS2GROUP_FAILURE 128 -#define EC_R_PKPARAMETERS2GROUP_FAILURE 137 +#define EC_R_PKPARAMETERS2GROUP_FAILURE 127 #define EC_R_POINT_AT_INFINITY 106 #define EC_R_POINT_IS_NOT_ON_CURVE 107 #define EC_R_SLOT_FULL 108 #define EC_R_UNDEFINED_GENERATOR 113 -#define EC_R_UNDEFINED_ORDER 122 -#define EC_R_UNKNOWN_GROUP 116 -#define EC_R_UNKNOWN_NID 117 +#define EC_R_UNDEFINED_ORDER 128 +#define EC_R_UNKNOWN_GROUP 129 #define EC_R_UNKNOWN_ORDER 114 -#define EC_R_UNKNOWN_PARAMETERS_TYPE 129 -#define EC_R_WRONG_ORDER 140 +#define EC_R_WRONG_ORDER 130 #ifdef __cplusplus } diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c index c1879dc510..8aa07c4dce 100644 --- a/crypto/ec/ec_asn1.c +++ b/crypto/ec/ec_asn1.c @@ -770,7 +770,7 @@ EC_GROUP *EC_ASN1_pkparameters2group(const ECPKPARAMETERS *params) if (params->type == 0) { /* the curve is given by an OID */ tmp = OBJ_obj2nid(params->value.named_curve); - if ((ret = EC_GROUP_new_by_name(tmp)) == NULL) + if ((ret = EC_GROUP_new_by_nid(tmp)) == NULL) { ECerr(EC_F_EC_ASN1_PKPARAMETERS2GROUP, EC_R_EC_GROUP_NEW_BY_NAME_FAILURE); diff --git a/crypto/ec/ec_curve.c b/crypto/ec/ec_curve.c index 55ce45d8cf..93f775d556 100644 --- a/crypto/ec/ec_curve.c +++ b/crypto/ec/ec_curve.c @@ -1,4 +1,7 @@ /* crypto/ec/ec_curve.c */ +/* + * Written by Nils Larsch for the OpenSSL project. + */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -82,793 +85,1141 @@ #include "ec_lcl.h" #include <openssl/err.h> #include <openssl/obj_mac.h> -#include <openssl/asn1.h> -#include <openssl/asn1t.h> -/* #define _EC_GROUP_EXAMPLE_PRIME_CURVE \ - * "the prime number p", "a", "b", "the compressed base point", "y-bit", "order", "cofactor" - */ +typedef struct ec_curve_data_st { + int field_type; /* either NID_X9_62_prime_field or + * NID_X9_62_characteristic_two_field */ + const char *p; /* either a prime number or a polynomial */ + const char *a; + const char *b; + const char *x; /* the x coordinate of the generator */ + const char *y; /* the y coordinate of the generator */ + const char *order; /* the order of the group generated by the + * generator */ + const BN_ULONG cofactor;/* the cofactor */ + const unsigned char *seed;/* the seed (optional) */ + size_t seed_len; + const char *comment; /* a short (less than 80 characters) + * description of the curve */ +} EC_CURVE_DATA; + /* the nist prime curves */ -#define _EC_GROUP_NIST_PRIME_192 \ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF",\ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC",\ - "64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1",\ - "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012",1,\ - "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831",1 -#define _EC_GROUP_NIST_PRIME_224 \ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001",\ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE",\ - "B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4",\ - "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21",0,\ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D",1 -#define _EC_GROUP_NIST_PRIME_384 \ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF",\ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC",\ - "B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF",\ - "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7",1,\ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973",1 -#define _EC_GROUP_NIST_PRIME_521 \ - "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",\ - "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC",\ - "051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B"\ - "315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00",\ - "C6858E06B70404E9CD9E3ECB662395B4429C648139053F"\ - "B521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66",0,\ - "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\ - "FFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409",1 +static const unsigned char _EC_NIST_PRIME_192_SEED[] = { + 0x30,0x45,0xAE,0x6F,0xC8,0x42,0x2F,0x64,0xED,0x57, + 0x95,0x28,0xD3,0x81,0x20,0xEA,0xE1,0x21,0x96,0xD5}; +static const EC_CURVE_DATA _EC_NIST_PRIME_192 = { + NID_X9_62_prime_field, + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC", + "64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1", + "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012", + "07192b95ffc8da78631011ed6b24cdd573f977a11e794811", + "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831",1, + _EC_NIST_PRIME_192_SEED, 20, + "192 bit prime curve from the X9.62 draft" + }; + +static const unsigned char _EC_NIST_PRIME_224_SEED[] = { + 0xBD,0x71,0x34,0x47,0x99,0xD5,0xC7,0xFC,0xDC,0x45, + 0xB5,0x9F,0xA3,0xB9,0xAB,0x8F,0x6A,0x94,0x8B,0xC5}; +static const EC_CURVE_DATA _EC_NIST_PRIME_224 = { + NID_X9_62_prime_field, + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE", + "B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4", + "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21", + "bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D",1, + _EC_NIST_PRIME_224_SEED, 20, + "SECG/NIST recommended curve over a 224 bit prime field" + }; + +static const unsigned char _EC_NIST_PRIME_384_SEED[] = { + 0xA3,0x35,0x92,0x6A,0xA3,0x19,0xA2,0x7A,0x1D,0x00, + 0x89,0x6A,0x67,0x73,0xA4,0x82,0x7A,0xCD,0xAC,0x73}; +static const EC_CURVE_DATA _EC_NIST_PRIME_384 = { + NID_X9_62_prime_field, + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFF" + "FFF0000000000000000FFFFFFFF", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFF" + "FFF0000000000000000FFFFFFFC", + "B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC6563" + "98D8A2ED19D2A85C8EDD3EC2AEF", + "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F" + "25DBF55296C3A545E3872760AB7", + "3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b" + "1ce1d7e819d7a431d7c90ea0e5f", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0" + "DB248B0A77AECEC196ACCC52973",1, + _EC_NIST_PRIME_384_SEED, 20, + "SECG/NIST recommended curve over a 384 bit prime field" + }; + +static const unsigned char _EC_NIST_PRIME_521_SEED[] = { + 0xD0,0x9E,0x88,0x00,0x29,0x1C,0xB8,0x53,0x96,0xCC, + 0x67,0x17,0x39,0x32,0x84,0xAA,0xA0,0xDA,0x64,0xBA}; +static const EC_CURVE_DATA _EC_NIST_PRIME_521 = { + NID_X9_62_prime_field, + "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", + "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC", + "051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156" + "193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00", + "C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14" + "B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66", + "011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c9" + "7ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650", + "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51" + "868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409",1, + _EC_NIST_PRIME_521_SEED, 20, + "SECG/NIST recommended curve over a 521 bit prime field" + }; /* the x9.62 prime curves (minus the nist prime curves) */ -#define _EC_GROUP_X9_62_PRIME_192V2 \ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF",\ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC",\ - "CC22D6DFB95C6B25E49C0D6364A4E5980C393AA21668D953",\ - "EEA2BAE7E1497842F2DE7769CFE9C989C072AD696F48034A",1,\ - "FFFFFFFFFFFFFFFFFFFFFFFE5FB1A724DC80418648D8DD31",1 -#define _EC_GROUP_X9_62_PRIME_192V3 \ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF",\ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC",\ - "22123DC2395A05CAA7423DAECCC94760A7D462256BD56916",\ - "7D29778100C65A1DA1783716588DCE2B8B4AEE8E228F1896",0,\ - "FFFFFFFFFFFFFFFFFFFFFFFF7A62D031C83F4294F640EC13",1 -#define _EC_GROUP_X9_62_PRIME_239V1 \ - "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFF",\ - "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFC",\ - "6B016C3BDCF18941D0D654921475CA71A9DB2FB27D1D37796185C2942C0A",\ - "0FFA963CDCA8816CCC33B8642BEDF905C3D358573D3F27FBBD3B3CB9AAAF",0,\ - "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFF9E5E9A9F5D9071FBD1522688909D0B",1 -#define _EC_GROUP_X9_62_PRIME_239V2 \ - "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFF",\ - "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFC",\ - "617FAB6832576CBBFED50D99F0249C3FEE58B94BA0038C7AE84C8C832F2C",\ - "38AF09D98727705120C921BB5E9E26296A3CDCF2F35757A0EAFD87B830E7",0,\ - "7FFFFFFFFFFFFFFFFFFFFFFF800000CFA7E8594377D414C03821BC582063",1 -#define _EC_GROUP_X9_62_PRIME_239V3 \ - "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFF",\ - "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFC",\ - "255705FA2A306654B1F4CB03D6A750A30C250102D4988717D9BA15AB6D3E",\ - "6768AE8E18BB92CFCF005C949AA2C6D94853D0E660BBF854B1C9505FE95A",1,\ - "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFF975DEB41B3A6057C3C432146526551",1 -#define _EC_GROUP_X9_62_PRIME_256V1 \ - "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF",\ - "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC",\ - "5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B",\ - "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296",1,\ - "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551",1 +static const unsigned char _EC_X9_62_PRIME_192V2_SEED[] = { + 0x31,0xA9,0x2E,0xE2,0x02,0x9F,0xD1,0x0D,0x90,0x1B, + 0x11,0x3E,0x99,0x07,0x10,0xF0,0xD2,0x1A,0xC6,0xB6}; +static const EC_CURVE_DATA _EC_X9_62_PRIME_192V2 = { + NID_X9_62_prime_field, + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC", + "CC22D6DFB95C6B25E49C0D6364A4E5980C393AA21668D953", + "EEA2BAE7E1497842F2DE7769CFE9C989C072AD696F48034A", + "6574d11d69b6ec7a672bb82a083df2f2b0847de970b2de15", + "FFFFFFFFFFFFFFFFFFFFFFFE5FB1A724DC80418648D8DD31",1, + _EC_X9_62_PRIME_192V2_SEED, 20, + "192 bit prime curve from the X9.62 draft" + }; + +static const unsigned char _EC_X9_62_PRIME_192V3_SEED[] = { + 0xC4,0x69,0x68,0x44,0x35,0xDE,0xB3,0x78,0xC4,0xB6, + 0x5C,0xA9,0x59,0x1E,0x2A,0x57,0x63,0x05,0x9A,0x2E}; +static const EC_CURVE_DATA _EC_X9_62_PRIME_192V3 = { + NID_X9_62_prime_field, + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC", + "22123DC2395A05CAA7423DAECCC94760A7D462256BD56916", + "7D29778100C65A1DA1783716588DCE2B8B4AEE8E228F1896", + "38a90f22637337334b49dcb66a6dc8f9978aca7648a943b0", + "FFFFFFFFFFFFFFFFFFFFFFFF7A62D031C83F4294F640EC13",1, + _EC_X9_62_PRIME_192V3_SEED, 20, + "192 bit prime curve from the X9.62 draft" + }; + +static const unsigned char _EC_X9_62_PRIME_239V1_SEED[] = { + 0xE4,0x3B,0xB4,0x60,0xF0,0xB8,0x0C,0xC0,0xC0,0xB0, + 0x75,0x79,0x8E,0x94,0x80,0x60,0xF8,0x32,0x1B,0x7D}; +static const EC_CURVE_DATA _EC_X9_62_PRIME_239V1 = { + NID_X9_62_prime_field, + "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFF", + "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFC", + "6B016C3BDCF18941D0D654921475CA71A9DB2FB27D1D37796185C2942C0A", + "0FFA963CDCA8816CCC33B8642BEDF905C3D358573D3F27FBBD3B3CB9AAAF", + "7debe8e4e90a5dae6e4054ca530ba04654b36818ce226b39fccb7b02f1ae", + "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFF9E5E9A9F5D9071FBD1522688909D0B",1, + _EC_X9_62_PRIME_239V1_SEED, 20, + "239 bit prime curve from the X9.62 draft" + }; + +static const unsigned char _EC_X9_62_PRIME_239V2_SEED[] = { + 0xE8,0xB4,0x01,0x16,0x04,0x09,0x53,0x03,0xCA,0x3B, + 0x80,0x99,0x98,0x2B,0xE0,0x9F,0xCB,0x9A,0xE6,0x16}; +static const EC_CURVE_DATA _EC_X9_62_PRIME_239V2 = { + NID_X9_62_prime_field, + "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFF", + "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFC", + "617FAB6832576CBBFED50D99F0249C3FEE58B94BA0038C7AE84C8C832F2C", + "38AF09D98727705120C921BB5E9E26296A3CDCF2F35757A0EAFD87B830E7", + "5b0125e4dbea0ec7206da0fc01d9b081329fb555de6ef460237dff8be4ba", + "7FFFFFFFFFFFFFFFFFFFFFFF800000CFA7E8594377D414C03821BC582063",1, + _EC_X9_62_PRIME_239V2_SEED, 20, + "239 bit prime curve from the X9.62 draft" + }; + +static const unsigned char _EC_X9_62_PRIME_239V3_SEED[] = { + 0x7D,0x73,0x74,0x16,0x8F,0xFE,0x34,0x71,0xB6,0x0A, + 0x85,0x76,0x86,0xA1,0x94,0x75,0xD3,0xBF,0xA2,0xFF}; +static const EC_CURVE_DATA _EC_X9_62_PRIME_239V3 = { + NID_X9_62_prime_field, + "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFF", + "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFF8000000000007FFFFFFFFFFC", + "255705FA2A306654B1F4CB03D6A750A30C250102D4988717D9BA15AB6D3E", + "6768AE8E18BB92CFCF005C949AA2C6D94853D0E660BBF854B1C9505FE95A", + "1607e6898f390c06bc1d552bad226f3b6fcfe48b6e818499af18e3ed6cf3", + "7FFFFFFFFFFFFFFFFFFFFFFF7FFFFF975DEB41B3A6057C3C432146526551",1, + _EC_X9_62_PRIME_239V3_SEED, 20, + "239 bit prime curve from the X9.62 draft" + }; + +static const unsigned char _EC_X9_62_PRIME_256V1_SEED[] = { + 0xC4,0x9D,0x36,0x08,0x86,0xE7,0x04,0x93,0x6A,0x66, + 0x78,0xE1,0x13,0x9D,0x26,0xB7,0x81,0x9F,0x7E,0x90}; +static const EC_CURVE_DATA _EC_X9_62_PRIME_256V1 = { + NID_X9_62_prime_field, + "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", + "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC", + "5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B", + "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", + "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5", + "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551",1, + _EC_X9_62_PRIME_256V1_SEED, 20, + "256 bit prime curve from the X9.62 draft" + }; /* the secg prime curves (minus the nist and x9.62 prime curves) */ -#define _EC_GROUP_SECG_PRIME_112R1 \ - "DB7C2ABF62E35E668076BEAD208B",\ - "DB7C2ABF62E35E668076BEAD2088",\ - "659EF8BA043916EEDE8911702B22",\ - "09487239995A5EE76B55F9C2F098",0,\ - "DB7C2ABF62E35E7628DFAC6561C5",1 -#define _EC_GROUP_SECG_PRIME_112R2 \ - "DB7C2ABF62E35E668076BEAD208B",\ - "6127C24C05F38A0AAAF65C0EF02C",\ - "51DEF1815DB5ED74FCC34C85D709",\ - "4BA30AB5E892B4E1649DD0928643",1,\ - "36DF0AAFD8B8D7597CA10520D04B",4 -#define _EC_GROUP_SECG_PRIME_128R1 \ - "FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF",\ - "FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC",\ - "E87579C11079F43DD824993C2CEE5ED3",\ - "161FF7528B899B2D0C28607CA52C5B86",1,\ - "FFFFFFFE0000000075A30D1B9038A115",1 -#define _EC_GROUP_SECG_PRIME_128R2 \ - "FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF",\ - "D6031998D1B3BBFEBF59CC9BBFF9AEE1",\ - "5EEEFCA380D02919DC2C6558BB6D8A5D",\ - "7B6AA5D85E572983E6FB32A7CDEBC140",0,\ - "3FFFFFFF7FFFFFFFBE0024720613B5A3",4 -#define _EC_GROUP_SECG_PRIME_160K1 \ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73",\ - "0",\ - "7",\ - "3B4C382CE37AA192A4019E763036F4F5DD4D7EBB",0,\ - "0100000000000000000001B8FA16DFAB9ACA16B6B3",1 -#define _EC_GROUP_SECG_PRIME_160R1 \ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF",\ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC",\ - "1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45",\ - "4A96B5688EF573284664698968C38BB913CBFC82",0,\ - "0100000000000000000001F4C8F927AED3CA752257",1 -#define _EC_GROUP_SECG_PRIME_160R2 \ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73",\ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC70",\ - "B4E134D3FB59EB8BAB57274904664D5AF50388BA",\ - "52DCB034293A117E1F4FF11B30F7199D3144CE6D",0,\ - "0100000000000000000000351EE786A818F3A1A16B",1 -#define _EC_GROUP_SECG_PRIME_192K1 \ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37",\ - "0",\ - "3",\ - "DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D",1,\ - "FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D",1 -#define _EC_GROUP_SECG_PRIME_224K1 \ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFE56D",\ - "0",\ - "5",\ - "A1455B334DF099DF30FC28A169A467E9E47075A90F7E650EB6B7A45C",1,\ - "010000000000000000000000000001DCE8D2EC6184CAF0A971769FB1F7",1 -#define _EC_GROUP_SECG_PRIME_256K1 \ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F",\ - "0",\ - "7",\ - "79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798",0,\ - "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141",1 +static const unsigned char _EC_SECG_PRIME_112R1_SEED[] = { + 0x00,0xF5,0x0B,0x02,0x8E,0x4D,0x69,0x6E,0x67,0x68, + 0x75,0x61,0x51,0x75,0x29,0x04,0x72,0x78,0x3F,0xB1}; +static const EC_CURVE_DATA _EC_SECG_PRIME_112R1 = { + NID_X9_62_prime_field, + "DB7C2ABF62E35E668076BEAD208B", + "DB7C2ABF62E35E668076BEAD2088", + "659EF8BA043916EEDE8911702B22", + "09487239995A5EE76B55F9C2F098", + "a89ce5af8724c0a23e0e0ff77500", + "DB7C2ABF62E35E7628DFAC6561C5",1, + _EC_SECG_PRIME_112R1_SEED, 20, + "SECG/WTLS recommended curve over a 112 bit prime field" + }; + +static const unsigned char _EC_SECG_PRIME_112R2_SEED[] = { + 0x00,0x27,0x57,0xA1,0x11,0x4D,0x69,0x6E,0x67,0x68, + 0x75,0x61,0x51,0x75,0x53,0x16,0xC0,0x5E,0x0B,0xD4}; +static const EC_CURVE_DATA _EC_SECG_PRIME_112R2 = { + NID_X9_62_prime_field, + "DB7C2ABF62E35E668076BEAD208B", + "6127C24C05F38A0AAAF65C0EF02C", + "51DEF1815DB5ED74FCC34C85D709", + "4BA30AB5E892B4E1649DD0928643", + "adcd46f5882e3747def36e956e97", + "36DF0AAFD8B8D7597CA10520D04B",4, + _EC_SECG_PRIME_112R2_SEED, 20, + "SECG recommended curve over a 112 bit prime field" + }; + +static const unsigned char _EC_SECG_PRIME_128R1_SEED[] = { + 0x00,0x0E,0x0D,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61, + 0x51,0x75,0x0C,0xC0,0x3A,0x44,0x73,0xD0,0x36,0x79}; +static const EC_CURVE_DATA _EC_SECG_PRIME_128R1 = { + NID_X9_62_prime_field, + "FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF", + "FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC", + "E87579C11079F43DD824993C2CEE5ED3", + "161FF7528B899B2D0C28607CA52C5B86", + "cf5ac8395bafeb13c02da292dded7a83", + "FFFFFFFE0000000075A30D1B9038A115",1, + _EC_SECG_PRIME_128R1_SEED, 20, + "SECG recommended curve over a 128 bit prime field" + }; + +static const unsigned char _EC_SECG_PRIME_128R2_SEED[] = { + 0x00,0x4D,0x69,0x6E,0x67,0x68,0x75,0x61,0x51,0x75, + 0x12,0xD8,0xF0,0x34,0x31,0xFC,0xE6,0x3B,0x88,0xF4}; +static const EC_CURVE_DATA _EC_SECG_PRIME_128R2 = { + NID_X9_62_prime_field, + "FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF", + "D6031998D1B3BBFEBF59CC9BBFF9AEE1", + "5EEEFCA380D02919DC2C6558BB6D8A5D", + "7B6AA5D85E572983E6FB32A7CDEBC140", + "27b6916a894d3aee7106fe805fc34b44", + "3FFFFFFF7FFFFFFFBE0024720613B5A3",4, + _EC_SECG_PRIME_128R2_SEED, 20, + "SECG recommended curve over a 128 bit prime field" + }; + +static const EC_CURVE_DATA _EC_SECG_PRIME_160K1 = { + NID_X9_62_prime_field, + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73", + "0", + "7", + "3B4C382CE37AA192A4019E763036F4F5DD4D7EBB", + "938cf935318fdced6bc28286531733c3f03c4fee", + "0100000000000000000001B8FA16DFAB9ACA16B6B3",1, + NULL, 0, + "SECG recommended curve over a 160 bit prime field" + }; + +static const unsigned char _EC_SECG_PRIME_160R1_SEED[] = { + 0x10,0x53,0xCD,0xE4,0x2C,0x14,0xD6,0x96,0xE6,0x76, + 0x87,0x56,0x15,0x17,0x53,0x3B,0xF3,0xF8,0x33,0x45}; +static const EC_CURVE_DATA _EC_SECG_PRIME_160R1 = { + NID_X9_62_prime_field, + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC", + "1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45", + "4A96B5688EF573284664698968C38BB913CBFC82", + "23a628553168947d59dcc912042351377ac5fb32", + "0100000000000000000001F4C8F927AED3CA752257",1, + _EC_SECG_PRIME_160R1_SEED, 20, + "SECG recommended curve over a 160 bit prime field" + }; + +static const unsigned char _EC_SECG_PRIME_160R2_SEED[] = { + 0xB9,0x9B,0x99,0xB0,0x99,0xB3,0x23,0xE0,0x27,0x09, + 0xA4,0xD6,0x96,0xE6,0x76,0x87,0x56,0x15,0x17,0x51}; +static const EC_CURVE_DATA _EC_SECG_PRIME_160R2 = { + NID_X9_62_prime_field, + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC70", + "B4E134D3FB59EB8BAB57274904664D5AF50388BA", + "52DCB034293A117E1F4FF11B30F7199D3144CE6D", + "feaffef2e331f296e071fa0df9982cfea7d43f2e", + "0100000000000000000000351EE786A818F3A1A16B",1, + _EC_SECG_PRIME_160R2_SEED, 20, + "SECG/WTLS recommended curve over a 160 bit prime field" + }; + +static const EC_CURVE_DATA _EC_SECG_PRIME_192K1 = { + NID_X9_62_prime_field, + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37", + "0", + "3", + "DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D", + "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d", + "FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D",1, + NULL, 20, + "SECG recommended curve over a 192 bit prime field" + }; + +static const EC_CURVE_DATA _EC_SECG_PRIME_224K1 |