Signed-off-by: Mikhail Gusarov --- configure.ac | 9 +++++++++ include/dix-config.h.in | 3 +++ render/glyph.c | 12 ++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index f2718b8..9938fce 100644 --- a/configure.ac +++ b/configure.ac @@ -1104,6 +1104,15 @@ if test "x$SHA1_LIB" = "x" ; then [Use libmd SHA1 functions instead of OpenSSL libcrypto])]) fi +# +# libsha1 is SHA1-only tiny library. Useful for embedded systems. +# +if test "x$SHA1_LIB" = "x"; then + AC_CHECK_LIB([sha1], [sha1_begin], [SHA1_LIB="-lsha1" + AC_DEFINE([HAVE_SHA1_IN_LIBSHA1], [1], + [Use libsha1 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]) diff --git a/include/dix-config.h.in b/include/dix-config.h.in index 2515d83..025d16c 100644 --- a/include/dix-config.h.in +++ b/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 libsha1 functions instead of OpenSSL libcrypto */ +#undef HAVE_SHA1_IN_LIBSHA1 + /* Define to 1 if you have the `shmctl64' function. */ #undef HAVE_SHMCTL64 diff --git a/render/glyph.c b/render/glyph.c index 87b332e..2a2dd9e 100644 --- a/render/glyph.c +++ b/render/glyph.c @@ -26,8 +26,10 @@ #include #endif -#ifdef HAVE_SHA1_IN_LIBMD /* Use libmd for SHA1 */ +#if defined(HAVE_SHA1_IN_LIBMD) /* Use libmd for SHA1 */ # include +#elif defined(HAVE_SHA1_IN_LIBSHA1) +# include #else /* Use OpenSSL's libcrypto */ # include /* buggy openssl/sha.h wants size_t */ # include @@ -198,13 +200,19 @@ HashGlyph (xGlyphInfo *gi, unsigned long size, unsigned char sha1[20]) { -#ifdef HAVE_SHA1_IN_LIBMD /* Use libmd for SHA1 */ +#if defined(HAVE_SHA1_IN_LIBMD) /* Use libmd for SHA1 */ SHA1_CTX ctx; SHA1Init (&ctx); SHA1Update (&ctx, gi, sizeof (xGlyphInfo)); SHA1Update (&ctx, bits, size); SHA1Final (sha1, &ctx); +#elif defined(HAVE_SHA1_IN_LIBSHA1) + sha1_ctx ctx; + sha1_begin (&ctx); + sha1_hash (gi, sizeof(xGlyphInfo), &ctx); + sha1_hash (bits, size, &ctx); + sha1_end (sha1, &ctx); #else /* Use OpenSSL's libcrypto */ SHA_CTX ctx; int success; -- 1.6.2