]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
EVP: Have evp_pkey_cmp_any() detect if export wasn't possible
authorRichard Levitte <levitte@openssl.org>
Fri, 7 Aug 2020 16:47:04 +0000 (18:47 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 20 Aug 2020 05:46:30 +0000 (07:46 +0200)
There are some EC keys that can't be exported to provider keymgmt,
because the keymgmt implementation doesn't support certain forms of EC
keys.  This could lead to a crash caused by dereferencing a NULL
pointer, so we need to cover that case by returning an error instead.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12610)

crypto/evp/p_lib.c

index 145c5286ce69d9db28e5235242e2aa5d89a322ef..bee6337a88cc52817179e4bbf3f9ca2dde7f7529 100644 (file)
@@ -269,6 +269,10 @@ static int evp_pkey_cmp_any(const EVP_PKEY *a, const EVP_PKEY *b,
     if (keymgmt1 != keymgmt2)
         return -2;
 
+    /* If the keymgmt implementations are NULL, the export failed */
+    if (keymgmt1 == NULL)
+        return -2;
+
     return evp_keymgmt_match(keymgmt1, keydata1, keydata2, selection);
 }