diff options
author | Pauli <pauli@openssl.org> | 2022-01-17 13:09:41 +1100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-11-09 15:32:37 +0100 |
commit | 3fe69d976b5fa03e2a3930b3daa14d42238aa51e (patch) | |
tree | dbb63ded26c378417de5841d80ee61326f2d54a0 /test | |
parent | 15e6cb6223af17b0d27f26245f5057f735dc6b36 (diff) |
test: add cipher context dup test
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17529)
(cherry picked from commit ed16b0fc282d29f755e656043e8a70553ef7bea5)
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Diffstat (limited to 'test')
-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 252bb11ae1..7dd3382f77 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -426,6 +426,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; @@ -708,7 +709,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())) @@ -839,13 +840,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 |