summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorPatrick Steuer <patrick.steuer@de.ibm.com>2019-08-05 16:53:16 +0200
committerPatrick Steuer <patrick.steuer@de.ibm.com>2019-08-18 21:33:49 +0200
commit6087d4a6fb1877c668dcf934da6a2f9e402dff1d (patch)
treeb8c7212c2ced188f347dd0de8a58c578f4f10fe3 /crypto
parentec9cbe21519f85e65e2f128d3f04bfd904642079 (diff)
Directly return from final sha3/keccak_final if no bytes are requested
Requesting zero bytes from shake previously led to out-of-bounds write on some platforms. Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9433) (cherry picked from commit a890ef833d114da3430c2f2efd95e01714704d34)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/evp/m_sha3.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/evp/m_sha3.c b/crypto/evp/m_sha3.c
index 31379c0f6b..b6bbf58211 100644
--- a/crypto/evp/m_sha3.c
+++ b/crypto/evp/m_sha3.c
@@ -108,6 +108,9 @@ static int sha3_final(EVP_MD_CTX *evp_ctx, unsigned char *md)
size_t bsz = ctx->block_size;
size_t num = ctx->num;
+ if (ctx->md_size == 0)
+ return 1;
+
/*
* Pad the data with 10*1. Note that |num| can be |bsz - 1|
* in which case both byte operations below are performed on