Some applications crash when the storage provider its null.
Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/main.c | 16 +++++++++- dlls/ncrypt/ncrypt_internal.h | 56 +++++++++++++++++++++++++++++++++++ dlls/ncrypt/tests/ncrypt.c | 2 +- 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 dlls/ncrypt/ncrypt_internal.h
diff --git a/dlls/ncrypt/main.c b/dlls/ncrypt/main.c index f23b239d93f..7f844bf9e85 100644 --- a/dlls/ncrypt/main.c +++ b/dlls/ncrypt/main.c @@ -23,6 +23,7 @@ #include "windef.h" #include "winbase.h" #include "ncrypt.h" +#include "ncrypt_internal.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ncrypt); @@ -129,10 +130,23 @@ SECURITY_STATUS WINAPI NCryptOpenKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_HAN return NTE_NOT_SUPPORTED; }
+int allocate_storage_provider_object(struct ncrypt_object **providerobject) +{ + *providerobject = malloc(sizeof(struct ncrypt_object)); + if (providerobject == NULL) + { + ERR("Error allocating memory.\n"); + return NTE_NO_MEMORY; + } + memset(*providerobject, 0, sizeof(struct ncrypt_object)); + (*providerobject)->type = STORAGE_PROVIDER; + return ERROR_SUCCESS; +} + SECURITY_STATUS WINAPI NCryptOpenStorageProvider(NCRYPT_PROV_HANDLE *provider, const WCHAR *name, DWORD flags) { FIXME("(%p, %s, %u): stub\n", provider, wine_dbgstr_w(name), flags); - return NTE_NOT_SUPPORTED; + return allocate_storage_provider_object(provider); }
SECURITY_STATUS WINAPI NCryptSetProperty(NCRYPT_HANDLE object, const WCHAR *property, diff --git a/dlls/ncrypt/ncrypt_internal.h b/dlls/ncrypt/ncrypt_internal.h new file mode 100644 index 00000000000..1201cdd857a --- /dev/null +++ b/dlls/ncrypt/ncrypt_internal.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021 Santino Mazza + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef NCRYPT_INTERNAL_H +#define NCRYPT_INTERNAL_H + +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#include "winternl.h" + +struct ncrypt_storage_provider_object +{ + // FIXME Stub +}; + +enum ncrypt_object_type +{ + STORAGE_PROVIDER, +}; + +struct ncrypt_object_property +{ + WCHAR *key; + DWORD value_size; + VOID *value; +}; + +struct ncrypt_object +{ + enum ncrypt_object_type type; + DWORD number_of_properties; + struct ncrypt_object_property *properties; + union + { + struct ncrypt_storage_provider_object storage_provider; + } object; +}; + +#endif // NCRYPT_INTERNAL_H diff --git a/dlls/ncrypt/tests/ncrypt.c b/dlls/ncrypt/tests/ncrypt.c index b948665ebaa..76e5396b288 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -86,11 +86,11 @@ UCHAR invalid_rsa_key_blob[] = {
static void test_key_import_rsa(void) { - todo_wine { NCRYPT_PROV_HANDLE prov; SECURITY_STATUS ret = NCryptOpenStorageProvider(&prov, NULL, 0); ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret);
+ todo_wine { NCRYPT_KEY_HANDLE key = NULL; ret = NCryptImportKey(prov, NULL, BCRYPT_RSAPUBLIC_BLOB, NULL, &key, rsa_key_blob, sizeof(rsa_key_blob), 0); ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret);
Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/main.c | 116 +++++++++++++++++++++++++++++++--- dlls/ncrypt/ncrypt_internal.h | 37 +++++++++++ dlls/ncrypt/tests/ncrypt.c | 2 - 3 files changed, 143 insertions(+), 12 deletions(-)
diff --git a/dlls/ncrypt/main.c b/dlls/ncrypt/main.c index 7f844bf9e85..e82faa2c6d2 100644 --- a/dlls/ncrypt/main.c +++ b/dlls/ncrypt/main.c @@ -19,10 +19,12 @@ */
#include <stdarg.h> +#include <stdlib.h>
#include "windef.h" #include "winbase.h" #include "ncrypt.h" +#include "bcrypt.h" #include "ncrypt_internal.h" #include "wine/debug.h"
@@ -33,7 +35,7 @@ SECURITY_STATUS WINAPI NCryptCreatePersistedKey(NCRYPT_PROV_HANDLE provider, NCR DWORD flags) { FIXME("(0x%lx, %p, %s, %s, 0x%08x, 0x%08x): stub\n", provider, key, wine_dbgstr_w(algid), - wine_dbgstr_w(name), keyspec, flags); + wine_dbgstr_w(name), keyspec, flags); return NTE_NOT_SUPPORTED; }
@@ -41,7 +43,7 @@ SECURITY_STATUS WINAPI NCryptDecrypt(NCRYPT_KEY_HANDLE key, BYTE *input, DWORD i BYTE *output, DWORD outsize, DWORD *result, DWORD flags) { FIXME("(0x%lx, %p, %u, %p, %p, %u, %p, 0x%08x): stub\n", key, input, insize, padding, - output, outsize, result, flags); + output, outsize, result, flags); return NTE_NOT_SUPPORTED; }
@@ -55,7 +57,7 @@ SECURITY_STATUS WINAPI NCryptEncrypt(NCRYPT_KEY_HANDLE key, BYTE *input, DWORD i BYTE *output, DWORD outsize, DWORD *result, DWORD flags) { FIXME("(0x%lx, %p, %u, %p, %p, %u, %p, 0x%08x): stub\n", key, input, insize, padding, - output, outsize, result, flags); + output, outsize, result, flags); return NTE_NOT_SUPPORTED; }
@@ -96,18 +98,112 @@ SECURITY_STATUS WINAPI NCryptGetProperty(NCRYPT_HANDLE object, const WCHAR *prop DWORD outsize, DWORD *result, DWORD flags) { FIXME("(0x%lx, %s, %p, %u, %p, 0x%08x): stub\n", object, wine_dbgstr_w(property), output, outsize, - result, flags); + result, flags); return NTE_NOT_SUPPORTED; }
+int allocate_key_object(struct ncrypt_object **keyobject) +{ + *keyobject = malloc(sizeof(struct ncrypt_object)); + if (keyobject == NULL) + { + ERR("Error allocating memory.\n"); + return NTE_NO_MEMORY; + } + memset(*keyobject, 0, sizeof(struct ncrypt_object)); + (*keyobject)->type = KEY; + return ERROR_SUCCESS; +} + SECURITY_STATUS WINAPI NCryptImportKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_HANDLE decrypt_key, const WCHAR *type, NCryptBufferDesc *params, NCRYPT_KEY_HANDLE *key, - PBYTE data, DWORD datasize, DWORD flags) + BYTE *data, DWORD datasize, DWORD flags) { - FIXME("(0x%lx, 0x%lx, %s, %p, %p, %p, %u, 0x%08x): stub\n", provider, decrypt_key, - wine_dbgstr_w(type), params, - key, data, datasize, flags); - return NTE_NOT_SUPPORTED; + BCRYPT_KEY_BLOB *keyheader = (BCRYPT_KEY_BLOB *)data; + + if (decrypt_key != 0) + { + FIXME("Key blob decryption not implemented\n"); + return NTE_NOT_SUPPORTED; + } + + if (params != NULL) + { + FIXME("Parameter information not implemented\n"); + return NTE_NOT_SUPPORTED; + } + + if (flags == NCRYPT_SILENT_FLAG) + { + FIXME("Silent flag not implemented\n"); + } + else if (flags != 0) + { + ERR("Invalid flags 0x%x\n", flags); + return NTE_BAD_FLAGS; + } + + switch (keyheader->Magic) + { + case BCRYPT_RSAPUBLIC_MAGIC: + { + int ret; + DWORD expected_size; + struct ncrypt_object *rsakeyobject; + struct ncrypt_key_object *rsakey; + BYTE *public_exp; + BYTE *modulus; + BCRYPT_RSAKEY_BLOB *rsaheader = (BCRYPT_RSAKEY_BLOB *)data; + + if (datasize < sizeof(BCRYPT_RSAKEY_BLOB)) + { + ERR("Invalid buffer size.\n"); + return NTE_BAD_DATA; + } + + expected_size = sizeof(BCRYPT_RSAKEY_BLOB) + rsaheader->cbPublicExp + rsaheader->cbModulus; + if (datasize != expected_size) + { + ERR("Invalid buffer size.\n"); + return NTE_BAD_DATA; + } + + ret = allocate_key_object(&rsakeyobject); + if (ret != ERROR_SUCCESS) + return ret; + + rsakey = &rsakeyobject->object.key; + rsakey->algtype = RSA; + rsakey->payload.rsa_key.public_exp_size = rsaheader->cbPublicExp; + rsakey->payload.rsa_key.modulus_size = rsaheader->cbModulus; + rsakey->payload.rsa_key.public_exp = malloc(rsaheader->cbPublicExp); + if (rsakey->payload.rsa_key.public_exp == NULL) + { + ERR("Error allocating memory.\n"); + return NTE_NO_MEMORY; + } + rsakey->payload.rsa_key.modulus = malloc(rsaheader->cbModulus); + if (rsakey->payload.rsa_key.modulus == NULL) + { + ERR("Error allocating memory.\n"); + return NTE_NO_MEMORY; + } + + public_exp = &data[sizeof(BCRYPT_RSAKEY_BLOB)]; /* The public exp its after the header. */ + modulus = &public_exp[rsaheader->cbPublicExp]; /* The modulus its after the public exp. */ + memcpy(rsakey->payload.rsa_key.public_exp, public_exp, rsaheader->cbPublicExp); + memcpy(rsakey->payload.rsa_key.modulus, modulus, rsaheader->cbModulus); + + *key = (NCRYPT_KEY_HANDLE)rsakeyobject; + } + break; + + default: + ERR("Invalid key magic %x\n", keyheader->Magic); + return NTE_INVALID_PARAMETER; + } + + return ERROR_SUCCESS; }
SECURITY_STATUS WINAPI NCryptIsAlgSupported(NCRYPT_PROV_HANDLE provider, const WCHAR *algid, @@ -153,6 +249,6 @@ SECURITY_STATUS WINAPI NCryptSetProperty(NCRYPT_HANDLE object, const WCHAR *prop PBYTE input, DWORD insize, DWORD flags) { FIXME("(%lx, %s, %p, %u, 0x%08x): stub\n", object, wine_dbgstr_w(property), input, insize, - flags); + flags); return NTE_NOT_SUPPORTED; } diff --git a/dlls/ncrypt/ncrypt_internal.h b/dlls/ncrypt/ncrypt_internal.h index 1201cdd857a..0948d84925e 100644 --- a/dlls/ncrypt/ncrypt_internal.h +++ b/dlls/ncrypt/ncrypt_internal.h @@ -25,6 +25,41 @@ #include "winbase.h" #include "winternl.h"
+enum asymmetric_key_type +{ + PUBLIC, + PRIVATE, +}; + +enum key_algorithm_type +{ + DH, + DSA, + ECC, + RSA, +}; + +struct ncrypt_rsa_key +{ + DWORD public_exp_size; + BYTE *public_exp; + DWORD modulus_size; + BYTE *modulus; + DWORD prime1_size; + BYTE *prime1; + DWORD prime2_size; + BYTE *prime2; +}; + +struct ncrypt_key_object +{ + enum key_algorithm_type algtype; + union + { + struct ncrypt_rsa_key rsa_key; + } payload; +}; + struct ncrypt_storage_provider_object { // FIXME Stub @@ -32,6 +67,7 @@ struct ncrypt_storage_provider_object
enum ncrypt_object_type { + KEY, STORAGE_PROVIDER, };
@@ -49,6 +85,7 @@ struct ncrypt_object struct ncrypt_object_property *properties; union { + struct ncrypt_key_object key; struct ncrypt_storage_provider_object storage_provider; } object; }; diff --git a/dlls/ncrypt/tests/ncrypt.c b/dlls/ncrypt/tests/ncrypt.c index 76e5396b288..eecd44a7ceb 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -90,7 +90,6 @@ static void test_key_import_rsa(void) SECURITY_STATUS ret = NCryptOpenStorageProvider(&prov, NULL, 0); ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret);
- todo_wine { NCRYPT_KEY_HANDLE key = NULL; ret = NCryptImportKey(prov, NULL, BCRYPT_RSAPUBLIC_BLOB, NULL, &key, rsa_key_blob, sizeof(rsa_key_blob), 0); ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret); @@ -124,7 +123,6 @@ static void test_key_import_rsa(void) ok(ret == NTE_BAD_DATA, "got 0x%x\n", ret);
NCryptFreeObject(prov); - } }
START_TEST(ncrypt)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=108062
Your paranoid android.
=== build (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/tests/ncrypt.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/dlls/ncrypt/tests/ncrypt.c b/dlls/ncrypt/tests/ncrypt.c index eecd44a7ceb..f982f090254 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -125,7 +125,31 @@ static void test_key_import_rsa(void) NCryptFreeObject(prov); }
+static void test_ncrypt_free_object(void) +{ + NCRYPT_PROV_HANDLE prov; + SECURITY_STATUS ret = NCryptOpenStorageProvider(&prov, NULL, 0); + ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret); + + todo_wine { + NCRYPT_KEY_HANDLE key; + ret = NCryptImportKey(prov, (NCRYPT_KEY_HANDLE)NULL, BCRYPT_RSAPUBLIC_BLOB, NULL, &key, rsa_key_blob, sizeof(rsa_key_blob), 0); + ret = NCryptFreeObject(key); + ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret); + + key = 0; + ret = NCryptFreeObject(key); + ok(ret == NTE_INVALID_HANDLE, "got 0x%x\n", ret); + + key = malloc(50); + ret = NCryptFreeObject(key); + ok(ret == NTE_INVALID_HANDLE, "got 0x%x\n", ret); + free(key); + } +} + START_TEST(ncrypt) { test_key_import_rsa(); + test_ncrypt_free_object(); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=108063
Your paranoid android.
=== build (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/main.c | 57 +++++++++++++++++++++++++++++++++-- dlls/ncrypt/ncrypt_internal.h | 1 + dlls/ncrypt/tests/ncrypt.c | 2 -- 3 files changed, 56 insertions(+), 4 deletions(-)
diff --git a/dlls/ncrypt/main.c b/dlls/ncrypt/main.c index e82faa2c6d2..fa4f52b3ee3 100644 --- a/dlls/ncrypt/main.c +++ b/dlls/ncrypt/main.c @@ -88,10 +88,63 @@ SECURITY_STATUS WINAPI NCryptFreeBuffer(PVOID buf) return NTE_NOT_SUPPORTED; }
+int free_key_object(struct ncrypt_object *keyobject) +{ + struct ncrypt_key_object *key = &keyobject->object.key; + switch (key->algtype) + { + case RSA: + { + free(key->payload.rsa_key.modulus); + free(key->payload.rsa_key.public_exp); + if (key->payload.rsa_key.type == PRIVATE) + { + free(key->payload.rsa_key.prime1); + free(key->payload.rsa_key.prime2); + } + } + break; + + default: + { + ERR("invalid key object 0x%x\n", keyobject); + return NTE_INVALID_HANDLE; + } + break; + } + + return ERROR_SUCCESS; +} + SECURITY_STATUS WINAPI NCryptFreeObject(NCRYPT_HANDLE object) { - FIXME("(0x%lx): stub\n", object); - return NTE_NOT_SUPPORTED; + struct ncrypt_object *ncryptobj = (struct ncrypt_object *)object; + if (ncryptobj == NULL) + { + ERR("invalid handle 0x%x\n", ncryptobj); + return NTE_INVALID_HANDLE; + } + + switch (ncryptobj->type) + { + case KEY: + { + int ret = free_key_object(ncryptobj); + if (ret != ERROR_SUCCESS) + return ret; + } + break; + + default: + { + ERR("invalid handle 0x%x\n", ncryptobj); + return NTE_INVALID_HANDLE; + } + break; + } + + free(ncryptobj); + return ERROR_SUCCESS; }
SECURITY_STATUS WINAPI NCryptGetProperty(NCRYPT_HANDLE object, const WCHAR *property, PBYTE output, diff --git a/dlls/ncrypt/ncrypt_internal.h b/dlls/ncrypt/ncrypt_internal.h index 0948d84925e..81bd4bb442f 100644 --- a/dlls/ncrypt/ncrypt_internal.h +++ b/dlls/ncrypt/ncrypt_internal.h @@ -41,6 +41,7 @@ enum key_algorithm_type
struct ncrypt_rsa_key { + enum asymmetric_key_type type; 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 f982f090254..eacb53f2dd3 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -131,7 +131,6 @@ static void test_ncrypt_free_object(void) SECURITY_STATUS ret = NCryptOpenStorageProvider(&prov, NULL, 0); ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret);
- todo_wine { NCRYPT_KEY_HANDLE key; ret = NCryptImportKey(prov, (NCRYPT_KEY_HANDLE)NULL, BCRYPT_RSAPUBLIC_BLOB, NULL, &key, rsa_key_blob, sizeof(rsa_key_blob), 0); ret = NCryptFreeObject(key); @@ -145,7 +144,6 @@ static void test_ncrypt_free_object(void) ret = NCryptFreeObject(key); ok(ret == NTE_INVALID_HANDLE, "got 0x%x\n", ret); free(key); - } }
START_TEST(ncrypt)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=108064
Your paranoid android.
=== build (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
Signed-off-by: Santino Mazza mazzasantino1206@gmail.com --- dlls/ncrypt/main.c | 94 ++++++++++++++++++++++++++++++++++++-- dlls/ncrypt/tests/ncrypt.c | 24 ++++++++++ include/ncrypt.h | 2 + 3 files changed, 115 insertions(+), 5 deletions(-)
diff --git a/dlls/ncrypt/main.c b/dlls/ncrypt/main.c index fa4f52b3ee3..2b2875715d7 100644 --- a/dlls/ncrypt/main.c +++ b/dlls/ncrypt/main.c @@ -143,16 +143,53 @@ SECURITY_STATUS WINAPI NCryptFreeObject(NCRYPT_HANDLE object) break; }
+ free(ncryptobj->properties); free(ncryptobj); return ERROR_SUCCESS; }
-SECURITY_STATUS WINAPI NCryptGetProperty(NCRYPT_HANDLE object, const WCHAR *property, PBYTE output, +int get_object_property(struct ncrypt_object *obj, WCHAR *property_name, struct ncrypt_object_property *propertyout) +{ + if (obj->number_of_properties == 0) + return NTE_INVALID_PARAMETER; + + for (int i = 0; i < obj->number_of_properties; ++i) + { + struct ncrypt_object_property *property = &obj->properties[i]; + if (lstrcmpW(property->key, property_name) == 0) + { + memcpy(propertyout, property, sizeof(struct ncrypt_object_property)); + return ERROR_SUCCESS; + } + } + + return NTE_INVALID_PARAMETER; +} + +SECURITY_STATUS WINAPI NCryptGetProperty(NCRYPT_HANDLE object, const WCHAR *property, BYTE *output, DWORD outsize, DWORD *result, DWORD flags) { - FIXME("(0x%lx, %s, %p, %u, %p, 0x%08x): stub\n", object, wine_dbgstr_w(property), output, outsize, + FIXME("(0x%lx, %s, %p, %u, %p, 0x%08x): semi-stub\n", object, wine_dbgstr_w(property), output, outsize, result, flags); - return NTE_NOT_SUPPORTED; + + struct ncrypt_object *ncryptobj = (struct ncrypt_object *)object; + struct ncrypt_object_property prop; + int ret = get_object_property(ncryptobj, property, &prop); + + if (ret != ERROR_SUCCESS) + return ret; + + if (output == NULL) + { + *result = prop.value_size; + return ERROR_SUCCESS; + } + + if (outsize < prop.value_size) + return NTE_BUFFER_TOO_SMALL; + + memcpy(output, prop.value, prop.value_size); + return ERROR_SUCCESS; }
int allocate_key_object(struct ncrypt_object **keyobject) @@ -298,10 +335,57 @@ SECURITY_STATUS WINAPI NCryptOpenStorageProvider(NCRYPT_PROV_HANDLE *provider, c return allocate_storage_provider_object(provider); }
+int set_object_property(struct ncrypt_object *obj, WCHAR *property_name, BYTE *value, DWORD value_size) +{ + if (obj->number_of_properties == 0) + { + obj->properties = malloc(sizeof(struct ncrypt_object_property)); + if (obj->properties == NULL) + { + ERR("Error allocating memory."); + return NTE_NO_MEMORY; + } + obj->number_of_properties++; + } + else + { + obj->number_of_properties++; + obj->properties = realloc(obj->properties, sizeof(struct ncrypt_object_property) * obj->number_of_properties); + if (obj->properties == NULL) + { + ERR("Error allocating memory."); + return NTE_NO_MEMORY; + } + } + + struct ncrypt_object_property property; + property.key = malloc((lstrlenW(property_name) + 1) * 2); + if (property.key == NULL) + { + ERR("Error allocating memory."); + return NTE_NO_MEMORY; + } + lstrcpyW(property.key, property_name); + property.value_size = value_size; + property.value = malloc(value_size); + if (property.value == NULL) + { + ERR("Error allocating memory."); + return NTE_NO_MEMORY; + } + memcpy(property.value, value, value_size); + + memcpy(&obj->properties[obj->number_of_properties - 1], &property, sizeof(struct ncrypt_object_property)); + + return ERROR_SUCCESS; +} + SECURITY_STATUS WINAPI NCryptSetProperty(NCRYPT_HANDLE object, const WCHAR *property, - PBYTE input, DWORD insize, DWORD flags) + BYTE *input, DWORD insize, DWORD flags) { FIXME("(%lx, %s, %p, %u, 0x%08x): stub\n", object, wine_dbgstr_w(property), input, insize, flags); - return NTE_NOT_SUPPORTED; + + struct ncrypt_object *ncryptobj = (struct ncrypt_object *)object; + return set_object_property(ncryptobj, property, input, insize); } diff --git a/dlls/ncrypt/tests/ncrypt.c b/dlls/ncrypt/tests/ncrypt.c index eacb53f2dd3..ff4bc3be7cc 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -146,8 +146,32 @@ static void test_ncrypt_free_object(void) free(key); }
+static void test_get_property(void) +{ + NCRYPT_PROV_HANDLE prov; + SECURITY_STATUS ret = NCryptOpenStorageProvider(&prov, NULL, 0); + ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret); + + todo_wine { + NCRYPT_KEY_HANDLE key; + ret = NCryptImportKey(prov, (NCRYPT_KEY_HANDLE)NULL, BCRYPT_RSAPUBLIC_BLOB, NULL, &key, rsa_key_blob, sizeof(rsa_key_blob), 0); + + DWORD size; + ret = NCryptGetProperty(key, L"Algorithm Group", NULL, 0, &size, 0); + ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret); + ok(size == 8, "got 0x%x\n", size); + + WCHAR value[8]; + ret = NCryptGetProperty(key, L"Algorithm Group", value, 8, &size, 0); + ok(ret == ERROR_SUCCESS, "got 0x%x\n", ret); + ok(size == 8, "got 0x%x\n", size); + ok(lstrcmpW(value, L"RSA") == 0, "The string doesn't match with 'RSA'\n"); + } +} + START_TEST(ncrypt) { test_key_import_rsa(); test_ncrypt_free_object(); + test_get_property(); } diff --git a/include/ncrypt.h b/include/ncrypt.h index d83105ccf0a..0af961c0b3c 100644 --- a/include/ncrypt.h +++ b/include/ncrypt.h @@ -80,6 +80,8 @@ SECURITY_STATUS WINAPI NCryptOpenKey(NCRYPT_PROV_HANDLE, NCRYPT_KEY_HANDLE *, co SECURITY_STATUS WINAPI NCryptImportKey(NCRYPT_PROV_HANDLE, NCRYPT_KEY_HANDLE, const WCHAR *, NCryptBufferDesc *, NCRYPT_KEY_HANDLE *, PBYTE, DWORD, DWORD); SECURITY_STATUS WINAPI NCryptOpenStorageProvider(NCRYPT_PROV_HANDLE *, const WCHAR *, DWORD); +SECURITY_STATUS WINAPI NCryptSetProperty(NCRYPT_HANDLE, const WCHAR *, BYTE *, DWORD, DWORD); +SECURITY_STATUS WINAPI NCryptGetProperty(NCRYPT_HANDLE, const WCHAR *, BYTE *, DWORD, DWORD *, DWORD);
#ifdef __cplusplus }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=108065
Your paranoid android.
=== build (build log) ===
error: patch failed: include/ncrypt.h:80 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: include/ncrypt.h:80 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: include/ncrypt.h:80 Task: Patch failed to apply
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=108061
Your paranoid android.
=== build (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
On 15/2/22 15:45, Marvin wrote:
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=108061
Your paranoid android.
=== build (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
Woops, the patch that creates the test file has not yet been applied(https://source.winehq.org/patches/data/226876), should I resend it with the tests or I wait until the test get committed?
On Tue, 2022-02-15 at 15:54 -0300, Santino Mazza wrote:
On 15/2/22 15:45, Marvin wrote:
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=108061
Your paranoid android.
=== build (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
Woops, the patch that creates the test file has not yet been applied(https://source.winehq.org/patches/data/226876), should I resend it with the tests or I wait until the test get committed?
Please resend after the test is committed.
Ok, I will. Thanks!
El mar, 15 feb 2022 a la(s) 16:31, Hans Leidekker (hans@codeweavers.com) escribió:
On Tue, 2022-02-15 at 15:54 -0300, Santino Mazza wrote:
On 15/2/22 15:45, Marvin wrote:
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I
might be
wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=108061
Your paranoid android.
=== build (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
Woops, the patch that creates the test file has not yet been applied(https://source.winehq.org/patches/data/226876), should I resend it with the tests or I wait until the test get committed?
Please resend after the test is committed.