Contents of /trunk/xorg-server/patches/xorg-server-1.7.6-libsha1-support.patch
Parent Directory | Revision Log
Revision 1035 -
(show annotations)
(download)
Thu Apr 29 21:57:44 2010 UTC (14 years, 5 months ago) by niro
File size: 2512 byte(s)
Thu Apr 29 21:57:44 2010 UTC (14 years, 5 months ago) by niro
File size: 2512 byte(s)
support libsha1 sha1 implementation
1 | Signed-off-by: Mikhail Gusarov <dotted...@dottedmag.net> |
2 | --- |
3 | configure.ac | 9 +++++++++ |
4 | include/dix-config.h.in | 3 +++ |
5 | render/glyph.c | 12 ++++++++++-- |
6 | 3 files changed, 22 insertions(+), 2 deletions(-) |
7 | |
8 | diff --git a/configure.ac b/configure.ac |
9 | index f2718b8..9938fce 100644 |
10 | --- a/configure.ac |
11 | +++ b/configure.ac |
12 | @@ -1104,6 +1104,15 @@ if test "x$SHA1_LIB" = "x" ; then |
13 | [Use libmd SHA1 functions instead of OpenSSL libcrypto])]) |
14 | fi |
15 | |
16 | +# |
17 | +# libsha1 is SHA1-only tiny library. Useful for embedded systems. |
18 | +# |
19 | +if test "x$SHA1_LIB" = "x"; then |
20 | + AC_CHECK_LIB([sha1], [sha1_begin], [SHA1_LIB="-lsha1" |
21 | + AC_DEFINE([HAVE_SHA1_IN_LIBSHA1], [1], |
22 | + [Use libsha1 instead of OpenSSL libcrypto])]) |
23 | +fi |
24 | + |
25 | if test "x$SHA1_LIB" = "x" ; then |
26 | PKG_CHECK_EXISTS([OPENSSL], [openssl], [HAVE_OPENSSL_PKC=yes], |
27 | [HAVE_OPENSSL_PKC=no]) |
28 | diff --git a/include/dix-config.h.in b/include/dix-config.h.in |
29 | index 2515d83..025d16c 100644 |
30 | --- a/include/dix-config.h.in |
31 | +++ b/include/dix-config.h.in |
32 | @@ -157,6 +157,9 @@ |
33 | /* Define to use libmd SHA1 functions instead of OpenSSL libcrypto */ |
34 | #undef HAVE_SHA1_IN_LIBMD |
35 | |
36 | +/* Define to use libsha1 functions instead of OpenSSL libcrypto */ |
37 | +#undef HAVE_SHA1_IN_LIBSHA1 |
38 | + |
39 | /* Define to 1 if you have the `shmctl64' function. */ |
40 | #undef HAVE_SHMCTL64 |
41 | |
42 | diff --git a/render/glyph.c b/render/glyph.c |
43 | index 87b332e..2a2dd9e 100644 |
44 | --- a/render/glyph.c |
45 | +++ b/render/glyph.c |
46 | @@ -26,8 +26,10 @@ |
47 | #include <dix-config.h> |
48 | #endif |
49 | |
50 | -#ifdef HAVE_SHA1_IN_LIBMD /* Use libmd for SHA1 */ |
51 | +#if defined(HAVE_SHA1_IN_LIBMD) /* Use libmd for SHA1 */ |
52 | # include <sha1.h> |
53 | +#elif defined(HAVE_SHA1_IN_LIBSHA1) |
54 | +# include <libsha1.h> |
55 | #else /* Use OpenSSL's libcrypto */ |
56 | # include <stddef.h> /* buggy openssl/sha.h wants size_t */ |
57 | # include <openssl/sha.h> |
58 | @@ -198,13 +200,19 @@ HashGlyph (xGlyphInfo *gi, |
59 | unsigned long size, |
60 | unsigned char sha1[20]) |
61 | { |
62 | -#ifdef HAVE_SHA1_IN_LIBMD /* Use libmd for SHA1 */ |
63 | +#if defined(HAVE_SHA1_IN_LIBMD) /* Use libmd for SHA1 */ |
64 | SHA1_CTX ctx; |
65 | |
66 | SHA1Init (&ctx); |
67 | SHA1Update (&ctx, gi, sizeof (xGlyphInfo)); |
68 | SHA1Update (&ctx, bits, size); |
69 | SHA1Final (sha1, &ctx); |
70 | +#elif defined(HAVE_SHA1_IN_LIBSHA1) |
71 | + sha1_ctx ctx; |
72 | + sha1_begin (&ctx); |
73 | + sha1_hash (gi, sizeof(xGlyphInfo), &ctx); |
74 | + sha1_hash (bits, size, &ctx); |
75 | + sha1_end (sha1, &ctx); |
76 | #else /* Use OpenSSL's libcrypto */ |
77 | SHA_CTX ctx; |
78 | int success; |
79 | -- |
80 | 1.6.2 |