#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
* 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));
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);
/* 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;
return(nreturned);
}
-static des_cblock des_outbuf[10240]; /* > longest write */
+static unsigned char des_outbuf[10240]; /* > longest write */
int
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) {
}
/* 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