[2/2] bcrypt/tests: Added conformance test for BCryptGetFipsAlgorithmMode (try 2)

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


Test now queries registry values to compare them with the function's result.

---
  configure                     |  1 +
  configure.ac                  |  1 +
  dlls/bcrypt/tests/Makefile.in |  5 +++
  dlls/bcrypt/tests/bcrypt.c    | 98 
+++++++++++++++++++++++++++++++++++++++++++
  4 files changed, 105 insertions(+)
-------------- next part --------------
>From 8e89c5ceee70b1f8b087b119966da6e08663ab3b Mon Sep 17 00:00:00 2001
From: Kai Blaschke <kai.blaschke at kb-dev.net>
Date: Fri, 24 Jan 2014 20:12:54 +0100
Subject: bcrypt/tests: Added conformance test for BCryptGetFipsAlgorithmMode

---
 configure                     |  1 +
 configure.ac                  |  1 +
 dlls/bcrypt/tests/Makefile.in |  5 +++
 dlls/bcrypt/tests/bcrypt.c    | 98 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 105 insertions(+)
 create mode 100644 dlls/bcrypt/tests/Makefile.in
 create mode 100644 dlls/bcrypt/tests/bcrypt.c

diff --git a/configure b/configure
index c2d0dd0..6363f85 100755
--- a/configure
+++ b/configure
@@ -16548,6 +16548,7 @@ wine_fn_config_test dlls/avifil32/tests avifil32_test
 wine_fn_config_dll avifile.dll16 enable_win16
 wine_fn_config_dll avrt enable_avrt implib
 wine_fn_config_dll bcrypt enable_bcrypt
+wine_fn_config_test dlls/bcrypt/tests bcrypt_test
 wine_fn_config_dll browseui enable_browseui clean,po
 wine_fn_config_test dlls/browseui/tests browseui_test
 wine_fn_config_dll cabinet enable_cabinet implib
diff --git a/configure.ac b/configure.ac
index 4f51909..b370b19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2672,6 +2672,7 @@ WINE_CONFIG_TEST(dlls/avifil32/tests)
 WINE_CONFIG_DLL(avifile.dll16,enable_win16)
 WINE_CONFIG_DLL(avrt,,[implib])
 WINE_CONFIG_DLL(bcrypt)
+WINE_CONFIG_TEST(dlls/bcrypt/tests)
 WINE_CONFIG_DLL(browseui,,[clean,po])
 WINE_CONFIG_TEST(dlls/browseui/tests)
 WINE_CONFIG_DLL(cabinet,,[implib])
diff --git a/dlls/bcrypt/tests/Makefile.in b/dlls/bcrypt/tests/Makefile.in
new file mode 100644
index 0000000..4ba2d48
--- /dev/null
+++ b/dlls/bcrypt/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL = bcrypt.dll
+IMPORTS = advapi32
+
+C_SRCS = \
+	bcrypt.c
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
new file mode 100644
index 0000000..2c9bb2d
--- /dev/null
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2014 Kai Blaschke
+ *
+ * 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
+ */
+
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
+#include "wine/test.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "winternl.h"
+
+static NTSTATUS (WINAPI * pBCryptGetFipsAlgorithmMode) (BOOLEAN *);
+
+static void InitFunctionPtrs(void)
+{
+    HMODULE hBCrypt = LoadLibraryA("bcrypt.dll");
+    pBCryptGetFipsAlgorithmMode = (void*)GetProcAddress(hBCrypt, "BCryptGetFipsAlgorithmMode");
+}
+
+static void test_getFipsAlgorithmMode(void)
+{
+    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;
+    BOOLEAN expected;
+    BOOLEAN result;
+    NTSTATUS status;
+
+    if (!pBCryptGetFipsAlgorithmMode)
+    {
+        win_skip("Can't perform BCryptGetFipsAlgorithmMode tests\n");
+        return;
+    }
+    
+    expected = 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))
+        {
+            expected = (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))
+        {
+            expected = (BOOLEAN)enabled != 0;
+        }
+    }
+
+    status = pBCryptGetFipsAlgorithmMode(&result);
+    ok(!status, "expected status STATUS_SUCCESS(0), got 0x%08X\n", status);
+    ok(result == expected, "expected result %d, got %d\n", expected, result);
+
+    status = pBCryptGetFipsAlgorithmMode(NULL);
+    ok(status == STATUS_INVALID_PARAMETER,
+       "expected status STATUS_INVALID_PARAMETER(0xC000000D), got 0x%08X\n", status);
+}
+
+START_TEST(bcrypt)
+{
+    InitFunctionPtrs();
+    test_getFipsAlgorithmMode();
+}
-- 
1.8.3.2



More information about the wine-patches mailing list