summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-04-08 16:22:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-04-08 18:45:47 (GMT)
commit1ed2c7b11570f5d16bdc70d151fa78c3dccf6d38 (patch)
tree9fb56716945fd446dea3bb37401559766c3816cf /compat
parente46579643d56162299b1756b70d418005351b256 (diff)
downloadgit-1ed2c7b11570f5d16bdc70d151fa78c3dccf6d38.zip
git-1ed2c7b11570f5d16bdc70d151fa78c3dccf6d38.tar.gz
git-1ed2c7b11570f5d16bdc70d151fa78c3dccf6d38.tar.bz2
imap-send: use HMAC() function provided by OpenSSL
Fix compile errors with OpenSSL 1.1.0. HMAC_CTX is made opaque and HMAC_CTX_cleanup is removed in OpenSSL 1.1.0. But since we just want to calculate one HMAC, we can use HMAC() here, which exists since OpenSSL 0.9.6 at least. Signed-off-by: Kazuki Yamaguchi <k@rhe.jp> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat')
-rw-r--r--compat/apple-common-crypto.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/compat/apple-common-crypto.h b/compat/apple-common-crypto.h
index d3fb264..11727f3 100644
--- a/compat/apple-common-crypto.h
+++ b/compat/apple-common-crypto.h
@@ -3,12 +3,18 @@
#define HEADER_HMAC_H
#define HEADER_SHA_H
#include <CommonCrypto/CommonHMAC.h>
-#define HMAC_CTX CCHmacContext
-#define HMAC_Init(hmac, key, len, algo) CCHmacInit(hmac, algo, key, len)
-#define HMAC_Update CCHmacUpdate
-#define HMAC_Final(hmac, hash, ptr) CCHmacFinal(hmac, hash)
-#define HMAC_CTX_cleanup(ignore)
#define EVP_md5(...) kCCHmacAlgMD5
+/* CCHmac doesn't take md_len and the return type is void */
+#define HMAC git_CC_HMAC
+static inline unsigned char *git_CC_HMAC(CCHmacAlgorithm alg,
+ const void *key, int key_len,
+ const unsigned char *data, size_t data_len,
+ unsigned char *md, unsigned int *md_len)
+{
+ CCHmac(alg, key, key_len, data, data_len, md);
+ return md;
+}
+
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
#define APPLE_LION_OR_NEWER
#include <Security/Security.h>