Commit e6c4a735 authored by Steve Lhomme's avatar Steve Lhomme

update patchset

fix the rand linking
more gnutls cleaning
parent f35eec53
From e8501f778358d4dcab65193fe18d673c47f2291d Mon Sep 17 00:00:00 2001
From 7d3504f10814f45ac9f2747cb8ae33b2bf818670 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
Date: Tue, 10 Feb 2015 11:58:54 +0100
Subject: [PATCH 01/13] wasapi: Don't fail if the client is already initialized
Subject: [PATCH 01/15] wasapi: Don't fail if the client is already initialized
make the extra test only for Winstore builds
---
......
From 66ec850fcead8e65b74756d9033d2c277803ca66 Mon Sep 17 00:00:00 2001
From 6148cbcca157d7f9f4904f34c57dfa81985179c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
Date: Wed, 11 May 2016 17:37:47 +0200
Subject: [PATCH 02/13] gnutls: Set cannot_unload_broken_library for winrt
Subject: [PATCH 02/15] gnutls: Set cannot_unload_broken_library for winrt
---
modules/misc/gnutls.c | 3 +++
......
From 8d31239f7fbfaf4e6fec147d5e054ec02f18a27c Mon Sep 17 00:00:00 2001
From 78d25860ea0615585e83c83fe5ca0c1b07ce1d7b Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Kempf <jb@videolan.org>
Date: Wed, 16 Apr 2014 16:09:53 +0200
Subject: [PATCH 03/13] Cheat for Windows Store subtitles
Subject: [PATCH 03/15] Cheat for Windows Store subtitles
---
lib/video.c | 5 +++++
......
From c1465131bc12195c4dac69446362a19ef3d15d73 Mon Sep 17 00:00:00 2001
From 36a877447e8e5f4a0fce15db2c0ba71edd09d42d Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Kempf <jb@videolan.org>
Date: Wed, 12 Mar 2014 00:11:26 +0100
Subject: [PATCH 04/13] Accept the weird WinRT pathes
Subject: [PATCH 04/15] Accept the weird WinRT pathes
---
src/text/url.c | 5 +++++
......
From 6f25a619914351383ecaae1429287f09f28ac016 Mon Sep 17 00:00:00 2001
From 76c0ef13c646b8f9d92eda94ccd69354061f0731 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
Date: Tue, 2 Aug 2016 18:54:28 +0200
Subject: [PATCH 05/13] config: cmdline: Use msg_* instead of fprintf
Subject: [PATCH 05/15] config: cmdline: Use msg_* instead of fprintf
---
src/config/cmdline.c | 14 +++++++-------
......
From a925df9f33d5dee7da76c27b79c26ee41727219b Mon Sep 17 00:00:00 2001
From 647f95c7e0d7c54bf47fb7be11077fdfb5cf849d Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@videolabs.io>
Date: Fri, 30 Sep 2016 09:49:19 +0200
Subject: [PATCH 06/13] plugin cache: Windows doesn't like relative pathes in
Subject: [PATCH 06/15] plugin cache: Windows doesn't like relative pathes in
LoadLibraryEx()
Fixes "vlc-cache-gen ../modules" on Windows and general VLC_PLUGIN_PATH usage.
......
From 565a35e44d67133705eb8f392c033bd3c9141e3f Mon Sep 17 00:00:00 2001
From 0dbef29d136465dccd7faea36c9eead1045a5bba Mon Sep 17 00:00:00 2001
From: Steve Lhomme <slhomme@matroska.org>
Date: Fri, 2 Dec 2016 11:14:40 +0100
Subject: [PATCH 07/13] TEMPORARY: disable cuda/nvenc when building for
Subject: [PATCH 07/15] TEMPORARY: disable cuda/nvenc when building for
Winstore
---
......
From 18a5b5ed1082300fb9c3679019963280e5c1c0c3 Mon Sep 17 00:00:00 2001
From f7a06ddd59f607c9b55a7bf85d7ce78650a011d2 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@videolabs.io>
Date: Wed, 25 Jan 2017 10:49:37 +0100
Subject: [PATCH 08/13] core: avcodec requires 32-bytes memory alignment in
Subject: [PATCH 08/15] core: avcodec requires 32-bytes memory alignment in
many cases
For example a IA0L texture on Windows is not 32 bytes aligned and avcodec
......
From 0313edf917a9b448d430587a432b0304d534151b Mon Sep 17 00:00:00 2001
From 5202c1627c25477a699e14e18d36687f0d258ba1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
Date: Wed, 22 Nov 2017 14:13:15 +0100
Subject: [PATCH 09/13] contrib: ffmpeg: Fix winstore build
Subject: [PATCH 09/15] contrib: ffmpeg: Fix winstore build
---
contrib/src/ffmpeg/disable-wincrypt.patch | 10 ++++++++++
......
From 10072d3bad430484efd3017d1150b2194189f3f1 Mon Sep 17 00:00:00 2001
From 9c90bed7827cd86cbc7ecb22ae15b3942d563bc1 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@videolabs.io>
Date: Tue, 19 Dec 2017 12:39:06 +0100
Subject: [PATCH 10/13] contrib:avcodec: use a more recent FFmpeg version
Subject: [PATCH 10/15] contrib:avcodec: use a more recent FFmpeg version
So that it doesn't use bogus atomics based code
---
......
From 62affde5340f840672574bdb055ec2eadfa48463 Mon Sep 17 00:00:00 2001
From f1386679f8a6d330e25860677954c214455e656f Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Tue, 20 Feb 2018 11:24:43 +0100
Subject: [PATCH 11/13] contrib:mpg123: don't use forbidden APIs on Phone apps
Subject: [PATCH 11/15] contrib:mpg123: don't use forbidden APIs on Phone apps
---
contrib/src/mpg123/mpg123-winstore.patch | 11 +++++++++++
......
From c76de91140fe83e6f5e44f4d5474752ac28412bb Mon Sep 17 00:00:00 2001
From 7bf671380f7810877e5d8cae6246a3ccc7f7e665 Mon Sep 17 00:00:00 2001
From: Carola Nitz <nitz.carola@googlemail.com>
Date: Fri, 29 Sep 2017 14:49:02 +0200
Subject: [PATCH 12/13] contrib: use live555 version that is compatible with
Subject: [PATCH 12/15] contrib: use live555 version that is compatible with
LGPL2
---
......
From 7e273841066d77bf7a5e4e14679771e4d4873dce Mon Sep 17 00:00:00 2001
From 310fdbbdf51b6e29c225370bcdaacf686dd1ba7b Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Tue, 27 Mar 2018 18:57:41 +0200
Subject: [PATCH 13/13] rand: use bcrypt instead of CryptographicBufferStatics
Subject: [PATCH 13/15] rand: use bcrypt instead of CryptographicBufferStatics
for Winstore builds
It's available to winstore apps
It's available to winstore apps and on desktop since Vista.
The old API is deprecated.
---
src/win32/rand.c | 44 ++++++++------------------------------------
1 file changed, 8 insertions(+), 36 deletions(-)
configure.ac | 5 ++++-
src/win32/rand.c | 50 +++++++++++---------------------------------------
2 files changed, 15 insertions(+), 40 deletions(-)
diff --git a/configure.ac b/configure.ac
index 8baf233..0a1b43e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1124,7 +1124,10 @@ AH_BOTTOM([
dnl Win32 requires linking to ssp for stack-protection
AS_IF([test "${SYS}" = "mingw32"], [
LDFLAGS="${LDFLAGS} -lssp"
- AS_IF([test "${vlc_winstore_app}" != 1], [LDFLAGS="${LDFLAGS} -ladvapi32"])
+ dnl library for Crypt/BCrypt APIs
+ AS_IF([test "${vlc_winstore_app}" != 1],
+ [LDFLAGS="${LDFLAGS} -ladvapi32"],
+ [LDFLAGS="${LDFLAGS} -lbcrypt"])
])
])
diff --git a/src/win32/rand.c b/src/win32/rand.c
index 1aeb656..75466b7 100644
index 1aeb656..723a32b 100644
--- a/src/win32/rand.c
+++ b/src/win32/rand.c
@@ -27,11 +27,7 @@
@@ -27,17 +27,23 @@
#include <vlc_rand.h>
#if VLC_WINSTORE_APP
......@@ -25,10 +44,27 @@ index 1aeb656..75466b7 100644
#else
# include <wincrypt.h>
#endif
@@ -58,38 +54,14 @@ void vlc_rand_bytes (void *buf, size_t len)
void vlc_rand_bytes (void *buf, size_t len)
{
+#if VLC_WINSTORE_APP
+ BCRYPT_ALG_HANDLE algo_handle;
+ NTSTATUS ret = BCryptOpenAlgorithmProvider(&algo_handle, BCRYPT_RNG_ALGORITHM,
+ MS_PRIMITIVE_PROVIDER, 0);
+ if (BCRYPT_SUCCESS(ret))
+ {
+ BCryptGenRandom(algo_handle, buf, len, 0);
+ BCryptCloseAlgorithmProvider(algo_handle, 0);
+ }
+#else
size_t count = len;
uint8_t *p_buf = (uint8_t *)buf;
@@ -57,40 +63,6 @@ void vlc_rand_bytes (void *buf, size_t len)
p_buf += sizeof (val);
}
#if VLC_WINSTORE_APP
-#if VLC_WINSTORE_APP
- static const WCHAR *className = L"Windows.Security.Cryptography.CryptographicBuffer";
- const UINT32 clen = wcslen(className);
-
......@@ -52,14 +88,7 @@ index 1aeb656..75466b7 100644
- if (hr) {
- ICryptographicBufferStatics_Release(cryptoStatics);
- return;
+ BCRYPT_ALG_HANDLE algo_handle;
+ NTSTATUS ret = BCryptOpenAlgorithmProvider(&algo_handle, BCRYPT_RNG_ALGORITHM,
+ MS_PRIMITIVE_PROVIDER, 0);
+ if (BCRYPT_SUCCESS(ret))
+ {
+ BCryptGenRandom(algo_handle, buf, len, 0);
+ BCryptCloseAlgorithmProvider(algo_handle, 0);
}
- }
-
- UINT32 olength;
- unsigned char *rnd = NULL;
......@@ -68,9 +97,10 @@ index 1aeb656..75466b7 100644
-
- IBuffer_Release(buffer);
- ICryptographicBufferStatics_Release(cryptoStatics);
#else
-#else
HCRYPTPROV hProv;
/* acquire default encryption context */
if( CryptAcquireContext(
--
2.10.1.windows.1
From 029a086e198a74d3494ff6e37feb514aaeb70c41 Mon Sep 17 00:00:00 2001
From: Carola Nitz <nitz.carola@googlemail.com>
Date: Fri, 29 Sep 2017 14:49:02 +0200
Subject: [PATCH 14/15] contrib: use live555 version that is compatible with
LGPL2
---
contrib/src/live555/SHA512SUMS | 2 +-
contrib/src/live555/rules.mak | 5 +----
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/contrib/src/live555/SHA512SUMS b/contrib/src/live555/SHA512SUMS
index f459fb9d16..02b2a69734 100644
--- a/contrib/src/live555/SHA512SUMS
+++ b/contrib/src/live555/SHA512SUMS
@@ -1 +1 @@
-319639acef6474b2eec0bdfa3416ca3c88a60f57d9d22911eee018fc494978fde93a241556bc0ea309f0b6a35e0242bd44a8f4de83a845f80d9ca5f94254ade6 live.2016.11.28.tar.gz
+10846fd6d5482bbea131ae805137077997e9dec242665e3c01d699d5584154c65049e8c520ea855599e554154a148e61fea77b592d97c814a4a98c773658d8f5 live.2016.10.21.tar.gz
\ No newline at end of file
diff --git a/contrib/src/live555/rules.mak b/contrib/src/live555/rules.mak
index a2ef4f842c..5b0cbeb1d9 100644
--- a/contrib/src/live555/rules.mak
+++ b/contrib/src/live555/rules.mak
@@ -1,14 +1,12 @@
# live555
-LIVE555_VERSION := 2016.11.28
+LIVE555_VERSION := 2016.10.21
LIVE555_FILE := live.$(LIVE555_VERSION).tar.gz
LIVEDOTCOM_URL := http://live555.com/liveMedia/public/$(LIVE555_FILE)
ifdef BUILD_NETWORK
-ifdef GNUV3
PKGS += live555
endif
-endif
ifeq ($(call need_pkg,"live555"),)
PKGS_FOUND += live555
@@ -82,7 +80,6 @@ endif
SUBDIRS=groupsock liveMedia UsageEnvironment BasicUsageEnvironment
.live555: live555
- $(REQUIRE_GNUV3)
cd $< && for subdir in $(SUBDIRS); do \
echo "PREFIX = $(PREFIX)" >> $$subdir/Makefile.head && \
echo "LIBDIR = $(PREFIX)/lib" >> $$subdir/Makefile.head ; done
--
2.11.0
From bd5035c40d0777278d17547b360df99bd84a8f38 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Wed, 28 Mar 2018 09:10:39 +0200
Subject: [PATCH 14/15] keystore: CryptUnprotectData is officially found in
dpapi.h
In MS SDKs and in mingw64
---
modules/keystore/file_crypt_win32.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/keystore/file_crypt_win32.c b/modules/keystore/file_crypt_win32.c
index 9a7b387..ebbdcfc 100644
--- a/modules/keystore/file_crypt_win32.c
+++ b/modules/keystore/file_crypt_win32.c
@@ -26,7 +26,7 @@
#include "file_crypt.h"
#include <windows.h>
-#include <wincrypt.h>
+#include <dpapi.h>
typedef BOOL (WINAPI *ProcessFunc)(DATA_BLOB*, LPCWSTR, DATA_BLOB*, PVOID,
CRYPTPROTECT_PROMPTSTRUCT*, DWORD, DATA_BLOB*);
--
2.10.1.windows.1
From 0e8b67f5b51afdeaf62945f835f562a6798a4dc1 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@videolabs.io>
Date: Mon, 23 May 2016 09:18:17 +0200
Subject: [PATCH 15/15] contrib: gnutls: fix Winstore forbidden API calls
---
contrib/src/gnutls/rules.mak | 3 +
contrib/src/gnutls/winstore.patch | 421 ++++++++++++++++++++++++++++++++++++++
2 files changed, 424 insertions(+)
create mode 100644 contrib/src/gnutls/winstore.patch
diff --git a/contrib/src/gnutls/rules.mak b/contrib/src/gnutls/rules.mak
index 9cd29be..b04b3c0 100644
--- a/contrib/src/gnutls/rules.mak
+++ b/contrib/src/gnutls/rules.mak
@@ -38,6 +38,9 @@ ifdef HAVE_MACOSX
$(APPLY) $(SRC)/gnutls/gnutls-disable-connectx-macos.patch
endif
$(APPLY) $(SRC)/gnutls/gnutls-libidn.patch
+ifdef HAVE_WINSTORE
+ $(APPLY) $(SRC)/gnutls/winstore.patch
+endif
$(call pkg_static,"lib/gnutls.pc.in")
$(UPDATE_AUTOCONFIG)
$(MOVE)
diff --git a/contrib/src/gnutls/winstore.patch b/contrib/src/gnutls/winstore.patch
new file mode 100644
index 0000000..30861c7
--- /dev/null
+++ b/contrib/src/gnutls/winstore.patch
@@ -0,0 +1,421 @@
+--- gnutls/lib/nettle/sysrng-windows.c.winstore 2016-11-05 19:12:02.000000000 +0100
++++ gnutls/lib/nettle/sysrng-windows.c 2018-03-28 14:31:43.044698600 +0200
+@@ -29,6 +29,34 @@
+ * Original author Niels Möller.
+ */
+
++#include <windows.h>
++#include <winapifamily.h>
++#if WINAPI_PARTITION_DESKTOP
++#include <wincrypt.h>
++#else /* !WINAPI_PARTITION_DESKTOP */
++#include <bcrypt.h>
++typedef BCRYPT_ALG_HANDLE HCRYPTPROV;
++#define PROV_RSA_FULL 0
++#define CRYPT_SILENT 0
++#define CRYPT_VERIFYCONTEXT 0
++
++static BOOL CryptGenRandom(BCRYPT_ALG_HANDLE handle, DWORD dwLen, BYTE *pbBuffer)
++{
++ return BCRYPT_SUCCESS(BCryptGenRandom(handle, pbBuffer, dwLen, 0));
++}
++
++static BOOL CryptAcquireContext(BCRYPT_ALG_HANDLE *pHandle, LPCTSTR pszContainer, LPCTSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
++{
++ return BCRYPT_SUCCESS(BCryptOpenAlgorithmProvider(pHandle, BCRYPT_RNG_ALGORITHM,
++ MS_PRIMITIVE_PROVIDER, 0));
++}
++
++static BOOL CryptReleaseContext(BCRYPT_ALG_HANDLE handle, DWORD dwFlags)
++{
++ return BCRYPT_SUCCESS(BCryptCloseAlgorithmProvider(handle, 0));
++}
++#endif /* !WINAPI_PARTITION_DESKTOP */
++
+ #include "gnutls_int.h"
+ #include "errors.h"
+ #include <locks.h>
+@@ -45,9 +73,6 @@
+ /* The windows randomness gatherer.
+ */
+
+-#include <windows.h>
+-#include <wincrypt.h>
+-
+ static HCRYPTPROV device_fd = 0;
+
+ static
+--- gnutls/lib/system/certs.c.winstore 2017-04-07 07:52:07.000000000 +0200
++++ gnutls/lib/system/certs.c 2018-03-28 11:56:50.571166700 +0200
+@@ -21,6 +21,110 @@
+ *
+ */
+
++#ifdef _WIN32
++# include <windows.h>
++# include <wincrypt.h>
++
++#include <winapifamily.h>
++#if !WINAPI_PARTITION_DESKTOP
++# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0A00 /* Univeral Winstore */
++/* CertOpenSystemStore() is not available */
++static HCERTSTORE CertOpenSystemStore( HCRYPTPROV_LEGACY hprov, LPCSTR szSubsystemProtocol )
++{
++ return CertOpenStore( CERT_STORE_PROV_SYSTEM_A, X509_ASN_ENCODING, 0,
++ CERT_SYSTEM_STORE_CURRENT_USER, szSubsystemProtocol );
++}
++# else /*_WIN32_WINNT < 0x0A00 */
++/* CertOpenStore() is not available */
++# define COBJMACROS
++# define INITGUID
++# include <winstring.h>
++# include <windows.security.cryptography.certificates.h>
++# include <roapi.h>
++
++static HCERTSTORE CertOpenSystemStore(void *hprov, LPCSTR szSubsystemProtocol)
++{
++ static const WCHAR *className = L"Windows.Security.Cryptography.Certificates";
++ const UINT32 clen = wcslen(className);
++
++ HSTRING hClassName = NULL;
++ HSTRING_HEADER header;
++ HRESULT hr = WindowsCreateStringReference(className, clen, &header, &hClassName);
++ if (FAILED(hr)) {
++ WindowsDeleteString(hClassName);
++ return NULL;
++ }
++
++ ICertificateStoresStatics *certStoresStatics = NULL;
++ hr = RoGetActivationFactory(hClassName, &IID_ICertificateStoresStatics, (void**)&certStoresStatics);
++ WindowsDeleteString(hClassName);
++
++ if (FAILED(hr))
++ return NULL;
++
++ if (!strcmp(szSubsystemProtocol, "ROOT"))
++ {
++ ICertificateStore *result;
++ hr = ICertificateStoresStatics_get_TrustedRootCertificationAuthorities(certStoresStatics, &result);
++ ICertificateStoresStatics_Release(certStoresStatics);
++ if (SUCCEEDED(hr))
++ {
++ return result;
++ }
++ }
++ else if (!strcmp(szSubsystemProtocol, "CA"))
++ {
++ ICertificateStore *result;
++ hr = ICertificateStoresStatics_get_IntermediateCertificationAuthorities(certStoresStatics, &result);
++ ICertificateStoresStatics_Release(certStoresStatics);
++ if (SUCCEEDED(hr))
++ {
++ return result;
++ }
++ }
++ else
++ {
++ ICertificateStoresStatics_Release(certStoresStatics);
++ }
++
++ return NULL;
++}
++
++static PCCERT_CONTEXT CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pPrevCertContext)
++{
++ return NULL;
++}
++
++static PCCERT_CONTEXT CertFindCertificateInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType, const void *pvFindPara, PCCERT_CONTEXT pPrevCertContext)
++{
++ return NULL;
++}
++
++static BOOL CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, void *pvData, DWORD *pcbData)
++{
++ return FALSE;
++}
++
++static BOOL CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
++{
++ ICertificateStore *store = (ICertificateStore *)hCertStore;
++ HRESULT hr = ICertificateStoresStatics_Release(store);
++ return SUCCEEDED(hr);
++}
++
++static BOOL CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext)
++{
++ return FALSE;
++}
++
++static HCERTSTORE PFXImportCertStore(CRYPT_DATA_BLOB* pPFX, LPCWSTR szPassword, DWORD dwFlags)
++{
++ return NULL;
++}
++# endif /* _WIN32_WINNT < 0x0A00 */
++#endif /* !WINAPI_PARTITION_DESKTOP */
++#endif /* _WIN32 */
++
+ #include <config.h>
+ #include "gnutls_int.h"
+ #include "errors.h"
+@@ -32,9 +136,6 @@
+ #include "system.h"
+
+ #ifdef _WIN32
+-# include <windows.h>
+-# include <wincrypt.h>
+-
+ #else /* !_WIN32 */
+
+ # include <poll.h>
+--- gnutls/lib/system/keys-win.c.winstore 2018-03-28 14:33:51.385023100 +0200
++++ gnutls/lib/system/keys-win.c 2018-03-28 14:15:06.835899200 +0200
+@@ -26,6 +26,183 @@
+ #define _WIN32_WINNT 0x600
+ #endif
+
++#include <wincrypt.h>
++
++#include <winapifamily.h>
++#if !WINAPI_PARTITION_DESKTOP
++# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0A00 /* Univeral Winstore */
++/* CertOpenSystemStore() is not available */
++static HCERTSTORE CertOpenSystemStore( HCRYPTPROV_LEGACY hprov, LPCSTR szSubsystemProtocol )
++{
++ return CertOpenStore( CERT_STORE_PROV_SYSTEM_A, X509_ASN_ENCODING, 0,
++ CERT_SYSTEM_STORE_CURRENT_USER, szSubsystemProtocol );
++}
++# else /*_WIN32_WINNT < 0x0A00 */
++# include <bcrypt.h>
++typedef BCRYPT_ALG_HANDLE HCRYPTPROV;
++typedef BCRYPT_HASH_HANDLE HCRYPTHASH;
++typedef unsigned int ALG_ID;
++
++static BOOL CryptCreateHash(BCRYPT_ALG_HANDLE handle, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, BCRYPT_HASH_HANDLE *phHash)
++{
++ BCRYPT_ALG_HANDLE hh;
++ LPCWSTR pAlgo;
++ switch (Algid)
++ {
++ case CALG_MD5: pAlgo = BCRYPT_MD5_ALGORITHM; break;
++ case CALG_SHA1: pAlgo = BCRYPT_SHA1_ALGORITHM; break;
++ case CALG_SHA_256: pAlgo = BCRYPT_SHA256_ALGORITHM; break;
++ case CALG_SHA_384: pAlgo = BCRYPT_SHA384_ALGORITHM; break;
++ case CALG_SHA_512: pAlgo = BCRYPT_SHA512_ALGORITHM; break;
++ case CALG_SSL3_SHAMD5: pAlgo = BCRYPT_MD5_ALGORITHM; break;
++ case CALG_RSA_SIGN: pAlgo = BCRYPT_RSA_SIGN_ALGORITHM; break; /* not supported ? */
++ case CALG_DSS_SIGN: pAlgo = BCRYPT_DSA_ALGORITHM; break;
++ default: pAlgo = NULL; break;
++ }
++ if (pAlgo==NULL)
++ return FALSE;
++ NTSTATUS ret = BCryptOpenAlgorithmProvider(&hh, pAlgo, NULL, 0);
++ if (!BCRYPT_SUCCESS(ret))
++ return FALSE;
++ ret = BCryptCreateHash(hh, phHash, NULL, 0, NULL, 0, 0);
++ return BCRYPT_SUCCESS(ret);
++}
++
++static BOOL CryptDestroyHash(BCRYPT_HASH_HANDLE hHash)
++{
++ NTSTATUS ret = BCryptDestroyHash(hHash);
++ return BCRYPT_SUCCESS(ret);
++}
++
++static BOOL CryptDecrypt(HCRYPTKEY hKey, BCRYPT_HASH_HANDLE hHash, BOOL Final, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen)
++{
++ return FALSE;
++}
++
++static BOOL CryptSignHash(HCRYPTHASH hHash, DWORD dwKeySpec, LPCTSTR sDescription, DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen)
++{
++ return FALSE;
++}
++
++static BOOL CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
++{
++ LPCWSTR pszProperty;
++ switch (dwParam)
++ {
++ case HP_HASHSIZE: pszProperty = BCRYPT_HASH_LENGTH; break;
++ default: pszProperty = NULL; break;
++ }
++ if (pszProperty==NULL)
++ return FALSE;
++ NTSTATUS ret = BCryptGetProperty(hHash, pszProperty, pbData, *pdwDataLen, NULL, 0);
++}
++
++static BOOL CryptSetHashParam(BCRYPT_HASH_HANDLE hHash, DWORD dwParam, const BYTE *pbData, DWORD dwFlags)
++{
++ LPCWSTR pszProperty;
++ switch (dwParam)
++ {
++ case HP_HASHVAL: pszProperty = BCRYPT_HASH_OID_LIST; break;
++ default: pszProperty = NULL; break;
++ }
++ if (pszProperty==NULL)
++ return FALSE;
++ NTSTATUS ret = BCryptSetProperty(hHash, pszProperty, pbData, 0, 0);
++}
++
++/* CertOpenStore() is not available */
++# define COBJMACROS
++# define INITGUID
++# include <winstring.h>
++# include <windows.security.cryptography.certificates.h>
++# include <roapi.h>
++
++static HCERTSTORE CertOpenSystemStore(void *hprov, LPCSTR szSubsystemProtocol)
++{
++ static const WCHAR *className = L"Windows.Security.Cryptography.Certificates";
++ const UINT32 clen = wcslen(className);
++
++ HSTRING hClassName = NULL;
++ HSTRING_HEADER header;
++ HRESULT hr = WindowsCreateStringReference(className, clen, &header, &hClassName);
++ if (FAILED(hr)) {
++ WindowsDeleteString(hClassName);
++ return NULL;
++ }
++
++ ICertificateStoresStatics *certStoresStatics = NULL;
++ hr = RoGetActivationFactory(hClassName, &IID_ICertificateStoresStatics, (void**)&certStoresStatics);
++ WindowsDeleteString(hClassName);
++
++ if (FAILED(hr))
++ return NULL;
++
++ if (!strcmp(szSubsystemProtocol, "ROOT"))
++ {
++ ICertificateStore *result;
++ hr = ICertificateStoresStatics_get_TrustedRootCertificationAuthorities(certStoresStatics, &result);
++ ICertificateStoresStatics_Release(certStoresStatics);
++ if (SUCCEEDED(hr))
++ {
++ return result;
++ }
++ }
++ else if (!strcmp(szSubsystemProtocol, "CA"))
++ {
++ ICertificateStore *result;
++ hr = ICertificateStoresStatics_get_IntermediateCertificationAuthorities(certStoresStatics, &result);
++ ICertificateStoresStatics_Release(certStoresStatics);
++ if (SUCCEEDED(hr))
++ {
++ return result;
++ }
++ }
++ else
++ {
++ ICertificateStoresStatics_Release(certStoresStatics);
++ }
++
++ return NULL;
++}
++
++static PCCERT_CONTEXT CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pPrevCertContext)
++{
++ return NULL;
++}
++
++static PCCERT_CONTEXT CertFindCertificateInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType, const void *pvFindPara, PCCERT_CONTEXT pPrevCertContext)
++{
++ return NULL;
++}
++
++static BOOL CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, void *pvData, DWORD *pcbData)
++{
++ return FALSE;
++}
++
++static BOOL CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
++{
++ ICertificateStore *store = (ICertificateStore *)hCertStore;
++ HRESULT hr = ICertificateStoresStatics_Release(store);
++ return SUCCEEDED(hr);
++}
++
++static void CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
++{
++}
++
++static BOOL CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext)
++{
++ return FALSE;
++}
++
++static HCERTSTORE PFXImportCertStore(CRYPT_DATA_BLOB* pPFX, LPCWSTR szPassword, DWORD dwFlags)
++{
++ return NULL;
++}
++# endif /* _WIN32_WINNT < 0x0A00 */
++#endif /* !WINAPI_PARTITION_DESKTOP */
++
+ #include "gnutls_int.h"
+ #include "errors.h"
+ #include <gnutls/gnutls.h>
+@@ -41,20 +218,6 @@
+ #error should not be included
+ #endif
+
+-#include <wincrypt.h>
+-#include <winbase.h>
+-
+-#include <winapifamily.h>
+-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+-# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0A00 /* Univeral Winstore */
+-# undef CertOpenSystemStore
+-HCERTSTORE CertOpenSystemStore( HCRYPTPROV_LEGACY hprov, LPCSTR szSubsystemProtocol )
+-{
+- return CertOpenStore( CERT_STORE_PROV_SYSTEM_A, X509_ASN_ENCODING, 0,
+- CERT_SYSTEM_STORE_CURRENT_USER, szSubsystemProtocol );
+-}
+-# endif /* _WIN32_WINNT */
+-#endif /* WINAPI_FAMILY */
+
+ #define DYN_NCRYPT