[1/2] bcrypt: Added implementation of BCryptGetFipsAlgorithmMode (try 2)

Kai Blaschke kai.blaschke at kb-dev.net
Fri Jan 24 13:21:38 CST 2014


Second try, now returning exactly the same values as the Microsoft 
implementation.

Fixes wine bug 32194.

---
  dlls/bcrypt/Makefile.in   |  1 +
  dlls/bcrypt/bcrypt.spec   |  2 +-
  dlls/bcrypt/bcrypt_main.c | 52 
+++++++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 54 insertions(+), 1 deletion(-)
-------------- next part --------------
>From 80fb2cde553f4cd93cb5f28404b20c4cdf4dd14e Mon Sep 17 00:00:00 2001
From: Kai Blaschke <kai.blaschke at kb-dev.net>
Date: Fri, 24 Jan 2014 20:11:53 +0100
Subject: bcrypt: Added implementation of BCryptGetFipsAlgorithmMode

---
 dlls/bcrypt/Makefile.in   |  1 +
 dlls/bcrypt/bcrypt.spec   |  2 +-
 dlls/bcrypt/bcrypt_main.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/dlls/bcrypt/Makefile.in b/dlls/bcrypt/Makefile.in
index f9aacec..87e1429 100644
--- a/dlls/bcrypt/Makefile.in
+++ b/dlls/bcrypt/Makefile.in
@@ -1,4 +1,5 @@
 MODULE    = bcrypt.dll
+IMPORTS   = advapi32
 
 C_SRCS = \
 	bcrypt_main.c
diff --git a/dlls/bcrypt/bcrypt.spec b/dlls/bcrypt/bcrypt.spec
index e1ffb8a..f41e840 100644
--- a/dlls/bcrypt/bcrypt.spec
+++ b/dlls/bcrypt/bcrypt.spec
@@ -27,7 +27,7 @@
 @ stub BCryptGenRandom
 @ stub BCryptGenerateKeyPair
 @ stub BCryptGenerateSymmetricKey
-@ stub BCryptGetFipsAlgorithmMode
+@ stdcall BCryptGetFipsAlgorithmMode(ptr)
 @ stub BCryptGetProperty
 @ stub BCryptHashData
 @ stub BCryptImportKey
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 441b3ef..a505271 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -19,9 +19,12 @@
 
 #include "config.h"
 #include "wine/port.h"
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
 #include "wine/debug.h"
 
 #include "winbase.h"
+#include "winreg.h"
 #include "bcrypt.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(bcrypt);
@@ -50,3 +53,52 @@ NTSTATUS WINAPI BCryptEnumAlgorithms(ULONG dwAlgOperations, ULONG *pAlgCount,
 
     return ERROR_CALL_NOT_IMPLEMENTED;
 }
+
+NTSTATUS WINAPI BCryptGetFipsAlgorithmMode(BOOLEAN *pfEnabled)
+{
+    static const WCHAR policyKeyVistaW[] = {
+        'S','y','s','t','e','m','\\',
+        'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
+        'C','o','n','t','r','o','l','\\',
+        'L','s','a','\\',
+        'F','I','P','S','A','l','g','o','r','i','t','h','m','P','o','l','i','c','y',0};
+    static const WCHAR policyValueVistaW[] = {'E','n','a','b','l','e','d',0};
+    static const WCHAR policyKeyXPW[] = {
+        'S','y','s','t','e','m','\\',
+        'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
+        'C','o','n','t','r','o','l','\\',
+        'L','s','a',0};
+    static const WCHAR policyValueXPW[] = {
+        'F','I','P','S','A','l','g','o','r','i','t','h','m','P','o','l','i','c','y',0};
+    HKEY hkey;
+
+    if (!pfEnabled)
+    {
+        return STATUS_INVALID_PARAMETER;
+    }
+
+    *pfEnabled = FALSE;
+
+    if (!RegOpenKeyW(HKEY_LOCAL_MACHINE, policyKeyVistaW, &hkey))
+    {
+        DWORD enabled;
+        DWORD count = sizeof(enabled);
+        if (!RegGetValueW(HKEY_LOCAL_MACHINE, policyKeyVistaW, policyValueVistaW,
+            RRF_RT_REG_DWORD, NULL, &enabled, &count))
+        {
+            *pfEnabled = (BOOLEAN)enabled != 0;
+        }
+    }
+    else if (!RegOpenKeyW(HKEY_LOCAL_MACHINE, policyKeyXPW, &hkey))
+    {
+        DWORD enabled;
+        DWORD count = sizeof(enabled);
+        if (!RegGetValueW(HKEY_LOCAL_MACHINE, policyKeyXPW, policyValueXPW,
+            RRF_RT_REG_DWORD, NULL, &enabled, &count))
+        {
+            *pfEnabled = (BOOLEAN)enabled != 0;
+        }
+    }
+
+    return STATUS_SUCCESS;
+}
-- 
1.8.3.2



More information about the wine-patches mailing list