wintrust(4/6): Test and implement SoftpubInitialize
Juan Lang
juan.lang at gmail.com
Fri Aug 24 17:25:21 CDT 2007
This depends on patch 1 in the series, the calling convention change.
--Juan
-------------- next part --------------
From 9f394beb94c4cf9ce93fd34f2d8ba1b74dbaabf6 Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang at gmail.com>
Date: Fri, 24 Aug 2007 15:12:31 -0700
Subject: [PATCH] Test and implement SoftpubInitialize
---
dlls/wintrust/Makefile.in | 1
dlls/wintrust/softpub.c | 37 +++++++++++
dlls/wintrust/tests/Makefile.in | 5 +
dlls/wintrust/tests/softpub.c | 132 +++++++++++++++++++++++++++++++++++++++
dlls/wintrust/wintrust.spec | 2 -
5 files changed, 174 insertions(+), 3 deletions(-)
diff --git a/dlls/wintrust/Makefile.in b/dlls/wintrust/Makefile.in
index 4e84922..85bbd77 100644
--- a/dlls/wintrust/Makefile.in
+++ b/dlls/wintrust/Makefile.in
@@ -11,6 +11,7 @@ C_SRCS = \
asn.c \
crypt.c \
register.c \
+ softpub.c \
wintrust_main.c
RC_SRCS = \
diff --git a/dlls/wintrust/softpub.c b/dlls/wintrust/softpub.c
new file mode 100644
index 0000000..c5eb503
--- /dev/null
+++ b/dlls/wintrust/softpub.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2007 Juan Lang
+ *
+ * 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 <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+#include "wintrust.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(wintrust);
+
+HRESULT WINAPI SoftpubInitialize(CRYPT_PROVIDER_DATA *data)
+{
+ HRESULT ret = S_FALSE;
+
+ TRACE("(%p)\n", data);
+
+ if (data->padwTrustStepErrors &&
+ !data->padwTrustStepErrors[TRUSTERROR_STEP_FINAL_WVTINIT])
+ ret = S_OK;
+ TRACE("returning %08x\n", ret);
+ return ret;
+}
diff --git a/dlls/wintrust/tests/Makefile.in b/dlls/wintrust/tests/Makefile.in
index 59a7716..45b15a0 100644
--- a/dlls/wintrust/tests/Makefile.in
+++ b/dlls/wintrust/tests/Makefile.in
@@ -3,12 +3,13 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = wintrust.dll
-IMPORTS = crypt32 user32 advapi32 kernel32
+IMPORTS = wintrust crypt32 user32 advapi32 kernel32
CTESTS = \
asn.c \
crypt.c \
- register.c
+ register.c \
+ softpub.c
@MAKE_TEST_RULES@
diff --git a/dlls/wintrust/tests/softpub.c b/dlls/wintrust/tests/softpub.c
new file mode 100644
index 0000000..a474324
--- /dev/null
+++ b/dlls/wintrust/tests/softpub.c
@@ -0,0 +1,132 @@
+/*
+ * wintrust softpub functions tests
+ *
+ * Copyright 2007 Juan Lang
+ *
+ * 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 <assert.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winerror.h>
+#include <wintrust.h>
+#include <softpub.h>
+#include <mssip.h>
+#include <winuser.h>
+
+#include "wine/test.h"
+
+/* Just in case we're being built with borked headers, redefine function
+ * pointers to have the correct calling convention.
+ */
+typedef void *(WINAPI *SAFE_MEM_ALLOC)(DWORD);
+typedef void (WINAPI *SAFE_MEM_FREE)(void *);
+typedef BOOL (WINAPI *SAFE_ADD_STORE)(CRYPT_PROVIDER_DATA *,
+ HCERTSTORE);
+typedef BOOL (WINAPI *SAFE_ADD_SGNR)(CRYPT_PROVIDER_DATA *,
+ BOOL, DWORD, struct _CRYPT_PROVIDER_SGNR *);
+typedef BOOL (WINAPI *SAFE_ADD_CERT)(CRYPT_PROVIDER_DATA *,
+ DWORD, BOOL, DWORD, PCCERT_CONTEXT);
+typedef BOOL (WINAPI *SAFE_ADD_PRIVDATA)(CRYPT_PROVIDER_DATA *,
+ CRYPT_PROVIDER_PRIVDATA *);
+typedef HRESULT (WINAPI *SAFE_PROVIDER_INIT_CALL)(CRYPT_PROVIDER_DATA *);
+typedef HRESULT (WINAPI *SAFE_PROVIDER_OBJTRUST_CALL)(CRYPT_PROVIDER_DATA *);
+typedef HRESULT (WINAPI *SAFE_PROVIDER_SIGTRUST_CALL)(CRYPT_PROVIDER_DATA *);
+typedef HRESULT (WINAPI *SAFE_PROVIDER_CERTTRUST_CALL)(CRYPT_PROVIDER_DATA *);
+typedef HRESULT (WINAPI *SAFE_PROVIDER_FINALPOLICY_CALL)(CRYPT_PROVIDER_DATA *);
+typedef HRESULT (WINAPI *SAFE_PROVIDER_TESTFINALPOLICY_CALL)(
+ CRYPT_PROVIDER_DATA *);
+typedef HRESULT (WINAPI *SAFE_PROVIDER_CLEANUP_CALL)(CRYPT_PROVIDER_DATA *);
+typedef BOOL (WINAPI *SAFE_PROVIDER_CERTCHKPOLICY_CALL)(
+ CRYPT_PROVIDER_DATA *, DWORD, BOOL, DWORD);
+
+typedef struct _SAFE_PROVIDER_FUNCTIONS
+{
+ DWORD cbStruct;
+ SAFE_MEM_ALLOC pfnAlloc;
+ SAFE_MEM_FREE pfnFree;
+ SAFE_ADD_STORE pfnAddStore2Chain;
+ SAFE_ADD_SGNR pfnAddSgnr2Chain;
+ SAFE_ADD_CERT pfnAddCert2Chain;
+ SAFE_ADD_PRIVDATA pfnAddPrivData2Chain;
+ SAFE_PROVIDER_INIT_CALL pfnInitialize;
+ SAFE_PROVIDER_OBJTRUST_CALL pfnObjectTrust;
+ SAFE_PROVIDER_SIGTRUST_CALL pfnSignatureTrust;
+ SAFE_PROVIDER_CERTTRUST_CALL pfnCertificateTrust;
+ SAFE_PROVIDER_FINALPOLICY_CALL pfnFinalPolicy;
+ SAFE_PROVIDER_CERTCHKPOLICY_CALL pfnCertCheckPolicy;
+ SAFE_PROVIDER_TESTFINALPOLICY_CALL pfnTestFinalPolicy;
+ struct _CRYPT_PROVUI_FUNCS *psUIpfns;
+ SAFE_PROVIDER_CLEANUP_CALL pfnCleanupPolicy;
+} SAFE_PROVIDER_FUNCTIONS;
+
+static void testInitialize(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID)
+{
+ HRESULT ret;
+ CRYPT_PROVIDER_DATA data = { 0 };
+ WINTRUST_DATA wintrust_data = { 0 };
+
+ if (!funcs->pfnInitialize)
+ {
+ skip("missing pfnInitialize\n");
+ return;
+ }
+
+ /* Crashes
+ ret = funcs->pfnInitialize(NULL);
+ */
+ memset(&data, 0, sizeof(data));
+ ret = funcs->pfnInitialize(&data);
+ ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
+ data.padwTrustStepErrors =
+ funcs->pfnAlloc(TRUSTERROR_MAX_STEPS * sizeof(DWORD));
+ /* Without wintrust data set, crashes when padwTrustStepErrors is set */
+ data.pWintrustData = &wintrust_data;
+ if (data.padwTrustStepErrors)
+ {
+ /* Apparently, cdwTrustStepErrors does not need to be set. */
+ ret = funcs->pfnInitialize(&data);
+ ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
+ data.cdwTrustStepErrors = 1;
+ ret = funcs->pfnInitialize(&data);
+ ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
+ memset(data.padwTrustStepErrors, 0xba,
+ TRUSTERROR_MAX_STEPS * sizeof(DWORD));
+ ret = funcs->pfnInitialize(&data);
+ ok(ret == S_FALSE, "Expected S_FALSE, got %08x\n", ret);
+ data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_WVTINIT] = 0;
+ ret = funcs->pfnInitialize(&data);
+ ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
+ funcs->pfnFree(data.padwTrustStepErrors);
+ }
+}
+
+START_TEST(softpub)
+{
+ static GUID generic_verify_v2 = WINTRUST_ACTION_GENERIC_VERIFY_V2;
+ SAFE_PROVIDER_FUNCTIONS funcs = { sizeof(SAFE_PROVIDER_FUNCTIONS), 0 };
+ BOOL ret;
+
+ ret = WintrustLoadFunctionPointers(&generic_verify_v2,
+ (CRYPT_PROVIDER_FUNCTIONS *)&funcs);
+ if (!ret)
+ skip("WintrustLoadFunctionPointers failed\n");
+ else
+ {
+ testInitialize(&funcs, &generic_verify_v2);
+ }
+}
diff --git a/dlls/wintrust/wintrust.spec b/dlls/wintrust/wintrust.spec
index b822cbe..71f104c 100644
--- a/dlls/wintrust/wintrust.spec
+++ b/dlls/wintrust/wintrust.spec
@@ -64,7 +64,7 @@
@ stdcall SoftpubDllUnregisterServer()
@ stub SoftpubDumpStructure
@ stub SoftpubFreeDefUsageCallData
-@ stub SoftpubInitialize
+@ stdcall SoftpubInitialize(ptr)
@ stub SoftpubLoadDefUsageCallData
@ stub SoftpubLoadMessage
@ stub SoftpubLoadSignature
--
1.4.1
More information about the wine-patches
mailing list