[PATCH 06/16] ncrypt: Implement NCrypt{Encrypt, Decrypt}

abdaandroid at gmail.com abdaandroid at gmail.com
Sun Oct 11 10:45:25 CDT 2020


From: Ariel Darshan <abdaandroid at gmail.com>

Signed-off-by: Ariel Darshan <abdaandroid at gmail.com>
---
 dlls/ncrypt/main.c | 39 +++++++++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/dlls/ncrypt/main.c b/dlls/ncrypt/main.c
index 003add36502..4189132c395 100644
--- a/dlls/ncrypt/main.c
+++ b/dlls/ncrypt/main.c
@@ -73,9 +73,24 @@ SECURITY_STATUS WINAPI NCryptCreatePersistedKey(NCRYPT_PROV_HANDLE provider, NCR
 SECURITY_STATUS WINAPI NCryptDecrypt(NCRYPT_KEY_HANDLE key, BYTE *input, DWORD insize, void *padding,
                                      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,
+    struct ncrypt_key_instance *keyInstance;
+    struct ncrypt_provider_instance *providerInstance;
+
+    TRACE("(0x%lx, %p, %u, %p, %p, %u, %p, 0x%08x)\n", key, input, insize, padding,
                                                              output, outsize, result, flags);
-    return NTE_NOT_SUPPORTED;
+    if (!key)
+    {
+        return NTE_INVALID_HANDLE;
+    }
+    keyInstance = handle2key(key);
+
+    if (!keyInstance->provider)
+    {
+        return NTE_INVALID_HANDLE;
+    }
+    providerInstance = handle2provider(keyInstance->provider);
+
+    return providerInstance->functions.Decrypt(providerInstance->kspHandle, keyInstance->kspHandle, input, insize, padding, output, outsize, result, flags);
 }
 
 SECURITY_STATUS WINAPI NCryptDeleteKey(NCRYPT_KEY_HANDLE key, DWORD flags)
@@ -87,9 +102,25 @@ SECURITY_STATUS WINAPI NCryptDeleteKey(NCRYPT_KEY_HANDLE key, DWORD flags)
 SECURITY_STATUS WINAPI NCryptEncrypt(NCRYPT_KEY_HANDLE key, BYTE *input, DWORD insize, void *padding,
                                      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,
+    struct ncrypt_key_instance *keyInstance;
+    struct ncrypt_provider_instance *providerInstance;
+
+    TRACE("(0x%lx, %p, %u, %p, %p, %u, %p, 0x%08x)\n", key, input, insize, padding,
                                                              output, outsize, result, flags);
-    return NTE_NOT_SUPPORTED;
+
+    if (!key)
+    {
+        return NTE_INVALID_HANDLE;
+    }
+    keyInstance = handle2key(key);
+
+    if (!keyInstance->provider)
+    {
+        return NTE_INVALID_HANDLE;
+    }
+    providerInstance = handle2provider(keyInstance->provider);
+
+    return providerInstance->functions.Encrypt(providerInstance->kspHandle, keyInstance->kspHandle, input, insize, padding, output, outsize, result, flags);
 }
 
 SECURITY_STATUS WINAPI NCryptEnumAlgorithms(NCRYPT_PROV_HANDLE provider, DWORD alg_ops,
-- 
2.28.0




More information about the wine-devel mailing list