libarchive: Use CommonCrypto APIs on OS X only when available
Use each CommonCrypto API only when using an OS X SDK version new enough to provide it.
This commit is contained in:
parent
61a0251e82
commit
8f837fc9a9
@ -31,7 +31,7 @@
|
|||||||
#include "archive.h"
|
#include "archive.h"
|
||||||
#include "archive_cryptor_private.h"
|
#include "archive_cryptor_private.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
||||||
@ -114,7 +114,10 @@ pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
|
||||||
|
# if MAC_OS_X_VERSION_MAX_ALLOWED < 1090
|
||||||
|
# define kCCAlgorithmAES kCCAlgorithmAES128
|
||||||
|
# endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
||||||
|
@ -31,6 +31,13 @@
|
|||||||
#define ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
|
#define ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
# include <AvailabilityMacros.h>
|
||||||
|
# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
|
||||||
|
# define ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
|
||||||
#include <CommonCrypto/CommonCryptor.h>
|
#include <CommonCrypto/CommonCryptor.h>
|
||||||
#include <CommonCrypto/CommonKeyDerivation.h>
|
#include <CommonCrypto/CommonKeyDerivation.h>
|
||||||
#define AES_BLOCK_SIZE 16
|
#define AES_BLOCK_SIZE 16
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "archive.h"
|
#include "archive.h"
|
||||||
#include "archive_hmac_private.h"
|
#include "archive_hmac_private.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef ARCHIVE_HMAC_USE_Apple_CommonCrypto
|
||||||
|
|
||||||
static int
|
static int
|
||||||
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
|
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
|
||||||
|
@ -31,6 +31,13 @@
|
|||||||
#define ARCHIVE_HMAC_PRIVATE_H_INCLUDED
|
#define ARCHIVE_HMAC_PRIVATE_H_INCLUDED
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
# include <AvailabilityMacros.h>
|
||||||
|
# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||||
|
# define ARCHIVE_HMAC_USE_Apple_CommonCrypto
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ARCHIVE_HMAC_USE_Apple_CommonCrypto
|
||||||
#include <CommonCrypto/CommonHMAC.h>
|
#include <CommonCrypto/CommonHMAC.h>
|
||||||
|
|
||||||
typedef CCHmacContext archive_hmac_sha1_ctx;
|
typedef CCHmacContext archive_hmac_sha1_ctx;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user