[openssl] master update

tomas at openssl.org tomas at openssl.org
Fri Apr 23 08:48:33 UTC 2021


The branch master has been updated
       via  5af6e154d0a4cd5b1d3a46bcfab444e714364d67 (commit)
      from  0ba8bc058376d423d7c5649cfce83a23cce97267 (commit)


- Log -----------------------------------------------------------------
commit 5af6e154d0a4cd5b1d3a46bcfab444e714364d67
Author: Tomas Mraz <tomas at openssl.org>
Date:   Tue Apr 20 16:39:00 2021 +0200

    Trivial shortcuts for EVP_PKEY_eq()
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14942)

-----------------------------------------------------------------------

Summary of changes:
 crypto/evp/p_lib.c    |  6 ++++++
 test/evp_extra_test.c | 21 ++++++++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c
index db334fb1ef..a0dfff9195 100644
--- a/crypto/evp/p_lib.c
+++ b/crypto/evp/p_lib.c
@@ -327,6 +327,12 @@ int EVP_PKEY_eq(const EVP_PKEY *a, const EVP_PKEY *b)
      * is gone.
      */
 
+    /* Trivial shortcuts */
+    if (a == b)
+        return 1;
+    if (a == NULL || b == NULL)
+        return 0;
+
     if (a->keymgmt != NULL || b->keymgmt != NULL)
         return evp_pkey_cmp_any(a, b, (SELECT_PARAMETERS
                                        | OSSL_KEYMGMT_SELECT_PUBLIC_KEY));
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c
index a290878a7d..b781c583b5 100644
--- a/test/evp_extra_test.c
+++ b/test/evp_extra_test.c
@@ -478,7 +478,8 @@ static EVP_PKEY *load_example_hmac_key(void)
         0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
     };
 
-    pkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_HMAC, NULL, key, sizeof(key));
+    pkey = EVP_PKEY_new_raw_private_key_ex(testctx, "HMAC",
+                                           NULL, key, sizeof(key));
     if (!TEST_ptr(pkey))
         return NULL;
 
@@ -1544,10 +1545,14 @@ static struct keys_st {
 } keys[] = {
     {
         EVP_PKEY_HMAC, "0123456789", NULL
+#ifndef OPENSSL_NO_POLY1305
     }, {
         EVP_PKEY_POLY1305, "01234567890123456789012345678901", NULL
+#endif
+#ifndef OPENSSL_NO_SIPHASH
     }, {
         EVP_PKEY_SIPHASH, "0123456789012345", NULL
+#endif
     },
 #ifndef OPENSSL_NO_EC
     {
@@ -1576,16 +1581,14 @@ static int test_set_get_raw_keys_int(int tst, int pub, int uselibctx)
     size_t inlen, len = 0;
     EVP_PKEY *pkey;
 
-    if (nullprov != NULL)
-        return TEST_skip("Test does not support a non-default library context");
-
     /* Check if this algorithm supports public keys */
-    if (keys[tst].pub == NULL)
+    if (pub && keys[tst].pub == NULL)
         return 1;
 
     memset(buf, 0, sizeof(buf));
 
     if (pub) {
+#ifndef OPENSSL_NO_EC
         inlen = strlen(keys[tst].pub);
         in = (unsigned char *)keys[tst].pub;
         if (uselibctx) {
@@ -1601,6 +1604,9 @@ static int test_set_get_raw_keys_int(int tst, int pub, int uselibctx)
                                                in,
                                                inlen);
         }
+#else
+        return 1;
+#endif
     } else {
         inlen = strlen(keys[tst].priv);
         in = (unsigned char *)keys[tst].priv;
@@ -1619,6 +1625,7 @@ static int test_set_get_raw_keys_int(int tst, int pub, int uselibctx)
     }
 
     if (!TEST_ptr(pkey)
+            || !TEST_int_eq(EVP_PKEY_eq(pkey, pkey), 1)
             || (!pub && !TEST_true(EVP_PKEY_get_raw_private_key(pkey, NULL, &len)))
             || (pub && !TEST_true(EVP_PKEY_get_raw_public_key(pkey, NULL, &len)))
             || !TEST_true(len == inlen)
@@ -1635,9 +1642,9 @@ static int test_set_get_raw_keys_int(int tst, int pub, int uselibctx)
 
 static int test_set_get_raw_keys(int tst)
 {
-    return test_set_get_raw_keys_int(tst, 0, 0)
+    return (nullprov != NULL || test_set_get_raw_keys_int(tst, 0, 0))
            && test_set_get_raw_keys_int(tst, 0, 1)
-           && test_set_get_raw_keys_int(tst, 1, 0)
+           && (nullprov != NULL || test_set_get_raw_keys_int(tst, 1, 0))
            && test_set_get_raw_keys_int(tst, 1, 1);
 }
 


More information about the openssl-commits mailing list