RSA: Do not set NULL OAEP labels
authorBenjamin Kaduk <bkaduk@akamai.com>
Fri, 22 May 2020 18:13:24 +0000 (11:13 -0700)
committerBenjamin Kaduk <kaduk@mit.edu>
Thu, 28 May 2020 17:01:47 +0000 (10:01 -0700)
commit9c44916ce555a0280170c5fc519a0ebf693292f8
tree472e6733506af512549f9c5fe2a617b109646e37
parent7c302f8afc1d36ec12effd0c08047baced095b46
RSA: Do not set NULL OAEP labels

As of the previous commit, when a zero-length (string) parameter
is present in the parameters passed to a provider for a given operation,
we will produce an object corresponding to that zero-length parameter,
indicating to the underlying cryptographic operation that the parameter
was passed.  However, rsa_cms_decrypt() was relying on the previous
behavior, and unconditionally tried to call
EVP_PKEY_CTX_set0_rsa_oaep_label() even when the implicit default label
was used (and thus the relevant local variable was still NULL).
In the new setup that distinguishes present-but-empty and absent
more clearly, it is an error to attempt to set a NULL parameter,
even if it is zero-length.

Exercise more caution when setting parameters, and do not call
EVP_PKEY_CTX_set0_rsa_oaep_label() when there is not actually a
label provided.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11920)
crypto/rsa/rsa_ameth.c