*/
if (!ossl_assert(e == NULL || keytype == NULL))
return NULL;
- if (e == NULL)
+ if (e == NULL && (pkey == NULL || pkey->foreign == 0))
keytype = OBJ_nid2sn(id);
# ifndef OPENSSL_NO_ENGINE
*/
if (e != NULL)
pmeth = ENGINE_get_pkey_meth(e, id);
+ else if (pkey != NULL && pkey->foreign)
+ pmeth = EVP_PKEY_meth_find(id);
else
# endif
pmeth = evp_pkey_meth_find_added_by_application(id);