If we call EVP_EncryptUpdate/EVP_DecryptUpdate with length 0 we should
be able to handle it. Most importantly we shouldn't get different
results if we do this compared to if we don't!
An exception is made for CCM mode which has special handling for this in
the low level cipher function.
Fixes #8675
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10530)
{
PROV_CIPHER_CTX *ctx = (PROV_CIPHER_CTX *)vctx;
+ if (inl == 0) {
+ *outl = 0;
+ return 1;
+ }
+
if (outsize < inl) {
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
return 0;
{
PROV_GCM_CTX *ctx = (PROV_GCM_CTX *)vctx;
+ if (inl == 0) {
+ *outl = 0;
+ return 1;
+ }
+
if (outsize < inl) {
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
return -1;
if (!ctx->key_set || !update_iv(ctx))
return 0;
+ if (inl == 0) {
+ *outl = 0;
+ return 1;
+ }
+
/* Are we dealing with AAD or normal data here? */
if (out == NULL) {
buf = ctx->aad_buf;
{
PROV_AES_SIV_CTX *ctx = (PROV_AES_SIV_CTX *)vctx;
+ if (inl == 0) {
+ *outl = 0;
+ return 1;
+ }
+
if (outsize < inl) {
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
return 0;
PROV_AES_WRAP_CTX *ctx = (PROV_AES_WRAP_CTX *)vctx;
size_t len;
+ if (inl == 0) {
+ *outl = 0;
+ return 1;
+ }
+
if (outsize < inl) {
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
return -1;
PROV_CIPHER_HW_CHACHA20_POLY1305 *hw =
(PROV_CIPHER_HW_CHACHA20_POLY1305 *)ctx->hw;
+ if (inl == 0) {
+ *outl = 0;
+ return 1;
+ }
+
if (outsize < inl) {
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
return 0;
size_t inl)
{
*outl = 0;
+ if (inl == 0)
+ return 1;
if (outsize < inl) {
PROVerr(0, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
return 0;