1
1

gcrypt: Fix simple DES support.

Этот коммит содержится в:
Dmitriy Kuznetsov 2012-10-05 11:22:15 +02:00 коммит произвёл Andreas Schneider
родитель ceb8072b34
Коммит 1e836a03d2

Просмотреть файл

@ -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,