From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: git@vger.kernel.org
Cc: "Derrick Stolee" <stolee@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Duy Nguyen" <pclouds@gmail.com>,
"SZEDER Gábor" <szeder.dev@gmail.com>
Subject: [PATCH v3 12/12] hash: add an SHA-256 implementation using OpenSSL
Date: Mon, 22 Oct 2018 02:43:42 +0000 [thread overview]
Message-ID: <20181022024342.489564-13-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <20181022024342.489564-1-sandals@crustytoothpaste.net>
We already have OpenSSL routines available for SHA-1, so add routines
for SHA-256 as well.
On a Core i7-6600U, this SHA-256 implementation compares favorably to
the SHA1DC SHA-1 implementation:
SHA-1: 157 MiB/s (64 byte chunks); 337 MiB/s (16 KiB chunks)
SHA-256: 165 MiB/s (64 byte chunks); 408 MiB/s (16 KiB chunks)
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
Makefile | 7 +++++++
hash.h | 2 ++
2 files changed, 9 insertions(+)
diff --git a/Makefile b/Makefile
index 5a07e03100..36fd3a149b 100644
--- a/Makefile
+++ b/Makefile
@@ -183,6 +183,8 @@ all::
#
# Define GCRYPT_SHA256 to use the SHA-256 routines in libgcrypt.
#
+# Define OPENSSL_SHA256 to use the SHA-256 routines in OpenSSL.
+#
# Define NEEDS_CRYPTO_WITH_SSL if you need -lcrypto when using -lssl (Darwin).
#
# Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
@@ -1638,6 +1640,10 @@ endif
endif
endif
+ifdef OPENSSL_SHA256
+ EXTLIBS += $(LIB_4_CRYPTO)
+ BASIC_CFLAGS += -DSHA256_OPENSSL
+else
ifdef GCRYPT_SHA256
BASIC_CFLAGS += -DSHA256_GCRYPT
EXTLIBS += -lgcrypt
@@ -1645,6 +1651,7 @@ else
LIB_OBJS += sha256/block/sha256.o
BASIC_CFLAGS += -DSHA256_BLK
endif
+endif
ifdef SHA1_MAX_BLOCK_SIZE
LIB_OBJS += compat/sha1-chunked.o
diff --git a/hash.h b/hash.h
index 2ef098052d..adde708cf2 100644
--- a/hash.h
+++ b/hash.h
@@ -17,6 +17,8 @@
#if defined(SHA256_GCRYPT)
#include "sha256/gcrypt.h"
+#elif defined(SHA256_OPENSSL)
+#include <openssl/sha.h>
#else
#include "sha256/block/sha256.h"
#endif
prev parent reply other threads:[~2018-10-22 2:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-22 2:43 [PATCH v3 00/12] Base SHA-256 implementation brian m. carlson
2018-10-22 2:43 ` [PATCH v3 01/12] sha1-file: rename algorithm to "sha1" brian m. carlson
2018-10-22 2:43 ` [PATCH v3 02/12] sha1-file: provide functions to look up hash algorithms brian m. carlson
2018-10-22 2:43 ` [PATCH v3 03/12] hex: introduce functions to print arbitrary hashes brian m. carlson
2018-10-22 2:43 ` [PATCH v3 04/12] cache: make hashcmp and hasheq work with larger hashes brian m. carlson
2018-10-22 2:43 ` [PATCH v3 05/12] t: add basic tests for our SHA-1 implementation brian m. carlson
2018-10-22 2:43 ` [PATCH v3 06/12] t: make the sha1 test-tool helper generic brian m. carlson
2018-10-22 2:43 ` [PATCH v3 07/12] sha1-file: add a constant for hash block size brian m. carlson
2018-10-22 2:43 ` [PATCH v3 08/12] t/helper: add a test helper to compute hash speed brian m. carlson
2018-10-22 2:43 ` [PATCH v3 09/12] commit-graph: convert to using the_hash_algo brian m. carlson
2018-10-24 13:22 ` Derrick Stolee
2018-10-22 2:43 ` [PATCH v3 10/12] Add a base implementation of SHA-256 support brian m. carlson
2018-10-22 9:44 ` SZEDER Gábor
2018-10-23 0:43 ` brian m. carlson
2018-10-27 14:34 ` Jakub Narebski
2018-10-22 2:43 ` [PATCH v3 11/12] sha256: add an SHA-256 implementation using libgcrypt brian m. carlson
2018-10-22 2:43 ` brian m. carlson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181022024342.489564-13-sandals@crustytoothpaste.net \
--to=sandals@crustytoothpaste.net \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=stolee@gmail.com \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).