Skip to content

Commit 527b171

Browse files
committed
Merge branch 'da/darwin'
Newer MacOS X encourages the programs to compile and link with their CommonCrypto, not with OpenSSL. * da/darwin: imap-send: eliminate HMAC deprecation warnings on Mac OS X cache.h: eliminate SHA-1 deprecation warnings on Mac OS X Makefile: add support for Apple CommonCrypto facility Makefile: fix default regex settings on Darwin
2 parents 29d5350 + be4c828 commit 527b171

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ all::
140140
# specify your own (or DarwinPort's) include directories and
141141
# library directories by defining CFLAGS and LDFLAGS appropriately.
142142
#
143+
# Define NO_APPLE_COMMON_CRYPTO if you are building on Darwin/Mac OS X
144+
# and do not want to use Apple's CommonCrypto library. This allows you
145+
# to provide your own OpenSSL library, for example from MacPorts.
146+
#
143147
# Define BLK_SHA1 environment variable to make use of the bundled
144148
# optimized C SHA1 routine.
145149
#
@@ -1056,6 +1060,11 @@ ifeq ($(uname_S),Darwin)
10561060
BASIC_LDFLAGS += -L/opt/local/lib
10571061
endif
10581062
endif
1063+
ifndef NO_APPLE_COMMON_CRYPTO
1064+
APPLE_COMMON_CRYPTO = YesPlease
1065+
COMPAT_CFLAGS += -DAPPLE_COMMON_CRYPTO
1066+
endif
1067+
NO_REGEX = YesPlease
10591068
PTHREAD_LIBS =
10601069
endif
10611070

@@ -1389,11 +1398,17 @@ ifdef PPC_SHA1
13891398
SHA1_HEADER = "ppc/sha1.h"
13901399
LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
13911400
LIB_H += ppc/sha1.h
1401+
else
1402+
ifdef APPLE_COMMON_CRYPTO
1403+
COMPAT_CFLAGS += -DCOMMON_DIGEST_FOR_OPENSSL
1404+
SHA1_HEADER = <CommonCrypto/CommonDigest.h>
13921405
else
13931406
SHA1_HEADER = <openssl/sha.h>
13941407
EXTLIBS += $(LIB_4_CRYPTO)
13951408
endif
13961409
endif
1410+
endif
1411+
13971412
ifdef NO_PERL_MAKEMAKER
13981413
export NO_PERL_MAKEMAKER
13991414
endif

imap-send.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,18 @@
2929
#ifdef NO_OPENSSL
3030
typedef void *SSL;
3131
#else
32+
#ifdef APPLE_COMMON_CRYPTO
33+
#include <CommonCrypto/CommonHMAC.h>
34+
#define HMAC_CTX CCHmacContext
35+
#define HMAC_Init(hmac, key, len, algo) CCHmacInit(hmac, algo, key, len)
36+
#define HMAC_Update CCHmacUpdate
37+
#define HMAC_Final(hmac, hash, ptr) CCHmacFinal(hmac, hash)
38+
#define HMAC_CTX_cleanup(ignore)
39+
#define EVP_md5() kCCHmacAlgMD5
40+
#else
3241
#include <openssl/evp.h>
3342
#include <openssl/hmac.h>
43+
#endif
3444
#include <openssl/x509v3.h>
3545
#endif
3646

0 commit comments

Comments
 (0)