=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/rlogin/Attic/des_rw.c,v retrieving revision 1.2 retrieving revision 1.3 diff -c -r1.2 -r1.3 *** src/usr.bin/rlogin/Attic/des_rw.c 1995/12/16 22:20:31 1.2 --- src/usr.bin/rlogin/Attic/des_rw.c 1996/04/17 07:15:17 1.3 *************** *** 52,69 **** #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 - /* * NB: These routines will not function properly if NBIO * is set --- 52,61 ---- #include #include ! 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 * is set *************** *** 78,97 **** * The inkey parameter is actually the DES initial vector, * and the insched is the DES Key unwrapped for faster decryption */ ! int ! des_set_key(inkey, insched) ! des_cblock *inkey; ! des_key_schedule insched; { key = inkey; ! bcopy(insched, key_schedule, sizeof(key_schedule)); ! ! return 0; } void ! des_clear_key() { bzero((char *) key, sizeof(C_Block)); bzero((char *) key_schedule, sizeof(Key_schedule)); --- 70,89 ---- * The inkey parameter is actually the DES initial vector, * and the insched is the DES Key unwrapped for faster decryption */ + static int nstored = 0; ! void ! desrw_set_key(inkey, insched) ! bit_64 *inkey; ! u_char *insched; { key = inkey; ! key_schedule = insched; ! nstored = 0; } void ! desrw_clear_key() { bzero((char *) key, sizeof(C_Block)); bzero((char *) key_schedule, sizeof(Key_schedule)); *************** *** 104,112 **** register char *buf; int len; { - int nreturned = 0; long net_len, rd_len; ! int nstored = 0; if (nstored >= len) { (void) bcopy(store_ptr, buf, len); --- 96,103 ---- register char *buf; int len; { long net_len, rd_len; ! int nreturned = 0; if (nstored >= len) { (void) bcopy(store_ptr, buf, len); *************** *** 140,151 **** /* 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 */ if(net_len < 8) store_ptr = storage + 8 - net_len; --- 131,142 ---- /* pipe must have closed, return 0 */ return(0); } ! (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,173 **** return(nreturned); } ! static des_cblock des_outbuf[10240]; /* > longest write */ int des_write(fd, buf, len) --- 158,164 ---- return(nreturned); } ! static unsigned char des_outbuf[10240]; /* > longest write */ int des_write(fd, buf, len) *************** *** 176,182 **** int len; { static int seeded = 0; ! static des_cblock garbage_buf[8]; long net_len, garbage; if(len < 8) { --- 167,173 ---- int len; { static int seeded = 0; ! static char garbage_buf[8]; long net_len, garbage; if(len < 8) { *************** *** 192,202 **** } /* pcbc_encrypt outputs in 8-byte (64 bit) increments */ ! (void) des_pcbc_encrypt((len < 8) ? garbage_buf : (des_cblock *)buf, ! des_outbuf, (len < 8) ? 8 : len, ! key_schedule, /* DES key */ ! key, /* IV */ ENCRYPT); /* tell the other end the real amount, but send an 8-byte padded --- 183,193 ---- } /* pcbc_encrypt outputs in 8-byte (64 bit) increments */ ! (void) des_pcbc_encrypt((des_cblock *)((len < 8) ? garbage_buf : buf), ! (des_cblock *)des_outbuf, (len < 8) ? 8 : len, ! key_schedule, /* DES key */ ! (des_cblock *)key, /* IV */ ENCRYPT); /* tell the other end the real amount, but send an 8-byte padded