Commit efc62e66 authored by Patrick Steuer's avatar Patrick Steuer
Browse files

Test for out-of-bounds write when requesting zero bytes from shake



Signed-off-by: default avatarPatrick Steuer <patrick.steuer@de.ibm.com>

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9433)

(cherry picked from commit 3ce46435e6ebed69bec0fa3454cc195ced426d42)
parent 6087d4a6
Loading
Loading
Loading
Loading
+22 −0
Original line number Original line Diff line number Diff line
@@ -403,6 +403,28 @@ static int digest_test_run(EVP_TEST *t)
    }
    }


    if (EVP_MD_flags(expected->digest) & EVP_MD_FLAG_XOF) {
    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;
        got_len = expected->output_len;
        if (!EVP_DigestFinalXOF(mctx, got, got_len)) {
        if (!EVP_DigestFinalXOF(mctx, got, got_len)) {
            t->err = "DIGESTFINALXOF_ERROR";
            t->err = "DIGESTFINALXOF_ERROR";