summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/cipher.c
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2005-05-23 23:32:46 +0000
committerdjm <djm@openbsd.org>2005-05-23 23:32:46 +0000
commit64f736d280bb88c4e644b5ee8323ac2d639a7e0c (patch)
treee543f3de9c42fe734ee1bcf2afccbea9152347c8 /usr.bin/ssh/cipher.c
parentchange pool allocation of table entries, no longer use the oldnointr (diff)
downloadwireguard-openbsd-64f736d280bb88c4e644b5ee8323ac2d639a7e0c.tar.xz
wireguard-openbsd-64f736d280bb88c4e644b5ee8323ac2d639a7e0c.zip
add support for draft-harris-ssh-arcfour-fixes-02 improved arcfour modes;
ok markus@
Diffstat (limited to 'usr.bin/ssh/cipher.c')
-rw-r--r--usr.bin/ssh/cipher.c51
1 files changed, 33 insertions, 18 deletions
diff --git a/usr.bin/ssh/cipher.c b/usr.bin/ssh/cipher.c
index 68ca4d0bcb2..0bb61af9fe9 100644
--- a/usr.bin/ssh/cipher.c
+++ b/usr.bin/ssh/cipher.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: cipher.c,v 1.73 2005/01/23 10:18:12 djm Exp $");
+RCSID("$OpenBSD: cipher.c,v 1.74 2005/05/23 23:32:46 djm Exp $");
#include "xmalloc.h"
#include "log.h"
@@ -54,26 +54,29 @@ struct Cipher {
int number; /* for ssh1 only */
u_int block_size;
u_int key_len;
+ u_int discard_len;
const EVP_CIPHER *(*evptype)(void);
} ciphers[] = {
- { "none", SSH_CIPHER_NONE, 8, 0, EVP_enc_null },
- { "des", SSH_CIPHER_DES, 8, 8, EVP_des_cbc },
- { "3des", SSH_CIPHER_3DES, 8, 16, evp_ssh1_3des },
- { "blowfish", SSH_CIPHER_BLOWFISH, 8, 32, evp_ssh1_bf },
-
- { "3des-cbc", SSH_CIPHER_SSH2, 8, 24, EVP_des_ede3_cbc },
- { "blowfish-cbc", SSH_CIPHER_SSH2, 8, 16, EVP_bf_cbc },
- { "cast128-cbc", SSH_CIPHER_SSH2, 8, 16, EVP_cast5_cbc },
- { "arcfour", SSH_CIPHER_SSH2, 8, 16, EVP_rc4 },
- { "aes128-cbc", SSH_CIPHER_SSH2, 16, 16, EVP_aes_128_cbc },
- { "aes192-cbc", SSH_CIPHER_SSH2, 16, 24, EVP_aes_192_cbc },
- { "aes256-cbc", SSH_CIPHER_SSH2, 16, 32, EVP_aes_256_cbc },
+ { "none", SSH_CIPHER_NONE, 8, 0, 0, EVP_enc_null },
+ { "des", SSH_CIPHER_DES, 8, 8, 0, EVP_des_cbc },
+ { "3des", SSH_CIPHER_3DES, 8, 16, 0, evp_ssh1_3des },
+ { "blowfish", SSH_CIPHER_BLOWFISH, 8, 32, 0, evp_ssh1_bf },
+
+ { "3des-cbc", SSH_CIPHER_SSH2, 8, 24, 0, EVP_des_ede3_cbc },
+ { "blowfish-cbc", SSH_CIPHER_SSH2, 8, 16, 0, EVP_bf_cbc },
+ { "cast128-cbc", SSH_CIPHER_SSH2, 8, 16, 0, EVP_cast5_cbc },
+ { "arcfour", SSH_CIPHER_SSH2, 8, 16, 0, EVP_rc4 },
+ { "arcfour128", SSH_CIPHER_SSH2, 8, 16, 1536, EVP_rc4 },
+ { "arcfour256", SSH_CIPHER_SSH2, 8, 32, 1536, EVP_rc4 },
+ { "aes128-cbc", SSH_CIPHER_SSH2, 16, 16, 0, EVP_aes_128_cbc },
+ { "aes192-cbc", SSH_CIPHER_SSH2, 16, 24, 0, EVP_aes_192_cbc },
+ { "aes256-cbc", SSH_CIPHER_SSH2, 16, 32, 0, EVP_aes_256_cbc },
{ "rijndael-cbc@lysator.liu.se",
- SSH_CIPHER_SSH2, 16, 32, EVP_aes_256_cbc },
- { "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, evp_aes_128_ctr },
- { "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, evp_aes_128_ctr },
- { "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, evp_aes_128_ctr },
- { "acss@openssh.org", SSH_CIPHER_SSH2, 16, 5, EVP_acss },
+ SSH_CIPHER_SSH2, 16, 32, 0, EVP_aes_256_cbc },
+ { "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, 0, evp_aes_128_ctr },
+ { "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, 0, evp_aes_128_ctr },
+ { "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, 0, evp_aes_128_ctr },
+ { "acss@openssh.org", SSH_CIPHER_SSH2, 16, 5, 0, EVP_acss },
{ NULL, SSH_CIPHER_INVALID, 0, 0, NULL }
};
@@ -189,6 +192,7 @@ cipher_init(CipherContext *cc, Cipher *cipher,
static int dowarn = 1;
const EVP_CIPHER *type;
int klen;
+ u_char *junk, *discard;
if (cipher->number == SSH_CIPHER_DES) {
if (dowarn) {
@@ -226,6 +230,17 @@ cipher_init(CipherContext *cc, Cipher *cipher,
if (EVP_CipherInit(&cc->evp, NULL, (u_char *)key, NULL, -1) == 0)
fatal("cipher_init: EVP_CipherInit: set key failed for %s",
cipher->name);
+
+ if (cipher->discard_len > 0) {
+ junk = xmalloc(cipher->discard_len);
+ discard = xmalloc(cipher->discard_len);
+ if (EVP_Cipher(&cc->evp, discard, junk,
+ cipher->discard_len) == 0)
+ fatal("evp_crypt: EVP_Cipher failed during discard");
+ memset(discard, 0, cipher->discard_len);
+ xfree(junk);
+ xfree(discard);
+ }
}
void