Revision d588d4d9406691692c60d96e5893d49063129dab authored by Junio C Hamano on 22 January 2015, 21:45:07 UTC, committed by Junio C Hamano on 22 January 2015, 21:45:07 UTC
* git://github.com/git-l10n/git-po:
  l10n: correct indentation of show-branch usage
  l10n: de.po: translate 3 messages
  l10n: zh_CN: various fixes on command arguments
  l10n: vi.po(2298t): Updated 3 new strings
  l10n: sv.po: Update Swedish translation (2298t0f0u)
  l10n: fr.po v2.3.0 round 2
  l10n: git.pot: v2.3.0 round 2 (3 updated)
  l10n: de.po: translate 13 new messages
  l10n: de.po: fix typo
  l10n: de.po: translate "track" as "versionieren"
  l10n: zh_CN: translations for git v2.3.0-rc0
  l10n: sv.po: Update Swedish translation (2298t0f0u)
  l10n: fr.po v2.3.0 round 1
  l10n: vi.po(2298t): Updated and change Plural-Forms
  l10n: git.pot: v2.3.0 round 1 (13 new, 11 removed)
  l10n: ca.po: various fixes
2 parent s ab9432d + 1e60744
Raw File
apple-common-crypto.h
/* suppress inclusion of conflicting openssl functions */
#define OPENSSL_NO_MD5
#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
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
#define APPLE_LION_OR_NEWER
#include <Security/Security.h>
/* Apple's TYPE_BOOL conflicts with config.c */
#undef TYPE_BOOL
#endif

#ifdef APPLE_LION_OR_NEWER
#define git_CC_error_check(pattern, err) \
	do { \
		if (err) { \
			die(pattern, (long)CFErrorGetCode(err)); \
		} \
	} while(0)

#define EVP_EncodeBlock git_CC_EVP_EncodeBlock
static inline int git_CC_EVP_EncodeBlock(unsigned char *out,
		const unsigned char *in, int inlen)
{
	CFErrorRef err;
	SecTransformRef encoder;
	CFDataRef input, output;
	CFIndex length;

	encoder = SecEncodeTransformCreate(kSecBase64Encoding, &err);
	git_CC_error_check("SecEncodeTransformCreate failed: %ld", err);

	input = CFDataCreate(kCFAllocatorDefault, in, inlen);
	SecTransformSetAttribute(encoder, kSecTransformInputAttributeName,
			input, &err);
	git_CC_error_check("SecTransformSetAttribute failed: %ld", err);

	output = SecTransformExecute(encoder, &err);
	git_CC_error_check("SecTransformExecute failed: %ld", err);

	length = CFDataGetLength(output);
	CFDataGetBytes(output, CFRangeMake(0, length), out);

	CFRelease(output);
	CFRelease(input);
	CFRelease(encoder);

	return (int)strlen((const char *)out);
}

#define EVP_DecodeBlock git_CC_EVP_DecodeBlock
static int inline git_CC_EVP_DecodeBlock(unsigned char *out,
		const unsigned char *in, int inlen)
{
	CFErrorRef err;
	SecTransformRef decoder;
	CFDataRef input, output;
	CFIndex length;

	decoder = SecDecodeTransformCreate(kSecBase64Encoding, &err);
	git_CC_error_check("SecEncodeTransformCreate failed: %ld", err);

	input = CFDataCreate(kCFAllocatorDefault, in, inlen);
	SecTransformSetAttribute(decoder, kSecTransformInputAttributeName,
			input, &err);
	git_CC_error_check("SecTransformSetAttribute failed: %ld", err);

	output = SecTransformExecute(decoder, &err);
	git_CC_error_check("SecTransformExecute failed: %ld", err);

	length = CFDataGetLength(output);
	CFDataGetBytes(output, CFRangeMake(0, length), out);

	CFRelease(output);
	CFRelease(input);
	CFRelease(decoder);

	return (int)strlen((const char *)out);
}
#endif /* APPLE_LION_OR_NEWER */
back to top