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

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