summaryrefslogtreecommitdiffstats
path: root/external/xmlsec/BCryptKeyDerivation.patch.1
blob: 3747915f87d266bf8ce19ff9b8f541d62cb4a541 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
tdf#159519 Windows 7 does not have BCryptKeyDerivation

It just occurred to me that these functions would of course not be called
by LibreOffice so this is untested.

--- xmlsec/src/mscng/pbkdf2.c.orig	2024-02-21 19:02:56.539534152 +0100
+++ xmlsec/src/mscng/pbkdf2.c	2024-02-21 19:01:03.282270354 +0100
@@ -318,7 +318,20 @@
     }
 
     /* generate the output key */
+#if 1 // _WIN32_WINNT <= 0x0601
+    typedef NTSTATUS (WINAPI * BCryptKeyDerivationPtr)(
+        BCRYPT_KEY_HANDLE, BCryptBufferDesc *, PUCHAR, ULONG, ULONG *, ULONG);
+    HMODULE hBCrypt = GetModuleHandle("bcrypt.dll");
+    BCryptKeyDerivationPtr pBCryptKeyDerivation =
+        (BCryptKeyDerivationPtr) GetProcAddress(hBCrypt, "BCryptKeyDerivation");
+    if(NULL == pBCryptKeyDerivation) {
+        xmlSecMSCngNtError("BCryptKeyDerivation", NULL, status);
+        goto done;
+    }
+    status = (*pBCryptKeyDerivation)(
+#else
     status = BCryptKeyDerivation(
+#endif
         hKey,
         &paramsPBKDF2,
         pbOut,
--- xmlsec/src/mscng/concatkdf.c.orig	2024-02-21 19:02:37.962490885 +0100
+++ xmlsec/src/mscng/concatkdf.c	2024-02-21 19:01:37.961351134 +0100
@@ -318,7 +318,20 @@
     }
 
     /* generate the output key */
+#if 1 // _WIN32_WINNT <= 0x0601
+    typedef NTSTATUS (WINAPI * BCryptKeyDerivationPtr)(
+        BCRYPT_KEY_HANDLE, BCryptBufferDesc *, PUCHAR, ULONG, ULONG *, ULONG);
+    HMODULE hBCrypt = GetModuleHandle("bcrypt.dll");
+    BCryptKeyDerivationPtr pBCryptKeyDerivation =
+        (BCryptKeyDerivationPtr) GetProcAddress(hBCrypt, "BCryptKeyDerivation");
+    if(NULL == pBCryptKeyDerivation) {
+        xmlSecMSCngNtError("BCryptKeyDerivation", NULL, status);
+        goto done;
+    }
+    status = (*pBCryptKeyDerivation)(
+#else
     status = BCryptKeyDerivation(
+#endif
         hKey,
         &paramsCONCATKDF2,
         pbOut,