File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,6 +144,10 @@ all::
144144# Define PPC_SHA1 environment variable when running make to make use of
145145# a bundled SHA1 routine optimized for PowerPC.
146146#
147+ # Define SHA1_MAX_BLOCK_SIZE to limit the amount of data that will be hashed
148+ # in one call to the platform's SHA1_Update(). e.g. APPLE_COMMON_CRYPTO
149+ # wants 'SHA1_MAX_BLOCK_SIZE=1024L*1024L*1024L' defined.
150+ #
147151# Define NEEDS_CRYPTO_WITH_SSL if you need -lcrypto when using -lssl (Darwin).
148152#
149153# Define NEEDS_SSL_WITH_CRYPTO if you need -lssl when using -lcrypto (Darwin).
@@ -1340,6 +1344,11 @@ ifdef NO_POSIX_GOODIES
13401344 BASIC_CFLAGS += -DNO_POSIX_GOODIES
13411345endif
13421346
1347+ ifdef APPLE_COMMON_CRYPTO
1348+ # Apple CommonCrypto requires chunking
1349+ SHA1_MAX_BLOCK_SIZE = 1024L*1024L*1024L
1350+ endif
1351+
13431352ifdef BLK_SHA1
13441353 SHA1_HEADER = "block-sha1/sha1.h"
13451354 LIB_OBJS += block-sha1/sha1.o
@@ -1358,6 +1367,10 @@ endif
13581367endif
13591368endif
13601369
1370+ ifdef SHA1_MAX_BLOCK_SIZE
1371+ LIB_OBJS += compat/sha1-chunked.o
1372+ BASIC_CFLAGS += -DSHA1_MAX_BLOCK_SIZE="$(SHA1_MAX_BLOCK_SIZE)"
1373+ endif
13611374ifdef NO_PERL_MAKEMAKER
13621375 export NO_PERL_MAKEMAKER
13631376endif
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ void blk_SHA1_Init(blk_SHA_CTX *ctx);
1616void blk_SHA1_Update (blk_SHA_CTX * ctx , const void * dataIn , unsigned long len );
1717void blk_SHA1_Final (unsigned char hashout [20 ], blk_SHA_CTX * ctx );
1818
19- #define git_SHA_CTX blk_SHA_CTX
20- #define git_SHA1_Init blk_SHA1_Init
21- #define git_SHA1_Update blk_SHA1_Update
22- #define git_SHA1_Final blk_SHA1_Final
19+ #define platform_SHA_CTX blk_SHA_CTX
20+ #define platform_SHA1_Init blk_SHA1_Init
21+ #define platform_SHA1_Update blk_SHA1_Update
22+ #define platform_SHA1_Final blk_SHA1_Final
Original file line number Diff line number Diff line change 1111#include "string-list.h"
1212
1313#include SHA1_HEADER
14- #ifndef git_SHA_CTX
15- #define git_SHA_CTX SHA_CTX
16- #define git_SHA1_Init SHA1_Init
17- #define git_SHA1_Update SHA1_Update
18- #define git_SHA1_Final SHA1_Final
14+ #ifndef platform_SHA_CTX
15+ /*
16+ * platform's underlying implementation of SHA-1; could be OpenSSL,
17+ * blk_SHA, Apple CommonCrypto, etc... Note that including
18+ * SHA1_HEADER may have already defined platform_SHA_CTX for our
19+ * own implementations like block-sha1 and ppc-sha1, so we list
20+ * the default for OpenSSL compatible SHA-1 implementations here.
21+ */
22+ #define platform_SHA_CTX SHA_CTX
23+ #define platform_SHA1_Init SHA1_Init
24+ #define platform_SHA1_Update SHA1_Update
25+ #define platform_SHA1_Final SHA1_Final
26+ #endif
27+
28+ #define git_SHA_CTX platform_SHA_CTX
29+ #define git_SHA1_Init platform_SHA1_Init
30+ #define git_SHA1_Update platform_SHA1_Update
31+ #define git_SHA1_Final platform_SHA1_Final
32+
33+ #ifdef SHA1_MAX_BLOCK_SIZE
34+ #include "compat/sha1-chunked.h"
35+ #undef git_SHA1_Update
36+ #define git_SHA1_Update git_SHA1_Update_Chunked
1937#endif
2038
2139#include <zlib.h>
Original file line number Diff line number Diff line change 1616#undef TYPE_BOOL
1717#endif
1818
19+ #ifndef SHA1_MAX_BLOCK_SIZE
20+ #error Using Apple Common Crypto library requires setting SHA1_MAX_BLOCK_SIZE
21+ #endif
22+
1923#ifdef APPLE_LION_OR_NEWER
2024#define git_CC_error_check (pattern , err ) \
2125 do { \
Original file line number Diff line number Diff line change 1+ #include "cache.h"
2+
3+ int git_SHA1_Update_Chunked (platform_SHA_CTX * c , const void * data , size_t len )
4+ {
5+ size_t nr ;
6+ size_t total = 0 ;
7+ const char * cdata = (const char * )data ;
8+
9+ while (len ) {
10+ nr = len ;
11+ if (nr > SHA1_MAX_BLOCK_SIZE )
12+ nr = SHA1_MAX_BLOCK_SIZE ;
13+ platform_SHA1_Update (c , cdata , nr );
14+ total += nr ;
15+ cdata += nr ;
16+ len -= nr ;
17+ }
18+ return total ;
19+ }
Original file line number Diff line number Diff line change 1+
2+ int git_SHA1_Update_Chunked (platform_SHA_CTX * c , const void * data , size_t len );
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ int ppc_SHA1_Init(ppc_SHA_CTX *c);
1919int ppc_SHA1_Update (ppc_SHA_CTX * c , const void * p , unsigned long n );
2020int ppc_SHA1_Final (unsigned char * hash , ppc_SHA_CTX * c );
2121
22- #define git_SHA_CTX ppc_SHA_CTX
23- #define git_SHA1_Init ppc_SHA1_Init
24- #define git_SHA1_Update ppc_SHA1_Update
25- #define git_SHA1_Final ppc_SHA1_Final
22+ #define platform_SHA_CTX ppc_SHA_CTX
23+ #define platform_SHA1_Init ppc_SHA1_Init
24+ #define platform_SHA1_Update ppc_SHA1_Update
25+ #define platform_SHA1_Final ppc_SHA1_Final
You can’t perform that action at this time.
0 commit comments