return ret;
}
+static int test_skey_to_diff_provider(void)
+{
+ OSSL_PROVIDER *fake_prov = NULL;
+ EVP_SKEY *key = NULL, *key2 = NULL;
+ const unsigned char *export_key = NULL;
+ size_t export_len;
+ 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;
+
+ deflprov = OSSL_PROVIDER_load(libctx, "default");
+ if (!TEST_ptr(deflprov))
+ return 0;
+
+ if (!TEST_ptr(fake_prov = fake_cipher_start(libctx)))
+ goto end;
+
+ if (!TEST_ptr(key = EVP_SKEY_import_raw_key(libctx, OSSL_SKEY_TYPE_GENERIC,
+ import_key, sizeof(import_key), NULL)))
+ goto end;
+
+ if (!TEST_ptr(key2 = EVP_SKEY_to_provider(key, libctx, fake_prov,
+ FAKE_CIPHER_FETCH_PROPS)))
+ goto end;
+
+ /* Different provider must return a different object */
+ if (!TEST_ptr_ne(key2, key))
+ goto end;
+
+ if (!TEST_int_gt(EVP_SKEY_get0_raw_key(key2, &export_key, &export_len), 0)
+ || !TEST_mem_eq(import_key, sizeof(import_key), export_key, export_len))
+ goto end;
+
+ ret = 1;
+end:
+ EVP_SKEY_free(key2);
+ EVP_SKEY_free(key);
+ fake_cipher_finish(fake_prov);
+ OSSL_PROVIDER_unload(deflprov);
+ return ret;
+}
+
int setup_tests(void)
{
libctx = OSSL_LIB_CTX_new();
ADD_TEST(test_skey_skeymgmt);
ADD_TEST(test_skey_to_same_provider);
+ ADD_TEST(test_skey_to_diff_provider);
ADD_TEST(test_aes_raw_skey);
#ifndef OPENSSL_NO_DES
ADD_TEST(test_des_raw_skey);
static const OSSL_ALGORITHM fake_skeymgmt_algs[] = {
{ "fake_cipher", FAKE_CIPHER_FETCH_PROPS, fake_skeymgmt_funcs, "Fake Cipher Key Management" },
+ { OSSL_SKEY_TYPE_GENERIC, FAKE_CIPHER_FETCH_PROPS, fake_skeymgmt_funcs, "Fake Generic Key Management" },
{ NULL, NULL, NULL, NULL }
};
static OSSL_FUNC_cipher_newctx_fn fake_newctx;