Re: [PATCH v2 12/13] hash: add an SHA-256 implementation using OpenSSL
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Oct 16, 2018, 15:36 UTC
- Message-ID
- <CACsJy8B3cK7VUfRYBa+Tqnke6gJ6FT9u+AsffAcGJQhQ5wcjvQ@mail.gmail.com>
- In-Reply-To
- <20181015021900.1030041-13-sandals@crustytoothpaste.net>
On Mon, Oct 15, 2018 at 4:22 AM brian m. carlson <sandals@crustytoothpaste.net> wrote:
> > We already have OpenSSL routines available for SHA-1, so add routines > for SHA-256 as well.
Since we have "hash-speed" tool now, it would be great to keep some numbers of these hash implementations in the commit message (and maybe sha1 as well just for comparison).
Show 52 quoted lines
> > 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 3d91555a81..3164e2aeee 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 9df562f2f6..9df06d56b4 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
-- Duy