diff options
author | mouring <mouring> | 2001-06-05 20:50:16 +0000 |
---|---|---|
committer | mouring <mouring> | 2001-06-05 20:50:16 +0000 |
commit | 8056e4497746e17fdf4ee6502a11768dd44eaebc (patch) | |
tree | b345f70fe7442af8296f464d998102b85e4c1bf8 /cipher.c | |
parent | b1524a28ded220b3067715e1d340fd7f47c41044 (diff) | |
download | openssh-8056e4497746e17fdf4ee6502a11768dd44eaebc.tar.gz |
- markus@cvs.openbsd.org 2001/05/28 22:51:11
[cipher.c cipher.h]
simpler 3des for ssh1
Diffstat (limited to 'cipher.c')
-rw-r--r-- | cipher.c | 33 |
1 files changed, 14 insertions, 19 deletions
@@ -35,7 +35,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: cipher.c,v 1.43 2001/02/04 15:32:23 stevesk Exp $"); +RCSID("$OpenBSD: cipher.c,v 1.44 2001/05/28 22:51:10 markus Exp $"); #include "xmalloc.h" #include "log.h" @@ -100,6 +100,7 @@ des3_setkey(CipherContext *cc, const u_char *key, u_int keylen) void des3_setiv(CipherContext *cc, const u_char *iv, u_int ivlen) { + memset(cc->u.des3.iv1, 0, sizeof(cc->u.des3.iv1)); memset(cc->u.des3.iv2, 0, sizeof(cc->u.des3.iv2)); memset(cc->u.des3.iv3, 0, sizeof(cc->u.des3.iv3)); if (iv == NULL) @@ -149,29 +150,23 @@ void des3_ssh1_encrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len) { - des_cblock iv1; - des_cblock *iv2 = &cc->u.des3.iv2; - des_cblock *iv3 = &cc->u.des3.iv3; - - memcpy(&iv1, iv2, 8); - - des_ncbc_encrypt(src, dest, len, cc->u.des3.key1, &iv1, DES_ENCRYPT); - des_ncbc_encrypt(dest, dest, len, cc->u.des3.key2, iv2, DES_DECRYPT); - des_ncbc_encrypt(dest, dest, len, cc->u.des3.key3, iv3, DES_ENCRYPT); + des_ncbc_encrypt(src, dest, len, cc->u.des3.key1, &cc->u.des3.iv1, + DES_ENCRYPT); + des_ncbc_encrypt(dest, dest, len, cc->u.des3.key2, &cc->u.des3.iv2, + DES_DECRYPT); + des_ncbc_encrypt(dest, dest, len, cc->u.des3.key3, &cc->u.des3.iv3, + DES_ENCRYPT); } void des3_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len) { - des_cblock iv1; - des_cblock *iv2 = &cc->u.des3.iv2; - des_cblock *iv3 = &cc->u.des3.iv3; - - memcpy(&iv1, iv2, 8); - - des_ncbc_encrypt(src, dest, len, cc->u.des3.key3, iv3, DES_DECRYPT); - des_ncbc_encrypt(dest, dest, len, cc->u.des3.key2, iv2, DES_ENCRYPT); - des_ncbc_encrypt(dest, dest, len, cc->u.des3.key1, &iv1, DES_DECRYPT); + des_ncbc_encrypt(src, dest, len, cc->u.des3.key3, &cc->u.des3.iv3, + DES_DECRYPT); + des_ncbc_encrypt(dest, dest, len, cc->u.des3.key2, &cc->u.des3.iv2, + DES_ENCRYPT); + des_ncbc_encrypt(dest, dest, len, cc->u.des3.key1, &cc->u.des3.iv1, + DES_DECRYPT); } /* Blowfish */ |