From 286207b477d10535f185a205b36343c920db5fe5 Mon Sep 17 00:00:00 2001 From: tholo Date: Wed, 17 Apr 1996 07:15:17 +0000 Subject: [PATCH] Make encrypted Kerberos logins work --- usr.bin/rlogin/des_rw.c | 57 +++++++++++++++++------------------------ usr.bin/rlogin/rlogin.c | 2 +- 2 files changed, 25 insertions(+), 34 deletions(-) diff --git a/usr.bin/rlogin/des_rw.c b/usr.bin/rlogin/des_rw.c index f8a326205b7..bf928f85551 100644 --- a/usr.bin/rlogin/des_rw.c +++ b/usr.bin/rlogin/des_rw.c @@ -52,17 +52,9 @@ static char rcsid[] = "$NetBSD: des_rw.c,v 1.2 1995/03/21 07:58:30 cgd Exp $"; #include #include -static des_cblock des_inbuf[10240], storage[10240], *store_ptr; -static des_cblock *key; -static des_key_schedule key_schedule; - -/* XXX these should be in a kerberos include file */ -int krb_net_read __P((int, char *, int)); -#ifdef notdef -/* XXX too hard to make this work */ -int des_pcbc_encrypt __P((des_cblock *, des_cblock *, long, - des_key_schedule, des_cblock *, int)); -#endif +static unsigned char des_inbuf[10240], storage[10240], *store_ptr; +static bit_64 *key; +static u_char *key_schedule; /* * NB: These routines will not function properly if NBIO @@ -78,20 +70,20 @@ int des_pcbc_encrypt __P((des_cblock *, des_cblock *, long, * The inkey parameter is actually the DES initial vector, * and the insched is the DES Key unwrapped for faster decryption */ +static int nstored = 0; -int -des_set_key(inkey, insched) - des_cblock *inkey; - des_key_schedule insched; +void +desrw_set_key(inkey, insched) + bit_64 *inkey; + u_char *insched; { key = inkey; - bcopy(insched, key_schedule, sizeof(key_schedule)); - - return 0; + key_schedule = insched; + nstored = 0; } void -des_clear_key() +desrw_clear_key() { bzero((char *) key, sizeof(C_Block)); bzero((char *) key_schedule, sizeof(Key_schedule)); @@ -104,9 +96,8 @@ des_read(fd, buf, len) register char *buf; int len; { - int nreturned = 0; long net_len, rd_len; - int nstored = 0; + int nreturned = 0; if (nstored >= len) { (void) bcopy(store_ptr, buf, len); @@ -140,12 +131,12 @@ des_read(fd, buf, len) /* pipe must have closed, return 0 */ return(0); } - (void) des_pcbc_encrypt(des_inbuf, /* inbuf */ - storage, /* outbuf */ - net_len, /* length */ - key_schedule, /* DES key */ - key, /* IV */ - DECRYPT); /* direction */ + (void) des_pcbc_encrypt((des_cblock *)des_inbuf, /* inbuf */ + (des_cblock *)storage, /* outbuf */ + rd_len, /* length */ + key_schedule, /* DES key */ + (des_cblock *)key, /* IV */ + DECRYPT); /* direction */ if(net_len < 8) store_ptr = storage + 8 - net_len; @@ -167,7 +158,7 @@ des_read(fd, buf, len) return(nreturned); } -static des_cblock des_outbuf[10240]; /* > longest write */ +static unsigned char des_outbuf[10240]; /* > longest write */ int des_write(fd, buf, len) @@ -176,7 +167,7 @@ des_write(fd, buf, len) int len; { static int seeded = 0; - static des_cblock garbage_buf[8]; + static char garbage_buf[8]; long net_len, garbage; if(len < 8) { @@ -192,11 +183,11 @@ des_write(fd, buf, len) } /* pcbc_encrypt outputs in 8-byte (64 bit) increments */ - (void) des_pcbc_encrypt((len < 8) ? garbage_buf : (des_cblock *)buf, - des_outbuf, + (void) des_pcbc_encrypt((des_cblock *)((len < 8) ? garbage_buf : buf), + (des_cblock *)des_outbuf, (len < 8) ? 8 : len, - key_schedule, /* DES key */ - key, /* IV */ + key_schedule, /* DES key */ + (des_cblock *)key, /* IV */ ENCRYPT); /* tell the other end the real amount, but send an 8-byte padded diff --git a/usr.bin/rlogin/rlogin.c b/usr.bin/rlogin/rlogin.c index aa75a2d14ce..c1bb31ee08e 100644 --- a/usr.bin/rlogin/rlogin.c +++ b/usr.bin/rlogin/rlogin.c @@ -213,7 +213,7 @@ main(argc, argv) #ifdef KERBEROS case 'x': doencrypt = 1; - des_set_key(&cred.session, schedule); + desrw_set_key(&cred.session, schedule); break; #endif case '?': -- 2.20.1