[BACK]Return to des_rw.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / rlogin

Diff for /src/usr.bin/rlogin/Attic/des_rw.c between version 1.2 and 1.3

version 1.2, 1995/12/16 22:20:31 version 1.3, 1996/04/17 07:15:17
Line 52 
Line 52 
 #include <time.h>  #include <time.h>
 #include <unistd.h>  #include <unistd.h>
   
 static des_cblock       des_inbuf[10240], storage[10240], *store_ptr;  static unsigned char    des_inbuf[10240], storage[10240], *store_ptr;
 static des_cblock       *key;  static bit_64           *key;
 static des_key_schedule key_schedule;  static u_char           *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   * NB: These routines will not function properly if NBIO
  *      is set   *      is set
Line 78 
Line 70 
  * The inkey parameter is actually the DES initial vector,   * The inkey parameter is actually the DES initial vector,
  * and the insched is the DES Key unwrapped for faster decryption   * and the insched is the DES Key unwrapped for faster decryption
  */   */
   static int nstored = 0;
   
 int  void
 des_set_key(inkey, insched)  desrw_set_key(inkey, insched)
         des_cblock              *inkey;          bit_64          *inkey;
         des_key_schedule        insched;          u_char          *insched;
 {  {
         key = inkey;          key = inkey;
         bcopy(insched, key_schedule, sizeof(key_schedule));          key_schedule = insched;
           nstored = 0;
         return 0;  
 }  }
   
 void  void
 des_clear_key()  desrw_clear_key()
 {  {
         bzero((char *) key, sizeof(C_Block));          bzero((char *) key, sizeof(C_Block));
         bzero((char *) key_schedule, sizeof(Key_schedule));          bzero((char *) key_schedule, sizeof(Key_schedule));
Line 104 
Line 96 
         register char *buf;          register char *buf;
         int len;          int len;
 {  {
         int nreturned = 0;  
         long net_len, rd_len;          long net_len, rd_len;
         int nstored = 0;          int nreturned = 0;
   
         if (nstored >= len) {          if (nstored >= len) {
                 (void) bcopy(store_ptr, buf, len);                  (void) bcopy(store_ptr, buf, len);
Line 140 
Line 131 
                 /* pipe must have closed, return 0 */                  /* pipe must have closed, return 0 */
                 return(0);                  return(0);
         }          }
         (void) des_pcbc_encrypt(des_inbuf,      /* inbuf */          (void) des_pcbc_encrypt((des_cblock *)des_inbuf,        /* inbuf */
                             storage,            /* outbuf */                              (des_cblock *)storage,              /* outbuf */
                             net_len,            /* length */                              rd_len,                             /* length */
                             key_schedule,       /* DES key */                              key_schedule,                       /* DES key */
                             key,                /* IV */                              (des_cblock *)key,                  /* IV */
                             DECRYPT);           /* direction */                              DECRYPT);                           /* direction */
   
         if(net_len < 8)          if(net_len < 8)
                 store_ptr = storage + 8 - net_len;                  store_ptr = storage + 8 - net_len;
Line 167 
Line 158 
         return(nreturned);          return(nreturned);
 }  }
   
 static  des_cblock des_outbuf[10240];   /* > longest write */  static unsigned char    des_outbuf[10240];      /* > longest write */
   
 int  int
 des_write(fd, buf, len)  des_write(fd, buf, len)
Line 176 
Line 167 
         int len;          int len;
 {  {
         static  int     seeded = 0;          static  int     seeded = 0;
         static  des_cblock      garbage_buf[8];          static  char    garbage_buf[8];
         long net_len, garbage;          long net_len, garbage;
   
         if(len < 8) {          if(len < 8) {
Line 192 
Line 183 
         }          }
         /* pcbc_encrypt outputs in 8-byte (64 bit) increments */          /* pcbc_encrypt outputs in 8-byte (64 bit) increments */
   
         (void) des_pcbc_encrypt((len < 8) ? garbage_buf : (des_cblock *)buf,          (void) des_pcbc_encrypt((des_cblock *)((len < 8) ? garbage_buf : buf),
                             des_outbuf,                              (des_cblock *)des_outbuf,
                             (len < 8) ? 8 : len,                              (len < 8) ? 8 : len,
                             key_schedule,       /* DES key */                              key_schedule,               /* DES key */
                             key,                /* IV */                              (des_cblock *)key,          /* IV */
                             ENCRYPT);                              ENCRYPT);
   
         /* tell the other end the real amount, but send an 8-byte padded          /* tell the other end the real amount, but send an 8-byte padded

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3