From 320951f42ff5def186da70d2e52457b7c1d06f50 Mon Sep 17 00:00:00 2001 From: Dmitriy Kuznetsov Date: Fri, 7 Sep 2012 12:19:43 +0200 Subject: kex: Add simple DES support for SSHv1. --- src/libgcrypt.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/libgcrypt.c') diff --git a/src/libgcrypt.c b/src/libgcrypt.c index 70ce828d..bc10bd8b 100644 --- a/src/libgcrypt.c +++ b/src/libgcrypt.c @@ -262,6 +262,17 @@ static void aes_decrypt(struct ssh_cipher_struct *cipher, void *in, void *out, gcry_cipher_decrypt(cipher->key[0], out, len, in, len); } +static int des1_set_key(struct ssh_cipher_struct *cipher, void *key){ + if(!cipher->key){ + if (alloc_key(cipher) < 0) { + return -1; + } + DES_set_odd_parity(key); + DES_set_key_unchecked(key,cipher->key); + } + return 0; +} + static int des3_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV) { if (cipher->key == NULL) { if (alloc_key(cipher) < 0) { @@ -285,6 +296,19 @@ static int des3_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV) { return 0; } + +static void des1_1_encrypt(struct ssh_cipher_struct *cipher, void *in, void *out, + unsigned long len, void *IV){ + + DES_ncbc_encrypt(in, out, len, cipher->key, IV, 1); +} + +static void des1_1_decrypt(struct ssh_cipher_struct *cipher, void *in, void *out, + unsigned long len, void *IV){ + + DES_ncbc_encrypt(in,out,len, cipher->key, IV, 0); +} + static void des3_encrypt(struct ssh_cipher_struct *cipher, void *in, void *out, unsigned long len) { gcry_cipher_encrypt(cipher->key[0], out, len, in, len); @@ -461,6 +485,17 @@ static struct ssh_cipher_struct ssh_ciphertab[] = { .cbc_encrypt = des3_1_encrypt, .cbc_decrypt = des3_1_decrypt }, + { + .name = "des-cbc-ssh1", + .blocksize = 8, + .keylen = sizeof(DES_key_schedule), + .key = NULL, + .keysize = 64, + .set_encrypt_key = des1_set_key, + .set_decrypt_key = des1_set_key, + .cbc_encrypt = des1_1_encrypt, + .cbc_decrypt = des1_1_decrypt + }, { .name = NULL, .blocksize = 0, -- cgit