diff options
author | Pauli <pauli@openssl.org> | 2022-01-25 11:47:23 +1100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-11-11 10:03:34 +0100 |
commit | 6e6024c37c36113313b3fe04bb4828a16de01ec2 (patch) | |
tree | 9a36761ded1823b7663744012571f581845560e3 /test | |
parent | 0f5229723ff6d0ccb9c4b67c6fc96032c9df1f63 (diff) |
test: change pkey kdf dup fail test to a pkey kdf dup success test
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/17572)
(cherry picked from commit 43332e405bea83a2d553e0519fdb04170879bc96)
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/evp_pkey_provided_test.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/test/evp_pkey_provided_test.c b/test/evp_pkey_provided_test.c index d1a287e277..3237884d7c 100644 --- a/test/evp_pkey_provided_test.c +++ b/test/evp_pkey_provided_test.c @@ -1698,11 +1698,10 @@ static OSSL_PARAM *do_construct_hkdf_params(char *digest, char *key, return params; } -/* Test that EVP_PKEY_CTX_dup() fails gracefully for a KDF */ -static int test_evp_pkey_ctx_dup_kdf_fail(void) +static int test_evp_pkey_ctx_dup_kdf(void) { int ret = 0; - size_t len = 0; + size_t len = 0, dlen = 0; EVP_PKEY_CTX *pctx = NULL, *dctx = NULL; OSSL_PARAM *params = NULL; @@ -1713,10 +1712,12 @@ static int test_evp_pkey_ctx_dup_kdf_fail(void) goto err; if (!TEST_int_eq(EVP_PKEY_derive_init_ex(pctx, params), 1)) goto err; - if (!TEST_int_eq(EVP_PKEY_derive(pctx, NULL, &len), 1) - || !TEST_size_t_eq(len, SHA256_DIGEST_LENGTH)) + if (!TEST_ptr(dctx = EVP_PKEY_CTX_dup(pctx))) goto err; - if (!TEST_ptr_null(dctx = EVP_PKEY_CTX_dup(pctx))) + if (!TEST_int_eq(EVP_PKEY_derive(pctx, NULL, &len), 1) + || !TEST_size_t_eq(len, SHA256_DIGEST_LENGTH) + || !TEST_int_eq(EVP_PKEY_derive(dctx, NULL, &dlen), 1) + || !TEST_size_t_eq(dlen, SHA256_DIGEST_LENGTH)) goto err; ret = 1; err: @@ -1736,7 +1737,7 @@ int setup_tests(void) if (!TEST_ptr(datadir = test_get_argument(0))) return 0; - ADD_TEST(test_evp_pkey_ctx_dup_kdf_fail); + ADD_TEST(test_evp_pkey_ctx_dup_kdf); ADD_TEST(test_evp_pkey_get_bn_param_large); ADD_TEST(test_fromdata_rsa); #ifndef OPENSSL_NO_DH |