aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-02-09 21:21:11 +0100
committerAris Adamantiadis <aris@0xbadc0de.be>2010-02-09 21:21:11 +0100
commitdc0d945f28fd3ff8f7c4cf90abeb6853b75b4aec (patch)
tree1323fb20e07388c658df9f7081d8382ef1e11fd2
parent96465a52eedc7f8c96e1d9dc7cf5e6438b670d0f (diff)
downloadlibssh-dc0d945f28fd3ff8f7c4cf90abeb6853b75b4aec.tar.gz
libssh-dc0d945f28fd3ff8f7c4cf90abeb6853b75b4aec.tar.xz
libssh-dc0d945f28fd3ff8f7c4cf90abeb6853b75b4aec.zip
Added aes128-ctr support for libcrypto (openssl)
-rw-r--r--libssh/wrapper.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/libssh/wrapper.c b/libssh/wrapper.c
index 4cfc71ba..b7de1532 100644
--- a/libssh/wrapper.c
+++ b/libssh/wrapper.c
@@ -570,6 +570,23 @@ static void aes_decrypt(struct crypto_struct *cipher, void *in, void *out,
unsigned long len, void *IV) {
AES_cbc_encrypt(in, out, len, cipher->key, IV, AES_DECRYPT);
}
+
+/** @internal
+ * @brief encrypts/decrypts data with stream cipher AES128_ctr
+ * @param len[in] must be a multiple of AES128 block size.
+ */
+static void aes_ctr128_encrypt(struct crypto_struct *cipher, void *in, void *out,
+ unsigned long len, void *IV) {
+ unsigned char tmp_buffer[128/8];
+ unsigned int num=0;
+ /* Some things are special with ctr128 :
+ * In this case, tmp_buffer is not being used, because it is used to store temporary data
+ * when an encryption is made on lengths that are not multiple of blocksize.
+ * Same for num, which is being used to store the current offset in blocksize in CTR
+ * function.
+ */
+ AES_ctr128_encrypt(in, out, len, cipher->key, IV, tmp_buffer, &num);
+}
#endif /* HAS_AES */
#ifdef HAS_DES
@@ -662,6 +679,17 @@ static struct crypto_struct ssh_ciphertab[] = {
#endif /* HAS_BLOWFISH */
#ifdef HAS_AES
{
+ "aes128-ctr",
+ 16,
+ sizeof(AES_KEY),
+ NULL,
+ 128,
+ aes_set_encrypt_key,
+ aes_set_encrypt_key,
+ aes_ctr128_encrypt,
+ aes_ctr128_encrypt
+ },
+ {
"aes128-cbc",
16,
sizeof(AES_KEY),