From e9551b12f8c17876a32e1cd075c83af3e7950980 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 8 Dec 2013 00:05:36 -0800 Subject: Use libcrypto's checksum implementations if available, for speed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On commonly used platform libcrypto uses architecture-specific assembly code, which is significantly faster than the C code we were using. See Pádraig Brady's note in . Merge from gnulib, incorporating: 2013-12-07 md5, sha1, sha256, sha512: add gl_SET_CRYPTO_CHECK_DEFAULT 2013-12-07 md5, sha1, sha256, sha512: add 'auto', and set-default method 2013-12-04 include_next: minimize code duplication 2013-12-03 md5, sha1, sha256, sha512: support mandating use of openssl 2013-12-02 md5, sha1, sha256, sha512: use openssl routines if available * configure.ac (--without-all): Set with_openssl_default too. Use gl_SET_CRYPTO_CHECK_DEFAULT to default to 'auto'. (HAVE_LIB_CRYPTO): New var. Say whether Emacs is configured to use a crypto library. * lib/gl_openssl.h, m4/absolute-header.m4, m4/gl-openssl.m4: New files, copied from gnulib. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * lib/md5.c, lib/md5.h, lib/sha1.c, lib/sha1.h: * lib/sha256.c, lib/sha256.h, lib/sha512.c, lib/sha512.h: * m4/include_next.m4, m4/md5.m4, m4/sha1.m4, m4/sha256.m4, m4/sha512.m4: Update from gnulib. * src/Makefile.in (LIB_CRYPTO): New macro. (LIBES): Use it. --- lib/sha256.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/sha256.c') diff --git a/lib/sha256.c b/lib/sha256.c index 4b2cee37fb5..9d6912cdc79 100644 --- a/lib/sha256.c +++ b/lib/sha256.c @@ -22,6 +22,9 @@ #include +#if HAVE_OPENSSL_SHA256 +# define GL_OPENSSL_INLINE _GL_EXTERN_INLINE +#endif #include "sha256.h" #include @@ -45,6 +48,7 @@ # error "invalid BLOCKSIZE" #endif +#if ! HAVE_OPENSSL_SHA256 /* This array contains the bytes used to pad the buffer to the next 64-byte boundary. */ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; @@ -163,6 +167,7 @@ sha224_finish_ctx (struct sha256_ctx *ctx, void *resbuf) sha256_conclude_ctx (ctx); return sha224_read_ctx (ctx, resbuf); } +#endif /* Compute SHA256 message digest for bytes read from STREAM. The resulting message digest number will be written into the 32 bytes @@ -308,6 +313,7 @@ sha224_stream (FILE *stream, void *resblock) return 0; } +#if ! HAVE_OPENSSL_SHA256 /* Compute SHA512 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message @@ -567,3 +573,4 @@ sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) h = ctx->state[7] += h; } } +#endif -- cgit v1.2.3