diff options
author | Matt Caswell <matt@openssl.org> | 2019-11-27 16:06:34 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2019-11-29 10:41:06 +0000 |
commit | 4b9c750be83644aca15a98e75b566e7f6c3644d7 (patch) | |
tree | 82b339cdaa72f764d4000f91acd07fab1a39fa6c /providers/common | |
parent | cff64af5532d3a1b0e2e9adf88454887efba01b2 (diff) |
Make sure we handle input NULL with length 0
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)
Diffstat (limited to 'providers/common')
-rw-r--r-- | providers/common/ciphers/cipher_common.c | 5 | ||||
-rw-r--r-- | providers/common/ciphers/cipher_gcm.c | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/providers/common/ciphers/cipher_common.c b/providers/common/ciphers/cipher_common.c index 8f39a168c8..83c370793b 100644 --- a/providers/common/ciphers/cipher_common.c +++ b/providers/common/ciphers/cipher_common.c @@ -291,6 +291,11 @@ int cipher_generic_stream_update(void *vctx, unsigned char *out, size_t *outl, { 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; diff --git a/providers/common/ciphers/cipher_gcm.c b/providers/common/ciphers/cipher_gcm.c index f479bc8fda..619d4f61b0 100644 --- a/providers/common/ciphers/cipher_gcm.c +++ b/providers/common/ciphers/cipher_gcm.c @@ -210,6 +210,11 @@ int gcm_stream_update(void *vctx, unsigned char *out, size_t *outl, { 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; |