[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] use libcrypto routines in gnulib

From: Pádraig Brady
Subject: [PATCH] use libcrypto routines in gnulib
Date: Mon, 02 Dec 2013 14:12:31 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

The speed of md5 and sha* hashes has lagged a bit in gnulib.
So to address that and to take advantage of the architecture
specific assembly used in libcrypto, the attached gnulib patch
allows projects to configure --with-openssl to use that if
available or fall back to the existing internal routines.

There should be no issue with licensing as this is
just making use of the libcrypto system library where available:

I tested this with coreutils, with openssl-1.0.0j on an i3-2310M
and get a nice performance boost of about 40%:

$ time src/sha1sum.old 
SHA1 (/home/padraig/Fedora-Live-Desktop-x86_64-20-Beta-5.iso) = 
real    0m4.692s
user    0m4.499s
sys     0m0.162s

$ time src/sha1sum --tag ~/Fedora-Live-Desktop-x86_64-20-Beta-5.iso
SHA1 (/home/padraig/Fedora-Live-Desktop-x86_64-20-Beta-5.iso) = 
real    0m2.685s
user    0m2.512s
sys     0m0.170s

$ time openssl sha1 
real    0m2.697s
user    0m2.538s
sys     0m0.157s

To use this from coreutils I configure with --with-openssl
and add in the appropriate libs as follows.
Note since the new libs are required, then is one of the reasons
I didn't enable this by default.  A related question though
is I'd like coreutils to change the default to enable this by default.
What would be the best way to do that, while still allowing users
to --with-openssl=no


diff --git a/src/ b/src/
index 1315e11..db3a2b7 100644
--- a/src/
+++ b/src/
@@ -293,6 +293,15 @@ src_stdbuf_LDADD += $(LIBICONV)
 src_timeout_LDADD += $(LIBICONV)
 src_truncate_LDADD += $(LIBICONV)

+# for libcrypto
+src_md5sum_LDADD += $(LIB_CRYPTO_MD5)
+src_sort_LDADD += $(LIB_CRYPTO_MD5)
+src_sha1sum_LDADD += $(LIB_CRYPTO_SHA1)
+src_sha224sum_LDADD += $(LIB_CRYPTO_SHA256)
+src_sha256sum_LDADD += $(LIB_CRYPTO_SHA256)
+src_sha384sum_LDADD += $(LIB_CRYPTO_SHA512)
+src_sha512sum_LDADD += $(LIB_CRYPTO_SHA512)
 # for canon_host
 src_pinky_LDADD += $(GETADDRINFO_LIB)

Attachment: gnulib-libcrypto.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]