diff options
author | Pauli <pauli@openssl.org> | 2021-06-24 11:32:50 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-06-25 14:51:13 +1000 |
commit | 4d7c39f40f89e0920d0a60e6cf5bf4f346bef757 (patch) | |
tree | a798940d402955d040b2075ddc108e891975c98f /test | |
parent | e86b2e78a4b7b618824c4e5cdf7f5d32feacd8b6 (diff) |
test: add EVP_Q_digest tests to evp_test
Fixes #15837
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/15888)
Diffstat (limited to 'test')
-rw-r--r-- | test/evp_test.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/test/evp_test.c b/test/evp_test.c index d8ddf27eaf..7ba19f1245 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -399,9 +399,12 @@ static int digest_update_fn(void *ctx, const unsigned char *buf, size_t buflen) static int digest_test_run(EVP_TEST *t) { DIGEST_DATA *expected = t->data; + EVP_TEST_BUFFER *inbuf; EVP_MD_CTX *mctx; unsigned char *got = NULL; unsigned int got_len; + size_t size; + int xof = 0; OSSL_PARAM params[2]; t->err = "TEST_FAILURE"; @@ -431,7 +434,8 @@ static int digest_test_run(EVP_TEST *t) goto err; } - if (EVP_MD_get_flags(expected->digest) & EVP_MD_FLAG_XOF) { + xof = (EVP_MD_get_flags(expected->digest) & EVP_MD_FLAG_XOF) != 0; + if (xof) { EVP_MD_CTX *mctx_cpy; char dont[] = "touch"; @@ -476,6 +480,24 @@ static int digest_test_run(EVP_TEST *t) t->err = NULL; + /* Test the EVP_Q_ interface as well */ + if (sk_EVP_TEST_BUFFER_num(expected->input) == 1 + && !xof + /* This should never fail but we need the returned pointer now */ + && !TEST_ptr(inbuf = sk_EVP_TEST_BUFFER_value(expected->input, 0)) + && !inbuf->count_set) { + OPENSSL_cleanse(got, sizeof(got)); + if (!TEST_true(EVP_Q_digest(libctx, + EVP_MD_get0_name(expected->fetched_digest), + NULL, inbuf->buf, inbuf->buflen, + got, &size)) + || !TEST_mem_eq(got, size, + expected->output, expected->output_len)) { + t->err = "EVP_Q_digest failed"; + goto err; + } + } + err: OPENSSL_free(got); EVP_MD_CTX_free(mctx); |