Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/main.c | 5 ++++- dlls/ncrypt/ncrypt_internal.h | 1 + dlls/ncrypt/tests/ncrypt.c | 17 ++++++++++++++--- include/ncrypt.h | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/dlls/ncrypt/main.c b/dlls/ncrypt/main.c index 22e2e9089ef..5098fd0d8ea 100644 --- a/dlls/ncrypt/main.c +++ b/dlls/ncrypt/main.c @@ -261,10 +261,13 @@ SECURITY_STATUS WINAPI NCryptImportKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_H }
public_exp = &data[sizeof(*rsaheader)]; /* The public exp is after the header. */ - modulus = &public_exp[rsaheader->cbPublicExp]; /* The modulus is after the public exp. */ + modulus = &public_exp[rsaheader->cbPublicExp]; /* The modulus is after the public exp. */ memcpy(key->rsa.public_exp, public_exp, rsaheader->cbPublicExp); memcpy(key->rsa.modulus, modulus, rsaheader->cbModulus);
+ set_object_property(object, NCRYPT_ALGORITHM_GROUP_PROPERTY, L"RSA", 8); + set_object_property(object, NCRYPT_LENGTH_PROPERTY, &key->rsa.bit_length, sizeof(DWORD)); + set_object_property(object, NCRYPT_PROVIDER_HANDLE_PROPERTY, &provider, sizeof(NCRYPT_PROV_HANDLE)); *handle = (NCRYPT_KEY_HANDLE)object; break; } diff --git a/dlls/ncrypt/ncrypt_internal.h b/dlls/ncrypt/ncrypt_internal.h index 986a17bb1eb..205ad37542e 100644 --- a/dlls/ncrypt/ncrypt_internal.h +++ b/dlls/ncrypt/ncrypt_internal.h @@ -26,6 +26,7 @@ enum key_algorithm
struct rsa_key { + DWORD bit_length; DWORD public_exp_size; BYTE *public_exp; DWORD modulus_size; diff --git a/dlls/ncrypt/tests/ncrypt.c b/dlls/ncrypt/tests/ncrypt.c index 181a5457003..b7ffd5dc0a3 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -169,6 +169,7 @@ static void test_get_property(void) NCRYPT_KEY_HANDLE key; SECURITY_STATUS ret; WCHAR value[4]; + DWORD keylength; DWORD size;
ret = NCryptOpenStorageProvider(&prov, NULL, 0); @@ -177,16 +178,26 @@ static void test_get_property(void) 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);
- todo_wine { - ret = NCryptGetProperty(key, L"Algorithm Group", NULL, 0, &size, 0); + 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, L"Algorithm Group", (BYTE *)value, sizeof(value), &size, 0); + ret = NCryptGetProperty(key, NCRYPT_ALGORITHM_GROUP_PROPERTY, (BYTE *)value, sizeof(value), &size, 0); ok(ret == ERROR_SUCCESS, "got %#lx\n", ret); + todo_wine { ok(size == 8, "got %lu\n", size); + } ok(!lstrcmpW(value, L"RSA"), "The string doesn't match with 'RSA'\n"); + + ret = NCryptGetProperty(key, NCRYPT_LENGTH_PROPERTY, NULL, 0, &size, 0); + ok(ret == ERROR_SUCCESS, "got %#lx\n", ret); + ok(size == sizeof(DWORD), "got %lu\n", size); + + ret = NCryptGetProperty(key, NCRYPT_LENGTH_PROPERTY, &keylength, size, &size, 0); + ok(ret == ERROR_SUCCESS, "got %#lx\n", ret); + todo_wine { + ok(keylength == 1024, "got %lu\n", keylength); }
NCryptFreeObject(prov); diff --git a/include/ncrypt.h b/include/ncrypt.h index 5a8ba7e88fc..f7372b30621 100644 --- a/include/ncrypt.h +++ b/include/ncrypt.h @@ -71,6 +71,40 @@ typedef ULONG_PTR NCRYPT_SECRET_HANDLE;
#define NCRYPT_SILENT_FLAG 0x00000040
+#define NCRYPT_NAME_PROPERTY L"Name" +#define NCRYPT_UNIQUE_NAME_PROPERTY L"Unique Name" +#define NCRYPT_ALGORITHM_PROPERTY L"Algorithm Name" +#define NCRYPT_LENGTH_PROPERTY L"Length" +#define NCRYPT_LENGTHS_PROPERTY L"Lengths" +#define NCRYPT_BLOCK_LENGTH_PROPERTY L"Block Length" +#define NCRYPT_UI_POLICY_PROPERTY L"UI Policy" +#define NCRYPT_EXPORT_POLICY_PROPERTY L"Export Policy" +#define NCRYPT_WINDOW_HANDLE_PROPERTY L"HWND Handle" +#define NCRYPT_USE_CONTEXT_PROPERTY L"Use Context" +#define NCRYPT_IMPL_TYPE_PROPERTY L"Impl Type" +#define NCRYPT_KEY_USAGE_PROPERTY L"Key Usage" +#define NCRYPT_KEY_TYPE_PROPERTY L"Key Type" +#define NCRYPT_VERSION_PROPERTY L"Version" +#define NCRYPT_SECURITY_DESCR_SUPPORT_PROPERTY L"Security Descr Support" +#define NCRYPT_SECURITY_DESCR_PROPERTY L"Security Descr" +#define NCRYPT_USE_COUNT_ENABLED_PROPERTY L"Enabled Use Count" +#define NCRYPT_USE_COUNT_PROPERTY L"Use Count" +#define NCRYPT_LAST_MODIFIED_PROPERTY L"Modified" +#define NCRYPT_MAX_NAME_LENGTH_PROPERTY L"Max Name Length" +#define NCRYPT_ALGORITHM_GROUP_PROPERTY L"Algorithm Group" +#define NCRYPT_PROVIDER_HANDLE_PROPERTY L"Provider Handle" +#define NCRYPT_PIN_PROPERTY L"SmartCardPin" +#define NCRYPT_READER_PROPERTY L"SmartCardReader" +#define NCRYPT_SMARTCARD_GUID_PROPERTY L"SmartCardGuid" +#define NCRYPT_CERTIFICATE_PROPERTY L"SmartCardKeyCertificate" +#define NCRYPT_PIN_PROMPT_PROPERTY L"SmartCardPinPrompt" +#define NCRYPT_USER_CERTSTORE_PROPERTY L"SmartCardUserCertStore" +#define NCRYPT_ROOT_CERTSTORE_PROPERTY L"SmartcardRootCertStore" +#define NCRYPT_SECURE_PIN_PROPERTY L"SmartCardSecurePin" +#define NCRYPT_ASSOCIATED_ECDH_KEY L"SmartCardAssociatedECDHKey" +#define NCRYPT_SCARD_PIN_ID L"SmartCardPinId" +#define NCRYPT_SCARD_PIN_INFO L"SmartCardPinInfo" + SECURITY_STATUS WINAPI NCryptCreatePersistedKey(NCRYPT_PROV_HANDLE, NCRYPT_KEY_HANDLE *, const WCHAR *, const WCHAR *, DWORD, DWORD); SECURITY_STATUS WINAPI NCryptDecrypt(NCRYPT_KEY_HANDLE, BYTE *, DWORD, void *, BYTE *, DWORD, DWORD *, DWORD); SECURITY_STATUS WINAPI NCryptEncrypt(NCRYPT_KEY_HANDLE, BYTE *, DWORD, void *, BYTE *, DWORD, DWORD *, DWORD);