gcrypt: Fix simple DES support.
Этот коммит содержится в:
родитель
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);
|
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(!cipher->key){
|
||||||
if (alloc_key(cipher) < 0) {
|
if (alloc_key(cipher) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
DES_set_odd_parity(key);
|
if (gcry_cipher_open(&cipher->key[0], GCRY_CIPHER_DES,
|
||||||
DES_set_key_unchecked(key,cipher->key);
|
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;
|
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,
|
static void des1_1_encrypt(struct ssh_cipher_struct *cipher, void *in,
|
||||||
unsigned long len, void *IV){
|
void *out, unsigned long len) {
|
||||||
|
gcry_cipher_encrypt(cipher->key[0], out, len, in, len);
|
||||||
DES_ncbc_encrypt(in, out, len, cipher->key, IV, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void des1_1_decrypt(struct ssh_cipher_struct *cipher, void *in, void *out,
|
static void des1_1_decrypt(struct ssh_cipher_struct *cipher, void *in,
|
||||||
unsigned long len, void *IV){
|
void *out, unsigned long len) {
|
||||||
|
gcry_cipher_decrypt(cipher->key[0], out, len, in, len);
|
||||||
DES_ncbc_encrypt(in,out,len, cipher->key, IV, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void des3_encrypt(struct ssh_cipher_struct *cipher, void *in,
|
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",
|
.name = "des-cbc-ssh1",
|
||||||
.blocksize = 8,
|
.blocksize = 8,
|
||||||
.keylen = sizeof(DES_key_schedule),
|
.keylen = sizeof(gcry_cipher_hd_t),
|
||||||
.key = NULL,
|
.key = NULL,
|
||||||
.keysize = 64,
|
.keysize = 64,
|
||||||
.set_encrypt_key = des1_set_key,
|
.set_encrypt_key = des1_set_key,
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user