summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--cipher.c33
-rw-r--r--cipher.h5
3 files changed, 21 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index b25584e89..3de936f63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -62,6 +62,9 @@
62 - markus@cvs.openbsd.org 2001/05/28 10:08:55 62 - markus@cvs.openbsd.org 2001/05/28 10:08:55
63 [authfile.c] 63 [authfile.c]
64 key_load_private: set comment to filename for PEM keys 64 key_load_private: set comment to filename for PEM keys
65 - markus@cvs.openbsd.org 2001/05/28 22:51:11
66 [cipher.c cipher.h]
67 simpler 3des for ssh1
65 68
6620010528 6920010528
67 - (tim) [conifgure.in] add setvbuf test needed for sftp-int.c 70 - (tim) [conifgure.in] add setvbuf test needed for sftp-int.c
@@ -5492,4 +5495,4 @@
5492 - Wrote replacements for strlcpy and mkdtemp 5495 - Wrote replacements for strlcpy and mkdtemp
5493 - Released 1.0pre1 5496 - Released 1.0pre1
5494 5497
5495$Id: ChangeLog,v 1.1241 2001/06/05 20:46:32 mouring Exp $ 5498$Id: ChangeLog,v 1.1242 2001/06/05 20:50:16 mouring Exp $
diff --git a/cipher.c b/cipher.c
index 5350703ef..fd93299ed 100644
--- a/cipher.c
+++ b/cipher.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: cipher.c,v 1.43 2001/02/04 15:32:23 stevesk Exp $"); 38RCSID("$OpenBSD: cipher.c,v 1.44 2001/05/28 22:51:10 markus Exp $");
39 39
40#include "xmalloc.h" 40#include "xmalloc.h"
41#include "log.h" 41#include "log.h"
@@ -100,6 +100,7 @@ des3_setkey(CipherContext *cc, const u_char *key, u_int keylen)
100void 100void
101des3_setiv(CipherContext *cc, const u_char *iv, u_int ivlen) 101des3_setiv(CipherContext *cc, const u_char *iv, u_int ivlen)
102{ 102{
103 memset(cc->u.des3.iv1, 0, sizeof(cc->u.des3.iv1));
103 memset(cc->u.des3.iv2, 0, sizeof(cc->u.des3.iv2)); 104 memset(cc->u.des3.iv2, 0, sizeof(cc->u.des3.iv2));
104 memset(cc->u.des3.iv3, 0, sizeof(cc->u.des3.iv3)); 105 memset(cc->u.des3.iv3, 0, sizeof(cc->u.des3.iv3));
105 if (iv == NULL) 106 if (iv == NULL)
@@ -149,29 +150,23 @@ void
149des3_ssh1_encrypt(CipherContext *cc, u_char *dest, const u_char *src, 150des3_ssh1_encrypt(CipherContext *cc, u_char *dest, const u_char *src,
150 u_int len) 151 u_int len)
151{ 152{
152 des_cblock iv1; 153 des_ncbc_encrypt(src, dest, len, cc->u.des3.key1, &cc->u.des3.iv1,
153 des_cblock *iv2 = &cc->u.des3.iv2; 154 DES_ENCRYPT);
154 des_cblock *iv3 = &cc->u.des3.iv3; 155 des_ncbc_encrypt(dest, dest, len, cc->u.des3.key2, &cc->u.des3.iv2,
155 156 DES_DECRYPT);
156 memcpy(&iv1, iv2, 8); 157 des_ncbc_encrypt(dest, dest, len, cc->u.des3.key3, &cc->u.des3.iv3,
157 158 DES_ENCRYPT);
158 des_ncbc_encrypt(src, dest, len, cc->u.des3.key1, &iv1, DES_ENCRYPT);
159 des_ncbc_encrypt(dest, dest, len, cc->u.des3.key2, iv2, DES_DECRYPT);
160 des_ncbc_encrypt(dest, dest, len, cc->u.des3.key3, iv3, DES_ENCRYPT);
161} 159}
162void 160void
163des3_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src, 161des3_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src,
164 u_int len) 162 u_int len)
165{ 163{
166 des_cblock iv1; 164 des_ncbc_encrypt(src, dest, len, cc->u.des3.key3, &cc->u.des3.iv3,
167 des_cblock *iv2 = &cc->u.des3.iv2; 165 DES_DECRYPT);
168 des_cblock *iv3 = &cc->u.des3.iv3; 166 des_ncbc_encrypt(dest, dest, len, cc->u.des3.key2, &cc->u.des3.iv2,
169 167 DES_ENCRYPT);
170 memcpy(&iv1, iv2, 8); 168 des_ncbc_encrypt(dest, dest, len, cc->u.des3.key1, &cc->u.des3.iv1,
171 169 DES_DECRYPT);
172 des_ncbc_encrypt(src, dest, len, cc->u.des3.key3, iv3, DES_DECRYPT);
173 des_ncbc_encrypt(dest, dest, len, cc->u.des3.key2, iv2, DES_ENCRYPT);
174 des_ncbc_encrypt(dest, dest, len, cc->u.des3.key1, &iv1, DES_DECRYPT);
175} 170}
176 171
177/* Blowfish */ 172/* Blowfish */
diff --git a/cipher.h b/cipher.h
index 6d929aaff..2ad4979c2 100644
--- a/cipher.h
+++ b/cipher.h
@@ -32,7 +32,7 @@
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35/* RCSID("$OpenBSD: cipher.h,v 1.25 2000/12/19 23:17:56 markus Exp $"); */ 35/* RCSID("$OpenBSD: cipher.h,v 1.26 2001/05/28 22:51:11 markus Exp $"); */
36 36
37#ifndef CIPHER_H 37#ifndef CIPHER_H
38#define CIPHER_H 38#define CIPHER_H
@@ -71,8 +71,9 @@ struct CipherContext {
71 struct { 71 struct {
72 des_key_schedule key1; 72 des_key_schedule key1;
73 des_key_schedule key2; 73 des_key_schedule key2;
74 des_cblock iv2;
75 des_key_schedule key3; 74 des_key_schedule key3;
75 des_cblock iv1;
76 des_cblock iv2;
76 des_cblock iv3; 77 des_cblock iv3;
77 } des3; 78 } des3;
78 struct { 79 struct {