EVP: Fix method to determine if a PKEY is legacy or not
authorRichard Levitte <levitte@openssl.org>
Sat, 4 Jan 2020 18:24:39 +0000 (19:24 +0100)
committerDmitry Belyavskiy <beldmit@gmail.com>
Mon, 6 Jan 2020 10:34:38 +0000 (13:34 +0300)
For the implementation of EVP_PKEY_CTX_new(), we determined if an
EVP_PKEY wass legacy or not by looking at 'pkey->pkey.ptr'.  It turns
out that this code could get an unassigned EVP_PKEY, with that pointer
being NULL, and the determination proven incorrect.

The check now looks at 'pkey->ameth' instead.

Fixes #10704

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10758)

crypto/evp/pmeth_lib.c

index b1bbb9c57e314c8531b0b0aeb173c0c1aa74dcba..8b49baf6abdba93e2e0eb56ccaf7a728b797dc2c 100644 (file)
@@ -131,7 +131,7 @@ static EVP_PKEY_CTX *int_ctx_new(OPENSSL_CTX *libctx,
      * If the key doesn't contain anything legacy, then it must be provided,
      * so we extract the necessary information and use that.
      */
-    if (pkey != NULL && pkey->pkey.ptr == NULL) {
+    if (pkey != NULL && pkey->ameth == NULL) {
         /* If we have an engine, something went wrong somewhere... */
         if (!ossl_assert(e == NULL))
             return NULL;