aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitriy Kuznetsov <dk@yandex.ru>2012-10-05 11:22:15 +0200
committerAndreas Schneider <asn@cryptomilk.org>2012-10-05 11:22:15 +0200
commit1e836a03d27ce50086e5babc9d46e3aa712fcf74 (patch)
treeb7e33f0b49f7d0fcd00072d728964eecf3c961ab /src
parentceb8072b34a581eb72ed43f7f7ce78fd9b0ea708 (diff)
downloadlibssh-1e836a03d27ce50086e5babc9d46e3aa712fcf74.tar.gz
libssh-1e836a03d27ce50086e5babc9d46e3aa712fcf74.tar.xz
libssh-1e836a03d27ce50086e5babc9d46e3aa712fcf74.zip
gcrypt: Fix simple DES support.
Diffstat (limited to 'src')
-rw-r--r--src/libgcrypt.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/libgcrypt.c b/src/libgcrypt.c
index bc10bd8b..899bccdf 100644
--- a/src/libgcrypt.c
+++ b/src/libgcrypt.c
@@ -262,13 +262,24 @@ 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){
+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);
+ if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_DES,
+ GCRY_CIPHER_MODE_CBC, 0)) {
+ SAFE_FREE(cipher->key);
+ return -1;
+ }
+ if (gcry_cipher_setkey(cipher->key[0], key, 8)) {
+ SAFE_FREE(cipher->key);
+ return -1;
+ }
+ if (gcry_cipher_setiv(cipher->key[0], IV, 8)) {
+ SAFE_FREE(cipher->key);
+ return -1;
+ }
}
return 0;
}
@@ -297,16 +308,14 @@ static int des3_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV) {
}
-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_encrypt(struct ssh_cipher_struct *cipher, void *in,
+ void *out, unsigned long len) {
+ gcry_cipher_encrypt(cipher->key[0], out, len, in, len);
}
-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 des1_1_decrypt(struct ssh_cipher_struct *cipher, void *in,
+ void *out, unsigned long len) {
+ gcry_cipher_decrypt(cipher->key[0], out, len, in, len);
}
static void des3_encrypt(struct ssh_cipher_struct *cipher, void *in,
@@ -488,7 +497,7 @@ static struct ssh_cipher_struct ssh_ciphertab[] = {
{
.name = "des-cbc-ssh1",
.blocksize = 8,
- .keylen = sizeof(DES_key_schedule),
+ .keylen = sizeof(gcry_cipher_hd_t),
.key = NULL,
.keysize = 64,
.set_encrypt_key = des1_set_key,