{"thread":{"id":"33860","subject":"[PATCH v7 1/3] Makefile: add support for Apple CommonCrypto facility","startedAt":"2013-05-18T00:32:35Z","lastAt":"2013-05-18T01:58:44Z","messageCount":5,"participants":["Eric Sunshine","Junio C Hamano"],"isPatch":true,"patchVersion":7,"patchTotal":3},"messages":[{"id":"217767","messageId":"1368837158-13915-1-git-send-email-sunshine@sunshineco.com","threadId":"33860","inReplyTo":null,"subject":"[PATCH v7 0/3] Begin replacing OpenSSL with CommonCrypto","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-05-18T00:32:35Z","receivedAt":"2013-05-18T00:32:35Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"This is a re-roll of David Aguilar's patch series which eliminates some\nof the OpenSSL deprecation warnings on Mac OS X.\n\nPatch 1 is new. It extracts the CommonCrypto-related Makefile\nboilerplate, from his SHA-1-related patch, into a distinct introductory\npatch which can then be referenced by subsequent patches.\n\nPatch 2, SHA-1 warning elimination, is effectively unchanged.\n\nPatch 3, HMAC warning elimination, no longer abuses\nCOMMON_DIGEST_FOR_OPENSSL, which is an implementation detail of\npatch 2. Instead, it checks for NO_APPLE_COMMON_CRYPTO introduced in\npatch 1.\n\nDavid Aguilar (3):\n  Makefile: add support for Apple CommonCrypto facility\n  cache.h: eliminate SHA-1 deprecation warnings on Mac OS X\n  imap-send: eliminate HMAC deprecation warnings on Mac OS X\n\n Makefile    | 15 +++++++++++++++\n imap-send.c | 10 ++++++++++\n 2 files changed, 25 insertions(+)\n\n-- \n1.8.2.3\n"},{"id":"217766","messageId":"1368837158-13915-2-git-send-email-sunshine@sunshineco.com","threadId":"33860","inReplyTo":"1368837158-13915-1-git-send-email-sunshine@sunshineco.com","subject":"[PATCH v7 1/3] Makefile: add support for Apple CommonCrypto facility","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-05-18T00:32:36Z","receivedAt":"2013-05-18T00:32:36Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"From: David Aguilar <davvid@gmail.com>\n\nAs of Mac OS X 10.7, Apple deprecated all OpenSSL functions due to\nOpenSSL ABI instability, thus leading to build warnings.  As a\nreplacement, Apple encourages developers to migrate to its own (stable)\nCommonCrypto facility.\n\nIntroduce boilerplate which controls whether Apple's CommonCrypto\nfacility is employed (enabled by default).  Also add a\nNO_APPLE_COMMON_CRYPTO flag which the user can tweak to override the\ndefault if OpenSSL is instead preferred.\n\n[es: extracted CommonCrypto-related Makefile boilerplate into separate\nintroductory patch]\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n Makefile | 9 +++++++++\n 1 file changed, 9 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex f698c1a..2178c2c 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -137,6 +137,10 @@ all::\n # specify your own (or DarwinPort's) include directories and\n # library directories by defining CFLAGS and LDFLAGS appropriately.\n #\n+# Define NO_APPLE_COMMON_CRYPTO if you are building on Darwin/Mac OS X\n+# and do not want to use Apple's CommonCrypto library.  This allows you\n+# to provide your own OpenSSL library, for example from MacPorts.\n+#\n # Define BLK_SHA1 environment variable to make use of the bundled\n # optimized C SHA1 routine.\n #\n@@ -1054,6 +1058,11 @@ ifeq ($(uname_S),Darwin)\n \t\t\tBASIC_LDFLAGS += -L/opt/local/lib\n \t\tendif\n \tendif\n+\tifndef NO_APPLE_COMMON_CRYPTO\n+\t\tAPPLE_COMMON_CRYPTO = YesPlease\n+\telse\n+\t\tCOMPAT_CFLAGS += -DNO_APPLE_COMMON_CRYPTO\n+\tendif\n \tNO_REGEX = YesPlease\n \tPTHREAD_LIBS =\n endif\n-- \n1.8.2.3\n"},{"id":"217768","messageId":"1368837158-13915-3-git-send-email-sunshine@sunshineco.com","threadId":"33860","inReplyTo":"1368837158-13915-1-git-send-email-sunshine@sunshineco.com","subject":"[PATCH v7 2/3] cache.h: eliminate SHA-1 deprecation warnings on Mac OS X","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-05-18T00:32:37Z","receivedAt":"2013-05-18T00:32:37Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"From: David Aguilar <davvid@gmail.com>\n\nAs of Mac OS X 10.7, Apple deprecated all OpenSSL functions due to\nOpenSSL ABI instability, thus leading to build diagnostics such as:\n\n\twarning: 'SHA1_Init' is deprecated\n\t(declared at /usr/include/openssl/sha.h:121)\n\nSilence the warnings by using Apple's CommonCrypto SHA-1 replacement\nfunctions for SHA1_Init(), SHA1_Update(), and SHA1_Final().\n\nCOMMON_DIGEST_FOR_OPENSSL is defined to instruct\n<CommonCrypto/CommonDigest.h> to provide compatibility macros\nassociating OpenSSL SHA-1 functions with their CommonCrypto\ncounterparts.\n\n[es: reworded commit message]\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n Makefile | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex 2178c2c..7a03fe9 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1398,10 +1398,16 @@ ifdef PPC_SHA1\n \tLIB_OBJS += ppc/sha1.o ppc/sha1ppc.o\n \tLIB_H += ppc/sha1.h\n else\n+ifdef APPLE_COMMON_CRYPTO\n+\tCOMPAT_CFLAGS += -DCOMMON_DIGEST_FOR_OPENSSL\n+\tSHA1_HEADER = <CommonCrypto/CommonDigest.h>\n+else\n \tSHA1_HEADER = <openssl/sha.h>\n \tEXTLIBS += $(LIB_4_CRYPTO)\n endif\n endif\n+endif\n+\n ifdef NO_PERL_MAKEMAKER\n \texport NO_PERL_MAKEMAKER\n endif\n-- \n1.8.2.3\n"},{"id":"217769","messageId":"1368837158-13915-4-git-send-email-sunshine@sunshineco.com","threadId":"33860","inReplyTo":"1368837158-13915-1-git-send-email-sunshine@sunshineco.com","subject":"[PATCH v7 3/3] imap-send: eliminate HMAC deprecation warnings on Mac OS X","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-05-18T00:32:38Z","receivedAt":"2013-05-18T00:32:38Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"From: David Aguilar <davvid@gmail.com>\n\nAs of Mac OS X 10.7, Apple deprecated all OpenSSL functions due to\nOpenSSL ABI instability.  Silence the warnings by using Apple's\nCommonCrypto HMAC replacement functions.\n\n[es: reworded commit message; eliminated abuse of\nCOMMON_DIGEST_FOR_OPENSSL by checking NO_APPLE_COMMON_CRYPTO instead]\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n imap-send.c | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\ndiff --git a/imap-send.c b/imap-send.c\nindex d9bcfb4..642448c 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -29,8 +29,18 @@\n #ifdef NO_OPENSSL\n typedef void *SSL;\n #else\n+#ifndef NO_APPLE_COMMON_CRYPTO\n+#include <CommonCrypto/CommonHMAC.h>\n+#define HMAC_CTX CCHmacContext\n+#define HMAC_Init(hmac, key, len, algo) CCHmacInit(hmac, algo, key, len)\n+#define HMAC_Update CCHmacUpdate\n+#define HMAC_Final(hmac, hash, ptr) CCHmacFinal(hmac, hash)\n+#define HMAC_CTX_cleanup\n+#define EVP_md5() kCCHmacAlgMD5\n+#else\n #include <openssl/evp.h>\n #include <openssl/hmac.h>\n+#endif\n #include <openssl/x509v3.h>\n #endif\n \n-- \n1.8.2.3\n"},{"id":"217773","messageId":"7v4ne1vyjv.fsf@alter.siamese.dyndns.org","threadId":"33860","inReplyTo":"1368837158-13915-4-git-send-email-sunshine@sunshineco.com","subject":"Re: [PATCH v7 3/3] imap-send: eliminate HMAC deprecation warnings on Mac OS X","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-05-18T01:58:44Z","receivedAt":"2013-05-18T01:58:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> From: David Aguilar <davvid@gmail.com>\n>\n> As of Mac OS X 10.7, Apple deprecated all OpenSSL functions due to\n> OpenSSL ABI instability.  Silence the warnings by using Apple's\n> CommonCrypto HMAC replacement functions.\n>\n> [es: reworded commit message; eliminated abuse of\n> COMMON_DIGEST_FOR_OPENSSL by checking NO_APPLE_COMMON_CRYPTO instead]\n>\n> Signed-off-by: David Aguilar <davvid@gmail.com>\n> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>\n> ---\n>  imap-send.c | 10 ++++++++++\n>  1 file changed, 10 insertions(+)\n>\n> diff --git a/imap-send.c b/imap-send.c\n> index d9bcfb4..642448c 100644\n> --- a/imap-send.c\n> +++ b/imap-send.c\n> @@ -29,8 +29,18 @@\n>  #ifdef NO_OPENSSL\n>  typedef void *SSL;\n>  #else\n> +#ifndef NO_APPLE_COMMON_CRYPTO\n> +#include <CommonCrypto/CommonHMAC.h>\n> +#define HMAC_CTX CCHmacContext\n> +#define HMAC_Init(hmac, key, len, algo) CCHmacInit(hmac, algo, key, len)\n> +#define HMAC_Update CCHmacUpdate\n> +#define HMAC_Final(hmac, hash, ptr) CCHmacFinal(hmac, hash)\n> +#define HMAC_CTX_cleanup\n> +#define EVP_md5() kCCHmacAlgMD5\n> +#else\n>  #include <openssl/evp.h>\n>  #include <openssl/hmac.h>\n> +#endif\n\nDoesn't this mean people on platforms that do not care what Apple\ndoes have to define NO_APPLE_COMMON_CRYPTO?\n\nHow about stopping this double-negation and do it more like this?\n\n * In Makefile (1/3), in uname_S == Darwin section, define\n   COMPAT_CFLAGS += DAPPLE_COMMON_CRYPTO by default, unless the\n   builder declines it with \"make NO_APPLE_COMMON_CRYPTO=NoThanks\"\n\n * Express this part as\n\n    #ifdef APPLE_COMMON_CRYPTO\n    ... do the common crypto thing ...\n    #else\n    ... everybody else ...\n    #endif\n\n>  #include <openssl/x509v3.h>\n>  #endif\n"}]}