Marek Chmiel : dssenh: Added CryptAcquireContext test for the DSSENH cryptographic service provider .
Alexandre Julliard
julliard at winehq.org
Mon Jul 2 13:22:01 CDT 2012
Module: wine
Branch: master
Commit: 4961caa83654c1b6e0171e055f34e53d3bfc05f0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4961caa83654c1b6e0171e055f34e53d3bfc05f0
Author: Marek Chmiel <kcmark at gmail.com>
Date: Fri Jun 1 22:38:03 2012 -0500
dssenh: Added CryptAcquireContext test for the DSSENH cryptographic service provider.
---
configure | 1 +
configure.ac | 1 +
dlls/dssenh/tests/Makefile.in | 7 ++
dlls/dssenh/tests/dssenh.c | 185 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 194 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index 2a26441..28999e9 100755
--- a/configure
+++ b/configure
@@ -15190,6 +15190,7 @@ wine_fn_config_dll drmclien enable_drmclien
wine_fn_config_dll dsound enable_dsound implib
wine_fn_config_test dlls/dsound/tests dsound_test
wine_fn_config_dll dssenh enable_dssenh
+wine_fn_config_test dlls/dssenh/tests dssenh_test
wine_fn_config_dll dswave enable_dswave
wine_fn_config_dll dwmapi enable_dwmapi implib
wine_fn_config_dll dxdiagn enable_dxdiagn po
diff --git a/configure.ac b/configure.ac
index 70e7663..a85459d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2606,6 +2606,7 @@ WINE_CONFIG_DLL(drmclien)
WINE_CONFIG_DLL(dsound,,[implib])
WINE_CONFIG_TEST(dlls/dsound/tests)
WINE_CONFIG_DLL(dssenh)
+WINE_CONFIG_TEST(dlls/dssenh/tests)
WINE_CONFIG_DLL(dswave)
WINE_CONFIG_DLL(dwmapi,,[implib])
WINE_CONFIG_DLL(dxdiagn,,[po])
diff --git a/dlls/dssenh/tests/Makefile.in b/dlls/dssenh/tests/Makefile.in
new file mode 100644
index 0000000..8150cbf
--- /dev/null
+++ b/dlls/dssenh/tests/Makefile.in
@@ -0,0 +1,7 @@
+TESTDLL = dssenh.dll
+IMPORTS = advapi32
+
+C_SRCS = \
+ dssenh.c
+
+ at MAKE_TEST_RULES@
diff --git a/dlls/dssenh/tests/dssenh.c b/dlls/dssenh/tests/dssenh.c
new file mode 100644
index 0000000..b77dd23
--- /dev/null
+++ b/dlls/dssenh/tests/dssenh.c
@@ -0,0 +1,185 @@
+/*
+ * Unit tests for dss functions
+ *
+ * Copyright (c) 2012 Marek Kamil Chmiel
+ *
+ * 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 <string.h>
+#include <stdio.h>
+#include "wine/test.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "wincrypt.h"
+
+static void test_acquire_context(void)
+{ /* failure tests common between all four CSP providers */
+
+ HCRYPTPROV hProv = 0;
+ BOOL result;
+
+ /* cannot acquire provider with 0 as Prov Type and NULL as CSP name */
+ SetLastError(0xdeadbeef);
+ result = CryptAcquireContextA(&hProv, NULL, NULL, 0, 0);
+ ok(!result && GetLastError() == NTE_BAD_PROV_TYPE,
+ "Expected NTE_BAD_PROV_TYPE, got %08x\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ result = CryptAcquireContextA(&hProv, NULL, NULL, 0, CRYPT_VERIFYCONTEXT);
+ ok(!result && GetLastError() == NTE_BAD_PROV_TYPE,
+ "Expected NTE_BAD_PROV_TYPE, got %08x\n", GetLastError());
+
+ /* flag allows us to delete a keyset, but not of an unknown provider */
+ SetLastError(0xdeadbeef);
+ result = CryptAcquireContextA(&hProv, NULL, NULL, 0, CRYPT_DELETEKEYSET);
+ ok(!result && GetLastError() == NTE_BAD_PROV_TYPE,
+ "Expected NTE_BAD_PROV_TYPE, got %08x\n", GetLastError());
+
+ /* cannot acquire along with PROV_RSA_SIG, not compatible */
+ SetLastError(0xdeadbeef);
+ result = CryptAcquireContextA(&hProv, NULL, MS_DEF_DSS_PROV_A, PROV_RSA_SIG, 0);
+ todo_wine
+ ok(!result && GetLastError() == NTE_PROV_TYPE_NO_MATCH,
+ "Expected NTE_PROV_TYPE_NO_MATCH, got %08x\n", GetLastError());
+
+ /* cannot acquire along with MS_DEF_RSA_SIG_PROV, not compatible */
+ SetLastError(0xdeadbeef);
+ result = CryptAcquireContextA(&hProv, NULL, MS_DEF_RSA_SIG_PROV, PROV_DSS, 0);
+ ok(!result && GetLastError() == NTE_KEYSET_NOT_DEF,
+ "Expected NTE_KEYSET_NOT_DEF, got %08x\n", GetLastError());
+
+ /* cannot acquire provider with 0 as Prov Type */
+ SetLastError(0xdeadbeef);
+ result = CryptAcquireContextA(&hProv, NULL, MS_DEF_DSS_PROV_A, 0, 0);
+ ok(!result && GetLastError() == NTE_BAD_PROV_TYPE,
+ "Expected NTE_BAD_PROV_TYPE, got %08x\n", GetLastError());
+
+ /* test base DSS provider (PROV_DSS) */
+
+ result = CryptAcquireContextA(
+ &hProv, NULL, MS_DEF_DSS_PROV_A, PROV_DSS, CRYPT_VERIFYCONTEXT);
+ if(!result)
+ {
+ skip("DSS csp is currently not available, skipping tests.");
+ return;
+ }
+ ok(result, "Expected no errors.\n");
+
+ result = CryptReleaseContext(hProv, 0);
+ ok(result, "Expected release of the provider.\n");
+
+ result = CryptAcquireContextA(
+ &hProv, NULL, MS_DEF_DSS_DH_PROV_A, PROV_DSS_DH, CRYPT_NEWKEYSET);
+ ok(result, "Expected no errors.\n");
+
+ result = CryptReleaseContext(hProv, 0);
+ ok(result, "Expected release of the provider.\n");
+
+ result = CryptAcquireContextA(&hProv, NULL, NULL, PROV_DSS, 0);
+ ok(result, "Expected no errors.\n");
+
+ result = CryptReleaseContext(hProv, 0);
+ ok(result, "Expected release of the provider.\n");
+
+ result = CryptAcquireContextA(&hProv, NULL, MS_DEF_DSS_PROV_A, PROV_DSS, 0);
+ ok(result, "Expected no errors.\n");
+
+ /* test DSS Diffie Hellman provider (PROV_DSS_DH) */
+
+ result = CryptAcquireContextA(
+ &hProv, NULL, MS_DEF_DSS_DH_PROV, PROV_DSS_DH, CRYPT_VERIFYCONTEXT);
+ ok(result, "Expected no errors.\n");
+
+ result = CryptReleaseContext(hProv, 0);
+ ok(result, "Expected release of the provider.\n");
+
+ result = CryptAcquireContextA(&hProv, NULL, NULL, PROV_DSS_DH, 0);
+ ok(result, "Expected no errors.\n");
+
+ result = CryptReleaseContext(hProv, 0);
+ ok(result, "Expected release of the provider.\n");
+
+ result = CryptAcquireContextA(&hProv, NULL, MS_DEF_DSS_DH_PROV, PROV_DSS_DH, 0);
+ ok(result, "Expected no errors.\n");
+
+ /* test DSS Enhanced provider (MS_ENH_DSS_DH_PROV) */
+
+ SetLastError(0xdeadbeef);
+ result = CryptAcquireContextA(
+ &hProv, NULL, MS_ENH_DSS_DH_PROV, PROV_DSS_DH, CRYPT_VERIFYCONTEXT);
+ if(!result && GetLastError() == NTE_KEYSET_NOT_DEF)
+ {
+ win_skip("DSSENH and Schannel provider is broken on WinNT4\n");
+ return;
+ }
+ ok(result, "Expected no errors.\n");
+
+ result = CryptReleaseContext(hProv, 0);
+ ok(result, "Expected release of the provider.\n");
+
+ result = CryptAcquireContextA(&hProv, NULL, MS_ENH_DSS_DH_PROV, PROV_DSS_DH, 0);
+ ok(result, "Expected no errors.\n");
+
+ result = CryptReleaseContext(hProv, 0);
+ ok(result, "Expected release of the provider.\n");
+
+ /* test DSS Schannel provider (PROV_DH_SCHANNEL) */
+
+ result = CryptAcquireContextA(
+ &hProv, NULL, MS_DEF_DH_SCHANNEL_PROV, PROV_DH_SCHANNEL, CRYPT_VERIFYCONTEXT);
+ ok(result, "Expected no errors.\n");
+
+ result = CryptReleaseContext(hProv, 0);
+ ok(result, "Expected release of the provider.\n");
+
+ result = CryptAcquireContextA(&hProv, NULL, NULL, PROV_DH_SCHANNEL, 0);
+ ok(result, "Expected no errors.\n");
+
+ result = CryptReleaseContext(hProv, 0);
+ ok(result, "Expected release of the provider.\n");
+
+ result = CryptAcquireContextA(
+ &hProv, NULL, MS_DEF_DH_SCHANNEL_PROV, PROV_DH_SCHANNEL, 0);
+ ok(result, "Expected no errors.\n");
+
+ result = CryptReleaseContext(hProv, 0);
+ ok(result, "Expected release of the provider.\n");
+
+ /* failure tests, cannot acquire context because the key container already exists */
+ SetLastError(0xdeadbeef);
+ result = CryptAcquireContextA(
+ &hProv, NULL, MS_DEF_DSS_DH_PROV, PROV_DSS_DH, CRYPT_NEWKEYSET);
+ ok(!result && GetLastError() == NTE_EXISTS,
+ "Expected NTE_EXISTS, got %08x\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ result = CryptAcquireContextA(
+ &hProv, NULL, MS_ENH_DSS_DH_PROV, PROV_DSS_DH, CRYPT_NEWKEYSET);
+ ok(!result && GetLastError() == NTE_EXISTS,
+ "Expected NTE_EXISTS, got %08x\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ result = CryptAcquireContextA(
+ &hProv, NULL, MS_DEF_DH_SCHANNEL_PROV, PROV_DH_SCHANNEL, CRYPT_NEWKEYSET);
+ ok(!result && GetLastError() == NTE_EXISTS,
+ "Expected NTE_EXISTS, got %08x\n", GetLastError());
+}
+
+START_TEST(dssenh)
+{
+ test_acquire_context();
+}
More information about the wine-cvs
mailing list