diff options
author | Patrick Steuer <patrick.steuer@de.ibm.com> | 2019-08-05 16:56:14 +0200 |
---|---|---|
committer | Patrick Steuer <patrick.steuer@de.ibm.com> | 2019-08-18 21:06:03 +0200 |
commit | 3ce46435e6ebed69bec0fa3454cc195ced426d42 (patch) | |
tree | 600628076a795eda39f768225b1cebaf8d2bdc96 /test/evp_test.c | |
parent | Directly return from final sha3/keccak_final if no bytes are requested (diff) | |
download | openssl-3ce46435e6ebed69bec0fa3454cc195ced426d42.tar.xz openssl-3ce46435e6ebed69bec0fa3454cc195ced426d42.zip |
Test for out-of-bounds write when requesting zero bytes from shake
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)
Diffstat (limited to 'test/evp_test.c')
-rw-r--r-- | test/evp_test.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/evp_test.c b/test/evp_test.c index 029738f296..76a0231c8b 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -407,6 +407,28 @@ static int digest_test_run(EVP_TEST *t) } if (EVP_MD_flags(expected->digest) & EVP_MD_FLAG_XOF) { + EVP_MD_CTX *mctx_cpy; + char dont[] = "touch"; + + if (!TEST_ptr(mctx_cpy = EVP_MD_CTX_new())) { + goto err; + } + if (!EVP_MD_CTX_copy(mctx_cpy, mctx)) { + EVP_MD_CTX_free(mctx_cpy); + goto err; + } + if (!EVP_DigestFinalXOF(mctx_cpy, (unsigned char *)dont, 0)) { + EVP_MD_CTX_free(mctx_cpy); + t->err = "DIGESTFINALXOF_ERROR"; + goto err; + } + if (!TEST_str_eq(dont, "touch")) { + EVP_MD_CTX_free(mctx_cpy); + t->err = "DIGESTFINALXOF_ERROR"; + goto err; + } + EVP_MD_CTX_free(mctx_cpy); + got_len = expected->output_len; if (!EVP_DigestFinalXOF(mctx, got, got_len)) { t->err = "DIGESTFINALXOF_ERROR"; |