EVP: Fix method to determine if a PKEY is legacy or not
EVP: Fix method to determine if a PKEY is legacy or not

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 <38c64d6e24766247aad56af3a6ddb0056ad36a44@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10758)

openssl/openssl,openssl/openssl,openssl/openssl,openssl/openssl,openssl/openssl,openssl/openssl