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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
From 6c6bbefdcf8a41dc71f9cbeca7ce972e2661fade Mon Sep 17 00:00:00 2001
From: Julien Cristau <jcristau@debian.org>
Date: Thu, 2 Apr 2009 02:34:49 +0200
Subject: [PATCH] Add libgcrypt as an option for sha1
---
configure.ac | 6 ++++++
include/dix-config.h.in | 3 +++
render/glyph.c | 12 ++++++++++++
3 files changed, 21 insertions(+), 0 deletions(-)
Index: xorg-server/configure.ac
===================================================================
--- xorg-server.orig/configure.ac
+++ xorg-server/configure.ac
@@ -1108,6 +1108,12 @@
[Use libmd SHA1 functions instead of OpenSSL libcrypto])])
fi
+if test "x$SHA1_LIB" = "x"; then
+ AC_CHECK_LIB([gcrypt], [gcry_md_open], [SHA1_LIB="-lgcrypt"
+ AC_DEFINE([HAVE_SHA1_IN_LIBGCRYPT], [1],
+ [Use libgcrypt SHA1 functions instead of OpenSSL libcrypto])])
+fi
+
if test "x$SHA1_LIB" = "x" ; then
PKG_CHECK_EXISTS([OPENSSL], [openssl], [HAVE_OPENSSL_PKC=yes],
[HAVE_OPENSSL_PKC=no])
Index: xorg-server/include/dix-config.h.in
===================================================================
--- xorg-server.orig/include/dix-config.h.in
+++ xorg-server/include/dix-config.h.in
@@ -157,6 +157,9 @@
/* Define to use libmd SHA1 functions instead of OpenSSL libcrypto */
#undef HAVE_SHA1_IN_LIBMD
+/* Define to use libgcrypt SHA1 functions instead of OpenSSL libcrypto */
+#undef HAVE_SHA1_IN_LIBGCRYPT
+
/* Define to 1 if you have the `shmctl64' function. */
#undef HAVE_SHMCTL64
Index: xorg-server/render/glyph.c
===================================================================
--- xorg-server.orig/render/glyph.c
+++ xorg-server/render/glyph.c
@@ -28,6 +28,8 @@
#ifdef HAVE_SHA1_IN_LIBMD /* Use libmd for SHA1 */
# include <sha1.h>
+#elif defined(HAVE_SHA1_IN_LIBGCRYPT)
+# include <gcrypt.h>
#else /* Use OpenSSL's libcrypto */
# include <stddef.h> /* buggy openssl/sha.h wants size_t */
# include <openssl/sha.h>
@@ -205,6 +207,26 @@
SHA1Update (&ctx, gi, sizeof (xGlyphInfo));
SHA1Update (&ctx, bits, size);
SHA1Final (sha1, &ctx);
+#elif defined(HAVE_SHA1_IN_LIBGCRYPT) /* Use libgcrypt for SHA1 */
+ static int init;
+ gcry_md_hd_t h;
+ gcry_error_t err;
+
+ if (!init) {
+ if (!gcry_check_version(NULL))
+ return BadAlloc;
+ gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
+ gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
+ init = 1;
+ }
+
+ err = gcry_md_open(&h, GCRY_MD_SHA1, 0);
+ if (err)
+ return BadAlloc;
+ gcry_md_write(h, gi, sizeof (xGlyphInfo));
+ gcry_md_write(h, bits, size);
+ memcpy(sha1, gcry_md_read(h, GCRY_MD_SHA1), 20);
+ gcry_md_close(h);
#else /* Use OpenSSL's libcrypto */
SHA_CTX ctx;
int success;
|