Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/tests/ncrypt.c | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
diff --git a/dlls/ncrypt/tests/ncrypt.c b/dlls/ncrypt/tests/ncrypt.c index d7623a04a83..5fc37bb425b 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -205,6 +205,51 @@ static void test_get_property(void) NCryptFreeObject(prov); }
+static void test_set_property() +{ + NCRYPT_PROV_HANDLE prov; + SECURITY_STATUS ret; + NCRYPT_KEY_HANDLE key; + DWORD keylength; + + ret = NCryptOpenStorageProvider(&prov, NULL, 0); + ok(ret == ERROR_SUCCESS, "got %#lx\n", ret); + + ret = NCryptImportKey(prov, 0, BCRYPT_RSAPUBLIC_BLOB, NULL, &key, rsa_key_blob, sizeof(rsa_key_blob), 0); + ok(ret == ERROR_SUCCESS, "got %#lx\n", ret); + keylength = 2048; + ret = NCryptSetProperty(key, NCRYPT_LENGTH_PROPERTY, &keylength, sizeof(DWORD), 0); + ok(ret == ERROR_SUCCESS || broken(ret == NTE_INVALID_HANDLE), "got %#lx\n", ret); + + ret = NCryptSetProperty(0, NCRYPT_LENGTH_PROPERTY, &keylength, sizeof(DWORD), 0); + ok(ret == NTE_INVALID_HANDLE, "got %#lx\n", ret); + + todo_wine + { + ret = NCryptSetProperty(key, NCRYPT_NAME_PROPERTY, L"Key name", sizeof(WCHAR) * 9, 0); + ok(ret == NTE_NOT_SUPPORTED, "got %#lx\n", ret); + + NCryptFreeObject(key); + + key = 0; + ret = NCryptCreatePersistedKey(prov, &key, BCRYPT_RSA_ALGORITHM, NULL, 0, 0); + ok(ret == ERROR_SUCCESS, "got %#lx\n", ret); + ok(key, "got null handle\n"); + + keylength = 2048; + ret = NCryptSetProperty(key, NCRYPT_LENGTH_PROPERTY, &keylength, sizeof(DWORD), 0); + ok(ret == ERROR_SUCCESS, "got %#lx\n", ret); + + ret = NCryptSetProperty(key, NCRYPT_NAME_PROPERTY, L"Key name", sizeof(WCHAR) * 9, 0); + ok(ret == NTE_NOT_SUPPORTED, "got %#lx\n", ret); + + ret = NCryptSetProperty(key, L"My Custom Property", L"value", sizeof(WCHAR) * 7, 0); + ok(ret == NTE_NOT_SUPPORTED, "got %#lx\n", ret); + } + NCryptFreeObject(key); + NCryptFreeObject(prov); +} + static void test_create_persisted_key() { NCRYPT_PROV_HANDLE prov; @@ -257,5 +302,6 @@ START_TEST(ncrypt) test_key_import_rsa(); test_ncrypt_free_object(); test_get_property(); + test_set_property(); test_create_persisted_key(); }