diff options
author | Benjamin Kaduk <bkaduk@akamai.com> | 2020-07-09 14:29:33 -0700 |
---|---|---|
committer | Benjamin Kaduk <bkaduk@akamai.com> | 2020-08-11 07:07:58 -0700 |
commit | bdc0df8ab5f3096aafd54d170c85887366920c4b (patch) | |
tree | 8b4a97db9d3701af49062f11d74f21b5be69e0e9 /test | |
parent | f43c947dd924cfb1f69c800648f80881bb542027 (diff) |
Avoid deprecated API in evp_test.c
Use EVP_CIPHER_CTX_get_iv_state() in cipher_test_enc() rather than
the deprecated EVP_CIPHER_CTX_iv().
[extended tests]
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12233)
Diffstat (limited to 'test')
-rw-r--r-- | test/evp_test.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/test/evp_test.c b/test/evp_test.c index f384a8d863..b980abc944 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -760,12 +760,16 @@ static int cipher_test_enc(EVP_TEST *t, int enc, } /* Check that we get the same IV back */ - if (expected->iv != NULL - && (EVP_CIPHER_flags(expected->cipher) & EVP_CIPH_CUSTOM_IV) == 0 - && !TEST_mem_eq(expected->iv, expected->iv_len, - EVP_CIPHER_CTX_iv(ctx_base), expected->iv_len)) { - t->err = "INVALID_IV"; - goto err; + if (expected->iv != NULL) { + /* Some (e.g., GCM) tests use IVs longer than EVP_MAX_IV_LENGTH. */ + unsigned char iv[128]; + if (!TEST_true(EVP_CIPHER_CTX_get_iv_state(ctx_base, iv, sizeof(iv))) + || ((EVP_CIPHER_flags(expected->cipher) & EVP_CIPH_CUSTOM_IV) == 0 + && !TEST_mem_eq(expected->iv, expected->iv_len, iv, + expected->iv_len))) { + t->err = "INVALID_IV"; + goto err; + } } /* Test that the cipher dup functions correctly if it is supported */ |