test: change pkey kdf dup fail test to a pkey kdf dup success test
@@ -1693,11 +1693,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;
@@ -1708,10 +1707,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:
@@ -1731,7 +1732,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
