Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/tests/ncrypt.c | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
diff --git a/dlls/ncrypt/tests/ncrypt.c b/dlls/ncrypt/tests/ncrypt.c index 9ffd4bfec50..d7623a04a83 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -205,9 +205,57 @@ static void test_get_property(void) NCryptFreeObject(prov); }
+static void test_create_persisted_key() +{ + NCRYPT_PROV_HANDLE prov; + NCRYPT_KEY_HANDLE key; + SECURITY_STATUS ret; + DWORD size; + DWORD keylength; + WCHAR alggroup[4]; + memset(alggroup, 0, sizeof(alggroup)); + + ret = NCryptOpenStorageProvider(&prov, NULL, 0); + ok(ret == ERROR_SUCCESS, "got %#lx\n", ret); + + todo_wine + { + key = 0; + ret = NCryptCreatePersistedKey(NULL, &key, BCRYPT_RSA_ALGORITHM, NULL, 0, 0); + ok(ret == NTE_INVALID_HANDLE, "got %#lx\n", ret); + + ret = NCryptCreatePersistedKey(prov, &key, NULL, NULL, 0, 0); + ok(ret == 0x800706f4 || broken(ret == NTE_FAIL), "got %#lx\n", ret); /* FIXME Find name for this error */ + + ret = NCryptCreatePersistedKey(prov, &key, BCRYPT_RSA_ALGORITHM, NULL, 0, 0); + ok(ret == ERROR_SUCCESS, "got %#lx\n", ret); + ok(key, "got null handle\n"); + + ret = NCryptGetProperty(key, NCRYPT_ALGORITHM_GROUP_PROPERTY, NULL, 0, &size, 0); + ok(ret == ERROR_SUCCESS, "got %#lx\n", ret); + ok(size == 8, "got %lu\n", size); + + size = 0; + ret = NCryptGetProperty(key, NCRYPT_ALGORITHM_GROUP_PROPERTY, (BYTE *)alggroup, sizeof(alggroup), &size, 0); + ok(ret == ERROR_SUCCESS, "got %#lx\n", ret); + ok(size == 8, "got %lu\n", size); + ok(!lstrcmpW(alggroup, L"RSA"), "The string doesn't match with 'RSA'\n"); + + ret = NCryptGetProperty(key, NCRYPT_LENGTH_PROPERTY, (BYTE *)&keylength, sizeof(DWORD), &size, 0); + ok(ret == ERROR_SUCCESS, "got %#lx\n", ret); + ok(size == 4, "got %lu\n", size); + ok(keylength == 1024, "got %lu\n", keylength); + + NCryptFinalizeKey(key, 0); + NCryptFreeObject(key); + NCryptFreeObject(prov); + } +} + START_TEST(ncrypt) { test_key_import_rsa(); test_ncrypt_free_object(); test_get_property(); + test_create_persisted_key(); }