diff options
author | Pauli <pauli@openssl.org> | 2022-01-17 13:09:41 +1100 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2022-01-19 21:50:22 +1100 |
commit | ed16b0fc282d29f755e656043e8a70553ef7bea5 (patch) | |
tree | 80930089c924d7c9025a490bd3a330e66c6ce86e /test/evp_test.c | |
parent | 0be4b0403d2f65adf0d037581223dbebd0fa135e (diff) |
test: add cipher context dup test
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17529)
Diffstat (limited to 'test/evp_test.c')
-rw-r--r-- | test/evp_test.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/test/evp_test.c b/test/evp_test.c index 22fc48df58..871f2a9c6b 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -427,6 +427,7 @@ static int digest_test_run(EVP_TEST *t) int xof = 0; OSSL_PARAM params[2]; + printf("test %s (%d %d)\n", t->name, t->s.start, t->s.curr); t->err = "TEST_FAILURE"; if (!TEST_ptr(mctx = EVP_MD_CTX_new())) goto err; @@ -707,7 +708,7 @@ static int cipher_test_enc(EVP_TEST *t, int enc, size_t in_len, out_len, donelen = 0; int ok = 0, tmplen, chunklen, tmpflen, i; EVP_CIPHER_CTX *ctx_base = NULL; - EVP_CIPHER_CTX *ctx = NULL; + EVP_CIPHER_CTX *ctx = NULL, *duped; t->err = "TEST_FAILURE"; if (!TEST_ptr(ctx_base = EVP_CIPHER_CTX_new())) @@ -838,13 +839,19 @@ static int cipher_test_enc(EVP_TEST *t, int enc, /* Test that the cipher dup functions correctly if it is supported */ ERR_set_mark(); - if (EVP_CIPHER_CTX_copy(ctx, ctx_base) != NULL) { + if (EVP_CIPHER_CTX_copy(ctx, ctx_base)) { EVP_CIPHER_CTX_free(ctx_base); ctx_base = NULL; } else { EVP_CIPHER_CTX_free(ctx); ctx = ctx_base; } + /* Likewise for dup */ + duped = EVP_CIPHER_CTX_dup(ctx); + if (duped != NULL) { + EVP_CIPHER_CTX_free(ctx); + ctx = duped; + } ERR_pop_to_mark(); if (expected->mac_key != NULL |