{"thread":{"id":"33805","subject":"[PATCH v4 2/3] imap-send: eliminate HMAC deprecation warnings on OS X 10.8","startedAt":"2013-05-13T08:23:38Z","lastAt":"2013-05-14T07:22:00Z","messageCount":4,"participants":["David Aguilar","Eric Sunshine"],"isPatch":true,"patchVersion":4,"patchTotal":3},"messages":[{"id":"217138","messageId":"1368433419-24065-1-git-send-email-davvid@gmail.com","threadId":"33805","inReplyTo":null,"subject":"[PATCH v4 2/3] imap-send: eliminate HMAC deprecation warnings on OS X 10.8","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2013-05-13T08:23:38Z","receivedAt":"2013-05-13T08:23:38Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Mac OS X Mountain Lion warns that HMAC_Init() and friends are\ndeprecated.  Use CommonCrypto's HMAC to eliminate the warnings.\n\nReviewed-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n1/3 not included since it is unchanged.\nThese are replacement patches for what's currently in \"pu\".\n\nChanges since last time:\n\nWe no longer say \"=1\" when defining COMMON_DIGEST_FOR_HMAC.\nI added the word \"deprecated\" to the commit message subject\nfor consistency with the other patches in this series.\n\n Makefile    |  5 +++++\n imap-send.c | 10 ++++++++++\n 2 files changed, 15 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex f698c1a..a0f7afc 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1054,6 +1054,7 @@ ifeq ($(uname_S),Darwin)\n \t\t\tBASIC_LDFLAGS += -L/opt/local/lib\n \t\tendif\n \tendif\n+\tCOMMON_DIGEST_HMAC = YesPlease\n \tNO_REGEX = YesPlease\n \tPTHREAD_LIBS =\n endif\n@@ -1393,6 +1394,10 @@ else\n \tEXTLIBS += $(LIB_4_CRYPTO)\n endif\n endif\n+\n+ifdef COMMON_DIGEST_HMAC\n+\tBASIC_CFLAGS += -DCOMMON_DIGEST_FOR_HMAC\n+endif\n ifdef NO_PERL_MAKEMAKER\n \texport NO_PERL_MAKEMAKER\n endif\ndiff --git a/imap-send.c b/imap-send.c\nindex d9bcfb4..1b2e69c 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+#ifdef COMMON_DIGEST_FOR_HMAC\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.3.rc1.52.g872cb7b\n"},{"id":"217139","messageId":"1368433419-24065-2-git-send-email-davvid@gmail.com","threadId":"33805","inReplyTo":"1368433419-24065-1-git-send-email-davvid@gmail.com","subject":"[PATCH v4 3/3] cache.h: eliminate SHA-1 deprecation warnings on OS X 10.8","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2013-05-13T08:23:39Z","receivedAt":"2013-05-13T08:23:39Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Mac OS X Mountain Lion prints warnings when building git:\n\n\twarning: 'SHA1_Init' is deprecated\n\t(declared at /usr/include/openssl/sha.h:121)\n\nSilence the warnings by using the CommonCrytpo SHA-1\nfunctions for SHA1_Init(), SHA1_Update(), and SHA1_Final().\n\nAdd a COMMON_DIGEST_SHA1 option to the Makefile to allow\nchoosing this implementation and define it by default on Darwin.\n\nDefine COMMON_DIGEST_FOR_OPENSSL to enable the OpenSSL\ncompatibility macros in CommonDigest.h.\n\nHelped-by: Eric Sunshine <sunshine@sunshineco.com>\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\nChanges since last round:\nCOMMON_DIGEST_FOR_OPENSSL is used to enable the compatibility macros.\n\n Makefile | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex a0f7afc..29c02ed 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1055,6 +1055,7 @@ ifeq ($(uname_S),Darwin)\n \t\tendif\n \tendif\n \tCOMMON_DIGEST_HMAC = YesPlease\n+\tCOMMON_DIGEST_SHA1 = YesPlease\n \tNO_REGEX = YesPlease\n \tPTHREAD_LIBS =\n endif\n@@ -1390,10 +1391,15 @@ ifdef PPC_SHA1\n \tLIB_OBJS += ppc/sha1.o ppc/sha1ppc.o\n \tLIB_H += ppc/sha1.h\n else\n+ifdef COMMON_DIGEST_SHA1\n+\tBASIC_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 COMMON_DIGEST_HMAC\n \tBASIC_CFLAGS += -DCOMMON_DIGEST_FOR_HMAC\n-- \n1.8.3.rc1.52.g872cb7b\n"},{"id":"217163","messageId":"CAPig+cQwhhwyt+XHXz2_PLqmZ=goy7pz-GC3kFqOHm1R6=70YA@mail.gmail.com","threadId":"33805","inReplyTo":"1368433419-24065-2-git-send-email-davvid@gmail.com","subject":"Re: [PATCH v4 3/3] cache.h: eliminate SHA-1 deprecation warnings on OS X 10.8","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-05-13T13:32:43Z","receivedAt":"2013-05-13T13:32:43Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, May 13, 2013 at 4:23 AM, David Aguilar <davvid@gmail.com> wrote:\n> Mac OS X Mountain Lion prints warnings when building git:\n>\n>         warning: 'SHA1_Init' is deprecated\n>         (declared at /usr/include/openssl/sha.h:121)\n>\n> Silence the warnings by using the CommonCrytpo SHA-1\n> functions for SHA1_Init(), SHA1_Update(), and SHA1_Final().\n>\n> Add a COMMON_DIGEST_SHA1 option to the Makefile to allow\n> choosing this implementation and define it by default on Darwin.\n\nThe approach of adding a Makefile option for each CommonCrypto\nfacility does not really scale well. For instance, these days, I\ngenerally build git against OpenSSL from MacPorts, which gives me a\nwarning-free git build since MacPorts/OpenSSL lacks those\nApple-specific deprecation flags. With this patch series introducing\nseveral Makefile knobs, people wishing to use MacPorts/OpenSSL will\nhave to tweak each knob. These patches already introduce two knobs\n(COMMON_DIGEST_SHA1, COMMON_DIGEST_HMAC). Adding more knobs to silence\nthe remaining 29 deprecation warnings will make the build more\ncumbersome for those who prefer OpenSSL. Instead, introducing a single\nknob (such as APPLE_COMMON_CRYPTO) would avoid this problem.\n\nMore generally, is the approach of trying to figure out CommonCrypto\nreplacements for DIGEST, HMAC, and the other 29 warnings worthwhile?\nAfter all, Apple introduced deprecation warnings due to the\nABI-instability of OpenSSL, not due to any particular flaw in OpenSSL\nor its API. A more manageable approach might simply be to disable that\nparticular warning on Darwin (via CFLAGS or perhaps '#pragma GCC\ndiagnostic ignored' for more fine-grained control).\n\n> Define COMMON_DIGEST_FOR_OPENSSL to enable the OpenSSL\n> compatibility macros in CommonDigest.h.\n>\n> Helped-by: Eric Sunshine <sunshine@sunshineco.com>\n> Signed-off-by: David Aguilar <davvid@gmail.com>\n> ---\n> Changes since last round:\n> COMMON_DIGEST_FOR_OPENSSL is used to enable the compatibility macros.\n>\n>  Makefile | 6 ++++++\n>  1 file changed, 6 insertions(+)\n>\n> diff --git a/Makefile b/Makefile\n> index a0f7afc..29c02ed 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -1055,6 +1055,7 @@ ifeq ($(uname_S),Darwin)\n>                 endif\n>         endif\n>         COMMON_DIGEST_HMAC = YesPlease\n> +       COMMON_DIGEST_SHA1 = YesPlease\n>         NO_REGEX = YesPlease\n>         PTHREAD_LIBS =\n>  endif\n> @@ -1390,10 +1391,15 @@ ifdef PPC_SHA1\n>         LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o\n>         LIB_H += ppc/sha1.h\n>  else\n> +ifdef COMMON_DIGEST_SHA1\n> +       BASIC_CFLAGS += -DCOMMON_DIGEST_FOR_OPENSSL\n> +       SHA1_HEADER = <CommonCrypto/CommonDigest.h>\n> +else\n>         SHA1_HEADER = <openssl/sha.h>\n>         EXTLIBS += $(LIB_4_CRYPTO)\n>  endif\n>  endif\n> +endif\n>\n>  ifdef COMMON_DIGEST_HMAC\n>         BASIC_CFLAGS += -DCOMMON_DIGEST_FOR_HMAC\n> --\n> 1.8.3.rc1.52.g872cb7b\n>\n"},{"id":"217312","messageId":"CAJDDKr7hYvDMWLo6VWNuS0E2FYdKqmuDrLEG6CPr+6f0uCS9_g@mail.gmail.com","threadId":"33805","inReplyTo":"CAPig+cQwhhwyt+XHXz2_PLqmZ=goy7pz-GC3kFqOHm1R6=70YA@mail.gmail.com","subject":"Re: [PATCH v4 3/3] cache.h: eliminate SHA-1 deprecation warnings on OS X 10.8","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2013-05-14T07:22:00Z","receivedAt":"2013-05-14T07:22:00Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Mon, May 13, 2013 at 6:32 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Mon, May 13, 2013 at 4:23 AM, David Aguilar <davvid@gmail.com> wrote:\n>> Mac OS X Mountain Lion prints warnings when building git:\n>>\n>>         warning: 'SHA1_Init' is deprecated\n>>         (declared at /usr/include/openssl/sha.h:121)\n>>\n>> Silence the warnings by using the CommonCrytpo SHA-1\n>> functions for SHA1_Init(), SHA1_Update(), and SHA1_Final().\n>>\n>> Add a COMMON_DIGEST_SHA1 option to the Makefile to allow\n>> choosing this implementation and define it by default on Darwin.\n>\n> The approach of adding a Makefile option for each CommonCrypto\n> facility does not really scale well. For instance, these days, I\n> generally build git against OpenSSL from MacPorts, which gives me a\n> warning-free git build since MacPorts/OpenSSL lacks those\n> Apple-specific deprecation flags. With this patch series introducing\n> several Makefile knobs, people wishing to use MacPorts/OpenSSL will\n> have to tweak each knob. These patches already introduce two knobs\n> (COMMON_DIGEST_SHA1, COMMON_DIGEST_HMAC). Adding more knobs to silence\n> the remaining 29 deprecation warnings will make the build more\n> cumbersome for those who prefer OpenSSL. Instead, introducing a single\n> knob (such as APPLE_COMMON_CRYPTO) would avoid this problem.\n\nThat sounds like a good idea.  In the very least these patches should\nbe redone to do that.\n\n> More generally, is the approach of trying to figure out CommonCrypto\n> replacements for DIGEST, HMAC, and the other 29 warnings worthwhile?\n> After all, Apple introduced deprecation warnings due to the\n> ABI-instability of OpenSSL, not due to any particular flaw in OpenSSL\n> or its API. A more manageable approach might simply be to disable that\n> particular warning on Darwin (via CFLAGS or perhaps '#pragma GCC\n> diagnostic ignored' for more fine-grained control).\n\nMy only fear would be that these deprecation warnings would one day\nbecome errors due to the functions being removed.  I don't know how\nelse to interpret \"deprecated\".\n\nIf we can accomplish the same thing without deprecated APIs (and not\nharm other platforms) then that is a good thing.  I doubt we can find\n1:1 replacements.  It'll probably have to be fleshed out in compat/.\n\nWarnings in 1 file (imap-send.c) is much better than warnings in 20\nfiles (git grep -l SHA1_Final), which is the itch I'm currently\nscratching.  I'll be mindful of making sure that the users can still\nplug in their own compliant OpenSSL.\n--\nDavid\n"}]}