Fix error reporting in EVP_PKEY_{sign,verify,verify_recover}
authorRichard Levitte <levitte@openssl.org>
Mon, 29 Jan 2024 07:51:52 +0000 (08:51 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 31 Jan 2024 10:40:54 +0000 (10:40 +0000)
commit8d60a4f1da13199c727cbc21a9bb807f02509985
treec1361342df156f8f86f81f1c5066fcad86094772
parent573836ae7a26d48b9f64c296e173630a832a99f5
Fix error reporting in EVP_PKEY_{sign,verify,verify_recover}

For some reason, those functions (and the _init functions too) would
raise EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE when the passed
ctx is NULL, and then not check if the provider supplied the function
that would support these libcrypto functions.

This corrects the situation, and has all those libcrypto functions
raise ERR_R_PASS_NULL_PARAMETER if ctx is NULL, and then check for the
corresponding provider supplied, and only when that one is missing,
raise EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE.

Because 0 doesn't mean error for EVP_PKEY_verify(), -1 is returned when
ERR_R_PASSED_NULL_PARAMETER is raised.  This is done consistently for all
affected functions.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23411)

(cherry picked from commit 5a25177d1b07ef6e754fec1747b57ee90ab1e028)
crypto/evp/signature.c