diff options
Diffstat (limited to 'test/keymgmt_internal_test.c')
-rw-r--r-- | test/keymgmt_internal_test.c | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/test/keymgmt_internal_test.c b/test/keymgmt_internal_test.c index e309c9e654..32e82d5b77 100644 --- a/test/keymgmt_internal_test.c +++ b/test/keymgmt_internal_test.c @@ -141,7 +141,7 @@ static int test_pass_rsa(FIXTURE *fixture) int ret = 0; RSA *rsa = NULL; BIGNUM *bn1 = NULL, *bn2 = NULL, *bn3 = NULL; - EVP_PKEY *pk = NULL; + EVP_PKEY *pk = NULL, *dup_pk = NULL; EVP_KEYMGMT *km = NULL, *km1 = NULL, *km2 = NULL, *km3 = NULL; void *provkey = NULL, *provkey2 = NULL; BIGNUM *bn_primes[1] = { NULL }; @@ -220,34 +220,47 @@ static int test_pass_rsa(FIXTURE *fixture) || !TEST_ptr_ne(km1, km2)) goto err; - km = km3; - /* Check that we can't export an RSA key into a RSA-PSS keymanager */ - if (!TEST_ptr_null(provkey2 = evp_pkey_export_to_provider(pk, NULL, &km, - NULL))) - goto err; - - if (!TEST_ptr(provkey = evp_pkey_export_to_provider(pk, NULL, &km1, NULL)) - || !TEST_true(evp_keymgmt_export(km2, provkey, - OSSL_KEYMGMT_SELECT_KEYPAIR, - &export_cb, keydata))) - goto err; - - /* - * At this point, the hope is that keydata will have all the numbers - * from the key. - */ - - for (i = 0; i < OSSL_NELEM(expected); i++) { - int rv = TEST_int_eq(expected[i], keydata[i]); - - if (!rv) - TEST_info("i = %zu", i); - else - ret++; + while (dup_pk == NULL) { + ret = 0; + km = km3; + /* Check that we can't export an RSA key into a RSA-PSS keymanager */ + if (!TEST_ptr_null(provkey2 = evp_pkey_export_to_provider(pk, NULL, + &km, + NULL))) + goto err; + + if (!TEST_ptr(provkey = evp_pkey_export_to_provider(pk, NULL, &km1, + NULL)) + || !TEST_true(evp_keymgmt_export(km2, provkey, + OSSL_KEYMGMT_SELECT_KEYPAIR, + &export_cb, keydata))) + goto err; + + /* + * At this point, the hope is that keydata will have all the numbers + * from the key. + */ + + for (i = 0; i < OSSL_NELEM(expected); i++) { + int rv = TEST_int_eq(expected[i], keydata[i]); + + if (!rv) + TEST_info("i = %zu", i); + else + ret++; + } + + ret = (ret == OSSL_NELEM(expected)); + if (!ret || !TEST_ptr(dup_pk = EVP_PKEY_dup(pk))) + goto err; + + ret = TEST_int_eq(EVP_PKEY_eq(pk, dup_pk), 1); + EVP_PKEY_free(pk); + pk = dup_pk; + if (!ret) + goto err; } - ret = (ret == OSSL_NELEM(expected)); - err: RSA_free(rsa); BN_free(bn1); |