aboutsummaryrefslogtreecommitdiff
path: root/src/libcrypto.c
diff options
context:
space:
mode:
authorDmitriy Kuznetsov <dk@yandex.ru>2012-09-07 12:19:43 +0200
committerAndreas Schneider <asn@cryptomilk.org>2012-09-07 12:19:43 +0200
commit320951f42ff5def186da70d2e52457b7c1d06f50 (patch)
treeb8dbd3e27959c3694c8639e3cd11335137a3a378 /src/libcrypto.c
parenta3f83e72740bfc0062ab8232e5a0325354ecc1a8 (diff)
downloadlibssh-320951f42ff5def186da70d2e52457b7c1d06f50.tar.gz
libssh-320951f42ff5def186da70d2e52457b7c1d06f50.tar.xz
libssh-320951f42ff5def186da70d2e52457b7c1d06f50.zip
kex: Add simple DES support for SSHv1.
Diffstat (limited to 'src/libcrypto.c')
-rw-r--r--src/libcrypto.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/libcrypto.c b/src/libcrypto.c
index 79775417..44b0fb36 100644
--- a/src/libcrypto.c
+++ b/src/libcrypto.c
@@ -415,6 +415,30 @@ static void des3_1_decrypt(struct ssh_cipher_struct *cipher, void *in,
#endif
}
+static int des1_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV){
+ if(!cipher->key){
+ if (alloc_key(cipher) < 0) {
+ return -1;
+ }
+ DES_set_odd_parity(key);
+ DES_set_key_unchecked(key,cipher->key);
+ }
+ cipher->IV=IV;
+ return 0;
+}
+
+static void des1_1_encrypt(struct ssh_cipher_struct *cipher, void *in, void *out,
+ unsigned long len){
+
+ DES_ncbc_encrypt(in, out, len, cipher->key, cipher->IV, 1);
+}
+
+static void des1_1_decrypt(struct ssh_cipher_struct *cipher, void *in, void *out,
+ unsigned long len){
+
+ DES_ncbc_encrypt(in,out,len, cipher->key, cipher->IV, 0);
+}
+
#endif /* HAS_DES */
/*
@@ -539,6 +563,18 @@ static struct ssh_cipher_struct ssh_ciphertab[] = {
des3_1_encrypt,
des3_1_decrypt
},
+ {
+ "des-cbc-ssh1",
+ 8,
+ sizeof(DES_key_schedule),
+ NULL,
+ NULL,
+ 64,
+ des1_set_key,
+ des1_set_key,
+ des1_1_encrypt,
+ des1_1_decrypt
+ },
#endif /* HAS_DES */
{
NULL,