aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-05-09 16:07:11 +0200
committermarha <marha@users.sourceforge.net>2012-05-09 16:07:11 +0200
commit58780b4306bd1254c6c0e65d255630d5c546005f (patch)
tree71c3b3842ee282b0228246840f5006c369684ab7 /xorg-server/os
parent38e785557684536d03fff096d56d5db61cc42e8a (diff)
parent8a448108ec0bc3a0a488b2234e0d12aee503c67c (diff)
downloadvcxsrv-58780b4306bd1254c6c0e65d255630d5c546005f.tar.gz
vcxsrv-58780b4306bd1254c6c0e65d255630d5c546005f.tar.bz2
vcxsrv-58780b4306bd1254c6c0e65d255630d5c546005f.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'xorg-server/os')
-rw-r--r--xorg-server/os/xsha1.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/xorg-server/os/xsha1.c b/xorg-server/os/xsha1.c
index dccce74b6..fa66c7a06 100644
--- a/xorg-server/os/xsha1.c
+++ b/xorg-server/os/xsha1.c
@@ -74,6 +74,48 @@ x_sha1_final(void *ctx, unsigned char result[20])
return 1;
}
+#elif defined(HAVE_SHA1_IN_CRYPTOAPI) /* Use CryptoAPI for SHA1 */
+
+#define WIN32_LEAN_AND_MEAN
+#include <X11/Xwindows.h>
+#include <wincrypt.h>
+
+static HCRYPTPROV hProv;
+
+void *
+x_sha1_init(void)
+{
+ HCRYPTHASH *ctx = malloc(sizeof(*ctx));
+
+ if (!ctx)
+ return NULL;
+ CryptAcquireContext(&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
+ CryptCreateHash(hProv, CALG_SHA1, 0, 0, ctx);
+ return ctx;
+}
+
+int
+x_sha1_update(void *ctx, void *data, int size)
+{
+ HCRYPTHASH *hHash = ctx;
+
+ CryptHashData(*hHash, data, size, 0);
+ return 1;
+}
+
+int
+x_sha1_final(void *ctx, unsigned char result[20])
+{
+ HCRYPTHASH *hHash = ctx;
+ DWORD len = 20;
+
+ CryptGetHashParam(*hHash, HP_HASHVAL, result, &len, 0);
+ CryptDestroyHash(*hHash);
+ CryptReleaseContext(hProv, 0);
+ free(ctx);
+ return 1;
+}
+
#elif defined(HAVE_SHA1_IN_LIBGCRYPT) /* Use libgcrypt for SHA1 */
#include <gcrypt.h>