From 9e407a943335c53aefd1285043d12ea247240376 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Thu, 11 Aug 2016 15:07:03 +0800 Subject: [PATCH] Add aes-ctr ciphers --- src/encrypt.c | 16 ++++++++++++++-- src/encrypt.h | 29 ++++++++++++++++------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/encrypt.c b/src/encrypt.c index 6112c1fd..4058652a 100644 --- a/src/encrypt.c +++ b/src/encrypt.c @@ -107,6 +107,9 @@ static const char *supported_ciphers[CIPHER_NUM] = { "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", + "aes-128-ctr", + "aes-192-ctr", + "aes-256-ctr", "bf-cfb", "camellia-128-cfb", "camellia-192-cfb", @@ -129,6 +132,9 @@ static const char *supported_ciphers_polarssl[CIPHER_NUM] = { "AES-128-CFB128", "AES-192-CFB128", "AES-256-CFB128", + "AES-128-CTR", + "AES-192-CTR", + "AES-256-CTR", "BLOWFISH-CFB64", "CAMELLIA-128-CFB128", "CAMELLIA-192-CFB128", @@ -152,6 +158,9 @@ static const char *supported_ciphers_mbedtls[CIPHER_NUM] = { "AES-128-CFB128", "AES-192-CFB128", "AES-256-CFB128", + "AES-128-CTR", + "AES-192-CTR", + "AES-256-CTR", "BLOWFISH-CFB64", "CAMELLIA-128-CFB128", "CAMELLIA-192-CFB128", @@ -175,6 +184,9 @@ static const CCAlgorithm supported_ciphers_applecc[CIPHER_NUM] = { kCCAlgorithmAES, kCCAlgorithmAES, kCCAlgorithmAES, + kCCAlgorithmInvalid, + kCCAlgorithmInvalid, + kCCAlgorithmInvalid, kCCAlgorithmBlowfish, kCCAlgorithmInvalid, kCCAlgorithmInvalid, @@ -192,11 +204,11 @@ static const CCAlgorithm supported_ciphers_applecc[CIPHER_NUM] = { #endif static const int supported_ciphers_iv_size[CIPHER_NUM] = { - 0, 0, 16, 16, 16, 16, 8, 16, 16, 16, 8, 8, 8, 8, 16, 8, 8, 12 + 0, 0, 16, 16, 16, 16, 16, 16, 16, 8, 16, 16, 16, 8, 8, 8, 8, 16, 8, 8, 12 }; static const int supported_ciphers_key_size[CIPHER_NUM] = { - 0, 16, 16, 16, 24, 32, 16, 16, 24, 32, 16, 8, 16, 16, 16, 32, 32, 32 + 0, 16, 16, 16, 24, 32, 16, 24, 32, 16, 16, 24, 32, 16, 8, 16, 16, 16, 32, 32, 32 }; static int safe_memcmp(const void *s1, const void *s2, size_t n) diff --git a/src/encrypt.h b/src/encrypt.h index 158129b5..61f88a36 100644 --- a/src/encrypt.h +++ b/src/encrypt.h @@ -119,7 +119,7 @@ typedef struct { #endif #define SODIUM_BLOCK_SIZE 64 -#define CIPHER_NUM 18 +#define CIPHER_NUM 21 #define NONE -1 #define TABLE 0 @@ -128,18 +128,21 @@ typedef struct { #define AES_128_CFB 3 #define AES_192_CFB 4 #define AES_256_CFB 5 -#define BF_CFB 6 -#define CAMELLIA_128_CFB 7 -#define CAMELLIA_192_CFB 8 -#define CAMELLIA_256_CFB 9 -#define CAST5_CFB 10 -#define DES_CFB 11 -#define IDEA_CFB 12 -#define RC2_CFB 13 -#define SEED_CFB 14 -#define SALSA20 15 -#define CHACHA20 16 -#define CHACHA20IETF 17 +#define AES_128_CTR 6 +#define AES_192_CTR 7 +#define AES_256_CTR 8 +#define BF_CFB 9 +#define CAMELLIA_128_CFB 10 +#define CAMELLIA_192_CFB 11 +#define CAMELLIA_256_CFB 12 +#define CAST5_CFB 13 +#define DES_CFB 14 +#define IDEA_CFB 15 +#define RC2_CFB 16 +#define SEED_CFB 17 +#define SALSA20 18 +#define CHACHA20 19 +#define CHACHA20IETF 20 #define ONETIMEAUTH_FLAG 0x10 #define ADDRTYPE_MASK 0xF