Fixup libkstream build.

This commit is contained in:
thorpej 2000-06-17 06:39:32 +00:00
parent 942546fe30
commit f955e93968
3 changed files with 38 additions and 78 deletions

View File

@ -1,10 +1,13 @@
# $NetBSD: Makefile,v 1.1.1.1 2000/06/17 06:24:28 thorpej Exp $
# $NetBSD: Makefile,v 1.2 2000/06/17 06:39:32 thorpej Exp $
LIB= kstream
SRCS= kstream.c kstream-des.c
COPTS+= -g
CPPFLAGS+=-I${DESTDIR}/usr/include/kerberosIV
INCS= kstream.h
INCSDIR=/usr/include/kerberosIV
SHLIB_MAJOR?= 1
SHLIB_MINOR?= 0

View File

@ -1,4 +1,4 @@
/* $NetBSD: kstream-des.c,v 1.1.1.1 2000/06/17 06:24:28 thorpej Exp $ */
/* $NetBSD: kstream-des.c,v 1.2 2000/06/17 06:39:32 thorpej Exp $ */
/* DES-encrypted-stream implementation for MIT Kerberos.
Written by Ken Raeburn (Raeburn@Cygnus.COM), based on algorithms
@ -73,10 +73,7 @@ static kstream_ptr losing_realloc (old_ptr, new_size)
between 8 and 16 is an annoyance, but rlogin actually relies on being
able to send 12 bytes in one chunk. Bleah! */
static void
do_encrypt (out, inp, p)
ksdb *out;
ksdb *inp;
priv *p;
do_encrypt (ksdb *out, ksdb *inp, priv *p)
{
union {
char buf[16];
@ -134,16 +131,13 @@ do_encrypt (out, inp, p)
if (x)
abort ();
}
des_pcbc_encrypt ((des_cblock *)in.ptr, (des_cblock *)ptr, in.length,
p->x.u.sched, (des_cblock *)p->x.ivec, ENCRYPT);
des_pcbc_encrypt (in.ptr, ptr, in.length,
p->x.u.sched, (des_cblock *)p->x.ivec, 1);
out->ptr = ptr + ((in.length + 7) & ~7);
}
static int
encrypt (outp, inp, k)
ksdb *outp;
ksdb *inp;
kstream k;
encrypt (ksdb *outp, ksdb *inp, kstream k)
{
const int small_block_size = 16;
priv *p = (priv *) k->data;
@ -184,10 +178,7 @@ encrypt (outp, inp, k)
int _kstream_des_debug_OOB = 0;
static int
decrypt (outp, inp, k)
ksdb *outp;
ksdb *inp;
kstream k;
decrypt (ksdb *outp, ksdb *inp, kstream k)
{
char *ptr = inp->ptr;
unsigned long x = 0;
@ -202,7 +193,7 @@ decrypt (outp, inp, k)
and we still lose... */
x = *ptr & 0xff; /* get the first char */
while (x) {
if(_kstream_des_debug_OOB) fprintf(stderr,"BAD BYTE %02x\n\r", x);
if(_kstream_des_debug_OOB) fprintf(stderr,"BAD BYTE %02lx\n\r", x);
error_count++; /* count the bad byte */
ptr++; /* and skip it */
if(inp->length == error_count) {
@ -239,8 +230,8 @@ decrypt (outp, inp, k)
assert (p->buf1 != 0 || sz == 0);
outp->ptr = p->buf1;
outp->length = x;
pcbc_encrypt ((des_cblock *)ptr, (des_cblock *)outp->ptr, sz, p->x.u.sched,
(des_cblock *)p->x.ivec, DECRYPT);
pcbc_encrypt (ptr, outp->ptr, sz, p->x.u.sched,
(des_cblock *)p->x.ivec, 0);
if (p->no_right_justify == 0
&& x < 8)
outp->ptr = p->buf1 + 8 - x;
@ -248,9 +239,7 @@ decrypt (outp, inp, k)
}
static int
init (k, data)
kstream k;
void *data;
init (kstream k, void *data)
{
priv *p;
@ -267,9 +256,7 @@ init (k, data)
}
static int
rcp_init (k, data)
kstream k;
void *data;
rcp_init (kstream k, void *data)
{
int x = init (k, data);
((priv *)(k->data))->no_right_justify = 1;
@ -277,9 +264,7 @@ rcp_init (k, data)
}
static int
rlogin_init (k, data)
kstream k;
void *data;
rlogin_init (kstream k, void *data)
{
int x = init (k, data);
((priv *)(k->data))->protect_rlogin_oob = 1;
@ -287,8 +272,7 @@ rlogin_init (k, data)
}
static void
destroy (k)
kstream k;
destroy (kstream k)
{
priv *p = (priv *) k->data;
if (p->buf1)
@ -307,10 +291,8 @@ static const struct kstream_crypt_ctl_block kstream_des_rcp_ccb = {
};
kstream
kstream_create_rlogin_from_fd (fd, P_sched, ivec)
int fd;
kstream_ptr P_sched;
des_cblock (*ivec);
kstream_create_rlogin_from_fd (int fd, kstream_ptr P_sched,
des_cblock (*ivec))
{
Key_schedule *sched = (Key_schedule *) P_sched;
kstream_des_init_block x;
@ -323,10 +305,8 @@ kstream_create_rlogin_from_fd (fd, P_sched, ivec)
}
kstream
kstream_create_rcp_from_fd (fd, P_sched, ivec)
int fd;
kstream_ptr P_sched;
des_cblock (*ivec);
kstream_create_rcp_from_fd (int fd, kstream_ptr P_sched,
des_cblock (*ivec))
{
Key_schedule *sched = (Key_schedule *) P_sched;
kstream_des_init_block x;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kstream.c,v 1.1.1.1 2000/06/17 06:24:28 thorpej Exp $ */
/* $NetBSD: kstream.c,v 1.2 2000/06/17 06:39:32 thorpej Exp $ */
/* Encrypted-stream implementation for MIT Kerberos.
Written by Ken Raeburn (Raeburn@Cygnus.COM).
@ -42,6 +42,7 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/* Only use alloca if we've got gcc 2 or better */
#ifdef __GNUC__
@ -65,7 +66,6 @@ char *malloc ();
char *realloc ();
void free ();
#endif
extern int errno;
#ifdef sun
#ifndef solaris20
@ -74,31 +74,24 @@ extern int errno;
#endif
#endif
static void fifo__init (this)
fifo *this;
static void fifo__init (fifo *this)
{
this->next_write = this->next_read = 0;
memset (this->data, 0, sizeof (this->data));
}
static char *fifo__data_start (this)
fifo *this;
static char *fifo__data_start (fifo *this)
{
return this->data + this->next_read;
}
static size_t fifo__bytes_available (this)
fifo *this;
static size_t fifo__bytes_available (fifo *this)
{
return this->next_write - this->next_read;
}
static size_t fifo__space_available (this)
fifo *this;
static size_t fifo__space_available (fifo *this)
{
return sizeof (this->data) - fifo__bytes_available (this);
}
static int fifo__append (this, ptr, len)
fifo *this;
const char *ptr;
size_t len;
static int fifo__append (fifo *this, const char *ptr, size_t len)
{
if (len > fifo__space_available (this))
len = fifo__space_available (this);
@ -113,10 +106,7 @@ static int fifo__append (this, ptr, len)
this->next_write += len;
return len;
}
static int fifo__extract (this, ptr, len)
fifo *this;
char *ptr;
size_t len;
static int fifo__extract (fifo *this, char *ptr, size_t len)
{
size_t n = fifo__bytes_available (this);
if (len > n)
@ -129,8 +119,7 @@ static int fifo__extract (this, ptr, len)
return len;
}
static void kstream_rec__init (this)
kstream_rec *this;
static void kstream_rec__init (kstream_rec *this)
{
fifo__init (&this->in_crypt);
fifo__init (&this->in_clear);
@ -138,10 +127,8 @@ static void kstream_rec__init (this)
}
kstream
kstream_create_from_fd (fd, ctl, data)
int fd;
const struct kstream_crypt_ctl_block *ctl;
void *data;
kstream_create_from_fd (int fd, const struct kstream_crypt_ctl_block *ctl,
void *data)
{
kstream k;
k = (kstream) malloc (sizeof (kstream_rec));
@ -161,8 +148,7 @@ kstream_create_from_fd (fd, ctl, data)
}
int
kstream_destroy (k)
kstream k;
kstream_destroy (kstream k)
{
int x = kstream_flush (k);
if (k->ctl && k->ctl->destroy)
@ -172,18 +158,13 @@ kstream_destroy (k)
}
void
kstream_set_buffer_mode (k, mode)
kstream k;
int mode;
kstream_set_buffer_mode (kstream k, int mode)
{
k->buffering = mode;
}
int
kstream_write (k, p_data, p_len)
kstream k;
kstream_ptr p_data;
size_t p_len;
kstream_write (kstream k, kstream_ptr p_data, size_t p_len)
{
size_t len = p_len;
char *data = p_data;
@ -208,8 +189,7 @@ kstream_write (k, p_data, p_len)
}
int
kstream_flush (k)
kstream k;
kstream_flush (kstream k)
{
int x, n;
fifo *out = &k->out_clear;
@ -253,10 +233,7 @@ kstream_flush (k)
}
int
kstream_read (k, p_data, p_len)
kstream k;
kstream_ptr p_data;
size_t p_len;
kstream_read (kstream k, kstream_ptr p_data, size_t p_len)
{
char *data = p_data;
size_t len = p_len;