Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/main.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/ncrypt/main.c b/dlls/ncrypt/main.c index 6b1a87ea785..22e2e9089ef 100644 --- a/dlls/ncrypt/main.c +++ b/dlls/ncrypt/main.c @@ -322,6 +322,7 @@ static SECURITY_STATUS set_object_property(struct object *object, const WCHAR *n ERR("Error allocating memory."); return NTE_NO_MEMORY; } + property = &object->properties[object->num_properties]; object->num_properties++; } else
Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/ncrypt_internal.h | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/dlls/ncrypt/ncrypt_internal.h b/dlls/ncrypt/ncrypt_internal.h index fe5f27ea1eb..986a17bb1eb 100644 --- a/dlls/ncrypt/ncrypt_internal.h +++ b/dlls/ncrypt/ncrypt_internal.h @@ -73,3 +73,7 @@ struct object struct storage_provider storage_provider; }; }; + + +static const struct object_property *get_object_property(struct object *object, const WCHAR *name); +static SECURITY_STATUS set_object_property(struct object *object, const WCHAR *name, BYTE *value, DWORD value_size);
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);
Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/main.c | 7 ++----- dlls/ncrypt/tests/ncrypt.c | 2 -- 2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/dlls/ncrypt/main.c b/dlls/ncrypt/main.c index 5098fd0d8ea..a487c2f6059 100644 --- a/dlls/ncrypt/main.c +++ b/dlls/ncrypt/main.c @@ -165,11 +165,8 @@ SECURITY_STATUS WINAPI NCryptGetProperty(NCRYPT_HANDLE handle, const WCHAR *name if (flags) FIXME("flags %#lx not supported\n", flags);
if (!(property = get_object_property(object, name))) return NTE_INVALID_PARAMETER; - if (!output) - { - *result = property->value_size; - return ERROR_SUCCESS; - } + *result = property->value_size; + if (!output) return ERROR_SUCCESS; if (outsize < property->value_size) return NTE_BUFFER_TOO_SMALL;
memcpy(output, property->value, property->value_size); diff --git a/dlls/ncrypt/tests/ncrypt.c b/dlls/ncrypt/tests/ncrypt.c index b7ffd5dc0a3..61f9684a3c0 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -185,9 +185,7 @@ static void test_get_property(void) 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);
Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/main.c | 1 + dlls/ncrypt/tests/ncrypt.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/ncrypt/main.c b/dlls/ncrypt/main.c index a487c2f6059..d4761537864 100644 --- a/dlls/ncrypt/main.c +++ b/dlls/ncrypt/main.c @@ -241,6 +241,7 @@ SECURITY_STATUS WINAPI NCryptImportKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_H
key = &object->key; key->alg = RSA; + key->rsa.bit_length = rsaheader->BitLength; key->rsa.public_exp_size = rsaheader->cbPublicExp; key->rsa.modulus_size = rsaheader->cbModulus; if (!(key->rsa.public_exp = malloc(rsaheader->cbPublicExp))) diff --git a/dlls/ncrypt/tests/ncrypt.c b/dlls/ncrypt/tests/ncrypt.c index 61f9684a3c0..bde9d39c4f7 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -194,9 +194,7 @@ static void test_get_property(void)
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); }
With this change now some applications which uses ncrypt for signature validation work. For example, the visual studio installer (using dotnet from winetricks).
Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/main.c | 9 +++++++++ dlls/ncrypt/ncrypt.spec | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/dlls/ncrypt/main.c b/dlls/ncrypt/main.c index d4761537864..75b8e7685a4 100644 --- a/dlls/ncrypt/main.c +++ b/dlls/ncrypt/main.c @@ -368,3 +368,12 @@ SECURITY_STATUS WINAPI NCryptSetProperty(NCRYPT_HANDLE handle, const WCHAR *name
return set_object_property(object, name, input, insize); } + +SECURITY_STATUS NCryptVerifySignature(NCRYPT_KEY_HANDLE key, VOID *padding_info, + BYTE *hash_value, DWORD hash_value_size, BYTE *signature, + DWORD signature_size, DWORD flags) +{ + FIXME("(%lx, %lx, %lx, %x, %lx, %x, %x): stub\n", key, padding_info, hash_value, hash_value_size, + signature, signature_size, flags); + return ERROR_SUCCESS; +} diff --git a/dlls/ncrypt/ncrypt.spec b/dlls/ncrypt/ncrypt.spec index 0e92609790c..bb914616373 100644 --- a/dlls/ncrypt/ncrypt.spec +++ b/dlls/ncrypt/ncrypt.spec @@ -101,7 +101,7 @@ @ stub NCryptUnprotectKey @ stub NCryptUnprotectSecret @ stub NCryptVerifyClaim -@ stub NCryptVerifySignature +@ stdcall NCryptVerifySignature(ptr ptr ptr long ptr long long) @ stub SslChangeNotify @ stub SslComputeClientAuthHash @ stub SslComputeEapKeyBlock