~ubuntu-branches/ubuntu/lucid/xorg-server/lucid-updates

« back to all changes in this revision

Viewing changes to debian/patches/02_Add-libgcrypt-as-an-option-for-sha1.diff

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington, Timo Aaltonen, Bryce Harrington
  • Date: 2010-03-24 12:04:20 UTC
  • mfrom: (1.1.32 upstream) (0.11.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100324120420-qbk5la526uy4k8xe
Tags: 2:1.7.6-1ubuntu1
[Timo Aaltonen]
* Merge from Debian unstable.
* Drop patch 107, included in Debian.
* Drop patch 108, included upstream.
* control: Drop the udeb, we don't need it for lucid.
* control: Relax/drop some build-deps caused by the udeb.

[Bryce Harrington]
* Add 110_findglyphbyhash-fix.patch from upstream to fix a sporadic
  crash in FindGlyphByHash.
  (LP: #401045)
* Renumber patch 201_armel-drv-fallbacks.patch to 111

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From 6c6bbefdcf8a41dc71f9cbeca7ce972e2661fade Mon Sep 17 00:00:00 2001
2
 
From: Julien Cristau <jcristau@debian.org>
3
 
Date: Thu, 2 Apr 2009 02:34:49 +0200
4
 
Subject: [PATCH] Add libgcrypt as an option for sha1
5
 
 
6
 
Included upstream in 1.7.99.x in a different way:
7
 
commit a60e676f1fd243c78859440b87652f523d3f2ec1
8
 
---
9
 
 configure.ac            |    6 ++++++
10
 
 include/dix-config.h.in |    3 +++
11
 
 render/glyph.c          |   12 ++++++++++++
12
 
 3 files changed, 21 insertions(+), 0 deletions(-)
13
 
 
14
 
Index: xorg-server/configure.ac
15
 
===================================================================
16
 
--- xorg-server.orig/configure.ac
17
 
+++ xorg-server/configure.ac
18
 
@@ -1299,6 +1299,12 @@
19
 
             [Use libmd SHA1 functions instead of OpenSSL libcrypto])])
20
 
 fi
21
 
 
22
 
+if test "x$SHA1_LIB" = "x"; then
23
 
+  AC_CHECK_LIB([gcrypt], [gcry_md_open], [SHA1_LIB="-lgcrypt"
24
 
+            AC_DEFINE([HAVE_SHA1_IN_LIBGCRYPT], [1],
25
 
+            [Use libgcrypt SHA1 functions instead of OpenSSL libcrypto])])
26
 
+fi
27
 
+
28
 
 if test "x$SHA1_LIB" = "x" ; then
29
 
   PKG_CHECK_EXISTS([OPENSSL], [openssl], [HAVE_OPENSSL_PKC=yes],
30
 
                     [HAVE_OPENSSL_PKC=no])
31
 
Index: xorg-server/include/dix-config.h.in
32
 
===================================================================
33
 
--- xorg-server.orig/include/dix-config.h.in
34
 
+++ xorg-server/include/dix-config.h.in
35
 
@@ -163,6 +163,9 @@
36
 
 /* Define to use libmd SHA1 functions instead of OpenSSL libcrypto */
37
 
 #undef HAVE_SHA1_IN_LIBMD
38
 
 
39
 
+/* Define to use libgcrypt SHA1 functions instead of OpenSSL libcrypto */
40
 
+#undef HAVE_SHA1_IN_LIBGCRYPT
41
 
+
42
 
 /* Define to 1 if you have the `shmctl64' function. */
43
 
 #undef HAVE_SHMCTL64
44
 
 
45
 
Index: xorg-server/render/glyph.c
46
 
===================================================================
47
 
--- xorg-server.orig/render/glyph.c
48
 
+++ xorg-server/render/glyph.c
49
 
@@ -28,6 +28,8 @@
50
 
 
51
 
 #ifdef HAVE_SHA1_IN_LIBMD /* Use libmd for SHA1 */
52
 
 # include <sha1.h>
53
 
+#elif defined(HAVE_SHA1_IN_LIBGCRYPT)
54
 
+# include <gcrypt.h>
55
 
 #else /* Use OpenSSL's libcrypto */
56
 
 # include <stddef.h>  /* buggy openssl/sha.h wants size_t */
57
 
 # include <openssl/sha.h>
58
 
@@ -205,6 +207,26 @@
59
 
     SHA1Update (&ctx, gi, sizeof (xGlyphInfo));
60
 
     SHA1Update (&ctx, bits, size);
61
 
     SHA1Final (sha1, &ctx);
62
 
+#elif defined(HAVE_SHA1_IN_LIBGCRYPT) /* Use libgcrypt for SHA1 */
63
 
+    static int init;
64
 
+    gcry_md_hd_t h;
65
 
+    gcry_error_t err;
66
 
+
67
 
+    if (!init) {
68
 
+       if (!gcry_check_version(NULL))
69
 
+           return BadAlloc;
70
 
+       gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
71
 
+       gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
72
 
+       init = 1;
73
 
+    }
74
 
+
75
 
+    err = gcry_md_open(&h, GCRY_MD_SHA1, 0);
76
 
+    if (err)
77
 
+       return BadAlloc;
78
 
+    gcry_md_write(h, gi, sizeof (xGlyphInfo));
79
 
+    gcry_md_write(h, bits, size);
80
 
+    memcpy(sha1, gcry_md_read(h, GCRY_MD_SHA1), 20);
81
 
+    gcry_md_close(h);
82
 
 #else /* Use OpenSSL's libcrypto */
83
 
     SHA_CTX ctx;
84
 
     int success;