From 50d144a7305c6f454a8f8f1a10ac7234eac2ceeb Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Tue, 8 Nov 2016 11:40:32 +0800 Subject: add aes-ctr cipher support --- src/protocol/internal/all_ciphers.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/protocol/internal/all_ciphers.c (limited to 'src/protocol/internal/all_ciphers.c') diff --git a/src/protocol/internal/all_ciphers.c b/src/protocol/internal/all_ciphers.c new file mode 100644 index 0000000..3a524ee --- /dev/null +++ b/src/protocol/internal/all_ciphers.c @@ -0,0 +1,34 @@ +#include "ssh_crypto_common.h" +#include "ssh_cipher.h" +#include + +#define EVP_CIPHER_FUNC(name, evp, k, i, b) \ + static SSH_CIPHER* evp_##name(int e) { return new_ssh_cipher_evp(evp, k, i, b, e); } + +EVP_CIPHER_FUNC(aes256_ctr, EVP_aes_256_ctr, 32, 16, 16) +EVP_CIPHER_FUNC(aes192_ctr, EVP_aes_192_ctr, 24, 16, 16) +EVP_CIPHER_FUNC(aes128_ctr, EVP_aes_128_ctr, 16, 16, 16) +EVP_CIPHER_FUNC(3des_cbc, EVP_des_ede3_cbc, 24, 8, 8) + +struct +{ + const char *name; + NEW_CIPHER f; +} all_ciphers[] = { + { "aes256-ctr", evp_aes256_ctr }, + { "aes192-ctr", evp_aes192_ctr }, + { "aes128-ctr", evp_aes128_ctr }, + { "3des-cbc", evp_3des_cbc }, + { NULL, NULL } +}; + +NEW_CIPHER search_cipher(const char *s) +{ + int i = search_name((name_sp)all_ciphers, s); + if (i!=-1) + return all_ciphers[i].f; + else + return NULL; +} + +const char all_ciphers_list[] = "aes256-ctr,aes192-ctr,aes128-ctr,3des-cbc"; -- cgit v1.2.3