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.
6
Signed-off-by: Cyril Brulebois <kibi@debian.org>
8
[jcristau: forward-ported from 1.7 to 1.8]
9
Signed-off-by: Julien Cristau <jcristau@debian.org>
13
@@ -1361,7 +1361,7 @@ CORE_INCS='-I$(top_srcdir)/include -I$(t
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"
26
+AC_CHECK_LIB([nettle], [nettle_sha1_init], [HAVE_LIBNETTLE=yes])
27
+if test "x$with_sha1" = x && test "x$HAVE_LIBNETTLE" = xyes; then
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
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
42
/* Define to use libsha1 for SHA1 */
43
#undef HAVE_SHA1_IN_LIBSHA1
45
+/* Define to use libnettle SHA1 */
46
+#undef HAVE_SHA1_IN_LIBNETTLE
48
/* Define to 1 if you have the `shmctl64' function. */
53
@@ -190,6 +190,32 @@ x_sha1_final(void *ctx, unsigned char re
57
+#elif defined(HAVE_SHA1_IN_LIBNETTLE)
59
+#include <nettle/sha.h>
61
+void *x_sha1_init(void)
63
+ struct sha1_ctx *ctx = malloc(sizeof(*ctx));
70
+int x_sha1_update(void *ctx, void *data, int size)
72
+ sha1_update(ctx, size, data);
76
+int x_sha1_final(void *ctx, unsigned char result[20])
78
+ sha1_digest(ctx, 20, result);
83
#else /* Use OpenSSL's libcrypto */
85
#include <stddef.h> /* buggy openssl/sha.h wants size_t */