Make encrypted Kerberos logins work
authortholo <tholo@openbsd.org>
Wed, 17 Apr 1996 07:15:17 +0000 (07:15 +0000)
committertholo <tholo@openbsd.org>
Wed, 17 Apr 1996 07:15:17 +0000 (07:15 +0000)
usr.bin/rlogin/des_rw.c
usr.bin/rlogin/rlogin.c

index f8a3262..bf928f8 100644 (file)
@@ -52,17 +52,9 @@ static char rcsid[] = "$NetBSD: des_rw.c,v 1.2 1995/03/21 07:58:30 cgd Exp $";
 #include <time.h>
 #include <unistd.h>
 
-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
index aa75a2d..c1bb31e 100644 (file)
@@ -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 '?':