~ubuntu-branches/ubuntu/vivid/xorg-server/vivid

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Maarten Lankhorst
  • Date: 2013-07-03 12:03:57 UTC
  • mfrom: (1.1.56)
  • Revision ID: package-import@ubuntu.com-20130703120357-caosebpn11zu2zj0
Tags: 2:1.14.1-0ubuntu0.8
Use correct version for libxfixes3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From a6119f6cd7e47041044fcc9c15a6e3f9f189b3ed Mon Sep 17 00:00:00 2001
2
 
From: Cyril Brulebois <kibi@debian.org>
3
 
Date: Sun, 14 Mar 2010 22:01:47 +0100
4
 
Subject: [PATCH] Add libnettle as option for sha1.
5
 
 
6
 
Signed-off-by: Cyril Brulebois <kibi@debian.org>
7
 
 
8
 
[jcristau: forward-ported from 1.7 to 1.8]
9
 
Signed-off-by: Julien Cristau <jcristau@debian.org>
10
 
---
11
 
--- a/configure.ac
12
 
+++ b/configure.ac
13
 
@@ -1361,7 +1361,7 @@ CORE_INCS='-I$(top_srcdir)/include -I$(t
14
 
 
15
 
 # SHA1 hashing
16
 
 AC_ARG_WITH([sha1],
17
 
-            [AS_HELP_STRING([--with-sha1=libc|libmd|libgcrypt|libcrypto|libsha1|CommonCrypto|CryptoAPI],
18
 
+            [AS_HELP_STRING([--with-sha1=libc|libmd|libgcrypt|libcrypto|libsha1|CommonCrypto|CryptoAPI|nettle],
19
 
                             [choose SHA1 implementation])])
20
 
 AC_CHECK_FUNC([SHA1Init], [HAVE_SHA1_IN_LIBC=yes])
21
 
 if test "x$with_sha1" = x && test "x$HAVE_SHA1_IN_LIBC" = xyes; then
22
 
@@ -1457,6 +1457,16 @@ if test "x$with_sha1" = xlibcrypto; then
23
 
                SHA1_CFLAGS="$OPENSSL_CFLAGS"
24
 
        fi
25
 
 fi
26
 
+AC_CHECK_LIB([nettle], [nettle_sha1_init], [HAVE_LIBNETTLE=yes])
27
 
+if test "x$with_sha1" = x && test "x$HAVE_LIBNETTLE" = xyes; then
28
 
+       with_sha1=nettle
29
 
+fi
30
 
+if test "x$with_sha1" = xnettle; then
31
 
+       AC_DEFINE([HAVE_SHA1_IN_LIBNETTLE], [1],
32
 
+                 [Use libnettle SHA1 functions])
33
 
+       # XXX hack for d-i: use the static lib
34
 
+       SHA1_LIBS=-l:libnettle.a
35
 
+fi
36
 
 AC_MSG_CHECKING([for SHA1 implementation])
37
 
 if test "x$with_sha1" = x; then
38
 
        AC_MSG_ERROR([No suitable SHA1 implementation found])
39
 
--- a/include/dix-config.h.in
40
 
+++ b/include/dix-config.h.in
41
 
@@ -160,6 +160,9 @@
42
 
 /* Define to use libsha1 for SHA1 */
43
 
 #undef HAVE_SHA1_IN_LIBSHA1
44
 
 
45
 
+/* Define to use libnettle SHA1 */
46
 
+#undef HAVE_SHA1_IN_LIBNETTLE
47
 
+
48
 
 /* Define to 1 if you have the `shmctl64' function. */
49
 
 #undef HAVE_SHMCTL64
50
 
 
51
 
--- a/os/xsha1.c
52
 
+++ b/os/xsha1.c
53
 
@@ -190,6 +190,32 @@ x_sha1_final(void *ctx, unsigned char re
54
 
     return 1;
55
 
 }
56
 
 
57
 
+#elif defined(HAVE_SHA1_IN_LIBNETTLE)
58
 
+
59
 
+#include <nettle/sha.h>
60
 
+
61
 
+void *x_sha1_init(void)
62
 
+{
63
 
+    struct sha1_ctx *ctx = malloc(sizeof(*ctx));
64
 
+    if (!ctx)
65
 
+        return NULL;
66
 
+    sha1_init(ctx);
67
 
+    return ctx;
68
 
+}
69
 
+
70
 
+int x_sha1_update(void *ctx, void *data, int size)
71
 
+{
72
 
+    sha1_update(ctx, size, data);
73
 
+    return 1;
74
 
+}
75
 
+
76
 
+int x_sha1_final(void *ctx, unsigned char result[20])
77
 
+{
78
 
+    sha1_digest(ctx, 20, result);
79
 
+    free(ctx);
80
 
+    return 1;
81
 
+}
82
 
+
83
 
 #else                           /* Use OpenSSL's libcrypto */
84
 
 
85
 
 #include <stddef.h>             /* buggy openssl/sha.h wants size_t */