{"thread":{"id":"33784","subject":"[PATCH] imap-send: eliminate HMAC warnings on OS X 10.8","startedAt":"2013-05-11T04:43:26Z","lastAt":"2013-05-11T06:27:36Z","messageCount":2,"participants":["David Aguilar","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"216959","messageId":"1368247406-10334-1-git-send-email-davvid@gmail.com","threadId":"33784","inReplyTo":null,"subject":"[PATCH] imap-send: eliminate HMAC warnings on OS X 10.8","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2013-05-11T04:43:26Z","receivedAt":"2013-05-11T04:43:26Z","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\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\nThis builds upon the patch I sent earlier, so technically it's 2/2\n\nWhile researching these errors I found this:\n\nhttp://opensource.apple.com/source/Git/Git-37/src/git/imap-send.c\n\nThe approach in this patch is similar in spirit, but simpler since\nit avoids pushing #ifdefs into the function bodies.\n\n Makefile    |  5 +++++\n imap-send.c | 10 ++++++++++\n 2 files changed, 15 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex d8a45b4..7e12999 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1055,6 +1055,7 @@ ifeq ($(uname_S),Darwin)\n \t\tendif\n \tendif\n \tCOMMON_DIGEST_SHA1 = YesPlease\n+\tCOMMON_DIGEST_HMAC = YesPlease\n \tPTHREAD_LIBS =\n endif\n \n@@ -1399,6 +1400,10 @@ else\n endif\n endif\n endif\n+\n+ifdef COMMON_DIGEST_HMAC\n+\tBASIC_CFLAGS += -DCOMMON_DIGEST_FOR_HMAC=1\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.46.g9f9589e\n"},{"id":"216965","messageId":"20130511062736.GE3394@elie","threadId":"33784","inReplyTo":"1368247406-10334-1-git-send-email-davvid@gmail.com","subject":"Re: [PATCH] imap-send: eliminate HMAC warnings on OS X 10.8","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-05-11T06:27:36Z","receivedAt":"2013-05-11T06:27:36Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"David Aguilar wrote:\n\n> Mac OS X Mountain Lion warns that HMAC_Init() and friends are\n> deprecated.  Use CommonCrypto's HMAC to eliminate the warnings.\n\nMakes sense, and if the #define trick stops working some day\ndue to some conflicting macro in an openssl header some day, it\nwould just break the build, so this should be safe.  For what it's\nworth,\n\nReviewed-by: Jonathan Nieder <jrnieder@gmail.com>\n\n[...]\n> This builds upon the patch I sent earlier, so technically it's 2/2\n\nI'm less sure about whether patch 1/2 is a good idea.  Luckily the\nconflicts when trying to untangle the two are only textual.\n\nThanks,\nJonathan\n"}]}