isaacpittman-hitachi / rpms / openssl

Forked from rpms/openssl 2 years ago
Clone

Blame SOURCES/openssl-1.1.1-ec-curves.patch

da7b65
diff -up openssl-1.1.1h/apps/speed.c.curves openssl-1.1.1h/apps/speed.c
da7b65
--- openssl-1.1.1h/apps/speed.c.curves	2020-09-22 14:55:07.000000000 +0200
da7b65
+++ openssl-1.1.1h/apps/speed.c	2020-11-06 13:27:15.659288431 +0100
3a273b
@@ -490,90 +490,30 @@ static double rsa_results[RSA_NUM][2];
3a273b
 #endif /* OPENSSL_NO_RSA */
3a273b
 
3a273b
 enum {
3a273b
-    R_EC_P160,
3a273b
-    R_EC_P192,
3a273b
     R_EC_P224,
3a273b
     R_EC_P256,
3a273b
     R_EC_P384,
3a273b
     R_EC_P521,
3a273b
-#ifndef OPENSSL_NO_EC2M
3a273b
-    R_EC_K163,
3a273b
-    R_EC_K233,
3a273b
-    R_EC_K283,
3a273b
-    R_EC_K409,
3a273b
-    R_EC_K571,
3a273b
-    R_EC_B163,
3a273b
-    R_EC_B233,
3a273b
-    R_EC_B283,
3a273b
-    R_EC_B409,
3a273b
-    R_EC_B571,
3a273b
-#endif
3a273b
-    R_EC_BRP256R1,
3a273b
-    R_EC_BRP256T1,
3a273b
-    R_EC_BRP384R1,
3a273b
-    R_EC_BRP384T1,
3a273b
-    R_EC_BRP512R1,
3a273b
-    R_EC_BRP512T1,
3a273b
     R_EC_X25519,
3a273b
     R_EC_X448
3a273b
 };
3a273b
 
3a273b
 #ifndef OPENSSL_NO_EC
3a273b
 static OPT_PAIR ecdsa_choices[] = {
3a273b
-    {"ecdsap160", R_EC_P160},
3a273b
-    {"ecdsap192", R_EC_P192},
3a273b
     {"ecdsap224", R_EC_P224},
3a273b
     {"ecdsap256", R_EC_P256},
3a273b
     {"ecdsap384", R_EC_P384},
3a273b
     {"ecdsap521", R_EC_P521},
3a273b
-# ifndef OPENSSL_NO_EC2M
3a273b
-    {"ecdsak163", R_EC_K163},
3a273b
-    {"ecdsak233", R_EC_K233},
3a273b
-    {"ecdsak283", R_EC_K283},
3a273b
-    {"ecdsak409", R_EC_K409},
3a273b
-    {"ecdsak571", R_EC_K571},
3a273b
-    {"ecdsab163", R_EC_B163},
3a273b
-    {"ecdsab233", R_EC_B233},
3a273b
-    {"ecdsab283", R_EC_B283},
3a273b
-    {"ecdsab409", R_EC_B409},
3a273b
-    {"ecdsab571", R_EC_B571},
3a273b
-# endif
3a273b
-    {"ecdsabrp256r1", R_EC_BRP256R1},
3a273b
-    {"ecdsabrp256t1", R_EC_BRP256T1},
3a273b
-    {"ecdsabrp384r1", R_EC_BRP384R1},
3a273b
-    {"ecdsabrp384t1", R_EC_BRP384T1},
3a273b
-    {"ecdsabrp512r1", R_EC_BRP512R1},
3a273b
-    {"ecdsabrp512t1", R_EC_BRP512T1}
3a273b
 };
3a273b
 # define ECDSA_NUM       OSSL_NELEM(ecdsa_choices)
3a273b
 
3a273b
 static double ecdsa_results[ECDSA_NUM][2];    /* 2 ops: sign then verify */
3a273b
 
3a273b
 static const OPT_PAIR ecdh_choices[] = {
3a273b
-    {"ecdhp160", R_EC_P160},
3a273b
-    {"ecdhp192", R_EC_P192},
3a273b
     {"ecdhp224", R_EC_P224},
3a273b
     {"ecdhp256", R_EC_P256},
3a273b
     {"ecdhp384", R_EC_P384},
3a273b
     {"ecdhp521", R_EC_P521},
3a273b
-# ifndef OPENSSL_NO_EC2M
3a273b
-    {"ecdhk163", R_EC_K163},
3a273b
-    {"ecdhk233", R_EC_K233},
3a273b
-    {"ecdhk283", R_EC_K283},
3a273b
-    {"ecdhk409", R_EC_K409},
3a273b
-    {"ecdhk571", R_EC_K571},
3a273b
-    {"ecdhb163", R_EC_B163},
3a273b
-    {"ecdhb233", R_EC_B233},
3a273b
-    {"ecdhb283", R_EC_B283},
3a273b
-    {"ecdhb409", R_EC_B409},
3a273b
-    {"ecdhb571", R_EC_B571},
3a273b
-# endif
3a273b
-    {"ecdhbrp256r1", R_EC_BRP256R1},
3a273b
-    {"ecdhbrp256t1", R_EC_BRP256T1},
3a273b
-    {"ecdhbrp384r1", R_EC_BRP384R1},
3a273b
-    {"ecdhbrp384t1", R_EC_BRP384T1},
3a273b
-    {"ecdhbrp512r1", R_EC_BRP512R1},
3a273b
-    {"ecdhbrp512t1", R_EC_BRP512T1},
3a273b
     {"ecdhx25519", R_EC_X25519},
3a273b
     {"ecdhx448", R_EC_X448}
3a273b
 };
da7b65
@@ -1502,31 +1442,10 @@ int speed_main(int argc, char **argv)
3a273b
         unsigned int bits;
3a273b
     } test_curves[] = {
3a273b
         /* Prime Curves */
3a273b
-        {"secp160r1", NID_secp160r1, 160},
3a273b
-        {"nistp192", NID_X9_62_prime192v1, 192},
3a273b
         {"nistp224", NID_secp224r1, 224},
3a273b
         {"nistp256", NID_X9_62_prime256v1, 256},
3a273b
         {"nistp384", NID_secp384r1, 384},
3a273b
         {"nistp521", NID_secp521r1, 521},
3a273b
-# ifndef OPENSSL_NO_EC2M
3a273b
-        /* Binary Curves */
3a273b
-        {"nistk163", NID_sect163k1, 163},
3a273b
-        {"nistk233", NID_sect233k1, 233},
3a273b
-        {"nistk283", NID_sect283k1, 283},
3a273b
-        {"nistk409", NID_sect409k1, 409},
3a273b
-        {"nistk571", NID_sect571k1, 571},
3a273b
-        {"nistb163", NID_sect163r2, 163},
3a273b
-        {"nistb233", NID_sect233r1, 233},
3a273b
-        {"nistb283", NID_sect283r1, 283},
3a273b
-        {"nistb409", NID_sect409r1, 409},
3a273b
-        {"nistb571", NID_sect571r1, 571},
3a273b
-# endif
3a273b
-        {"brainpoolP256r1", NID_brainpoolP256r1, 256},
3a273b
-        {"brainpoolP256t1", NID_brainpoolP256t1, 256},
3a273b
-        {"brainpoolP384r1", NID_brainpoolP384r1, 384},
3a273b
-        {"brainpoolP384t1", NID_brainpoolP384t1, 384},
3a273b
-        {"brainpoolP512r1", NID_brainpoolP512r1, 512},
3a273b
-        {"brainpoolP512t1", NID_brainpoolP512t1, 512},
3a273b
         /* Other and ECDH only ones */
3a273b
         {"X25519", NID_X25519, 253},
3a273b
         {"X448", NID_X448, 448}
da7b65
@@ -2026,9 +1945,9 @@ int speed_main(int argc, char **argv)
3a273b
 #  endif
3a273b
 
3a273b
 #  ifndef OPENSSL_NO_EC
3a273b
-    ecdsa_c[R_EC_P160][0] = count / 1000;
3a273b
-    ecdsa_c[R_EC_P160][1] = count / 1000 / 2;
3a273b
-    for (i = R_EC_P192; i <= R_EC_P521; i++) {
3a273b
+    ecdsa_c[R_EC_P224][0] = count / 1000;
3a273b
+    ecdsa_c[R_EC_P224][1] = count / 1000 / 2;
3a273b
+    for (i = R_EC_P256; i <= R_EC_P521; i++) {
3a273b
         ecdsa_c[i][0] = ecdsa_c[i - 1][0] / 2;
3a273b
         ecdsa_c[i][1] = ecdsa_c[i - 1][1] / 2;
3a273b
         if (ecdsa_doit[i] <= 1 && ecdsa_c[i][0] == 0)
da7b65
@@ -2040,7 +1959,7 @@ int speed_main(int argc, char **argv)
3a273b
             }
3a273b
         }
3a273b
     }
3a273b
-#   ifndef OPENSSL_NO_EC2M
3a273b
+#   if 0
3a273b
     ecdsa_c[R_EC_K163][0] = count / 1000;
3a273b
     ecdsa_c[R_EC_K163][1] = count / 1000 / 2;
3a273b
     for (i = R_EC_K233; i <= R_EC_K571; i++) {
da7b65
@@ -2071,8 +1990,8 @@ int speed_main(int argc, char **argv)
3a273b
     }
3a273b
 #   endif
3a273b
 
3a273b
-    ecdh_c[R_EC_P160][0] = count / 1000;
3a273b
-    for (i = R_EC_P192; i <= R_EC_P521; i++) {
3a273b
+    ecdh_c[R_EC_P224][0] = count / 1000;
3a273b
+    for (i = R_EC_P256; i <= R_EC_P521; i++) {
3a273b
         ecdh_c[i][0] = ecdh_c[i - 1][0] / 2;
3a273b
         if (ecdh_doit[i] <= 1 && ecdh_c[i][0] == 0)
3a273b
             ecdh_doit[i] = 0;
da7b65
@@ -2082,7 +2001,7 @@ int speed_main(int argc, char **argv)
3a273b
             }
3a273b
         }
3a273b
     }
3a273b
-#   ifndef OPENSSL_NO_EC2M
3a273b
+#   if 0
3a273b
     ecdh_c[R_EC_K163][0] = count / 1000;
3a273b
     for (i = R_EC_K233; i <= R_EC_K571; i++) {
3a273b
         ecdh_c[i][0] = ecdh_c[i - 1][0] / 2;
da7b65
diff -up openssl-1.1.1h/crypto/ec/ecp_smpl.c.curves openssl-1.1.1h/crypto/ec/ecp_smpl.c
da7b65
--- openssl-1.1.1h/crypto/ec/ecp_smpl.c.curves	2020-09-22 14:55:07.000000000 +0200
da7b65
+++ openssl-1.1.1h/crypto/ec/ecp_smpl.c	2020-11-06 13:27:15.659288431 +0100
3a273b
@@ -145,6 +145,11 @@ int ec_GFp_simple_group_set_curve(EC_GRO
3a273b
         return 0;
3a273b
     }
3a273b
 
3a273b
+    if (BN_num_bits(p) < 224) {
3a273b
+        ECerr(EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE, EC_R_UNSUPPORTED_FIELD);
3a273b
+        return 0;
3a273b
+    }
3a273b
+
3a273b
     if (ctx == NULL) {
3a273b
         ctx = new_ctx = BN_CTX_new();
3a273b
         if (ctx == NULL)
da7b65
diff -up openssl-1.1.1h/test/ecdsatest.h.curves openssl-1.1.1h/test/ecdsatest.h
da7b65
--- openssl-1.1.1h/test/ecdsatest.h.curves	2020-11-06 13:27:15.627288114 +0100
da7b65
+++ openssl-1.1.1h/test/ecdsatest.h	2020-11-06 13:27:15.660288441 +0100
3a273b
@@ -32,23 +32,6 @@ typedef struct {
3a273b
 } ecdsa_cavs_kat_t;
3a273b
 
3a273b
 static const ecdsa_cavs_kat_t ecdsa_cavs_kats[] = {
3a273b
-    /* prime KATs from X9.62 */
3a273b
-    {NID_X9_62_prime192v1, NID_sha1,
3a273b
-     "616263",                  /* "abc" */
3a273b
-     "1a8d598fc15bf0fd89030b5cb1111aeb92ae8baf5ea475fb",
3a273b
-     "0462b12d60690cdcf330babab6e69763b471f994dd702d16a563bf5ec08069705ffff65e"
3a273b
-     "5ca5c0d69716dfcb3474373902",
3a273b
-     "fa6de29746bbeb7f8bb1e761f85f7dfb2983169d82fa2f4e",
3a273b
-     "885052380ff147b734c330c43d39b2c4a89f29b0f749fead",
3a273b
-     "e9ecc78106def82bf1070cf1d4d804c3cb390046951df686"},
3a273b
-    {NID_X9_62_prime239v1, NID_sha1,
3a273b
-     "616263",                  /* "abc" */
3a273b
-     "7ef7c6fabefffdea864206e80b0b08a9331ed93e698561b64ca0f7777f3d",
3a273b
-     "045b6dc53bc61a2548ffb0f671472de6c9521a9d2d2534e65abfcbd5fe0c707fd9f1ed2e"
3a273b
-     "65f09f6ce0893baf5e8e31e6ae82ea8c3592335be906d38dee",
3a273b
-     "656c7196bf87dcc5d1f1020906df2782360d36b2de7a17ece37d503784af",
3a273b
-     "2cb7f36803ebb9c427c58d8265f11fc5084747133078fc279de874fbecb0",
3a273b
-     "2eeae988104e9c2234a3c2beb1f53bfa5dc11ff36a875d1e3ccb1f7e45cf"},
3a273b
     /* prime KATs from NIST CAVP */
3a273b
     {NID_secp224r1, NID_sha224,
3a273b
      "699325d6fc8fbbb4981a6ded3c3a54ad2e4e3db8a5669201912064c64e700c139248cdc1"
da7b65
--- openssl-1.1.1h/test/recipes/15-test_genec.t.ec-curves	2020-11-06 13:58:36.402895540 +0100
da7b65
+++ openssl-1.1.1h/test/recipes/15-test_genec.t	2020-11-06 13:59:38.508484498 +0100
da7b65
@@ -20,45 +20,11 @@ plan skip_all => "This test is unsupport
da7b65
     if disabled("ec");
da7b65
 
da7b65
 my @prime_curves = qw(
da7b65
-    secp112r1
da7b65
-    secp112r2
da7b65
-    secp128r1
da7b65
-    secp128r2
da7b65
-    secp160k1
da7b65
-    secp160r1
da7b65
-    secp160r2
da7b65
-    secp192k1
da7b65
-    secp224k1
da7b65
     secp224r1
da7b65
     secp256k1
da7b65
     secp384r1
da7b65
     secp521r1
da7b65
-    prime192v1
da7b65
-    prime192v2
da7b65
-    prime192v3
da7b65
-    prime239v1
da7b65
-    prime239v2
da7b65
-    prime239v3
da7b65
     prime256v1
da7b65
-    wap-wsg-idm-ecid-wtls6
da7b65
-    wap-wsg-idm-ecid-wtls7
da7b65
-    wap-wsg-idm-ecid-wtls8
da7b65
-    wap-wsg-idm-ecid-wtls9
da7b65
-    wap-wsg-idm-ecid-wtls12
da7b65
-    brainpoolP160r1
da7b65
-    brainpoolP160t1
da7b65
-    brainpoolP192r1
da7b65
-    brainpoolP192t1
da7b65
-    brainpoolP224r1
da7b65
-    brainpoolP224t1
da7b65
-    brainpoolP256r1
da7b65
-    brainpoolP256t1
da7b65
-    brainpoolP320r1
da7b65
-    brainpoolP320t1
da7b65
-    brainpoolP384r1
da7b65
-    brainpoolP384t1
da7b65
-    brainpoolP512r1
da7b65
-    brainpoolP512t1
da7b65
 );
da7b65
 
da7b65
 my @binary_curves = qw(
da7b65
@@ -115,7 +81,6 @@ push(@other_curves, 'SM2')
da7b65
     if !disabled("sm2");
da7b65
 
da7b65
 my @curve_aliases = qw(
da7b65
-    P-192
da7b65
     P-224
da7b65
     P-256
da7b65
     P-384