Blame SOURCES/openssl-1.0.2a-fips-ec.patch

96a864
diff -up openssl-1.0.2a/crypto/ecdh/ecdhtest.c.fips-ec openssl-1.0.2a/crypto/ecdh/ecdhtest.c
96a864
--- openssl-1.0.2a/crypto/ecdh/ecdhtest.c.fips-ec	2015-03-19 14:30:36.000000000 +0100
96a864
+++ openssl-1.0.2a/crypto/ecdh/ecdhtest.c	2015-04-22 19:00:19.721884512 +0200
96a864
@@ -501,11 +501,13 @@ int main(int argc, char *argv[])
96a864
         goto err;
96a864
 
96a864
     /* NIST PRIME CURVES TESTS */
96a864
+# if 0
96a864
     if (!test_ecdh_curve
96a864
         (NID_X9_62_prime192v1, "NIST Prime-Curve P-192", ctx, out))
96a864
         goto err;
96a864
     if (!test_ecdh_curve(NID_secp224r1, "NIST Prime-Curve P-224", ctx, out))
96a864
         goto err;
96a864
+# endif
96a864
     if (!test_ecdh_curve
96a864
         (NID_X9_62_prime256v1, "NIST Prime-Curve P-256", ctx, out))
96a864
         goto err;
96a864
@@ -536,13 +538,14 @@ int main(int argc, char *argv[])
96a864
     if (!test_ecdh_curve(NID_sect571r1, "NIST Binary-Curve B-571", ctx, out))
96a864
         goto err;
96a864
 # endif
96a864
+# if 0
96a864
     if (!test_ecdh_kat(out, "Brainpool Prime-Curve brainpoolP256r1", 256))
96a864
         goto err;
96a864
     if (!test_ecdh_kat(out, "Brainpool Prime-Curve brainpoolP384r1", 384))
96a864
         goto err;
96a864
     if (!test_ecdh_kat(out, "Brainpool Prime-Curve brainpoolP512r1", 512))
96a864
         goto err;
96a864
-
96a864
+# endif
96a864
     ret = 0;
96a864
 
96a864
  err:
96a864
diff -up openssl-1.0.2a/crypto/ecdh/ech_lib.c.fips-ec openssl-1.0.2a/crypto/ecdh/ech_lib.c
96a864
--- openssl-1.0.2a/crypto/ecdh/ech_lib.c.fips-ec	2015-03-19 14:19:00.000000000 +0100
96a864
+++ openssl-1.0.2a/crypto/ecdh/ech_lib.c	2015-04-22 19:00:19.721884512 +0200
96a864
@@ -93,14 +93,7 @@ void ECDH_set_default_method(const ECDH_
96a864
 const ECDH_METHOD *ECDH_get_default_method(void)
96a864
 {
96a864
     if (!default_ECDH_method) {
96a864
-#ifdef OPENSSL_FIPS
96a864
-        if (FIPS_mode())
96a864
-            return FIPS_ecdh_openssl();
96a864
-        else
96a864
-            return ECDH_OpenSSL();
96a864
-#else
96a864
         default_ECDH_method = ECDH_OpenSSL();
96a864
-#endif
96a864
     }
96a864
     return default_ECDH_method;
96a864
 }
96a864
diff -up openssl-1.0.2a/crypto/ecdh/ech_ossl.c.fips-ec openssl-1.0.2a/crypto/ecdh/ech_ossl.c
96a864
--- openssl-1.0.2a/crypto/ecdh/ech_ossl.c.fips-ec	2015-03-19 14:30:36.000000000 +0100
96a864
+++ openssl-1.0.2a/crypto/ecdh/ech_ossl.c	2015-04-22 19:00:19.722884536 +0200
96a864
@@ -78,6 +78,10 @@
96a864
 #include <openssl/obj_mac.h>
96a864
 #include <openssl/bn.h>
96a864
 
96a864
+#ifdef OPENSSL_FIPS
96a864
+# include <openssl/fips.h>
96a864
+#endif
96a864
+
96a864
 static int ecdh_compute_key(void *out, size_t len, const EC_POINT *pub_key,
96a864
                             EC_KEY *ecdh,
96a864
                             void *(*KDF) (const void *in, size_t inlen,
96a864
@@ -90,7 +94,7 @@ static ECDH_METHOD openssl_ecdh_meth = {
96a864
     NULL,                       /* init */
96a864
     NULL,                       /* finish */
96a864
 #endif
96a864
-    0,                          /* flags */
96a864
+    ECDH_FLAG_FIPS_METHOD,      /* flags */
96a864
     NULL                        /* app_data */
96a864
 };
96a864
 
96a864
@@ -119,6 +123,13 @@ static int ecdh_compute_key(void *out, s
96a864
     size_t buflen, len;
96a864
     unsigned char *buf = NULL;
96a864
 
96a864
+#ifdef OPENSSL_FIPS
96a864
+    if (FIPS_selftest_failed()) {
96a864
+        FIPSerr(FIPS_F_ECDH_COMPUTE_KEY, FIPS_R_FIPS_SELFTEST_FAILED);
96a864
+        return -1;
96a864
+    }
96a864
+#endif
96a864
+
96a864
     if (outlen > INT_MAX) {
96a864
         ECDHerr(ECDH_F_ECDH_COMPUTE_KEY, ERR_R_MALLOC_FAILURE); /* sort of,
96a864
                                                                  * anyway */
96a864
diff -up openssl-1.0.2a/crypto/ecdsa/ecdsatest.c.fips-ec openssl-1.0.2a/crypto/ecdsa/ecdsatest.c
96a864
--- openssl-1.0.2a/crypto/ecdsa/ecdsatest.c.fips-ec	2015-03-19 14:19:00.000000000 +0100
96a864
+++ openssl-1.0.2a/crypto/ecdsa/ecdsatest.c	2015-04-22 19:00:19.722884536 +0200
96a864
@@ -138,11 +138,14 @@ int restore_rand(void)
96a864
 }
96a864
 
96a864
 static int fbytes_counter = 0;
96a864
-static const char *numbers[8] = {
96a864
+static const char *numbers[10] = {
96a864
+    "651056770906015076056810763456358567190100156695615665659",
96a864
     "651056770906015076056810763456358567190100156695615665659",
96a864
     "6140507067065001063065065565667405560006161556565665656654",
96a864
     "8763001015071075675010661307616710783570106710677817767166"
96a864
         "71676178726717",
96a864
+    "8763001015071075675010661307616710783570106710677817767166"
96a864
+        "71676178726717",
96a864
     "7000000175690566466555057817571571075705015757757057795755"
96a864
         "55657156756655",
96a864
     "1275552191113212300012030439187146164646146646466749494799",
96a864
@@ -158,7 +161,7 @@ int fbytes(unsigned char *buf, int num)
96a864
     int ret;
96a864
     BIGNUM *tmp = NULL;
96a864
 
96a864
-    if (fbytes_counter >= 8)
96a864
+    if (fbytes_counter >= 10)
96a864
         return 0;
96a864
     tmp = BN_new();
96a864
     if (!tmp)
96a864
@@ -532,8 +535,10 @@ int main(void)
96a864
     RAND_seed(rnd_seed, sizeof(rnd_seed));
96a864
 
96a864
     /* the tests */
96a864
+# if 0
96a864
     if (!x9_62_tests(out))
96a864
         goto err;
96a864
+# endif
96a864
     if (!test_builtin(out))
96a864
         goto err;
96a864
 
96a864
diff -up openssl-1.0.2a/crypto/ecdsa/ecs_lib.c.fips-ec openssl-1.0.2a/crypto/ecdsa/ecs_lib.c
96a864
--- openssl-1.0.2a/crypto/ecdsa/ecs_lib.c.fips-ec	2015-03-19 14:30:36.000000000 +0100
96a864
+++ openssl-1.0.2a/crypto/ecdsa/ecs_lib.c	2015-04-22 19:00:19.722884536 +0200
96a864
@@ -80,14 +80,7 @@ void ECDSA_set_default_method(const ECDS
96a864
 const ECDSA_METHOD *ECDSA_get_default_method(void)
96a864
 {
96a864
     if (!default_ECDSA_method) {
96a864
-#ifdef OPENSSL_FIPS
96a864
-        if (FIPS_mode())
96a864
-            return FIPS_ecdsa_openssl();
96a864
-        else
96a864
-            return ECDSA_OpenSSL();
96a864
-#else
96a864
         default_ECDSA_method = ECDSA_OpenSSL();
96a864
-#endif
96a864
     }
96a864
     return default_ECDSA_method;
96a864
 }
96a864
diff -up openssl-1.0.2a/crypto/ecdsa/ecs_ossl.c.fips-ec openssl-1.0.2a/crypto/ecdsa/ecs_ossl.c
96a864
--- openssl-1.0.2a/crypto/ecdsa/ecs_ossl.c.fips-ec	2015-03-19 14:30:36.000000000 +0100
96a864
+++ openssl-1.0.2a/crypto/ecdsa/ecs_ossl.c	2015-04-22 19:00:19.722884536 +0200
96a864
@@ -60,6 +60,9 @@
96a864
 #include <openssl/err.h>
96a864
 #include <openssl/obj_mac.h>
96a864
 #include <openssl/bn.h>
96a864
+#ifdef OPENSSL_FIPS
96a864
+# include <openssl/fips.h>
96a864
+#endif
96a864
 
96a864
 static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dlen,
96a864
                                 const BIGNUM *, const BIGNUM *,
96a864
@@ -78,7 +81,7 @@ static ECDSA_METHOD openssl_ecdsa_meth =
96a864
     NULL,                       /* init */
96a864
     NULL,                       /* finish */
96a864
 #endif
96a864
-    0,                          /* flags */
96a864
+    ECDSA_FLAG_FIPS_METHOD,     /* flags */
96a864
     NULL                        /* app_data */
96a864
 };
96a864
 
96a864
@@ -245,6 +248,13 @@ static ECDSA_SIG *ecdsa_do_sign(const un
96a864
     ECDSA_DATA *ecdsa;
96a864
     const BIGNUM *priv_key;
96a864
 
96a864
+#ifdef OPENSSL_FIPS
96a864
+    if (FIPS_selftest_failed()) {
96a864
+        FIPSerr(FIPS_F_ECDSA_DO_SIGN, FIPS_R_FIPS_SELFTEST_FAILED);
96a864
+        return NULL;
96a864
+    }
96a864
+#endif
96a864
+
96a864
     ecdsa = ecdsa_check(eckey);
96a864
     group = EC_KEY_get0_group(eckey);
96a864
     priv_key = EC_KEY_get0_private_key(eckey);
96a864
@@ -358,6 +368,13 @@ static int ecdsa_do_verify(const unsigne
96a864
     const EC_GROUP *group;
96a864
     const EC_POINT *pub_key;
96a864
 
96a864
+#ifdef OPENSSL_FIPS
96a864
+    if (FIPS_selftest_failed()) {
96a864
+        FIPSerr(FIPS_F_ECDSA_DO_VERIFY, FIPS_R_FIPS_SELFTEST_FAILED);
96a864
+        return -1;
96a864
+    }
96a864
+#endif
96a864
+
96a864
     /* check input values */
96a864
     if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL ||
96a864
         (pub_key = EC_KEY_get0_public_key(eckey)) == NULL || sig == NULL) {
96a864
diff -up openssl-1.0.2a/crypto/ec/ec_cvt.c.fips-ec openssl-1.0.2a/crypto/ec/ec_cvt.c
96a864
--- openssl-1.0.2a/crypto/ec/ec_cvt.c.fips-ec	2015-03-19 14:30:36.000000000 +0100
96a864
+++ openssl-1.0.2a/crypto/ec/ec_cvt.c	2015-04-22 19:01:08.703040756 +0200
96a864
@@ -82,10 +82,6 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const B
96a864
     const EC_METHOD *meth;
96a864
     EC_GROUP *ret;
96a864
 
96a864
-#ifdef OPENSSL_FIPS
96a864
-    if (FIPS_mode())
96a864
-        return FIPS_ec_group_new_curve_gfp(p, a, b, ctx);
96a864
-#endif
96a864
 #if defined(OPENSSL_BN_ASM_MONT)
96a864
     /*
96a864
      * This might appear controversial, but the fact is that generic
96a864
@@ -160,10 +156,6 @@ EC_GROUP *EC_GROUP_new_curve_GF2m(const
96a864
     const EC_METHOD *meth;
96a864
     EC_GROUP *ret;
96a864
 
96a864
-# ifdef OPENSSL_FIPS
96a864
-    if (FIPS_mode())
96a864
-        return FIPS_ec_group_new_curve_gf2m(p, a, b, ctx);
96a864
-# endif
96a864
     meth = EC_GF2m_simple_method();
96a864
 
96a864
     ret = EC_GROUP_new(meth);
96a864
diff -up openssl-1.0.2a/crypto/ec/ec_key.c.fips-ec openssl-1.0.2a/crypto/ec/ec_key.c
96a864
--- openssl-1.0.2a/crypto/ec/ec_key.c.fips-ec	2015-03-19 14:19:00.000000000 +0100
96a864
+++ openssl-1.0.2a/crypto/ec/ec_key.c	2015-04-22 19:00:19.722884536 +0200
96a864
@@ -64,9 +64,6 @@
96a864
 #include <string.h>
96a864
 #include "ec_lcl.h"
96a864
 #include <openssl/err.h>
96a864
-#ifdef OPENSSL_FIPS
96a864
-# include <openssl/fips.h>
96a864
-#endif
96a864
 
96a864
 EC_KEY *EC_KEY_new(void)
96a864
 {
96a864
@@ -227,6 +224,38 @@ int EC_KEY_up_ref(EC_KEY *r)
96a864
     return ((i > 1) ? 1 : 0);
96a864
 }
96a864
 
96a864
+#ifdef OPENSSL_FIPS
96a864
+
96a864
+# include <openssl/evp.h>
96a864
+# include <openssl/fips.h>
96a864
+# include <openssl/fips_rand.h>
96a864
+
96a864
+static int fips_check_ec(EC_KEY *key)
96a864
+{
96a864
+    EVP_PKEY *pk;
96a864
+    unsigned char tbs[] = "ECDSA Pairwise Check Data";
96a864
+    int ret = 0;
96a864
+
96a864
+    if ((pk = EVP_PKEY_new()) == NULL)
96a864
+        goto err;
96a864
+
96a864
+    EVP_PKEY_set1_EC_KEY(pk, key);
96a864
+
96a864
+    if (fips_pkey_signature_test(pk, tbs, -1, NULL, 0, NULL, 0, NULL))
96a864
+        ret = 1;
96a864
+
96a864
+ err:
96a864
+    if (ret == 0) {
96a864
+        FIPSerr(FIPS_F_FIPS_CHECK_EC, FIPS_R_PAIRWISE_TEST_FAILED);
96a864
+        fips_set_selftest_fail();
96a864
+    }
96a864
+    if (pk)
96a864
+        EVP_PKEY_free(pk);
96a864
+    return ret;
96a864
+}
96a864
+
96a864
+#endif
96a864
+
96a864
 int EC_KEY_generate_key(EC_KEY *eckey)
96a864
 {
96a864
     int ok = 0;
96a864
@@ -235,8 +264,10 @@ int EC_KEY_generate_key(EC_KEY *eckey)
96a864
     EC_POINT *pub_key = NULL;
96a864
 
96a864
 #ifdef OPENSSL_FIPS
96a864
-    if (FIPS_mode())
96a864
-        return FIPS_ec_key_generate_key(eckey);
96a864
+    if (FIPS_selftest_failed()) {
96a864
+        FIPSerr(FIPS_F_EC_KEY_GENERATE_KEY, FIPS_R_FIPS_SELFTEST_FAILED);
96a864
+        return 0;
96a864
+    }
96a864
 #endif
96a864
 
96a864
     if (!eckey || !eckey->group) {
96a864
@@ -277,6 +308,14 @@ int EC_KEY_generate_key(EC_KEY *eckey)
96a864
     eckey->priv_key = priv_key;
96a864
     eckey->pub_key = pub_key;
96a864
 
96a864
+#ifdef OPENSSL_FIPS
96a864
+    if (!fips_check_ec(eckey)) {
96a864
+        eckey->priv_key = NULL;
96a864
+        eckey->pub_key = NULL;
96a864
+        goto err;
96a864
+    }
96a864
+#endif
96a864
+
96a864
     ok = 1;
96a864
 
96a864
  err:
96a864
@@ -408,10 +447,12 @@ int EC_KEY_set_public_key_affine_coordin
96a864
             goto err;
96a864
     }
96a864
     /*
96a864
-     * Check if retrieved coordinates match originals: if not values are out
96a864
-     * of range.
96a864
+     * Check if retrieved coordinates match originals and are less
96a864
+     * than field order: if not values are out of range.
96a864
      */
96a864
-    if (BN_cmp(x, tx) || BN_cmp(y, ty)) {
96a864
+    if (BN_cmp(x, tx) || BN_cmp(y, ty)
96a864
+        || (BN_cmp(x, &key->group->field) >= 0)
96a864
+        || (BN_cmp(y, &key->group->field) >= 0)) {
96a864
         ECerr(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES,
96a864
               EC_R_COORDINATES_OUT_OF_RANGE);
96a864
         goto err;
96a864
diff -up openssl-1.0.2a/crypto/ec/ecp_mont.c.fips-ec openssl-1.0.2a/crypto/ec/ecp_mont.c
96a864
--- openssl-1.0.2a/crypto/ec/ecp_mont.c.fips-ec	2015-03-19 14:19:00.000000000 +0100
96a864
+++ openssl-1.0.2a/crypto/ec/ecp_mont.c	2015-04-22 19:00:19.722884536 +0200
96a864
@@ -63,10 +63,6 @@
96a864
 
96a864
 #include <openssl/err.h>
96a864
 
96a864
-#ifdef OPENSSL_FIPS
96a864
-# include <openssl/fips.h>
96a864
-#endif
96a864
-
96a864
 #include "ec_lcl.h"
96a864
 
96a864
 const EC_METHOD *EC_GFp_mont_method(void)
96a864
@@ -111,11 +107,6 @@ const EC_METHOD *EC_GFp_mont_method(void
96a864
         ec_GFp_mont_field_set_to_one
96a864
     };
96a864
 
96a864
-#ifdef OPENSSL_FIPS
96a864
-    if (FIPS_mode())
96a864
-        return fips_ec_gfp_mont_method();
96a864
-#endif
96a864
-
96a864
     return &ret;
96a864
 }
96a864
 
96a864
diff -up openssl-1.0.2a/crypto/ec/ecp_nist.c.fips-ec openssl-1.0.2a/crypto/ec/ecp_nist.c
96a864
--- openssl-1.0.2a/crypto/ec/ecp_nist.c.fips-ec	2015-03-19 14:19:00.000000000 +0100
96a864
+++ openssl-1.0.2a/crypto/ec/ecp_nist.c	2015-04-22 19:00:19.723884560 +0200
96a864
@@ -67,10 +67,6 @@
96a864
 #include <openssl/obj_mac.h>
96a864
 #include "ec_lcl.h"
96a864
 
96a864
-#ifdef OPENSSL_FIPS
96a864
-# include <openssl/fips.h>
96a864
-#endif
96a864
-
96a864
 const EC_METHOD *EC_GFp_nist_method(void)
96a864
 {
96a864
     static const EC_METHOD ret = {
96a864
@@ -113,11 +109,6 @@ const EC_METHOD *EC_GFp_nist_method(void
96a864
         0                       /* field_set_to_one */
96a864
     };
96a864
 
96a864
-#ifdef OPENSSL_FIPS
96a864
-    if (FIPS_mode())
96a864
-        return fips_ec_gfp_nist_method();
96a864
-#endif
96a864
-
96a864
     return &ret;
96a864
 }
96a864
 
96a864
diff -up openssl-1.0.2a/crypto/ec/ecp_smpl.c.fips-ec openssl-1.0.2a/crypto/ec/ecp_smpl.c
96a864
--- openssl-1.0.2a/crypto/ec/ecp_smpl.c.fips-ec	2015-03-19 14:19:00.000000000 +0100
96a864
+++ openssl-1.0.2a/crypto/ec/ecp_smpl.c	2015-04-22 19:00:19.723884560 +0200
96a864
@@ -66,10 +66,6 @@
96a864
 #include <openssl/err.h>
96a864
 #include <openssl/symhacks.h>
96a864
 
96a864
-#ifdef OPENSSL_FIPS
96a864
-# include <openssl/fips.h>
96a864
-#endif
96a864
-
96a864
 #include "ec_lcl.h"
96a864
 
96a864
 const EC_METHOD *EC_GFp_simple_method(void)
96a864
@@ -114,11 +110,6 @@ const EC_METHOD *EC_GFp_simple_method(vo
96a864
         0                       /* field_set_to_one */
96a864
     };
96a864
 
96a864
-#ifdef OPENSSL_FIPS
96a864
-    if (FIPS_mode())
96a864
-        return fips_ec_gfp_simple_method();
96a864
-#endif
96a864
-
96a864
     return &ret;
96a864
 }
96a864
 
96a864
@@ -187,6 +178,11 @@ int ec_GFp_simple_group_set_curve(EC_GRO
96a864
         return 0;
96a864
     }
96a864
 
96a864
+    if (BN_num_bits(p) < 256) {
96a864
+        ECerr(EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE, EC_R_UNSUPPORTED_FIELD);
96a864
+        return 0;
96a864
+    }
96a864
+
96a864
     if (ctx == NULL) {
96a864
         ctx = new_ctx = BN_CTX_new();
96a864
         if (ctx == NULL)
96a864
diff -up openssl-1.0.2a/crypto/evp/m_ecdsa.c.fips-ec openssl-1.0.2a/crypto/evp/m_ecdsa.c
96a864
--- openssl-1.0.2a/crypto/evp/m_ecdsa.c.fips-ec	2015-03-19 14:30:36.000000000 +0100
96a864
+++ openssl-1.0.2a/crypto/evp/m_ecdsa.c	2015-04-22 19:00:19.723884560 +0200
96a864
@@ -136,7 +136,7 @@ static const EVP_MD ecdsa_md = {
96a864
     NID_ecdsa_with_SHA1,
96a864
     NID_ecdsa_with_SHA1,
96a864
     SHA_DIGEST_LENGTH,
96a864
-    EVP_MD_FLAG_PKEY_DIGEST,
96a864
+    EVP_MD_FLAG_PKEY_DIGEST | EVP_MD_FLAG_FIPS,
96a864
     init,
96a864
     update,
96a864
     final,
96a864
diff -up openssl-1.0.2a/crypto/fips/cavs/fips_ecdhvs.c.fips-ec openssl-1.0.2a/crypto/fips/cavs/fips_ecdhvs.c
96a864
--- openssl-1.0.2a/crypto/fips/cavs/fips_ecdhvs.c.fips-ec	2015-04-22 19:00:19.723884560 +0200
96a864
+++ openssl-1.0.2a/crypto/fips/cavs/fips_ecdhvs.c	2015-04-22 19:00:19.723884560 +0200
96a864
@@ -0,0 +1,456 @@
96a864
+/* fips/ecdh/fips_ecdhvs.c */
96a864
+/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
96a864
+ * project.
96a864
+ */
96a864
+/* ====================================================================
96a864
+ * Copyright (c) 2011 The OpenSSL Project.  All rights reserved.
96a864
+ *
96a864
+ * Redistribution and use in source and binary forms, with or without
96a864
+ * modification, are permitted provided that the following conditions
96a864
+ * are met:
96a864
+ *
96a864
+ * 1. Redistributions of source code must retain the above copyright
96a864
+ *    notice, this list of conditions and the following disclaimer. 
96a864
+ *
96a864
+ * 2. Redistributions in binary form must reproduce the above copyright
96a864
+ *    notice, this list of conditions and the following disclaimer in
96a864
+ *    the documentation and/or other materials provided with the
96a864
+ *    distribution.
96a864
+ *
96a864
+ * 3. All advertising materials mentioning features or use of this
96a864
+ *    software must display the following acknowledgment:
96a864
+ *    "This product includes software developed by the OpenSSL Project
96a864
+ *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
96a864
+ *
96a864
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
96a864
+ *    endorse or promote products derived from this software without
96a864
+ *    prior written permission. For written permission, please contact
96a864
+ *    licensing@OpenSSL.org.
96a864
+ *
96a864
+ * 5. Products derived from this software may not be called "OpenSSL"
96a864
+ *    nor may "OpenSSL" appear in their names without prior written
96a864
+ *    permission of the OpenSSL Project.
96a864
+ *
96a864
+ * 6. Redistributions of any form whatsoever must retain the following
96a864
+ *    acknowledgment:
96a864
+ *    "This product includes software developed by the OpenSSL Project
96a864
+ *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
96a864
+ *
96a864
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
96a864
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
96a864
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
96a864
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
96a864
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
96a864
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
96a864
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
96a864
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
96a864
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
96a864
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
96a864
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
96a864
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
96a864
+ * ====================================================================
96a864
+ */
96a864
+
96a864
+#define OPENSSL_FIPSAPI
96a864
+#include <openssl/opensslconf.h>
96a864
+
96a864
+#ifndef OPENSSL_FIPS
96a864
+# include <stdio.h>
96a864
+
96a864
+int main(int argc, char **argv)
96a864
+{
96a864
+    printf("No FIPS ECDH support\n");
96a864
+    return (0);
96a864
+}
96a864
+#else
96a864
+
96a864
+# include <openssl/crypto.h>
96a864
+# include <openssl/bn.h>
96a864
+# include <openssl/ecdh.h>
96a864
+# include <openssl/fips.h>
96a864
+# include <openssl/err.h>
96a864
+# include <openssl/evp.h>
96a864
+# include <string.h>
96a864
+# include <ctype.h>
96a864
+
96a864
+# include "fips_utl.h"
96a864
+
96a864
+static const EVP_MD *eparse_md(char *line)
96a864
+{
96a864
+    char *p;
96a864
+    if (line[0] != '[' || line[1] != 'E')
96a864
+        return NULL;
96a864
+    p = strchr(line, '-');
96a864
+    if (!p)
96a864
+        return NULL;
96a864
+    line = p + 1;
96a864
+    p = strchr(line, ']');
96a864
+    if (!p)
96a864
+        return NULL;
96a864
+    *p = 0;
96a864
+    p = line;
96a864
+    while (isspace(*p))
96a864
+        p++;
96a864
+    if (!strcmp(p, "SHA1"))
96a864
+        return EVP_sha1();
96a864
+    else if (!strcmp(p, "SHA224"))
96a864
+        return EVP_sha224();
96a864
+    else if (!strcmp(p, "SHA256"))
96a864
+        return EVP_sha256();
96a864
+    else if (!strcmp(p, "SHA384"))
96a864
+        return EVP_sha384();
96a864
+    else if (!strcmp(p, "SHA512"))
96a864
+        return EVP_sha512();
96a864
+    else
96a864
+        return NULL;
96a864
+}
96a864
+
96a864
+static int lookup_curve2(char *cname)
96a864
+{
96a864
+    char *p;
96a864
+    p = strchr(cname, ']');
96a864
+    if (!p) {
96a864
+        fprintf(stderr, "Parse error: missing ]\n");
96a864
+        return NID_undef;
96a864
+    }
96a864
+    *p = 0;
96a864
+
96a864
+    if (!strcmp(cname, "B-163"))
96a864
+        return NID_sect163r2;
96a864
+    if (!strcmp(cname, "B-233"))
96a864
+        return NID_sect233r1;
96a864
+    if (!strcmp(cname, "B-283"))
96a864
+        return NID_sect283r1;
96a864
+    if (!strcmp(cname, "B-409"))
96a864
+        return NID_sect409r1;
96a864
+    if (!strcmp(cname, "B-571"))
96a864
+        return NID_sect571r1;
96a864
+    if (!strcmp(cname, "K-163"))
96a864
+        return NID_sect163k1;
96a864
+    if (!strcmp(cname, "K-233"))
96a864
+        return NID_sect233k1;
96a864
+    if (!strcmp(cname, "K-283"))
96a864
+        return NID_sect283k1;
96a864
+    if (!strcmp(cname, "K-409"))
96a864
+        return NID_sect409k1;
96a864
+    if (!strcmp(cname, "K-571"))
96a864
+        return NID_sect571k1;
96a864
+    if (!strcmp(cname, "P-192"))
96a864
+        return NID_X9_62_prime192v1;
96a864
+    if (!strcmp(cname, "P-224"))
96a864
+        return NID_secp224r1;
96a864
+    if (!strcmp(cname, "P-256"))
96a864
+        return NID_X9_62_prime256v1;
96a864
+    if (!strcmp(cname, "P-384"))
96a864
+        return NID_secp384r1;
96a864
+    if (!strcmp(cname, "P-521"))
96a864
+        return NID_secp521r1;
96a864
+
96a864
+    fprintf(stderr, "Unknown Curve name %s\n", cname);
96a864
+    return NID_undef;
96a864
+}
96a864
+
96a864
+static int lookup_curve(char *cname)
96a864
+{
96a864
+    char *p;
96a864
+    p = strchr(cname, ':');
96a864
+    if (!p) {
96a864
+        fprintf(stderr, "Parse error: missing :\n");
96a864
+        return NID_undef;
96a864
+    }
96a864
+    cname = p + 1;
96a864
+    while (isspace(*cname))
96a864
+        cname++;
96a864
+    return lookup_curve2(cname);
96a864
+}
96a864
+
96a864
+static EC_POINT *make_peer(EC_GROUP *group, BIGNUM *x, BIGNUM *y)
96a864
+{
96a864
+    EC_POINT *peer;
96a864
+    int rv;
96a864
+    BN_CTX *c;
96a864
+    peer = EC_POINT_new(group);
96a864
+    if (!peer)
96a864
+        return NULL;
96a864
+    c = BN_CTX_new();
96a864
+    if (EC_METHOD_get_field_type(EC_GROUP_method_of(group))
96a864
+        == NID_X9_62_prime_field)
96a864
+        rv = EC_POINT_set_affine_coordinates_GFp(group, peer, x, y, c);
96a864
+    else
96a864
+# ifdef OPENSSL_NO_EC2M
96a864
+    {
96a864
+        fprintf(stderr, "ERROR: GF2m not supported\n");
96a864
+        exit(1);
96a864
+    }
96a864
+# else
96a864
+        rv = EC_POINT_set_affine_coordinates_GF2m(group, peer, x, y, c);
96a864
+# endif
96a864
+
96a864
+    BN_CTX_free(c);
96a864
+    if (rv)
96a864
+        return peer;
96a864
+    EC_POINT_free(peer);
96a864
+    return NULL;
96a864
+}
96a864
+
96a864
+static int ec_print_key(FILE *out, EC_KEY *key, int add_e, int exout)
96a864
+{
96a864
+    const EC_POINT *pt;
96a864
+    const EC_GROUP *grp;
96a864
+    const EC_METHOD *meth;
96a864
+    int rv;
96a864
+    BIGNUM *tx, *ty;
96a864
+    const BIGNUM *d = NULL;
96a864
+    BN_CTX *ctx;
96a864
+    ctx = BN_CTX_new();
96a864
+    if (!ctx)
96a864
+        return 0;
96a864
+    tx = BN_CTX_get(ctx);
96a864
+    ty = BN_CTX_get(ctx);
96a864
+    if (!tx || !ty)
96a864
+        return 0;
96a864
+    grp = EC_KEY_get0_group(key);
96a864
+    pt = EC_KEY_get0_public_key(key);
96a864
+    if (exout)
96a864
+        d = EC_KEY_get0_private_key(key);
96a864
+    meth = EC_GROUP_method_of(grp);
96a864
+    if (EC_METHOD_get_field_type(meth) == NID_X9_62_prime_field)
96a864
+        rv = EC_POINT_get_affine_coordinates_GFp(grp, pt, tx, ty, ctx);
96a864
+    else
96a864
+# ifdef OPENSSL_NO_EC2M
96a864
+    {
96a864
+        fprintf(stderr, "ERROR: GF2m not supported\n");
96a864
+        exit(1);
96a864
+    }
96a864
+# else
96a864
+        rv = EC_POINT_get_affine_coordinates_GF2m(grp, pt, tx, ty, ctx);
96a864
+# endif
96a864
+
96a864
+    if (add_e) {
96a864
+        do_bn_print_name(out, "QeIUTx", tx);
96a864
+        do_bn_print_name(out, "QeIUTy", ty);
96a864
+        if (d)
96a864
+            do_bn_print_name(out, "QeIUTd", d);
96a864
+    } else {
96a864
+        do_bn_print_name(out, "QIUTx", tx);
96a864
+        do_bn_print_name(out, "QIUTy", ty);
96a864
+        if (d)
96a864
+            do_bn_print_name(out, "QIUTd", d);
96a864
+    }
96a864
+
96a864
+    BN_CTX_free(ctx);
96a864
+
96a864
+    return rv;
96a864
+
96a864
+}
96a864
+
96a864
+static void ec_output_Zhash(FILE *out, int exout, EC_GROUP *group,
96a864
+                            BIGNUM *ix, BIGNUM *iy, BIGNUM *id, BIGNUM *cx,
96a864
+                            BIGNUM *cy, const EVP_MD *md,
96a864
+                            unsigned char *rhash, size_t rhashlen)
96a864
+{
96a864
+    EC_KEY *ec = NULL;
96a864
+    EC_POINT *peerkey = NULL;
96a864
+    unsigned char *Z;
96a864
+    unsigned char chash[EVP_MAX_MD_SIZE];
96a864
+    int Zlen;
96a864
+    ec = EC_KEY_new();
96a864
+    EC_KEY_set_flags(ec, EC_FLAG_COFACTOR_ECDH);
96a864
+    EC_KEY_set_group(ec, group);
96a864
+    peerkey = make_peer(group, cx, cy);
96a864
+    if (rhash == NULL) {
96a864
+        if (md)
96a864
+            rhashlen = M_EVP_MD_size(md);
96a864
+        EC_KEY_generate_key(ec);
96a864
+        ec_print_key(out, ec, md ? 1 : 0, exout);
96a864
+    } else {
96a864
+        EC_KEY_set_public_key_affine_coordinates(ec, ix, iy);
96a864
+        EC_KEY_set_private_key(ec, id);
96a864
+    }
96a864
+    Zlen = (EC_GROUP_get_degree(group) + 7) / 8;
96a864
+    Z = OPENSSL_malloc(Zlen);
96a864
+    if (!Z)
96a864
+        exit(1);
96a864
+    ECDH_compute_key(Z, Zlen, peerkey, ec, 0);
96a864
+    if (md) {
96a864
+        if (exout)
96a864
+            OutputValue("Z", Z, Zlen, out, 0);
96a864
+        FIPS_digest(Z, Zlen, chash, NULL, md);
96a864
+        OutputValue(rhash ? "IUTHashZZ" : "HashZZ", chash, rhashlen, out, 0);
96a864
+        if (rhash) {
96a864
+            fprintf(out, "Result = %s\n",
96a864
+                    memcmp(chash, rhash, rhashlen) ? "F" : "P");
96a864
+        }
96a864
+    } else
96a864
+        OutputValue("ZIUT", Z, Zlen, out, 0);
96a864
+    OPENSSL_cleanse(Z, Zlen);
96a864
+    OPENSSL_free(Z);
96a864
+    EC_KEY_free(ec);
96a864
+    EC_POINT_free(peerkey);
96a864
+}
96a864
+
96a864
+# ifdef FIPS_ALGVS
96a864
+int fips_ecdhvs_main(int argc, char **argv)
96a864
+# else
96a864
+int main(int argc, char **argv)
96a864
+# endif
96a864
+{
96a864
+    char **args = argv + 1;
96a864
+    int argn = argc - 1;
96a864
+    FILE *in, *out;
96a864
+    char buf[2048], lbuf[2048];
96a864
+    unsigned char *rhash = NULL;
96a864
+    long rhashlen;
96a864
+    BIGNUM *cx = NULL, *cy = NULL;
96a864
+    BIGNUM *id = NULL, *ix = NULL, *iy = NULL;
96a864
+    const EVP_MD *md = NULL;
96a864
+    EC_GROUP *group = NULL;
96a864
+    char *keyword = NULL, *value = NULL;
96a864
+    int do_verify = -1, exout = 0;
96a864
+    int rv = 1;
96a864
+
96a864
+    int curve_nids[5] = { 0, 0, 0, 0, 0 };
96a864
+    int param_set = -1;
96a864
+
96a864
+    fips_algtest_init();
96a864
+
96a864
+    if (argn && !strcmp(*args, "ecdhver")) {
96a864
+        do_verify = 1;
96a864
+        args++;
96a864
+        argn--;
96a864
+    } else if (argn && !strcmp(*args, "ecdhgen")) {
96a864
+        do_verify = 0;
96a864
+        args++;
96a864
+        argn--;
96a864
+    }
96a864
+
96a864
+    if (argn && !strcmp(*args, "-exout")) {
96a864
+        exout = 1;
96a864
+        args++;
96a864
+        argn--;
96a864
+    }
96a864
+
96a864
+    if (do_verify == -1) {
96a864
+        fprintf(stderr, "%s [ecdhver|ecdhgen|] [-exout] (infile outfile)\n",
96a864
+                argv[0]);
96a864
+        exit(1);
96a864
+    }
96a864
+
96a864
+    if (argn == 2) {
96a864
+        in = fopen(*args, "r");
96a864
+        if (!in) {
96a864
+            fprintf(stderr, "Error opening input file\n");
96a864
+            exit(1);
96a864
+        }
96a864
+        out = fopen(args[1], "w");
96a864
+        if (!out) {
96a864
+            fprintf(stderr, "Error opening output file\n");
96a864
+            exit(1);
96a864
+        }
96a864
+    } else if (argn == 0) {
96a864
+        in = stdin;
96a864
+        out = stdout;
96a864
+    } else {
96a864
+        fprintf(stderr, "%s [dhver|dhgen|] [-exout] (infile outfile)\n",
96a864
+                argv[0]);
96a864
+        exit(1);
96a864
+    }
96a864
+
96a864
+    while (fgets(buf, sizeof(buf), in) != NULL) {
96a864
+        fputs(buf, out);
96a864
+        if (buf[0] == '[' && buf[1] == 'E') {
96a864
+            int c = buf[2];
96a864
+            if (c < 'A' || c > 'E')
96a864
+                goto parse_error;
96a864
+            param_set = c - 'A';
96a864
+            /* If just [E?] then initial paramset */
96a864
+            if (buf[3] == ']')
96a864
+                continue;
96a864
+            if (group)
96a864
+                EC_GROUP_free(group);
96a864
+            group = EC_GROUP_new_by_curve_name(curve_nids[c - 'A']);
96a864
+        }
96a864
+        if (strlen(buf) > 10 && !strncmp(buf, "[Curve", 6)) {
96a864
+            int nid;
96a864
+            if (param_set == -1)
96a864
+                goto parse_error;
96a864
+            nid = lookup_curve(buf);
96a864
+            if (nid == NID_undef)
96a864
+                goto parse_error;
96a864
+            curve_nids[param_set] = nid;
96a864
+        }
96a864
+
96a864
+        if (strlen(buf) > 4 && buf[0] == '[' && buf[2] == '-') {
96a864
+            int nid = lookup_curve2(buf + 1);
96a864
+            if (nid == NID_undef)
96a864
+                goto parse_error;
96a864
+            if (group)
96a864
+                EC_GROUP_free(group);
96a864
+            group = EC_GROUP_new_by_curve_name(nid);
96a864
+            if (!group) {
96a864
+                fprintf(stderr, "ERROR: unsupported curve %s\n", buf + 1);
96a864
+                return 1;
96a864
+            }
96a864
+        }
96a864
+
96a864
+        if (strlen(buf) > 6 && !strncmp(buf, "[E", 2)) {
96a864
+            md = eparse_md(buf);
96a864
+            if (md == NULL)
96a864
+                goto parse_error;
96a864
+            continue;
96a864
+        }
96a864
+        if (!parse_line(&keyword, &value, lbuf, buf))
96a864
+            continue;
96a864
+        if (!strcmp(keyword, "QeCAVSx") || !strcmp(keyword, "QCAVSx")) {
96a864
+            if (!do_hex2bn(&cx, value))
96a864
+                goto parse_error;
96a864
+        } else if (!strcmp(keyword, "QeCAVSy") || !strcmp(keyword, "QCAVSy")) {
96a864
+            if (!do_hex2bn(&cy, value))
96a864
+                goto parse_error;
96a864
+            if (do_verify == 0)
96a864
+                ec_output_Zhash(out, exout, group,
96a864
+                                NULL, NULL, NULL,
96a864
+                                cx, cy, md, rhash, rhashlen);
96a864
+        } else if (!strcmp(keyword, "deIUT")) {
96a864
+            if (!do_hex2bn(&id, value))
96a864
+                goto parse_error;
96a864
+        } else if (!strcmp(keyword, "QeIUTx")) {
96a864
+            if (!do_hex2bn(&ix, value))
96a864
+                goto parse_error;
96a864
+        } else if (!strcmp(keyword, "QeIUTy")) {
96a864
+            if (!do_hex2bn(&iy, value))
96a864
+                goto parse_error;
96a864
+        } else if (!strcmp(keyword, "CAVSHashZZ")) {
96a864
+            if (!md)
96a864
+                goto parse_error;
96a864
+            rhash = hex2bin_m(value, &rhashlen);
96a864
+            if (!rhash || rhashlen != M_EVP_MD_size(md))
96a864
+                goto parse_error;
96a864
+            ec_output_Zhash(out, exout, group, ix, iy, id, cx, cy,
96a864
+                            md, rhash, rhashlen);
96a864
+        }
96a864
+    }
96a864
+    rv = 0;
96a864
+ parse_error:
96a864
+    if (id)
96a864
+        BN_free(id);
96a864
+    if (ix)
96a864
+        BN_free(ix);
96a864
+    if (iy)
96a864
+        BN_free(iy);
96a864
+    if (cx)
96a864
+        BN_free(cx);
96a864
+    if (cy)
96a864
+        BN_free(cy);
96a864
+    if (group)
96a864
+        EC_GROUP_free(group);
96a864
+    if (in && in != stdin)
96a864
+        fclose(in);
96a864
+    if (out && out != stdout)
96a864
+        fclose(out);
96a864
+    if (rv)
96a864
+        fprintf(stderr, "Error Parsing request file\n");
96a864
+    return rv;
96a864
+}
96a864
+
96a864
+#endif
96a864
diff -up openssl-1.0.2a/crypto/fips/cavs/fips_ecdsavs.c.fips-ec openssl-1.0.2a/crypto/fips/cavs/fips_ecdsavs.c
96a864
--- openssl-1.0.2a/crypto/fips/cavs/fips_ecdsavs.c.fips-ec	2015-04-22 19:00:19.723884560 +0200
96a864
+++ openssl-1.0.2a/crypto/fips/cavs/fips_ecdsavs.c	2015-04-22 19:00:19.723884560 +0200
96a864
@@ -0,0 +1,486 @@
96a864
+/* fips/ecdsa/fips_ecdsavs.c */
96a864
+/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
96a864
+ * project.
96a864
+ */
96a864
+/* ====================================================================
96a864
+ * Copyright (c) 2011 The OpenSSL Project.  All rights reserved.
96a864
+ *
96a864
+ * Redistribution and use in source and binary forms, with or without
96a864
+ * modification, are permitted provided that the following conditions
96a864
+ * are met:
96a864
+ *
96a864
+ * 1. Redistributions of source code must retain the above copyright
96a864
+ *    notice, this list of conditions and the following disclaimer. 
96a864
+ *
96a864
+ * 2. Redistributions in binary form must reproduce the above copyright
96a864
+ *    notice, this list of conditions and the following disclaimer in
96a864
+ *    the documentation and/or other materials provided with the
96a864
+ *    distribution.
96a864
+ *
96a864
+ * 3. All advertising materials mentioning features or use of this
96a864
+ *    software must display the following acknowledgment:
96a864
+ *    "This product includes software developed by the OpenSSL Project
96a864
+ *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
96a864
+ *
96a864
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
96a864
+ *    endorse or promote products derived from this software without
96a864
+ *    prior written permission. For written permission, please contact
96a864
+ *    licensing@OpenSSL.org.
96a864
+ *
96a864
+ * 5. Products derived from this software may not be called "OpenSSL"
96a864
+ *    nor may "OpenSSL" appear in their names without prior written
96a864
+ *    permission of the OpenSSL Project.
96a864
+ *
96a864
+ * 6. Redistributions of any form whatsoever must retain the following
96a864
+ *    acknowledgment:
96a864
+ *    "This product includes software developed by the OpenSSL Project
96a864
+ *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
96a864
+ *
96a864
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
96a864
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
96a864
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
96a864
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
96a864
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
96a864
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
96a864
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
96a864
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
96a864
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
96a864
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
96a864
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
96a864
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
96a864
+ * ====================================================================
96a864
+ */
96a864
+
96a864
+#define OPENSSL_FIPSAPI
96a864
+#include <openssl/opensslconf.h>
96a864
+#include <stdio.h>
96a864
+
96a864
+#ifndef OPENSSL_FIPS
96a864
+
96a864
+int main(int argc, char **argv)
96a864
+{
96a864
+    printf("No FIPS ECDSA support\n");
96a864
+    return (0);
96a864
+}
96a864
+#else
96a864
+
96a864
+# include <string.h>
96a864
+# include <ctype.h>
96a864
+# include <openssl/err.h>
96a864
+# include <openssl/bn.h>
96a864
+# include <openssl/ecdsa.h>
96a864
+# include <openssl/evp.h>
96a864
+# include "fips_utl.h"
96a864
+
96a864
+# include <openssl/objects.h>
96a864
+
96a864
+static int elookup_curve(char *in, char *curve_name, const EVP_MD **pmd)
96a864
+{
96a864
+    char *cname, *p;
96a864
+    /* Copy buffer as we will change it */
96a864
+    strcpy(curve_name, in);
96a864
+    cname = curve_name + 1;
96a864
+    p = strchr(cname, ']');
96a864
+    if (!p) {
96a864
+        fprintf(stderr, "Parse error: missing ]\n");
96a864
+        return NID_undef;
96a864
+    }
96a864
+    *p = 0;
96a864
+    p = strchr(cname, ',');
96a864
+    if (p) {
96a864
+        if (!pmd) {
96a864
+            fprintf(stderr, "Parse error: unexpected digest\n");
96a864
+            return NID_undef;
96a864
+        }
96a864
+        *p = 0;
96a864
+        p++;
96a864
+
96a864
+        if (!strcmp(p, "SHA-1"))
96a864
+            *pmd = EVP_sha1();
96a864
+        else if (!strcmp(p, "SHA-224"))
96a864
+            *pmd = EVP_sha224();
96a864
+        else if (!strcmp(p, "SHA-256"))
96a864
+            *pmd = EVP_sha256();
96a864
+        else if (!strcmp(p, "SHA-384"))
96a864
+            *pmd = EVP_sha384();
96a864
+        else if (!strcmp(p, "SHA-512"))
96a864
+            *pmd = EVP_sha512();
96a864
+        else {
96a864
+            fprintf(stderr, "Unknown digest %s\n", p);
96a864
+            return NID_undef;
96a864
+        }
96a864
+    } else if (pmd)
96a864
+        *pmd = EVP_sha1();
96a864
+
96a864
+    if (!strcmp(cname, "B-163"))
96a864
+        return NID_sect163r2;
96a864
+    if (!strcmp(cname, "B-233"))
96a864
+        return NID_sect233r1;
96a864
+    if (!strcmp(cname, "B-283"))
96a864
+        return NID_sect283r1;
96a864
+    if (!strcmp(cname, "B-409"))
96a864
+        return NID_sect409r1;
96a864
+    if (!strcmp(cname, "B-571"))
96a864
+        return NID_sect571r1;
96a864
+    if (!strcmp(cname, "K-163"))
96a864
+        return NID_sect163k1;
96a864
+    if (!strcmp(cname, "K-233"))
96a864
+        return NID_sect233k1;
96a864
+    if (!strcmp(cname, "K-283"))
96a864
+        return NID_sect283k1;
96a864
+    if (!strcmp(cname, "K-409"))
96a864
+        return NID_sect409k1;
96a864
+    if (!strcmp(cname, "K-571"))
96a864
+        return NID_sect571k1;
96a864
+    if (!strcmp(cname, "P-192"))
96a864
+        return NID_X9_62_prime192v1;
96a864
+    if (!strcmp(cname, "P-224"))
96a864
+        return NID_secp224r1;
96a864
+    if (!strcmp(cname, "P-256"))
96a864
+        return NID_X9_62_prime256v1;
96a864
+    if (!strcmp(cname, "P-384"))
96a864
+        return NID_secp384r1;
96a864
+    if (!strcmp(cname, "P-521"))
96a864
+        return NID_secp521r1;
96a864
+
96a864
+    fprintf(stderr, "Unknown Curve name %s\n", cname);
96a864
+    return NID_undef;
96a864
+}
96a864
+
96a864
+static int ec_get_pubkey(EC_KEY *key, BIGNUM *x, BIGNUM *y)
96a864
+{
96a864
+    const EC_POINT *pt;
96a864
+    const EC_GROUP *grp;
96a864
+    const EC_METHOD *meth;
96a864
+    int rv;
96a864
+    BN_CTX *ctx;
96a864
+    ctx = BN_CTX_new();
96a864
+    if (!ctx)
96a864
+        return 0;
96a864
+    grp = EC_KEY_get0_group(key);
96a864
+    pt = EC_KEY_get0_public_key(key);
96a864
+    meth = EC_GROUP_method_of(grp);
96a864
+    if (EC_METHOD_get_field_type(meth) == NID_X9_62_prime_field)
96a864
+        rv = EC_POINT_get_affine_coordinates_GFp(grp, pt, x, y, ctx);
96a864
+    else
96a864
+# ifdef OPENSSL_NO_EC2M
96a864
+    {
96a864
+        fprintf(stderr, "ERROR: GF2m not supported\n");
96a864
+        exit(1);
96a864
+    }
96a864
+# else
96a864
+        rv = EC_POINT_get_affine_coordinates_GF2m(grp, pt, x, y, ctx);
96a864
+# endif
96a864
+
96a864
+    BN_CTX_free(ctx);
96a864
+
96a864
+    return rv;
96a864
+
96a864
+}
96a864
+
96a864
+static int KeyPair(FILE *in, FILE *out)
96a864
+{
96a864
+    char buf[2048], lbuf[2048];
96a864
+    char *keyword, *value;
96a864
+    int curve_nid = NID_undef;
96a864
+    int i, count;
96a864
+    BIGNUM *Qx = NULL, *Qy = NULL;
96a864
+    const BIGNUM *d = NULL;
96a864
+    EC_KEY *key = NULL;
96a864
+    Qx = BN_new();
96a864
+    Qy = BN_new();
96a864
+    while (fgets(buf, sizeof buf, in) != NULL) {
96a864
+        if (*buf == '[' && buf[2] == '-') {
96a864
+            if (buf[2] == '-')
96a864
+                curve_nid = elookup_curve(buf, lbuf, NULL);
96a864
+            fputs(buf, out);
96a864
+            continue;
96a864
+        }
96a864
+        if (!parse_line(&keyword, &value, lbuf, buf)) {
96a864
+            fputs(buf, out);
96a864
+            continue;
96a864
+        }
96a864
+        if (!strcmp(keyword, "N")) {
96a864
+            count = atoi(value);
96a864
+
96a864
+            for (i = 0; i < count; i++) {
96a864
+
96a864
+                key = EC_KEY_new_by_curve_name(curve_nid);
96a864
+                if (!EC_KEY_generate_key(key)) {
96a864
+                    fprintf(stderr, "Error generating key\n");
96a864
+                    return 0;
96a864
+                }
96a864
+
96a864
+                if (!ec_get_pubkey(key, Qx, Qy)) {
96a864
+                    fprintf(stderr, "Error getting public key\n");
96a864
+                    return 0;
96a864
+                }
96a864
+
96a864
+                d = EC_KEY_get0_private_key(key);
96a864
+
96a864
+                do_bn_print_name(out, "d", d);
96a864
+                do_bn_print_name(out, "Qx", Qx);
96a864
+                do_bn_print_name(out, "Qy", Qy);
96a864
+                fputs(RESP_EOL, out);
96a864
+                EC_KEY_free(key);
96a864
+
96a864
+            }
96a864
+
96a864
+        }
96a864
+
96a864
+    }
96a864
+    BN_free(Qx);
96a864
+    BN_free(Qy);
96a864
+    return 1;
96a864
+}
96a864
+
96a864
+static int PKV(FILE *in, FILE *out)
96a864
+{
96a864
+
96a864
+    char buf[2048], lbuf[2048];
96a864
+    char *keyword, *value;
96a864
+    int curve_nid = NID_undef;
96a864
+    BIGNUM *Qx = NULL, *Qy = NULL;
96a864
+    EC_KEY *key = NULL;
96a864
+    while (fgets(buf, sizeof buf, in) != NULL) {
96a864
+        fputs(buf, out);
96a864
+        if (*buf == '[' && buf[2] == '-') {
96a864
+            curve_nid = elookup_curve(buf, lbuf, NULL);
96a864
+            if (curve_nid == NID_undef)
96a864
+                return 0;
96a864
+
96a864
+        }
96a864
+        if (!parse_line(&keyword, &value, lbuf, buf))
96a864
+            continue;
96a864
+        if (!strcmp(keyword, "Qx")) {
96a864
+            if (!do_hex2bn(&Qx, value)) {
96a864
+                fprintf(stderr, "Invalid Qx value\n");
96a864
+                return 0;
96a864
+            }
96a864
+        }
96a864
+        if (!strcmp(keyword, "Qy")) {
96a864
+            int rv;
96a864
+            if (!do_hex2bn(&Qy, value)) {
96a864
+                fprintf(stderr, "Invalid Qy value\n");
96a864
+                return 0;
96a864
+            }
96a864
+            key = EC_KEY_new_by_curve_name(curve_nid);
96a864
+            no_err = 1;
96a864
+            rv = EC_KEY_set_public_key_affine_coordinates(key, Qx, Qy);
96a864
+            no_err = 0;
96a864
+            EC_KEY_free(key);
96a864
+            fprintf(out, "Result = %s" RESP_EOL, rv ? "P" : "F");
96a864
+        }
96a864
+
96a864
+    }
96a864
+    BN_free(Qx);
96a864
+    BN_free(Qy);
96a864
+    return 1;
96a864
+}
96a864
+
96a864
+static int SigGen(FILE *in, FILE *out)
96a864
+{
96a864
+    char buf[2048], lbuf[2048];
96a864
+    char *keyword, *value;
96a864
+    unsigned char *msg;
96a864
+    int curve_nid = NID_undef;
96a864
+    long mlen;
96a864
+    BIGNUM *Qx = NULL, *Qy = NULL;
96a864
+    EC_KEY *key = NULL;
96a864
+    ECDSA_SIG *sig = NULL;
96a864
+    const EVP_MD *digest = NULL;
96a864
+    Qx = BN_new();
96a864
+    Qy = BN_new();
96a864
+    while (fgets(buf, sizeof buf, in) != NULL) {
96a864
+        fputs(buf, out);
96a864
+        if (*buf == '[') {
96a864
+            curve_nid = elookup_curve(buf, lbuf, &digest);
96a864
+            if (curve_nid == NID_undef)
96a864
+                return 0;
96a864
+        }
96a864
+        if (!parse_line(&keyword, &value, lbuf, buf))
96a864
+            continue;
96a864
+        if (!strcmp(keyword, "Msg")) {
96a864
+            msg = hex2bin_m(value, &mlen);
96a864
+            if (!msg) {
96a864
+                fprintf(stderr, "Invalid Message\n");
96a864
+                return 0;
96a864
+            }
96a864
+
96a864
+            key = EC_KEY_new_by_curve_name(curve_nid);
96a864
+            if (!EC_KEY_generate_key(key)) {
96a864
+                fprintf(stderr, "Error generating key\n");
96a864
+                return 0;
96a864
+            }
96a864
+
96a864
+            if (!ec_get_pubkey(key, Qx, Qy)) {
96a864
+                fprintf(stderr, "Error getting public key\n");
96a864
+                return 0;
96a864
+            }
96a864
+
96a864
+            sig = FIPS_ecdsa_sign(key, msg, mlen, digest);
96a864
+
96a864
+            if (!sig) {
96a864
+                fprintf(stderr, "Error signing message\n");
96a864
+                return 0;
96a864
+            }
96a864
+
96a864
+            do_bn_print_name(out, "Qx", Qx);
96a864
+            do_bn_print_name(out, "Qy", Qy);
96a864
+            do_bn_print_name(out, "R", sig->r);
96a864
+            do_bn_print_name(out, "S", sig->s);
96a864
+
96a864
+            EC_KEY_free(key);
96a864
+            OPENSSL_free(msg);
96a864
+            FIPS_ecdsa_sig_free(sig);
96a864
+
96a864
+        }
96a864
+
96a864
+    }
96a864
+    BN_free(Qx);
96a864
+    BN_free(Qy);
96a864
+    return 1;
96a864
+}
96a864
+
96a864
+static int SigVer(FILE *in, FILE *out)
96a864
+{
96a864
+    char buf[2048], lbuf[2048];
96a864
+    char *keyword, *value;
96a864
+    unsigned char *msg = NULL;
96a864
+    int curve_nid = NID_undef;
96a864
+    long mlen;
96a864
+    BIGNUM *Qx = NULL, *Qy = NULL;
96a864
+    EC_KEY *key = NULL;
96a864
+    ECDSA_SIG sg, *sig = &sg;
96a864
+    const EVP_MD *digest = NULL;
96a864
+    sig->r = NULL;
96a864
+    sig->s = NULL;
96a864
+    while (fgets(buf, sizeof buf, in) != NULL) {
96a864
+        fputs(buf, out);
96a864
+        if (*buf == '[') {
96a864
+            curve_nid = elookup_curve(buf, lbuf, &digest);
96a864
+            if (curve_nid == NID_undef)
96a864
+                return 0;
96a864
+        }
96a864
+        if (!parse_line(&keyword, &value, lbuf, buf))
96a864
+            continue;
96a864
+        if (!strcmp(keyword, "Msg")) {
96a864
+            msg = hex2bin_m(value, &mlen);
96a864
+            if (!msg) {
96a864
+                fprintf(stderr, "Invalid Message\n");
96a864
+                return 0;
96a864
+            }
96a864
+        }
96a864
+
96a864
+        if (!strcmp(keyword, "Qx")) {
96a864
+            if (!do_hex2bn(&Qx, value)) {
96a864
+                fprintf(stderr, "Invalid Qx value\n");
96a864
+                return 0;
96a864
+            }
96a864
+        }
96a864
+        if (!strcmp(keyword, "Qy")) {
96a864
+            if (!do_hex2bn(&Qy, value)) {
96a864
+                fprintf(stderr, "Invalid Qy value\n");
96a864
+                return 0;
96a864
+            }
96a864
+        }
96a864
+        if (!strcmp(keyword, "R")) {
96a864
+            if (!do_hex2bn(&sig->r, value)) {
96a864
+                fprintf(stderr, "Invalid R value\n");
96a864
+                return 0;
96a864
+            }
96a864
+        }
96a864
+        if (!strcmp(keyword, "S")) {
96a864
+            int rv;
96a864
+            if (!do_hex2bn(&sig->s, value)) {
96a864
+                fprintf(stderr, "Invalid S value\n");
96a864
+                return 0;
96a864
+            }
96a864
+            key = EC_KEY_new_by_curve_name(curve_nid);
96a864
+            rv = EC_KEY_set_public_key_affine_coordinates(key, Qx, Qy);
96a864
+
96a864
+            if (rv != 1) {
96a864
+                fprintf(stderr, "Error setting public key\n");
96a864
+                return 0;
96a864
+            }
96a864
+
96a864
+            no_err = 1;
96a864
+            rv = FIPS_ecdsa_verify(key, msg, mlen, digest, sig);
96a864
+            EC_KEY_free(key);
96a864
+            if (msg)
96a864
+                OPENSSL_free(msg);
96a864
+            no_err = 0;
96a864
+
96a864
+            fprintf(out, "Result = %s" RESP_EOL, rv ? "P" : "F");
96a864
+        }
96a864
+
96a864
+    }
96a864
+    if (sig->r)
96a864
+        BN_free(sig->r);
96a864
+    if (sig->s)
96a864
+        BN_free(sig->s);
96a864
+    if (Qx)
96a864
+        BN_free(Qx);
96a864
+    if (Qy)
96a864
+        BN_free(Qy);
96a864
+    return 1;
96a864
+}
96a864
+
96a864
+# ifdef FIPS_ALGVS
96a864
+int fips_ecdsavs_main(int argc, char **argv)
96a864
+# else
96a864
+int main(int argc, char **argv)
96a864
+# endif
96a864
+{
96a864
+    FILE *in = NULL, *out = NULL;
96a864
+    const char *cmd = argv[1];
96a864
+    int rv = 0;
96a864
+    fips_algtest_init();
96a864
+
96a864
+    if (argc == 4) {
96a864
+        in = fopen(argv[2], "r");
96a864
+        if (!in) {
96a864
+            fprintf(stderr, "Error opening input file\n");
96a864
+            exit(1);
96a864
+        }
96a864
+        out = fopen(argv[3], "w");
96a864
+        if (!out) {
96a864
+            fprintf(stderr, "Error opening output file\n");
96a864
+            exit(1);
96a864
+        }
96a864
+    } else if (argc == 2) {
96a864
+        in = stdin;
96a864
+        out = stdout;
96a864
+    }
96a864
+
96a864
+    if (!cmd) {
96a864
+        fprintf(stderr, "fips_ecdsavs [KeyPair|PKV|SigGen|SigVer]\n");
96a864
+        return 1;
96a864
+    }
96a864
+    if (!strcmp(cmd, "KeyPair"))
96a864
+        rv = KeyPair(in, out);
96a864
+    else if (!strcmp(cmd, "PKV"))
96a864
+        rv = PKV(in, out);
96a864
+    else if (!strcmp(cmd, "SigVer"))
96a864
+        rv = SigVer(in, out);
96a864
+    else if (!strcmp(cmd, "SigGen"))
96a864
+        rv = SigGen(in, out);
96a864
+    else {
96a864
+        fprintf(stderr, "Unknown command %s\n", cmd);
96a864
+        return 1;
96a864
+    }
96a864
+
96a864
+    if (argc == 4) {
96a864
+        fclose(in);
96a864
+        fclose(out);
96a864
+    }
96a864
+
96a864
+    if (rv <= 0) {
96a864
+        fprintf(stderr, "Error running %s\n", cmd);
96a864
+        return 1;
96a864
+    }
96a864
+
96a864
+    return 0;
96a864
+}
96a864
+
96a864
+#endif
96a864
diff -up openssl-1.0.2a/crypto/fips/fips_ecdh_selftest.c.fips-ec openssl-1.0.2a/crypto/fips/fips_ecdh_selftest.c
96a864
--- openssl-1.0.2a/crypto/fips/fips_ecdh_selftest.c.fips-ec	2015-04-22 19:00:19.724884583 +0200
96a864
+++ openssl-1.0.2a/crypto/fips/fips_ecdh_selftest.c	2015-04-22 19:00:19.724884583 +0200
96a864
@@ -0,0 +1,242 @@
96a864
+/* fips/ecdh/fips_ecdh_selftest.c */
96a864
+/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
96a864
+ * project 2011.
96a864
+ */
96a864
+/* ====================================================================
96a864
+ * Copyright (c) 2011 The OpenSSL Project.  All rights reserved.
96a864
+ *
96a864
+ * Redistribution and use in source and binary forms, with or without
96a864
+ * modification, are permitted provided that the following conditions
96a864
+ * are met:
96a864
+ *
96a864
+ * 1. Redistributions of source code must retain the above copyright
96a864
+ *    notice, this list of conditions and the following disclaimer. 
96a864
+ *
96a864
+ * 2. Redistributions in binary form must reproduce the above copyright
96a864
+ *    notice, this list of conditions and the following disclaimer in
96a864
+ *    the documentation and/or other materials provided with the
96a864
+ *    distribution.
96a864
+ *
96a864
+ * 3. All advertising materials mentioning features or use of this
96a864
+ *    software must display the following acknowledgment:
96a864
+ *    "This product includes software developed by the OpenSSL Project
96a864
+ *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
96a864
+ *
96a864
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
96a864
+ *    endorse or promote products derived from this software without
96a864
+ *    prior written permission. For written permission, please contact
96a864
+ *    licensing@OpenSSL.org.
96a864
+ *
96a864
+ * 5. Products derived from this software may not be called "OpenSSL"
96a864
+ *    nor may "OpenSSL" appear in their names without prior written
96a864
+ *    permission of the OpenSSL Project.
96a864
+ *
96a864
+ * 6. Redistributions of any form whatsoever must retain the following
96a864
+ *    acknowledgment:
96a864
+ *    "This product includes software developed by the OpenSSL Project
96a864
+ *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
96a864
+ *
96a864
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
96a864
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
96a864
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
96a864
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
96a864
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
96a864
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
96a864
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
96a864
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
96a864
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
96a864
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
96a864
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
96a864
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
96a864
+ * ====================================================================
96a864
+ *
96a864
+ */
96a864
+
96a864
+#define OPENSSL_FIPSAPI
96a864
+
96a864
+#include <string.h>
96a864
+#include <openssl/crypto.h>
96a864
+#include <openssl/ec.h>
96a864
+#include <openssl/ecdh.h>
96a864
+#include <openssl/fips.h>
96a864
+#include <openssl/err.h>
96a864
+#include <openssl/evp.h>
96a864
+#include <openssl/bn.h>
96a864
+
96a864
+#ifdef OPENSSL_FIPS
96a864
+
96a864
+# include "fips_locl.h"
96a864
+
96a864
+static const unsigned char p256_qcavsx[] = {
96a864
+    0x52, 0xc6, 0xa5, 0x75, 0xf3, 0x04, 0x98, 0xb3, 0x29, 0x66, 0x0c, 0x62,
96a864
+    0x18, 0x60, 0x55, 0x41, 0x59, 0xd4, 0x60, 0x85, 0x99, 0xc1, 0x51, 0x13,
96a864
+    0x6f, 0x97, 0x85, 0x93, 0x33, 0x34, 0x07, 0x50
96a864
+};
96a864
+
96a864
+static const unsigned char p256_qcavsy[] = {
96a864
+    0x6f, 0x69, 0x24, 0xeb, 0xe9, 0x3b, 0xa7, 0xcc, 0x47, 0x17, 0xaa, 0x3f,
96a864
+    0x70, 0xfc, 0x10, 0x73, 0x0a, 0xcd, 0x21, 0xee, 0x29, 0x19, 0x1f, 0xaf,
96a864
+    0xb4, 0x1c, 0x1e, 0xc2, 0x8e, 0x97, 0x81, 0x6e
96a864
+};
96a864
+
96a864
+static const unsigned char p256_qiutx[] = {
96a864
+    0x71, 0x46, 0x88, 0x08, 0x92, 0x21, 0x1b, 0x10, 0x21, 0x74, 0xff, 0x0c,
96a864
+    0x94, 0xde, 0x34, 0x7c, 0x86, 0x74, 0xbe, 0x67, 0x41, 0x68, 0xd4, 0xc1,
96a864
+    0xe5, 0x75, 0x63, 0x9c, 0xa7, 0x46, 0x93, 0x6f
96a864
+};
96a864
+
96a864
+static const unsigned char p256_qiuty[] = {
96a864
+    0x33, 0x40, 0xa9, 0x6a, 0xf5, 0x20, 0xb5, 0x9e, 0xfc, 0x60, 0x1a, 0xae,
96a864
+    0x3d, 0xf8, 0x21, 0xd2, 0xa7, 0xca, 0x52, 0x34, 0xb9, 0x5f, 0x27, 0x75,
96a864
+    0x6c, 0x81, 0xbe, 0x32, 0x4d, 0xba, 0xbb, 0xf8
96a864
+};
96a864
+
96a864
+static const unsigned char p256_qiutd[] = {
96a864
+    0x1a, 0x48, 0x55, 0x6b, 0x11, 0xbe, 0x92, 0xd4, 0x1c, 0xd7, 0x45, 0xc3,
96a864
+    0x82, 0x81, 0x51, 0xf1, 0x23, 0x40, 0xb7, 0x83, 0xfd, 0x01, 0x6d, 0xbc,
96a864
+    0xa1, 0x66, 0xaf, 0x0a, 0x03, 0x23, 0xcd, 0xc8
96a864
+};
96a864
+
96a864
+static const unsigned char p256_ziut[] = {
96a864
+    0x77, 0x2a, 0x1e, 0x37, 0xee, 0xe6, 0x51, 0x02, 0x71, 0x40, 0xf8, 0x6a,
96a864
+    0x36, 0xf8, 0x65, 0x61, 0x2b, 0x18, 0x71, 0x82, 0x23, 0xe6, 0xf2, 0x77,
96a864
+    0xce, 0xec, 0xb8, 0x49, 0xc7, 0xbf, 0x36, 0x4f
96a864
+};
96a864
+
96a864
+typedef struct {
96a864
+    int curve;
96a864
+    const unsigned char *x1;
96a864
+    size_t x1len;
96a864
+    const unsigned char *y1;
96a864
+    size_t y1len;
96a864
+    const unsigned char *d1;
96a864
+    size_t d1len;
96a864
+    const unsigned char *x2;
96a864
+    size_t x2len;
96a864
+    const unsigned char *y2;
96a864
+    size_t y2len;
96a864
+    const unsigned char *z;
96a864
+    size_t zlen;
96a864
+} ECDH_SELFTEST_DATA;
96a864
+
96a864
+# define make_ecdh_test(nid, pr) { nid, \
96a864
+                                pr##_qiutx, sizeof(pr##_qiutx), \
96a864
+                                pr##_qiuty, sizeof(pr##_qiuty), \
96a864
+                                pr##_qiutd, sizeof(pr##_qiutd), \
96a864
+                                pr##_qcavsx, sizeof(pr##_qcavsx), \
96a864
+                                pr##_qcavsy, sizeof(pr##_qcavsy), \
96a864
+                                pr##_ziut, sizeof(pr##_ziut) }
96a864
+
96a864
+static ECDH_SELFTEST_DATA test_ecdh_data[] = {
96a864
+    make_ecdh_test(NID_X9_62_prime256v1, p256),
96a864
+};
96a864
+
96a864
+int FIPS_selftest_ecdh(void)
96a864
+{
96a864
+    EC_KEY *ec1 = NULL, *ec2 = NULL;
96a864
+    const EC_POINT *ecp = NULL;
96a864
+    BIGNUM *x = NULL, *y = NULL, *d = NULL;
96a864
+    unsigned char *ztmp = NULL;
96a864
+    int rv = 1;
96a864
+    size_t i;
96a864
+
96a864
+    for (i = 0; i < sizeof(test_ecdh_data) / sizeof(ECDH_SELFTEST_DATA); i++) {
96a864
+        ECDH_SELFTEST_DATA *ecd = test_ecdh_data + i;
96a864
+        if (!fips_post_started(FIPS_TEST_ECDH, ecd->curve, 0))
96a864
+            continue;
96a864
+        ztmp = OPENSSL_malloc(ecd->zlen);
96a864
+
96a864
+        x = BN_bin2bn(ecd->x1, ecd->x1len, x);
96a864
+        y = BN_bin2bn(ecd->y1, ecd->y1len, y);
96a864
+        d = BN_bin2bn(ecd->d1, ecd->d1len, d);
96a864
+
96a864
+        if (!x || !y || !d || !ztmp) {
96a864
+            rv = -1;
96a864
+            goto err;
96a864
+        }
96a864
+
96a864
+        ec1 = EC_KEY_new_by_curve_name(ecd->curve);
96a864
+        if (!ec1) {
96a864
+            rv = -1;
96a864
+            goto err;
96a864
+        }
96a864
+        EC_KEY_set_flags(ec1, EC_FLAG_COFACTOR_ECDH);
96a864
+
96a864
+        if (!EC_KEY_set_public_key_affine_coordinates(ec1, x, y)) {
96a864
+            rv = -1;
96a864
+            goto err;
96a864
+        }
96a864
+
96a864
+        if (!EC_KEY_set_private_key(ec1, d)) {
96a864
+            rv = -1;
96a864
+            goto err;
96a864
+        }
96a864
+
96a864
+        x = BN_bin2bn(ecd->x2, ecd->x2len, x);
96a864
+        y = BN_bin2bn(ecd->y2, ecd->y2len, y);
96a864
+
96a864
+        if (!x || !y) {
96a864
+            rv = -1;
96a864
+            goto err;
96a864
+        }
96a864
+
96a864
+        ec2 = EC_KEY_new_by_curve_name(ecd->curve);
96a864
+        if (!ec2) {
96a864
+            rv = -1;
96a864
+            goto err;
96a864
+        }
96a864
+        EC_KEY_set_flags(ec1, EC_FLAG_COFACTOR_ECDH);
96a864
+
96a864
+        if (!EC_KEY_set_public_key_affine_coordinates(ec2, x, y)) {
96a864
+            rv = -1;
96a864
+            goto err;
96a864
+        }
96a864
+
96a864
+        ecp = EC_KEY_get0_public_key(ec2);
96a864
+        if (!ecp) {
96a864
+            rv = -1;
96a864
+            goto err;
96a864
+        }
96a864
+
96a864
+        if (!ECDH_compute_key(ztmp, ecd->zlen, ecp, ec1, 0)) {
96a864
+            rv = -1;
96a864
+            goto err;
96a864
+        }
96a864
+
96a864
+        if (!fips_post_corrupt(FIPS_TEST_ECDH, ecd->curve, NULL))
96a864
+            ztmp[0] ^= 0x1;
96a864
+
96a864
+        if (memcmp(ztmp, ecd->z, ecd->zlen)) {
96a864
+            fips_post_failed(FIPS_TEST_ECDH, ecd->curve, 0);
96a864
+            rv = 0;
96a864
+        } else if (!fips_post_success(FIPS_TEST_ECDH, ecd->curve, 0))
96a864
+            goto err;
96a864
+
96a864
+        EC_KEY_free(ec1);
96a864
+        ec1 = NULL;
96a864
+        EC_KEY_free(ec2);
96a864
+        ec2 = NULL;
96a864
+        OPENSSL_free(ztmp);
96a864
+        ztmp = NULL;
96a864
+    }
96a864
+
96a864
+ err:
96a864
+
96a864
+    if (x)
96a864
+        BN_clear_free(x);
96a864
+    if (y)
96a864
+        BN_clear_free(y);
96a864
+    if (d)
96a864
+        BN_clear_free(d);
96a864
+    if (ec1)
96a864
+        EC_KEY_free(ec1);
96a864
+    if (ec2)
96a864
+        EC_KEY_free(ec2);
96a864
+    if (ztmp)
96a864
+        OPENSSL_free(ztmp);
96a864
+
96a864
+    return rv;
96a864
+
96a864
+}
96a864
+
96a864
+#endif
96a864
diff -up openssl-1.0.2a/crypto/fips/fips_ecdsa_selftest.c.fips-ec openssl-1.0.2a/crypto/fips/fips_ecdsa_selftest.c
96a864
--- openssl-1.0.2a/crypto/fips/fips_ecdsa_selftest.c.fips-ec	2015-04-22 19:00:19.724884583 +0200
96a864
+++ openssl-1.0.2a/crypto/fips/fips_ecdsa_selftest.c	2015-04-22 19:00:19.724884583 +0200
96a864
@@ -0,0 +1,165 @@
96a864
+/* fips/ecdsa/fips_ecdsa_selftest.c */
96a864
+/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
96a864
+ * project 2011.
96a864
+ */
96a864
+/* ====================================================================
96a864
+ * Copyright (c) 2011 The OpenSSL Project.  All rights reserved.
96a864
+ *
96a864
+ * Redistribution and use in source and binary forms, with or without
96a864
+ * modification, are permitted provided that the following conditions
96a864
+ * are met:
96a864
+ *
96a864
+ * 1. Redistributions of source code must retain the above copyright
96a864
+ *    notice, this list of conditions and the following disclaimer. 
96a864
+ *
96a864
+ * 2. Redistributions in binary form must reproduce the above copyright
96a864
+ *    notice, this list of conditions and the following disclaimer in
96a864
+ *    the documentation and/or other materials provided with the
96a864
+ *    distribution.
96a864
+ *
96a864
+ * 3. All advertising materials mentioning features or use of this
96a864
+ *    software must display the following acknowledgment:
96a864
+ *    "This product includes software developed by the OpenSSL Project
96a864
+ *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
96a864
+ *
96a864
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
96a864
+ *    endorse or promote products derived from this software without
96a864
+ *    prior written permission. For written permission, please contact
96a864
+ *    licensing@OpenSSL.org.
96a864
+ *
96a864
+ * 5. Products derived from this software may not be called "OpenSSL"
96a864
+ *    nor may "OpenSSL" appear in their names without prior written
96a864
+ *    permission of the OpenSSL Project.
96a864
+ *
96a864
+ * 6. Redistributions of any form whatsoever must retain the following
96a864
+ *    acknowledgment:
96a864
+ *    "This product includes software developed by the OpenSSL Project
96a864
+ *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
96a864
+ *
96a864
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
96a864
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
96a864
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
96a864
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
96a864
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
96a864
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
96a864
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
96a864
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
96a864
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
96a864
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
96a864
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
96a864
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
96a864
+ * ====================================================================
96a864
+ *
96a864
+ */
96a864
+
96a864
+#define OPENSSL_FIPSAPI
96a864
+
96a864
+#include <string.h>
96a864
+#include <openssl/crypto.h>
96a864
+#include <openssl/ec.h>
96a864
+#include <openssl/ecdsa.h>
96a864
+#include <openssl/fips.h>
96a864
+#include <openssl/err.h>
96a864
+#include <openssl/evp.h>
96a864
+#include <openssl/bn.h>
96a864
+
96a864
+#ifdef OPENSSL_FIPS
96a864
+
96a864
+static const char P_256_name[] = "ECDSA P-256";
96a864
+
96a864
+static const unsigned char P_256_d[] = {
96a864
+    0x51, 0xbd, 0x06, 0xa1, 0x1c, 0xda, 0xe2, 0x12, 0x99, 0xc9, 0x52, 0x3f,
96a864
+    0xea, 0xa4, 0xd2, 0xd1, 0xf4, 0x7f, 0xd4, 0x3e, 0xbd, 0xf8, 0xfc, 0x87,
96a864
+    0xdc, 0x82, 0x53, 0x21, 0xee, 0xa0, 0xdc, 0x64
96a864
+};
96a864
+
96a864
+static const unsigned char P_256_qx[] = {
96a864
+    0x23, 0x89, 0xe0, 0xf4, 0x69, 0xe0, 0x49, 0xe5, 0xc7, 0xe5, 0x40, 0x6e,
96a864
+    0x8f, 0x25, 0xdd, 0xad, 0x11, 0x16, 0x14, 0x9b, 0xab, 0x44, 0x06, 0x31,
96a864
+    0xbf, 0x5e, 0xa6, 0x44, 0xac, 0x86, 0x00, 0x07
96a864
+};
96a864
+
96a864
+static const unsigned char P_256_qy[] = {
96a864
+    0xb3, 0x05, 0x0d, 0xd0, 0xdc, 0xf7, 0x40, 0xe6, 0xf9, 0xd8, 0x6d, 0x7b,
96a864
+    0x63, 0xca, 0x97, 0xe6, 0x12, 0xf9, 0xd4, 0x18, 0x59, 0xbe, 0xb2, 0x5e,
96a864
+    0x4a, 0x6a, 0x77, 0x23, 0xf4, 0x11, 0x9d, 0xeb
96a864
+};
96a864
+
96a864
+typedef struct {
96a864
+    int curve;
96a864
+    const char *name;
96a864
+    const unsigned char *x;
96a864
+    size_t xlen;
96a864
+    const unsigned char *y;
96a864
+    size_t ylen;
96a864
+    const unsigned char *d;
96a864
+    size_t dlen;
96a864
+} EC_SELFTEST_DATA;
96a864
+
96a864
+# define make_ecdsa_test(nid, pr) { nid, pr##_name, \
96a864
+                                pr##_qx, sizeof(pr##_qx), \
96a864
+                                pr##_qy, sizeof(pr##_qy), \
96a864
+                                pr##_d, sizeof(pr##_d)}
96a864
+
96a864
+static EC_SELFTEST_DATA test_ec_data[] = {
96a864
+    make_ecdsa_test(NID_X9_62_prime256v1, P_256),
96a864
+};
96a864
+
96a864
+int FIPS_selftest_ecdsa()
96a864
+{
96a864
+    EC_KEY *ec = NULL;
96a864
+    BIGNUM *x = NULL, *y = NULL, *d = NULL;
96a864
+    EVP_PKEY *pk = NULL;
96a864
+    int rv = 0;
96a864
+    size_t i;
96a864
+
96a864
+    for (i = 0; i < sizeof(test_ec_data) / sizeof(EC_SELFTEST_DATA); i++) {
96a864
+        EC_SELFTEST_DATA *ecd = test_ec_data + i;
96a864
+
96a864
+        x = BN_bin2bn(ecd->x, ecd->xlen, x);
96a864
+        y = BN_bin2bn(ecd->y, ecd->ylen, y);
96a864
+        d = BN_bin2bn(ecd->d, ecd->dlen, d);
96a864
+
96a864
+        if (!x || !y || !d)
96a864
+            goto err;
96a864
+
96a864
+        ec = EC_KEY_new_by_curve_name(ecd->curve);
96a864
+        if (!ec)
96a864
+            goto err;
96a864
+
96a864
+        if (!EC_KEY_set_public_key_affine_coordinates(ec, x, y))
96a864
+            goto err;
96a864
+
96a864
+        if (!EC_KEY_set_private_key(ec, d))
96a864
+            goto err;
96a864
+
96a864
+        if ((pk = EVP_PKEY_new()) == NULL)
96a864
+            goto err;
96a864
+
96a864
+        EVP_PKEY_assign_EC_KEY(pk, ec);
96a864
+
96a864
+        if (!fips_pkey_signature_test(pk, NULL, 0,
96a864
+                                      NULL, 0, EVP_sha256(), 0, ecd->name))
96a864
+            goto err;
96a864
+    }
96a864
+
96a864
+    rv = 1;
96a864
+
96a864
+ err:
96a864
+
96a864
+    if (x)
96a864
+        BN_clear_free(x);
96a864
+    if (y)
96a864
+        BN_clear_free(y);
96a864
+    if (d)
96a864
+        BN_clear_free(d);
96a864
+    if (pk)
96a864
+        EVP_PKEY_free(pk);
96a864
+    else if (ec)
96a864
+        EC_KEY_free(ec);
96a864
+
96a864
+    return rv;
96a864
+
96a864
+}
96a864
+
96a864
+#endif
96a864
diff -up openssl-1.0.2a/crypto/fips/fips.h.fips-ec openssl-1.0.2a/crypto/fips/fips.h
96a864
--- openssl-1.0.2a/crypto/fips/fips.h.fips-ec	2015-04-22 19:00:19.688883733 +0200
96a864
+++ openssl-1.0.2a/crypto/fips/fips.h	2015-04-22 19:00:19.724884583 +0200
96a864
@@ -93,6 +93,8 @@ extern "C" {
96a864
     void FIPS_corrupt_dsa(void);
96a864
     void FIPS_corrupt_dsa_keygen(void);
96a864
     int FIPS_selftest_dsa(void);
96a864
+    int FIPS_selftest_ecdsa(void);
96a864
+    int FIPS_selftest_ecdh(void);
96a864
     void FIPS_corrupt_rng(void);
96a864
     void FIPS_rng_stick(void);
96a864
     void FIPS_x931_stick(int onoff);
96a864
diff -up openssl-1.0.2a/crypto/fips/fips_post.c.fips-ec openssl-1.0.2a/crypto/fips/fips_post.c
96a864
--- openssl-1.0.2a/crypto/fips/fips_post.c.fips-ec	2015-04-22 19:00:19.688883733 +0200
96a864
+++ openssl-1.0.2a/crypto/fips/fips_post.c	2015-04-22 19:00:19.724884583 +0200
96a864
@@ -95,8 +95,12 @@ int FIPS_selftest(void)
96a864
         rv = 0;
96a864
     if (!FIPS_selftest_rsa())
96a864
         rv = 0;
96a864
+    if (!FIPS_selftest_ecdsa())
96a864
+        rv = 0;
96a864
     if (!FIPS_selftest_dsa())
96a864
         rv = 0;
96a864
+    if (!FIPS_selftest_ecdh())
96a864
+        rv = 0;
96a864
     return rv;
96a864
 }
96a864
 
96a864
diff -up openssl-1.0.2a/crypto/fips/Makefile.fips-ec openssl-1.0.2a/crypto/fips/Makefile
96a864
--- openssl-1.0.2a/crypto/fips/Makefile.fips-ec	2015-04-22 19:00:19.691883805 +0200
96a864
+++ openssl-1.0.2a/crypto/fips/Makefile	2015-04-22 19:00:19.724884583 +0200
96a864
@@ -24,13 +24,13 @@ LIBSRC=fips_aes_selftest.c fips_des_self
96a864
     fips_rsa_selftest.c fips_sha_selftest.c fips.c fips_dsa_selftest.c  fips_rand.c \
96a864
     fips_rsa_x931g.c fips_post.c fips_drbg_ctr.c fips_drbg_hash.c fips_drbg_hmac.c \
96a864
     fips_drbg_lib.c fips_drbg_rand.c fips_drbg_selftest.c fips_rand_lib.c \
96a864
-    fips_cmac_selftest.c fips_enc.c fips_md.c
96a864
+    fips_cmac_selftest.c fips_ecdh_selftest.c fips_ecdsa_selftest.c fips_enc.c fips_md.c
96a864
 
96a864
 LIBOBJ=fips_aes_selftest.o fips_des_selftest.o fips_hmac_selftest.o fips_rand_selftest.o \
96a864
     fips_rsa_selftest.o fips_sha_selftest.o fips.o fips_dsa_selftest.o  fips_rand.o \
96a864
     fips_rsa_x931g.o fips_post.o fips_drbg_ctr.o fips_drbg_hash.o fips_drbg_hmac.o \
96a864
     fips_drbg_lib.o fips_drbg_rand.o fips_drbg_selftest.o fips_rand_lib.o \
96a864
-    fips_cmac_selftest.o fips_enc.o fips_md.o
96a864
+    fips_cmac_selftest.o fips_ecdh_selftest.o fips_ecdsa_selftest.o fips_enc.o fips_md.o
96a864
 
96a864
 LIBCRYPTO=-L.. -lcrypto
96a864
 
96a864
@@ -119,6 +119,21 @@ fips_aes_selftest.o: ../../include/opens
96a864
 fips_aes_selftest.o: ../../include/openssl/safestack.h
96a864
 fips_aes_selftest.o: ../../include/openssl/stack.h
96a864
 fips_aes_selftest.o: ../../include/openssl/symhacks.h fips_aes_selftest.c
96a864
+fips_cmac_selftest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
96a864
+fips_cmac_selftest.o: ../../include/openssl/cmac.h
96a864
+fips_cmac_selftest.o: ../../include/openssl/crypto.h
96a864
+fips_cmac_selftest.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
96a864
+fips_cmac_selftest.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
96a864
+fips_cmac_selftest.o: ../../include/openssl/lhash.h
96a864
+fips_cmac_selftest.o: ../../include/openssl/obj_mac.h
96a864
+fips_cmac_selftest.o: ../../include/openssl/objects.h
96a864
+fips_cmac_selftest.o: ../../include/openssl/opensslconf.h
96a864
+fips_cmac_selftest.o: ../../include/openssl/opensslv.h
96a864
+fips_cmac_selftest.o: ../../include/openssl/ossl_typ.h
96a864
+fips_cmac_selftest.o: ../../include/openssl/safestack.h
96a864
+fips_cmac_selftest.o: ../../include/openssl/stack.h
96a864
+fips_cmac_selftest.o: ../../include/openssl/symhacks.h fips_cmac_selftest.c
96a864
+fips_cmac_selftest.o: fips_locl.h
96a864
 fips_des_selftest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
96a864
 fips_des_selftest.o: ../../include/openssl/crypto.h
96a864
 fips_des_selftest.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
96a864
@@ -232,6 +247,46 @@ fips_dsa_selftest.o: ../../include/opens
96a864
 fips_dsa_selftest.o: ../../include/openssl/stack.h
96a864
 fips_dsa_selftest.o: ../../include/openssl/symhacks.h fips_dsa_selftest.c
96a864
 fips_dsa_selftest.o: fips_locl.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/ecdh.h ../../include/openssl/err.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/lhash.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/obj_mac.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/objects.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/opensslconf.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/opensslv.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/ossl_typ.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/safestack.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/stack.h
96a864
+fips_ecdh_selftest.o: ../../include/openssl/symhacks.h fips_ecdh_selftest.c
96a864
+fips_ecdh_selftest.o: fips_locl.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/bn.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/crypto.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/ecdsa.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/err.h ../../include/openssl/evp.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/fips.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/lhash.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/obj_mac.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/objects.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/opensslconf.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/opensslv.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/ossl_typ.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/safestack.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/stack.h
96a864
+fips_ecdsa_selftest.o: ../../include/openssl/symhacks.h fips_ecdsa_selftest.c
96a864
+fips_enc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
96a864
+fips_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
96a864
+fips_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
96a864
+fips_enc.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
96a864
+fips_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
96a864
+fips_enc.o: ../../include/openssl/opensslconf.h
96a864
+fips_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
96a864
+fips_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
96a864
+fips_enc.o: ../../include/openssl/symhacks.h fips_enc.c
96a864
 fips_hmac_selftest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
96a864
 fips_hmac_selftest.o: ../../include/openssl/crypto.h
96a864
 fips_hmac_selftest.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
96a864
@@ -246,6 +301,15 @@ fips_hmac_selftest.o: ../../include/open
96a864
 fips_hmac_selftest.o: ../../include/openssl/safestack.h
96a864
 fips_hmac_selftest.o: ../../include/openssl/stack.h
96a864
 fips_hmac_selftest.o: ../../include/openssl/symhacks.h fips_hmac_selftest.c
96a864
+fips_md.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
96a864
+fips_md.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
96a864
+fips_md.o: ../../include/openssl/err.h ../../include/openssl/evp.h
96a864
+fips_md.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
96a864
+fips_md.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
96a864
+fips_md.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
96a864
+fips_md.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
96a864
+fips_md.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
96a864
+fips_md.o: fips_md.c
96a864
 fips_post.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
96a864
 fips_post.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
96a864
 fips_post.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
96a864
diff -up openssl-1.0.2a/version.map.fips-ec openssl-1.0.2a/version.map
96a864
--- openssl-1.0.2a/version.map.fips-ec	2015-04-22 19:00:19.704884111 +0200
96a864
+++ openssl-1.0.2a/version.map	2015-04-22 19:00:19.724884583 +0200
96a864
@@ -6,6 +6,10 @@ OPENSSL_1.0.1 {
96a864
 	    _original*;
96a864
 	    _current*;
96a864
 };
96a864
+OPENSSL_1.0.1_EC {
96a864
+    global:
96a864
+            EC*;
96a864
+};
96a864
 OPENSSL_1.0.2 {
96a864
     global:
96a864
 	    SSLeay;