From d714d1f1822fd68f344aae90925c36b3fc85faad Mon Sep 17 00:00:00 2001 From: Roger Shimizu Date: Wed, 25 Jan 2017 19:20:21 +0900 Subject: [PATCH] Refine #1133 second time (#1136) --- src/encrypt.c | 8 ++++++++ src/encrypt.h | 2 ++ src/utils.c | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/src/encrypt.c b/src/encrypt.c index 404b96dd..f04d8efe 100644 --- a/src/encrypt.c +++ b/src/encrypt.c @@ -197,7 +197,9 @@ static const CCAlgorithm supported_ciphers_applecc[CIPHER_NUM] = { kCCAlgorithmInvalid, kCCAlgorithmInvalid, kCCAlgorithmInvalid, +#if SODIUM_LIBRARY_VERSION_MAJOR >= 8 kCCAlgorithmInvalid +#endif }; static const CCMode supported_modes_applecc[CIPHER_NUM] = { @@ -221,7 +223,9 @@ static const CCMode supported_modes_applecc[CIPHER_NUM] = { kCCAlgorithmInvalid, kCCAlgorithmInvalid, kCCAlgorithmInvalid, +#if SODIUM_LIBRARY_VERSION_MAJOR >= 8 kCCAlgorithmInvalid +#endif }; #endif @@ -1303,7 +1307,11 @@ enc_key_init(int method, const char *pass) FATAL("Failed to initialize sodium"); } +#if SODIUM_LIBRARY_VERSION_MAJOR >= 8 if (method == SALSA20 || method == CHACHA20 || method == CHACHA20IETF) { +#else + if (method == SALSA20 || method == CHACHA20) { +#endif #if defined(USE_CRYPTO_OPENSSL) cipher.info = NULL; cipher.key_len = supported_ciphers_key_size[method]; diff --git a/src/encrypt.h b/src/encrypt.h index 5e754773..9bf3b03c 100644 --- a/src/encrypt.h +++ b/src/encrypt.h @@ -134,7 +134,9 @@ typedef struct { #define SEED_CFB 17 #define SALSA20 18 #define CHACHA20 19 +#if SODIUM_LIBRARY_VERSION_MAJOR >= 8 #define CHACHA20IETF 20 +#endif #define ONETIMEAUTH_FLAG 0x10 #define ADDRTYPE_MASK 0xEF diff --git a/src/utils.c b/src/utils.c index b54be242..d3e3d676 100644 --- a/src/utils.c +++ b/src/utils.c @@ -278,9 +278,15 @@ usage() printf( " camellia-256-cfb, cast5-cfb, des-cfb,\n"); printf( +#if SODIUM_LIBRARY_VERSION_MAJOR >= 8 " idea-cfb, rc2-cfb, seed-cfb, salsa20,\n"); printf( " chacha20 and chacha20-ietf.\n"); +#else + " idea-cfb, rc2-cfb, seed-cfb, salsa20 and\n"); + printf( + " chacha20.\n"); +#endif printf( " The default cipher is rc4-md5.\n"); printf("\n");