}
#endif
+static int test_skey_to_same_provider(void)
+{
+ OSSL_PROVIDER *fake_prov = NULL;
+ EVP_SKEY *key = NULL, *key2 = NULL;
+ OSSL_PARAM params[3];
+ unsigned char import_key[KEY_SIZE] = {
+ 0x53,
+ 0x4B,
+ 0x45,
+ 0x59,
+ 0x53,
+ 0x4B,
+ 0x45,
+ 0x59,
+ 0x53,
+ 0x4B,
+ 0x45,
+ 0x59,
+ 0x53,
+ 0x4B,
+ 0x45,
+ 0x59,
+ };
+ int ret = 0;
+
+ if (!TEST_ptr(fake_prov = fake_cipher_start(libctx)))
+ goto end;
+
+ params[0] = OSSL_PARAM_construct_utf8_string(FAKE_CIPHER_PARAM_KEY_NAME,
+ "fake key name", 0);
+ params[1] = OSSL_PARAM_construct_octet_string(OSSL_SKEY_PARAM_RAW_BYTES,
+ import_key, sizeof(import_key));
+ params[2] = OSSL_PARAM_construct_end();
+
+ if (!TEST_ptr(key = EVP_SKEY_import(libctx, "fake_cipher",
+ FAKE_CIPHER_FETCH_PROPS,
+ OSSL_SKEYMGMT_SELECT_ALL, params)))
+ goto end;
+
+ if (!TEST_ptr(key2 = EVP_SKEY_to_provider(key, libctx, fake_prov,
+ FAKE_CIPHER_FETCH_PROPS)))
+ goto end;
+
+ /* Same provider should return same object with bumped refcount */
+ if (!TEST_ptr_eq(key2, key))
+ goto end;
+
+ ret = 1;
+end:
+ EVP_SKEY_free(key2);
+ EVP_SKEY_free(key);
+ fake_cipher_finish(fake_prov);
+ return ret;
+}
+
int setup_tests(void)
{
libctx = OSSL_LIB_CTX_new();
ADD_TEST(test_skey_cipher);
ADD_TEST(test_skey_skeymgmt);
+ ADD_TEST(test_skey_to_same_provider);
ADD_TEST(test_aes_raw_skey);
#ifndef OPENSSL_NO_DES
ADD_TEST(test_des_raw_skey);