[PATCH] darwin: Use CommonCrypto to compute SHA1

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

 



From d5b06f19d5043a261ff007f19dfe88ae0ddde00f Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston <jeremyhu@xxxxxxxxx>
Date: Mon, 8 Mar 2010 15:10:54 -0800
Subject: [PATCH] darwin: Use CommonCrypto to compute SHA1

Signed-off-by: Jeremy Huddleston <jeremyhu@xxxxxxxxx>
Reviewed-by: Kevin Van Vechten <kvv@xxxxxxxxx>
---
 Makefile |   14 ++++++++++++++
 cache.h  |    7 +++++++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index f64610a..bb4a1f0 100644
--- a/Makefile
+++ b/Makefile
@@ -91,6 +91,10 @@ all::
# Define PPC_SHA1 environment variable when running make to make use of
 # a bundled SHA1 routine optimized for PowerPC.
 #
+# Define COMMONCRYPTO_SHA1 environment variable when running make to make
+# use of the Darwin/Mac OS X Common Cryptography library for SHA1
+# computation (instead of libcrypto).
+#
# 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).
@@ -775,6 +779,7 @@ ifeq ($(uname_S),SCO_SV)
 	TAR = gtar
 endif
 ifeq ($(uname_S),Darwin)
+	COMMONCRYPTO_SHA1 = YesPlease
 	NEEDS_CRYPTO_WITH_SSL = YesPlease
 	NEEDS_SSL_WITH_CRYPTO = YesPlease
 	NEEDS_LIBICONV = YesPlease
@@ -1155,7 +1160,11 @@ ifndef NO_OPENSSL
 	endif
 else
 	BASIC_CFLAGS += -DNO_OPENSSL
+ifndef COMMONCRYPTO_SHA1
+ifndef PPC_SHA1
 	BLK_SHA1 = 1
+endif
+endif
 	OPENSSL_LIBSSL =
 endif
 ifdef NEEDS_SSL_WITH_CRYPTO
@@ -1313,10 +1322,15 @@ ifdef PPC_SHA1
 	LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
 	LIB_H += ppc/sha1.h
 else
+ifdef COMMONCRYPTO_SHA1
+	SHA1_HEADER = <CommonCrypto/CommonDigest.h>
+	BASIC_CFLAGS += -DUSE_COMMONCRYPTO_SHA1
+else
 	SHA1_HEADER = <openssl/sha.h>
 	EXTLIBS += $(LIB_4_CRYPTO)
 endif
 endif
+endif
 ifdef NO_PERL_MAKEMAKER
 	export NO_PERL_MAKEMAKER
 endif
diff --git a/cache.h b/cache.h
index 89f6a40..135b25e 100644
--- a/cache.h
+++ b/cache.h
@@ -8,11 +8,18 @@

 #include SHA1_HEADER
 #ifndef git_SHA_CTX
+#ifdef USE_COMMONCRYPTO_SHA1
+#define git_SHA_CTX	CC_SHA1_CTX
+#define git_SHA1_Init	CC_SHA1_Init
+#define git_SHA1_Update	CC_SHA1_Update
+#define git_SHA1_Final	CC_SHA1_Final
+#else
 #define git_SHA_CTX	SHA_CTX
 #define git_SHA1_Init	SHA1_Init
 #define git_SHA1_Update	SHA1_Update
 #define git_SHA1_Final	SHA1_Final
 #endif
+#endif

 #include <zlib.h>
 #if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
--
1.6.3.1



Attachment: 0001-darwin-Use-CommonCrypto-to-compute-SHA1.patch
Description: Binary data

<<attachment: smime.p7s>>


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]