From: Santino Mazza mazzasantino1206@gmail.com
Signed-off-by: Santino Mazza mazzasantino1206@gmail.com Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/ncrypt/main.c | 51 +++++++++++++++++++++++++++++++++++--- dlls/ncrypt/tests/ncrypt.c | 2 -- 2 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/dlls/ncrypt/main.c b/dlls/ncrypt/main.c index 0d5a40b7b26..fcf5bdbe3e7 100644 --- a/dlls/ncrypt/main.c +++ b/dlls/ncrypt/main.c @@ -86,10 +86,55 @@ SECURITY_STATUS WINAPI NCryptFreeBuffer(PVOID buf) return NTE_NOT_SUPPORTED; }
-SECURITY_STATUS WINAPI NCryptFreeObject(NCRYPT_HANDLE object) +static SECURITY_STATUS free_key_object(struct key *key) { - FIXME("(0x%lx): stub\n", object); - return NTE_NOT_SUPPORTED; + switch (key->alg) + { + case RSA: + { + free(key->rsa.modulus); + free(key->rsa.public_exp); + free(key->rsa.prime1); + free(key->rsa.prime2); + break; + } + default: + WARN("invalid key %p\n", key); + return NTE_INVALID_HANDLE; + } + return ERROR_SUCCESS; +} + +SECURITY_STATUS WINAPI NCryptFreeObject(NCRYPT_HANDLE handle) +{ + struct object *object = (struct object *)handle; + SECURITY_STATUS ret = ERROR_SUCCESS; + + TRACE("(%#Ix)\n", handle); + + if (!object) + { + WARN("invalid handle %#Ix\n", handle); + return NTE_INVALID_HANDLE; + } + + switch (object->type) + { + case KEY: + { + if ((ret = free_key_object(&object->key))) return ret; + break; + } + case STORAGE_PROVIDER: + break; + + default: + WARN("invalid handle %#Ix\n", handle); + return NTE_INVALID_HANDLE; + } + + free(object); + return ret; }
SECURITY_STATUS WINAPI NCryptGetProperty(NCRYPT_HANDLE object, const WCHAR *property, PBYTE output, diff --git a/dlls/ncrypt/tests/ncrypt.c b/dlls/ncrypt/tests/ncrypt.c index 01d33e93755..430cb0ae52c 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -148,7 +148,6 @@ static void test_ncrypt_free_object(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 = NCryptFreeObject(key); ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
@@ -160,7 +159,6 @@ static void test_ncrypt_free_object(void) ret = NCryptFreeObject((NCRYPT_KEY_HANDLE)buf); ok(ret == NTE_INVALID_HANDLE, "got %#lx\n", ret); free(buf); - } }
START_TEST(ncrypt)