Backport from HEAD:
authorDr. Stephen Henson <steve@openssl.org>
Mon, 6 Jun 2011 11:49:36 +0000 (11:49 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Mon, 6 Jun 2011 11:49:36 +0000 (11:49 +0000)
New option to disable characteristic two fields in EC code.

Make no-ec2m work on Win32 build.

23 files changed:
CHANGES
crypto/bn/bn.h
crypto/bn/bn_gf2m.c
crypto/bn/bntest.c
crypto/ec/ec.h
crypto/ec/ec2_mult.c
crypto/ec/ec2_smpl.c
crypto/ec/ec_asn1.c
crypto/ec/ec_curve.c
crypto/ec/ec_cvt.c
crypto/ec/ec_err.c
crypto/ec/ec_key.c
crypto/ec/ec_lib.c
crypto/ec/eck_prn.c
crypto/ec/ectest.c
crypto/ecdh/ecdhtest.c
crypto/ecdh/ech_ossl.c
crypto/ecdsa/ecdsatest.c
crypto/ecdsa/ecs_ossl.c
crypto/err/err.h
ssl/ssltest.c
util/mk1mf.pl
util/mkdef.pl

diff --git a/CHANGES b/CHANGES
index cea65ccf418e56362ef7ce14f4d03779121657fc..32ca287bcc8f2445550b0ce9c7d2ea8048fa24d3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,9 @@
 
  Changes between 1.0.0d and 1.0.1  [xx XXX xxxx]
 
 
  Changes between 1.0.0d and 1.0.1  [xx XXX xxxx]
 
+  *) New build option no-ec2m to disable characteristic 2 code.
+     [Steve Henson]
+
   *) Backport libcrypto audit of return value checking from HEAD, not
      all cases can be covered as some introduce binary incompatibilities.
      [Steve Henson]
   *) Backport libcrypto audit of return value checking from HEAD, not
      all cases can be covered as some introduce binary incompatibilities.
      [Steve Henson]
index dc4fec461669952fea9f4a04972f55e4d14d0e05..f34248ec4f87bfeaf900870587fe02615230bb61 100644 (file)
@@ -623,6 +623,8 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
 int    BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
        BN_RECP_CTX *recp, BN_CTX *ctx);
 
 int    BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
        BN_RECP_CTX *recp, BN_CTX *ctx);
 
+#ifndef OPENSSL_NO_EC2M
+
 /* Functions for arithmetic over binary polynomials represented by BIGNUMs. 
  *
  * The BIGNUM::neg property of BIGNUMs representing binary polynomials is
 /* Functions for arithmetic over binary polynomials represented by BIGNUMs. 
  *
  * The BIGNUM::neg property of BIGNUMs representing binary polynomials is
@@ -674,6 +676,8 @@ int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
 int    BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);
 int    BN_GF2m_arr2poly(const int p[], BIGNUM *a);
 
 int    BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);
 int    BN_GF2m_arr2poly(const int p[], BIGNUM *a);
 
+#endif
+
 /* faster mod functions for the 'NIST primes' 
  * 0 <= a < p^2 */
 int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
 /* faster mod functions for the 'NIST primes' 
  * 0 <= a < p^2 */
 int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
index 527b0fa15be51ada3725d3d77704b26e8f8619ff..3bf017feda7e804370acc7c277665e163466594e 100644 (file)
@@ -94,6 +94,8 @@
 #include "cryptlib.h"
 #include "bn_lcl.h"
 
 #include "cryptlib.h"
 #include "bn_lcl.h"
 
+#ifndef OPENSSL_NO_EC2M
+
 /* Maximum number of iterations before BN_GF2m_mod_solve_quad_arr should fail. */
 #define MAX_ITERATIONS 50
 
 /* Maximum number of iterations before BN_GF2m_mod_solve_quad_arr should fail. */
 #define MAX_ITERATIONS 50
 
@@ -1032,3 +1034,4 @@ int BN_GF2m_arr2poly(const int p[], BIGNUM *a)
        return 1;
        }
 
        return 1;
        }
 
+#endif
index 0cd99c5b4bb11f03daab7792493e7eec0e15dbd7..06f5954acc39083ea56981b6ccb8730d64ff5026 100644 (file)
@@ -262,7 +262,7 @@ int main(int argc, char *argv[])
        message(out,"BN_mod_sqrt");
        if (!test_sqrt(out,ctx)) goto err;
        (void)BIO_flush(out);
        message(out,"BN_mod_sqrt");
        if (!test_sqrt(out,ctx)) goto err;
        (void)BIO_flush(out);
-
+#ifndef OPENSSL_NO_EC2M
        message(out,"BN_GF2m_add");
        if (!test_gf2m_add(out)) goto err;
        (void)BIO_flush(out);
        message(out,"BN_GF2m_add");
        if (!test_gf2m_add(out)) goto err;
        (void)BIO_flush(out);
@@ -298,7 +298,7 @@ int main(int argc, char *argv[])
        message(out,"BN_GF2m_mod_solve_quad");
        if (!test_gf2m_mod_solve_quad(out,ctx)) goto err;
        (void)BIO_flush(out);
        message(out,"BN_GF2m_mod_solve_quad");
        if (!test_gf2m_mod_solve_quad(out,ctx)) goto err;
        (void)BIO_flush(out);
-
+#endif
        BN_CTX_free(ctx);
        BIO_free(out);
 
        BN_CTX_free(ctx);
        BIO_free(out);
 
@@ -1061,7 +1061,7 @@ int test_exp(BIO *bp, BN_CTX *ctx)
        BN_free(one);
        return(1);
        }
        BN_free(one);
        return(1);
        }
-
+#ifndef OPENSSL_NO_EC2M
 int test_gf2m_add(BIO *bp)
        {
        BIGNUM a,b,c;
 int test_gf2m_add(BIO *bp)
        {
        BIGNUM a,b,c;
@@ -1636,7 +1636,7 @@ int test_gf2m_mod_solve_quad(BIO *bp,BN_CTX *ctx)
        BN_free(e);
        return ret;
        }
        BN_free(e);
        return ret;
        }
-
+#endif
 static int genprime_cb(int p, int n, BN_GENCB *arg)
        {
        char c='*';
 static int genprime_cb(int p, int n, BN_GENCB *arg)
        {
        char c='*';
index c95285e59769ce0cde34d262dc4bb9a7b278fbda..64d0a2948d7d232cedab52faf032d405bd82b0ef 100644 (file)
@@ -158,7 +158,7 @@ const EC_METHOD *EC_GFp_nist_method(void);
 const EC_METHOD *EC_GFp_nistp224_method(void);
 #endif
 
 const EC_METHOD *EC_GFp_nistp224_method(void);
 #endif
 
-
+#ifndef OPENSSL_NO_EC2M
 /********************************************************************/ 
 /*           EC_METHOD for curves over GF(2^m)                      */
 /********************************************************************/
 /********************************************************************/ 
 /*           EC_METHOD for curves over GF(2^m)                      */
 /********************************************************************/
@@ -168,6 +168,8 @@ const EC_METHOD *EC_GFp_nistp224_method(void);
  */
 const EC_METHOD *EC_GF2m_simple_method(void);
 
  */
 const EC_METHOD *EC_GF2m_simple_method(void);
 
+#endif
+
 
 /********************************************************************/
 /*                   EC_GROUP functions                             */
 
 /********************************************************************/
 /*                   EC_GROUP functions                             */
@@ -289,6 +291,7 @@ int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, co
  */
 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
 
  */
 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
 
+#ifndef OPENSSL_NO_EC2M
 /** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
  *  \param  group  EC_GROUP object
  *  \param  p      BIGNUM with the polynomial defining the underlying field
 /** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
  *  \param  group  EC_GROUP object
  *  \param  p      BIGNUM with the polynomial defining the underlying field
@@ -308,7 +311,7 @@ int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, c
  *  \return 1 on success and 0 if an error occured
  */
 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
  *  \return 1 on success and 0 if an error occured
  */
 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
-
+#endif
 /** Returns the number of bits needed to represent a field element 
  *  \param  group  EC_GROUP object
  *  \return number of bits needed to represent a field element
 /** Returns the number of bits needed to represent a field element 
  *  \param  group  EC_GROUP object
  *  \return number of bits needed to represent a field element
@@ -349,7 +352,7 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
  *  \return newly created EC_GROUP object with the specified parameters
  */
 EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
  *  \return newly created EC_GROUP object with the specified parameters
  */
 EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
-
+#ifndef OPENSSL_NO_EC2M
 /** Creates a new EC_GROUP object with the specified parameters defined
  *  over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
  *  \param  p    BIGNUM with the polynomial defining the underlying field
 /** Creates a new EC_GROUP object with the specified parameters defined
  *  over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
  *  \param  p    BIGNUM with the polynomial defining the underlying field
@@ -359,7 +362,7 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM
  *  \return newly created EC_GROUP object with the specified parameters
  */
 EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
  *  \return newly created EC_GROUP object with the specified parameters
  */
 EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
-
+#endif
 /** Creates a EC_GROUP object with a curve specified by a NID
  *  \param  nid  NID of the OID of the curve name
  *  \return newly created EC_GROUP object with specified curve or NULL
 /** Creates a EC_GROUP object with a curve specified by a NID
  *  \param  nid  NID of the OID of the curve name
  *  \return newly created EC_GROUP object with specified curve or NULL
@@ -488,7 +491,7 @@ int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
  */
 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
        const BIGNUM *x, int y_bit, BN_CTX *ctx);
  */
 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
        const BIGNUM *x, int y_bit, BN_CTX *ctx);
-
+#ifndef OPENSSL_NO_EC2M
 /** Sets the affine coordinates of a EC_POINT over GF2m
  *  \param  group  underlying EC_GROUP object
  *  \param  p      EC_POINT object
 /** Sets the affine coordinates of a EC_POINT over GF2m
  *  \param  group  underlying EC_GROUP object
  *  \param  p      EC_POINT object
@@ -521,7 +524,7 @@ int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
  */
 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
        const BIGNUM *x, int y_bit, BN_CTX *ctx);
  */
 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
        const BIGNUM *x, int y_bit, BN_CTX *ctx);
-
+#endif
 /** Encodes a EC_POINT object to a octet string
  *  \param  group  underlying EC_GROUP object
  *  \param  p      EC_POINT object
 /** Encodes a EC_POINT object to a octet string
  *  \param  group  underlying EC_GROUP object
  *  \param  p      EC_POINT object
@@ -660,9 +663,11 @@ int EC_GROUP_have_precompute_mult(const EC_GROUP *group);
 /* EC_GROUP_get_basis_type() returns the NID of the basis type
  * used to represent the field elements */
 int EC_GROUP_get_basis_type(const EC_GROUP *);
 /* EC_GROUP_get_basis_type() returns the NID of the basis type
  * used to represent the field elements */
 int EC_GROUP_get_basis_type(const EC_GROUP *);
+#ifndef OPENSSL_NO_EC2M
 int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
 int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, 
        unsigned int *k2, unsigned int *k3);
 int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
 int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, 
        unsigned int *k2, unsigned int *k3);
+#endif
 
 #define OPENSSL_EC_NAMED_CURVE 0x001
 
 
 #define OPENSSL_EC_NAMED_CURVE 0x001
 
@@ -1082,6 +1087,7 @@ void ERR_load_EC_strings(void);
 #define EC_R_DISCRIMINANT_IS_ZERO                       118
 #define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE               119
 #define EC_R_FIELD_TOO_LARGE                            143
 #define EC_R_DISCRIMINANT_IS_ZERO                       118
 #define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE               119
 #define EC_R_FIELD_TOO_LARGE                            143
+#define EC_R_GF2M_NOT_SUPPORTED                                 147
 #define EC_R_GROUP2PKPARAMETERS_FAILURE                         120
 #define EC_R_I2D_ECPKPARAMETERS_FAILURE                         121
 #define EC_R_INCOMPATIBLE_OBJECTS                       101
 #define EC_R_GROUP2PKPARAMETERS_FAILURE                         120
 #define EC_R_I2D_ECPKPARAMETERS_FAILURE                         121
 #define EC_R_INCOMPATIBLE_OBJECTS                       101
index e12b9b284a00298cec51623ec81193c2e86499b9..26f4a783fcc1efc5f98dd54946bd1556d59cc0c5 100644 (file)
@@ -71,6 +71,8 @@
 
 #include "ec_lcl.h"
 
 
 #include "ec_lcl.h"
 
+#ifndef OPENSSL_NO_EC2M
+
 
 /* Compute the x-coordinate x/z for the point 2*(x/z) in Montgomery projective 
  * coordinates.
 
 /* Compute the x-coordinate x/z for the point 2*(x/z) in Montgomery projective 
  * coordinates.
@@ -384,3 +386,5 @@ int ec_GF2m_have_precompute_mult(const EC_GROUP *group)
        {
        return ec_wNAF_have_precompute_mult(group);
        }
        {
        return ec_wNAF_have_precompute_mult(group);
        }
+
+#endif
index af94458ca7bab35d41cf137d317cd6f3fdb8dc47..a379c9b45095a2b811abe320dd232d2e84407e8c 100644 (file)
@@ -71,6 +71,8 @@
 
 #include "ec_lcl.h"
 
 
 #include "ec_lcl.h"
 
+#ifndef OPENSSL_NO_EC2M
+
 
 const EC_METHOD *EC_GF2m_simple_method(void)
        {
 
 const EC_METHOD *EC_GF2m_simple_method(void)
        {
@@ -1040,3 +1042,5 @@ int ec_GF2m_simple_field_div(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
        {
        return BN_GF2m_mod_div(r, a, b, &group->field, ctx);
        }
        {
        return BN_GF2m_mod_div(r, a, b, &group->field, ctx);
        }
+
+#endif
index ae555398594b8e6c02bd554015853000efeff744..175eec53428baa0e51a1817294b3a6dd7ee7e128 100644 (file)
@@ -83,7 +83,7 @@ int EC_GROUP_get_basis_type(const EC_GROUP *group)
                /* everything else is currently not supported */
                return 0;
        }
                /* everything else is currently not supported */
                return 0;
        }
-
+#ifndef OPENSSL_NO_EC2M
 int EC_GROUP_get_trinomial_basis(const EC_GROUP *group, unsigned int *k)
        {
        if (group == NULL)
 int EC_GROUP_get_trinomial_basis(const EC_GROUP *group, unsigned int *k)
        {
        if (group == NULL)
@@ -101,7 +101,6 @@ int EC_GROUP_get_trinomial_basis(const EC_GROUP *group, unsigned int *k)
 
        return 1;
        }
 
        return 1;
        }
-
 int EC_GROUP_get_pentanomial_basis(const EC_GROUP *group, unsigned int *k1,
        unsigned int *k2, unsigned int *k3)
        {
 int EC_GROUP_get_pentanomial_basis(const EC_GROUP *group, unsigned int *k1,
        unsigned int *k2, unsigned int *k3)
        {
@@ -124,7 +123,7 @@ int EC_GROUP_get_pentanomial_basis(const EC_GROUP *group, unsigned int *k1,
 
        return 1;
        }
 
        return 1;
        }
-
+#endif
 
 
 /* some structures needed for the asn1 encoding */
 
 
 /* some structures needed for the asn1 encoding */
@@ -340,6 +339,12 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field)
                        }
                }
        else    /* nid == NID_X9_62_characteristic_two_field */
                        }
                }
        else    /* nid == NID_X9_62_characteristic_two_field */
+#ifdef OPENSSL_NO_EC2M
+               {
+               ECerr(EC_F_EC_ASN1_GROUP2FIELDID, EC_R_GF2M_NOT_SUPPORTED);
+               goto err;
+               }
+#else
                {
                int             field_type;
                X9_62_CHARACTERISTIC_TWO *char_two;
                {
                int             field_type;
                X9_62_CHARACTERISTIC_TWO *char_two;
@@ -419,6 +424,7 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field)
                                }
                        }
                }
                                }
                        }
                }
+#endif
 
        ok = 1;
 
 
        ok = 1;
 
@@ -456,6 +462,7 @@ static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
                        goto err;
                        }
                }
                        goto err;
                        }
                }
+#ifndef OPENSSL_NO_EC2M
        else    /* nid == NID_X9_62_characteristic_two_field */
                {
                if (!EC_GROUP_get_curve_GF2m(group, NULL, tmp_1, tmp_2, NULL))
        else    /* nid == NID_X9_62_characteristic_two_field */
                {
                if (!EC_GROUP_get_curve_GF2m(group, NULL, tmp_1, tmp_2, NULL))
@@ -464,7 +471,7 @@ static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
                        goto err;
                        }
                }
                        goto err;
                        }
                }
-
+#endif
        len_1 = (size_t)BN_num_bytes(tmp_1);
        len_2 = (size_t)BN_num_bytes(tmp_2);
 
        len_1 = (size_t)BN_num_bytes(tmp_1);
        len_2 = (size_t)BN_num_bytes(tmp_2);
 
@@ -775,8 +782,13 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params)
 
        /* get the field parameters */
        tmp = OBJ_obj2nid(params->fieldID->fieldType);
 
        /* get the field parameters */
        tmp = OBJ_obj2nid(params->fieldID->fieldType);
-
        if (tmp == NID_X9_62_characteristic_two_field)
        if (tmp == NID_X9_62_characteristic_two_field)
+#ifdef OPENSSL_NO_EC2M
+               {
+               ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_GF2M_NOT_SUPPORTED);
+               goto err;
+               }
+#else
                {
                X9_62_CHARACTERISTIC_TWO *char_two;
 
                {
                X9_62_CHARACTERISTIC_TWO *char_two;
 
@@ -862,6 +874,7 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params)
                /* create the EC_GROUP structure */
                ret = EC_GROUP_new_curve_GF2m(p, a, b, NULL);
                }
                /* create the EC_GROUP structure */
                ret = EC_GROUP_new_curve_GF2m(p, a, b, NULL);
                }
+#endif
        else if (tmp == NID_X9_62_prime_field)
                {
                /* we have a curve over a prime field */
        else if (tmp == NID_X9_62_prime_field)
                {
                /* we have a curve over a prime field */
@@ -1065,6 +1078,7 @@ EC_GROUP *d2i_ECPKParameters(EC_GROUP **a, const unsigned char **in, long len)
        if ((group = ec_asn1_pkparameters2group(params)) == NULL)
                {
                ECerr(EC_F_D2I_ECPKPARAMETERS, EC_R_PKPARAMETERS2GROUP_FAILURE);
        if ((group = ec_asn1_pkparameters2group(params)) == NULL)
                {
                ECerr(EC_F_D2I_ECPKPARAMETERS, EC_R_PKPARAMETERS2GROUP_FAILURE);
+               ECPKPARAMETERS_free(params);
                return NULL; 
                }
 
                return NULL; 
                }
 
index 56a44d0e9ee91419f2276994454103ece446890f..85cd3b6b3d8e5d2c7b0777af6a13895d8e83a8b0 100644 (file)
@@ -703,6 +703,8 @@ static const struct { EC_CURVE_DATA h; unsigned char data[0+28*6]; }
          0x13,0xDD,0x29,0x45,0x5C,0x5C,0x2A,0x3D }
        };
 
          0x13,0xDD,0x29,0x45,0x5C,0x5C,0x2A,0x3D }
        };
 
+#ifndef OPENSSL_NO_EC2M
+
 /* characteristic two curves */
 static const struct { EC_CURVE_DATA h; unsigned char data[20+15*6]; }
        _EC_SECG_CHAR2_113R1 = {
 /* characteristic two curves */
 static const struct { EC_CURVE_DATA h; unsigned char data[20+15*6]; }
        _EC_SECG_CHAR2_113R1 = {
@@ -1817,6 +1819,8 @@ static const struct { EC_CURVE_DATA h; unsigned char data[0+24*6]; }
          0xBA,0xFC,0xA7,0x5E }
        };
 
          0xBA,0xFC,0xA7,0x5E }
        };
 
+#endif
+
 typedef struct _ec_list_element_st {
        int     nid;
        const EC_CURVE_DATA *data;
 typedef struct _ec_list_element_st {
        int     nid;
        const EC_CURVE_DATA *data;
@@ -1855,6 +1859,7 @@ static const ec_list_element curve_list[] = {
        { NID_X9_62_prime239v2, &_EC_X9_62_PRIME_239V2.h, 0, "X9.62 curve over a 239 bit prime field" },
        { NID_X9_62_prime239v3, &_EC_X9_62_PRIME_239V3.h, 0, "X9.62 curve over a 239 bit prime field" },
        { NID_X9_62_prime256v1, &_EC_X9_62_PRIME_256V1.h, 0, "X9.62/SECG curve over a 256 bit prime field" },
        { NID_X9_62_prime239v2, &_EC_X9_62_PRIME_239V2.h, 0, "X9.62 curve over a 239 bit prime field" },
        { NID_X9_62_prime239v3, &_EC_X9_62_PRIME_239V3.h, 0, "X9.62 curve over a 239 bit prime field" },
        { NID_X9_62_prime256v1, &_EC_X9_62_PRIME_256V1.h, 0, "X9.62/SECG curve over a 256 bit prime field" },
+#ifndef OPENSSL_NO_EC2M
        /* characteristic two field curves */
        /* NIST/SECG curves */
        { NID_sect113r1, &_EC_SECG_CHAR2_113R1.h, 0, "SECG curve over a 113 bit binary field" },
        /* characteristic two field curves */
        /* NIST/SECG curves */
        { NID_sect113r1, &_EC_SECG_CHAR2_113R1.h, 0, "SECG curve over a 113 bit binary field" },
@@ -1898,18 +1903,23 @@ static const ec_list_element curve_list[] = {
        { NID_wap_wsg_idm_ecid_wtls3, &_EC_NIST_CHAR2_163K.h, 0, "NIST/SECG/WTLS curve over a 163 bit binary field" },
        { NID_wap_wsg_idm_ecid_wtls4, &_EC_SECG_CHAR2_113R1.h, 0, "SECG curve over a 113 bit binary field" },
        { NID_wap_wsg_idm_ecid_wtls5, &_EC_X9_62_CHAR2_163V1.h, 0, "X9.62 curve over a 163 bit binary field" },
        { NID_wap_wsg_idm_ecid_wtls3, &_EC_NIST_CHAR2_163K.h, 0, "NIST/SECG/WTLS curve over a 163 bit binary field" },
        { NID_wap_wsg_idm_ecid_wtls4, &_EC_SECG_CHAR2_113R1.h, 0, "SECG curve over a 113 bit binary field" },
        { NID_wap_wsg_idm_ecid_wtls5, &_EC_X9_62_CHAR2_163V1.h, 0, "X9.62 curve over a 163 bit binary field" },
+#endif
        { NID_wap_wsg_idm_ecid_wtls6, &_EC_SECG_PRIME_112R1.h, 0, "SECG/WTLS curve over a 112 bit prime field" },
        { NID_wap_wsg_idm_ecid_wtls7, &_EC_SECG_PRIME_160R2.h, 0, "SECG/WTLS curve over a 160 bit prime field" },
        { NID_wap_wsg_idm_ecid_wtls8, &_EC_WTLS_8.h, 0, "WTLS curve over a 112 bit prime field" },
        { NID_wap_wsg_idm_ecid_wtls9, &_EC_WTLS_9.h, 0, "WTLS curve over a 160 bit prime field" },
        { NID_wap_wsg_idm_ecid_wtls6, &_EC_SECG_PRIME_112R1.h, 0, "SECG/WTLS curve over a 112 bit prime field" },
        { NID_wap_wsg_idm_ecid_wtls7, &_EC_SECG_PRIME_160R2.h, 0, "SECG/WTLS curve over a 160 bit prime field" },
        { NID_wap_wsg_idm_ecid_wtls8, &_EC_WTLS_8.h, 0, "WTLS curve over a 112 bit prime field" },
        { NID_wap_wsg_idm_ecid_wtls9, &_EC_WTLS_9.h, 0, "WTLS curve over a 160 bit prime field" },
+#ifndef OPENSSL_NO_EC2M
        { NID_wap_wsg_idm_ecid_wtls10, &_EC_NIST_CHAR2_233K.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field" },
        { NID_wap_wsg_idm_ecid_wtls11, &_EC_NIST_CHAR2_233B.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field" },
        { NID_wap_wsg_idm_ecid_wtls10, &_EC_NIST_CHAR2_233K.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field" },
        { NID_wap_wsg_idm_ecid_wtls11, &_EC_NIST_CHAR2_233B.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field" },
+#endif
        { NID_wap_wsg_idm_ecid_wtls12, &_EC_WTLS_12.h, 0, "WTLS curvs over a 224 bit prime field" },
        { NID_wap_wsg_idm_ecid_wtls12, &_EC_WTLS_12.h, 0, "WTLS curvs over a 224 bit prime field" },
+#ifndef OPENSSL_NO_EC2M
        /* IPSec curves */
        { NID_ipsec3, &_EC_IPSEC_155_ID3.h, 0, "\n\tIPSec/IKE/Oakley curve #3 over a 155 bit binary field.\n"
          "\tNot suitable for ECDSA.\n\tQuestionable extension field!" },
        { NID_ipsec4, &_EC_IPSEC_185_ID4.h, 0, "\n\tIPSec/IKE/Oakley curve #4 over a 185 bit binary field.\n"
          "\tNot suitable for ECDSA.\n\tQuestionable extension field!" },
        /* IPSec curves */
        { NID_ipsec3, &_EC_IPSEC_155_ID3.h, 0, "\n\tIPSec/IKE/Oakley curve #3 over a 155 bit binary field.\n"
          "\tNot suitable for ECDSA.\n\tQuestionable extension field!" },
        { NID_ipsec4, &_EC_IPSEC_185_ID4.h, 0, "\n\tIPSec/IKE/Oakley curve #4 over a 185 bit binary field.\n"
          "\tNot suitable for ECDSA.\n\tQuestionable extension field!" },
+#endif
 };
 
 #define curve_list_length (sizeof(curve_list)/sizeof(ec_list_element))
 };
 
 #define curve_list_length (sizeof(curve_list)/sizeof(ec_list_element))
@@ -1964,6 +1974,7 @@ static EC_GROUP *ec_group_new_from_data(const ec_list_element curve)
                        goto err;
                        }
                }
                        goto err;
                        }
                }
+#ifndef OPENSSL_NO_EC2M
        else    /* field_type == NID_X9_62_characteristic_two_field */
                {
                if ((group = EC_GROUP_new_curve_GF2m(p, a, b, ctx)) == NULL)
        else    /* field_type == NID_X9_62_characteristic_two_field */
                {
                if ((group = EC_GROUP_new_curve_GF2m(p, a, b, ctx)) == NULL)
@@ -1972,6 +1983,7 @@ static EC_GROUP *ec_group_new_from_data(const ec_list_element curve)
                        goto err;
                        }
                }
                        goto err;
                        }
                }
+#endif
 
        if ((P = EC_POINT_new(group)) == NULL)
                {
 
        if ((P = EC_POINT_new(group)) == NULL)
                {
@@ -1985,7 +1997,7 @@ static EC_GROUP *ec_group_new_from_data(const ec_list_element curve)
                ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB);
                goto err;
                }
                ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB);
                goto err;
                }
-       if (!EC_POINT_set_affine_coordinates_GF2m(group, P, x, y, ctx))
+       if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx))
                {
                ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB);
                goto err;
                {
                ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB);
                goto err;
index d45640bab902fb6ce28f5302ed2d9c1cb8259649..bbed1da455947affc947437fd8e313c24ecadf06 100644 (file)
@@ -122,7 +122,7 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM
        return ret;
        }
 
        return ret;
        }
 
-
+#ifndef OPENSSL_NO_EC2M
 EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
        {
        const EC_METHOD *meth;
 EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
        {
        const EC_METHOD *meth;
@@ -142,3 +142,4 @@ EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM
 
        return ret;
        }
 
        return ret;
        }
+#endif
index a05e44c0316afa046f9268e36f52a7b4a9dc34dc..15d539cbf41c0a065ac2ce67a9068b26491a2bcf 100644 (file)
@@ -213,6 +213,7 @@ static ERR_STRING_DATA EC_str_reasons[]=
 {ERR_REASON(EC_R_DISCRIMINANT_IS_ZERO)   ,"discriminant is zero"},
 {ERR_REASON(EC_R_EC_GROUP_NEW_BY_NAME_FAILURE),"ec group new by name failure"},
 {ERR_REASON(EC_R_FIELD_TOO_LARGE)        ,"field too large"},
 {ERR_REASON(EC_R_DISCRIMINANT_IS_ZERO)   ,"discriminant is zero"},
 {ERR_REASON(EC_R_EC_GROUP_NEW_BY_NAME_FAILURE),"ec group new by name failure"},
 {ERR_REASON(EC_R_FIELD_TOO_LARGE)        ,"field too large"},
+{ERR_REASON(EC_R_GF2M_NOT_SUPPORTED)     ,"gf2m not supported"},
 {ERR_REASON(EC_R_GROUP2PKPARAMETERS_FAILURE),"group2pkparameters failure"},
 {ERR_REASON(EC_R_I2D_ECPKPARAMETERS_FAILURE),"i2d ecpkparameters failure"},
 {ERR_REASON(EC_R_INCOMPATIBLE_OBJECTS)   ,"incompatible objects"},
 {ERR_REASON(EC_R_GROUP2PKPARAMETERS_FAILURE),"group2pkparameters failure"},
 {ERR_REASON(EC_R_I2D_ECPKPARAMETERS_FAILURE),"i2d ecpkparameters failure"},
 {ERR_REASON(EC_R_INCOMPATIBLE_OBJECTS)   ,"incompatible objects"},
index a9e780da443a5350b18a10bafd9f7d86879ed4d0..2e91b5405d229e027a64ba4c3cf1014116aa2812 100644 (file)
@@ -400,7 +400,7 @@ int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y)
 
        tx = BN_CTX_get(ctx);
        ty = BN_CTX_get(ctx);
 
        tx = BN_CTX_get(ctx);
        ty = BN_CTX_get(ctx);
-
+#ifndef OPENSSL_NO_EC2M
        if (is_char_two)
                {
                if (!EC_POINT_set_affine_coordinates_GF2m(key->group, point,
        if (is_char_two)
                {
                if (!EC_POINT_set_affine_coordinates_GF2m(key->group, point,
@@ -411,6 +411,7 @@ int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y)
                        goto err;
                }
        else
                        goto err;
                }
        else
+#endif
                {
                if (!EC_POINT_set_affine_coordinates_GFp(key->group, point,
                                                                x, y, ctx))
                {
                if (!EC_POINT_set_affine_coordinates_GFp(key->group, point,
                                                                x, y, ctx))
index dd7da0fcf93a54ed571366ca619cfefddadb246b..e0f0afcdf8dcdc13ade79ba82d155fa61e4ccd3f 100644 (file)
@@ -425,7 +425,7 @@ int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *
        return group->meth->group_get_curve(group, p, a, b, ctx);
        }
 
        return group->meth->group_get_curve(group, p, a, b, ctx);
        }
 
-
+#ifndef OPENSSL_NO_EC2M
 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
        {
        if (group->meth->group_set_curve == 0)
 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
        {
        if (group->meth->group_set_curve == 0)
@@ -446,7 +446,7 @@ int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM
                }
        return group->meth->group_get_curve(group, p, a, b, ctx);
        }
                }
        return group->meth->group_get_curve(group, p, a, b, ctx);
        }
-
+#endif
 
 int EC_GROUP_get_degree(const EC_GROUP *group)
        {
 
 int EC_GROUP_get_degree(const EC_GROUP *group)
        {
@@ -856,7 +856,7 @@ int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
        return group->meth->point_set_affine_coordinates(group, point, x, y, ctx);
        }
 
        return group->meth->point_set_affine_coordinates(group, point, x, y, ctx);
        }
 
-
+#ifndef OPENSSL_NO_EC2M
 int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point,
        const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
        {
 int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point,
        const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
        {
@@ -872,7 +872,7 @@ int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point,
                }
        return group->meth->point_set_affine_coordinates(group, point, x, y, ctx);
        }
                }
        return group->meth->point_set_affine_coordinates(group, point, x, y, ctx);
        }
-
+#endif
 
 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point,
        BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
 
 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point,
        BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
@@ -890,7 +890,7 @@ int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *p
        return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
        }
 
        return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
        }
 
-
+#ifndef OPENSSL_NO_EC2M
 int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *point,
        BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
        {
 int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *point,
        BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
        {
@@ -906,7 +906,7 @@ int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *
                }
        return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
        }
                }
        return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
        }
-
+#endif
 
 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
        const BIGNUM *x, int y_bit, BN_CTX *ctx)
 
 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
        const BIGNUM *x, int y_bit, BN_CTX *ctx)
@@ -924,7 +924,7 @@ int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *poi
        return group->meth->point_set_compressed_coordinates(group, point, x, y_bit, ctx);
        }
 
        return group->meth->point_set_compressed_coordinates(group, point, x, y_bit, ctx);
        }
 
-
+#ifndef OPENSSL_NO_EC2M
 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point,
        const BIGNUM *x, int y_bit, BN_CTX *ctx)
        {
 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point,
        const BIGNUM *x, int y_bit, BN_CTX *ctx)
        {
@@ -940,7 +940,7 @@ int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *po
                }
        return group->meth->point_set_compressed_coordinates(group, point, x, y_bit, ctx);
        }
                }
        return group->meth->point_set_compressed_coordinates(group, point, x, y_bit, ctx);
        }
-
+#endif
 
 size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form,
         unsigned char *buf, size_t len, BN_CTX *ctx)
 
 size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form,
         unsigned char *buf, size_t len, BN_CTX *ctx)
index 7d3e175ae756ba183ca9a1021b7c607e6d2981c1..06de8f3959d57d2bdebe85ea7ab2d5b3c3a414fe 100644 (file)
@@ -207,7 +207,7 @@ int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
                        reason = ERR_R_MALLOC_FAILURE;
                        goto err;
                        }
                        reason = ERR_R_MALLOC_FAILURE;
                        goto err;
                        }
-
+#ifndef OPENSSL_NO_EC2M
                if (is_char_two)
                        {
                        if (!EC_GROUP_get_curve_GF2m(x, p, a, b, ctx))
                if (is_char_two)
                        {
                        if (!EC_GROUP_get_curve_GF2m(x, p, a, b, ctx))
@@ -217,6 +217,7 @@ int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
                                }
                        }
                else /* prime field */
                                }
                        }
                else /* prime field */
+#endif
                        {
                        if (!EC_GROUP_get_curve_GFp(x, p, a, b, ctx))
                                {
                        {
                        if (!EC_GROUP_get_curve_GFp(x, p, a, b, ctx))
                                {
index 834d54ab599ba413e1e42f7e7b3ab11b5bf82663..9018e9344951efc1b5805921cc2199791f0c01d7 100644 (file)
@@ -776,6 +776,7 @@ static void prime_field_tests()
        if (!(_variable = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; \
        if (!EC_GROUP_copy(_variable, group)) ABORT; \
 
        if (!(_variable = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; \
        if (!EC_GROUP_copy(_variable, group)) ABORT; \
 
+#ifndef OPENSSL_NO_EC2M
 
 static void char2_field_tests()
        {       
 
 static void char2_field_tests()
        {       
@@ -1210,6 +1211,7 @@ static void char2_field_tests()
        if (C2_B571) EC_GROUP_free(C2_B571);
 
        }
        if (C2_B571) EC_GROUP_free(C2_B571);
 
        }
+#endif
 
 static void internal_curve_test(void)
        {
 
 static void internal_curve_test(void)
        {
@@ -1391,7 +1393,9 @@ int main(int argc, char *argv[])
 
        prime_field_tests();
        puts("");
 
        prime_field_tests();
        puts("");
+#ifndef OPENSSL_NO_EC2M
        char2_field_tests();
        char2_field_tests();
+#endif
 #ifdef EC_NISTP224_64_GCC_128
        nistp224_test();
 #endif
 #ifdef EC_NISTP224_64_GCC_128
        nistp224_test();
 #endif
index 212a87efa4ef1d3da5db9a9b1b6d2542d6eb6c79..823d7baa657c7242782c7d255ade55fd72c2afc8 100644 (file)
@@ -158,11 +158,13 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out)
                if (!EC_POINT_get_affine_coordinates_GFp(group,
                        EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err;
                }
                if (!EC_POINT_get_affine_coordinates_GFp(group,
                        EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err;
                }
+#ifndef OPENSSL_NO_EC2M
        else
                {
                if (!EC_POINT_get_affine_coordinates_GF2m(group,
                        EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err;
                }
        else
                {
                if (!EC_POINT_get_affine_coordinates_GF2m(group,
                        EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err;
                }
+#endif
 #ifdef NOISY
        BIO_puts(out,"  pri 1=");
        BN_print(out,a->priv_key);
 #ifdef NOISY
        BIO_puts(out,"  pri 1=");
        BN_print(out,a->priv_key);
@@ -183,11 +185,13 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out)
                if (!EC_POINT_get_affine_coordinates_GFp(group, 
                        EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err;
                }
                if (!EC_POINT_get_affine_coordinates_GFp(group, 
                        EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err;
                }
+#ifndef OPENSSL_NO_EC2M
        else
                {
                if (!EC_POINT_get_affine_coordinates_GF2m(group, 
                        EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err;
                }
        else
                {
                if (!EC_POINT_get_affine_coordinates_GF2m(group, 
                        EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err;
                }
+#endif
 
 #ifdef NOISY
        BIO_puts(out,"  pri 2=");
 
 #ifdef NOISY
        BIO_puts(out,"  pri 2=");
@@ -324,6 +328,7 @@ int main(int argc, char *argv[])
        if (!test_ecdh_curve(NID_X9_62_prime256v1, "NIST Prime-Curve P-256", ctx, out)) goto err;
        if (!test_ecdh_curve(NID_secp384r1, "NIST Prime-Curve P-384", ctx, out)) goto err;
        if (!test_ecdh_curve(NID_secp521r1, "NIST Prime-Curve P-521", ctx, out)) goto err;
        if (!test_ecdh_curve(NID_X9_62_prime256v1, "NIST Prime-Curve P-256", ctx, out)) goto err;
        if (!test_ecdh_curve(NID_secp384r1, "NIST Prime-Curve P-384", ctx, out)) goto err;
        if (!test_ecdh_curve(NID_secp521r1, "NIST Prime-Curve P-521", ctx, out)) goto err;
+#ifndef OPENSSL_NO_EC2M
        /* NIST BINARY CURVES TESTS */
        if (!test_ecdh_curve(NID_sect163k1, "NIST Binary-Curve K-163", ctx, out)) goto err;
        if (!test_ecdh_curve(NID_sect163r2, "NIST Binary-Curve B-163", ctx, out)) goto err;
        /* NIST BINARY CURVES TESTS */
        if (!test_ecdh_curve(NID_sect163k1, "NIST Binary-Curve K-163", ctx, out)) goto err;
        if (!test_ecdh_curve(NID_sect163r2, "NIST Binary-Curve B-163", ctx, out)) goto err;
@@ -335,6 +340,7 @@ int main(int argc, char *argv[])
        if (!test_ecdh_curve(NID_sect409r1, "NIST Binary-Curve B-409", ctx, out)) goto err;
        if (!test_ecdh_curve(NID_sect571k1, "NIST Binary-Curve K-571", ctx, out)) goto err;
        if (!test_ecdh_curve(NID_sect571r1, "NIST Binary-Curve B-571", ctx, out)) goto err;
        if (!test_ecdh_curve(NID_sect409r1, "NIST Binary-Curve B-409", ctx, out)) goto err;
        if (!test_ecdh_curve(NID_sect571k1, "NIST Binary-Curve K-571", ctx, out)) goto err;
        if (!test_ecdh_curve(NID_sect571r1, "NIST Binary-Curve B-571", ctx, out)) goto err;
+#endif
 
        ret = 0;
 
 
        ret = 0;
 
index 2a40ff12dfa8c29c4624e49bb668f2c5d0eebbbf..4a30628fbcc98b8c9ef9f1aa71acb8b5cd687bd6 100644 (file)
@@ -157,6 +157,7 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
                        goto err;
                        }
                }
                        goto err;
                        }
                }
+#ifndef OPENSSL_NO_EC2M
        else
                {
                if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp, x, y, ctx)) 
        else
                {
                if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp, x, y, ctx)) 
@@ -165,6 +166,7 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
                        goto err;
                        }
                }
                        goto err;
                        }
                }
+#endif
 
        buflen = (EC_GROUP_get_degree(group) + 7)/8;
        len = BN_num_bytes(x);
 
        buflen = (EC_GROUP_get_degree(group) + 7)/8;
        len = BN_num_bytes(x);
index 26a4a9ee7c977c86658e2fdc006e3cec40f5a755..7590f6f5b054fab90f1932db174ae507b24f78a4 100644 (file)
@@ -262,6 +262,7 @@ int x9_62_tests(BIO *out)
                "3238135532097973577080787768312505059318910517550078427819"
                "78505179448783"))
                goto x962_err;
                "3238135532097973577080787768312505059318910517550078427819"
                "78505179448783"))
                goto x962_err;
+#ifndef OPENSSL_NO_EC2M
        if (!x9_62_test_internal(out, NID_X9_62_c2tnb191v1,
                "87194383164871543355722284926904419997237591535066528048",
                "308992691965804947361541664549085895292153777025772063598"))
        if (!x9_62_test_internal(out, NID_X9_62_c2tnb191v1,
                "87194383164871543355722284926904419997237591535066528048",
                "308992691965804947361541664549085895292153777025772063598"))
@@ -272,7 +273,7 @@ int x9_62_tests(BIO *out)
                "1970303740007316867383349976549972270528498040721988191026"
                "49413465737174"))
                goto x962_err;
                "1970303740007316867383349976549972270528498040721988191026"
                "49413465737174"))
                goto x962_err;
-
+#endif
        ret = 1;
 x962_err:
        if (!restore_rand())
        ret = 1;
 x962_err:
        if (!restore_rand())
index bbb5588cbeadc39195fd8fc4e5e982608b7a70c2..c4c3e891bd68e9670a141e5e60a05816f7c46644 100644 (file)
@@ -169,6 +169,7 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
                                goto err;
                        }
                }
                                goto err;
                        }
                }
+#ifndef OPENSSL_NO_EC2M
                else /* NID_X9_62_characteristic_two_field */
                {
                        if (!EC_POINT_get_affine_coordinates_GF2m(group,
                else /* NID_X9_62_characteristic_two_field */
                {
                        if (!EC_POINT_get_affine_coordinates_GF2m(group,
@@ -178,6 +179,7 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
                                goto err;
                        }
                }
                                goto err;
                        }
                }
+#endif
                if (!BN_nnmod(r, X, order, ctx))
                {
                        ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB);
                if (!BN_nnmod(r, X, order, ctx))
                {
                        ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB);
@@ -456,6 +458,7 @@ static int ecdsa_do_verify(const unsigned char *dgst, int dgst_len,
                        goto err;
                }
        }
                        goto err;
                }
        }
+#ifndef OPENSSL_NO_EC2M
        else /* NID_X9_62_characteristic_two_field */
        {
                if (!EC_POINT_get_affine_coordinates_GF2m(group,
        else /* NID_X9_62_characteristic_two_field */
        {
                if (!EC_POINT_get_affine_coordinates_GF2m(group,
@@ -465,7 +468,7 @@ static int ecdsa_do_verify(const unsigned char *dgst, int dgst_len,
                        goto err;
                }
        }
                        goto err;
                }
        }
-       
+#endif 
        if (!BN_nnmod(u1, X, order, ctx))
        {
                ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB);
        if (!BN_nnmod(u1, X, order, ctx))
        {
                ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB);
index 3d71e4212e4c4cb2ed4b9a86fa241b129b59d5bb..974cc9cc6f903129936edccff2d8ea78cdf5638b 100644 (file)
@@ -137,12 +137,6 @@ extern "C" {
 #define ERR_PUT_error(a,b,c,d,e)       ERR_put_error(a,b,c,NULL,0)
 #endif
 
 #define ERR_PUT_error(a,b,c,d,e)       ERR_put_error(a,b,c,NULL,0)
 #endif
 
-#ifdef OPENSSL_FIPS
-void FIPS_set_error_callbacks(
-       void (*put_cb)(int lib, int func,int reason,const char *file,int line),
-       void (*add_cb)(int num, va_list args) );
-#endif
-
 #include <errno.h>
 
 #define ERR_TXT_MALLOCED       0x01
 #include <errno.h>
 
 #define ERR_TXT_MALLOCED       0x01
index 582b9ca1655df6a9f8fab53797e9eff245146f0e..70950e1b4967777cdf9e47256cb8c77970dcbd94 100644 (file)
@@ -943,7 +943,11 @@ bad:
                                }
                        }
                else
                                }
                        }
                else
+#ifdef OPENSSL_NO_EC2M
+                       nid = NID_X9_62_prime256v1;
+#else
                        nid = NID_sect163r2;
                        nid = NID_sect163r2;
+#endif
 
                ecdh = EC_KEY_new_by_curve_name(nid);
                if (ecdh == NULL)
 
                ecdh = EC_KEY_new_by_curve_name(nid);
                if (ecdh == NULL)
index a29a3ca133eb3fbc7c3143a1dce626bca780b97a..2fbbace10c31c45091c52db882b9c2d20ddd4c50 100755 (executable)
@@ -273,6 +273,7 @@ $cflags.=" -DOPENSSL_NO_GOST" if $no_gost;
 $cflags.=" -DOPENSSL_NO_ENGINE"   if $no_engine;
 $cflags.=" -DOPENSSL_NO_HW"   if $no_hw;
 $cflags.=" -DOPENSSL_NO_JPAKE"    if $no_jpake;
 $cflags.=" -DOPENSSL_NO_ENGINE"   if $no_engine;
 $cflags.=" -DOPENSSL_NO_HW"   if $no_hw;
 $cflags.=" -DOPENSSL_NO_JPAKE"    if $no_jpake;
+$cflags.=" -DOPENSSL_NO_EC2M"    if $no_ec2m;
 $cflags.= " -DZLIB" if $zlib_opt;
 $cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
 
 $cflags.= " -DZLIB" if $zlib_opt;
 $cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
 
@@ -1062,6 +1063,7 @@ sub read_options
                "no-tlsext" => \$no_tlsext,
                "no-srp" => \$no_srp,
                "no-cms" => \$no_cms,
                "no-tlsext" => \$no_tlsext,
                "no-srp" => \$no_srp,
                "no-cms" => \$no_cms,
+               "no-ec2m" => \$no_ec2m,
                "no-jpake" => \$no_jpake,
                "no-ec-nistp224-64-gcc-128" => 0,
                "no-err" => \$no_err,
                "no-jpake" => \$no_jpake,
                "no-ec-nistp224-64-gcc-128" => 0,
                "no-err" => \$no_err,
index 602d7cf42011462d710afbb0a596e36cedddc1c0..cdea137a4f3754c2137dc1d8c3f6fc3946eb8d7a 100755 (executable)
@@ -84,7 +84,7 @@ my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT", "OS2" );
 my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
                         "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1",
                         "SHA256", "SHA512", "RIPEMD",
 my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
                         "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1",
                         "SHA256", "SHA512", "RIPEMD",
-                        "MDC2", "WHIRLPOOL", "RSA", "DSA", "DH", "EC", "ECDH", "ECDSA",
+                        "MDC2", "WHIRLPOOL", "RSA", "DSA", "DH", "EC", "ECDH", "ECDSA", "EC2M",
                         "HMAC", "AES", "CAMELLIA", "SEED", "GOST",
                         # ECP_NISTP224
                         "EC_NISTP224_64_GCC_128",
                         "HMAC", "AES", "CAMELLIA", "SEED", "GOST",
                         # ECP_NISTP224
                         "EC_NISTP224_64_GCC_128",
@@ -131,7 +131,7 @@ my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_aes; my $no_krb5;
 my $no_ec; my $no_ecdsa; my $no_ecdh; my $no_engine; my $no_hw;
 my $no_fp_api; my $no_static_engine=1; my $no_gmp; my $no_deprecated;
 my $no_rfc3779; my $no_psk; my $no_tlsext; my $no_cms; my $no_capieng;
 my $no_ec; my $no_ecdsa; my $no_ecdh; my $no_engine; my $no_hw;
 my $no_fp_api; my $no_static_engine=1; my $no_gmp; my $no_deprecated;
 my $no_rfc3779; my $no_psk; my $no_tlsext; my $no_cms; my $no_capieng;
-my $no_jpake; my $no_srp; my $no_ssl2; my $no_nistp_gcc;
+my $no_jpake; my $no_srp; my $no_ssl2; my $no_ec2m; my $no_nistp_gcc; 
 
 my $zlib;
 
 
 my $zlib;
 
@@ -219,6 +219,7 @@ foreach (@ARGV, split(/ /, $options))
        elsif (/^no-rfc3779$/)  { $no_rfc3779=1; }
        elsif (/^no-tlsext$/)   { $no_tlsext=1; }
        elsif (/^no-cms$/)      { $no_cms=1; }
        elsif (/^no-rfc3779$/)  { $no_rfc3779=1; }
        elsif (/^no-tlsext$/)   { $no_tlsext=1; }
        elsif (/^no-cms$/)      { $no_cms=1; }
+       elsif (/^no-ec2m$/)     { $no_ec2m=1; }
        elsif (/^no-ec-nistp224-64-gcc-128$/)   { $no_nistp_gcc=1; }
        elsif (/^no-ssl2$/)     { $no_ssl2=1; }
        elsif (/^no-capieng$/)  { $no_capieng=1; }
        elsif (/^no-ec-nistp224-64-gcc-128$/)   { $no_nistp_gcc=1; }
        elsif (/^no-ssl2$/)     { $no_ssl2=1; }
        elsif (/^no-capieng$/)  { $no_capieng=1; }
@@ -1179,6 +1180,7 @@ sub is_valid
                        if ($keyword eq "TLSEXT" && $no_tlsext) { return 0; }
                        if ($keyword eq "PSK" && $no_psk) { return 0; }
                        if ($keyword eq "CMS" && $no_cms) { return 0; }
                        if ($keyword eq "TLSEXT" && $no_tlsext) { return 0; }
                        if ($keyword eq "PSK" && $no_psk) { return 0; }
                        if ($keyword eq "CMS" && $no_cms) { return 0; }
+                       if ($keyword eq "EC2M" && $no_ec2m) { return 0; }
                        if ($keyword eq "EC_NISTP224_64_GCC_128" && $no_nistp_gcc)
                                        { return 0; }
                        if ($keyword eq "SSL2" && $no_ssl2) { return 0; }
                        if ($keyword eq "EC_NISTP224_64_GCC_128" && $no_nistp_gcc)
                                        { return 0; }
                        if ($keyword eq "SSL2" && $no_ssl2) { return 0; }