More ANSI/ISO 9899-1990 to the people!

Now actually builds (not including util) with DEC "cc -std1" and Sun
"acc -Xc".  There are still major prototype conflicts, but there isn't
much to do about this.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@192 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Unknown User d91-jda
1995-11-12 20:22:06 +00:00
parent 9f1661eb7a
commit a445da10c5
20 changed files with 268 additions and 489 deletions

View File

@@ -539,7 +539,6 @@ auth_name(data, cnt)
unsigned char *data;
int cnt;
{
Authenticator *ap;
unsigned char savename[256];
if (cnt < 1) {

View File

@@ -111,11 +111,4 @@ void ofb64_session P((Session_Key *, int));
int ofb64_keyid P((int, unsigned char *, int *));
void ofb64_printsub P((unsigned char *, int, unsigned char *, int));
#if OLD
int des_new_random_key P((Block));
void des_set_random_generator_seed P((Block));
void des_key_sched P((Block, Schedule));
void des_ecb_encrypt P((Block, Block, Schedule, int));
int des_string_to_key P((char *, Block));
#endif
#endif

View File

@@ -46,12 +46,14 @@ static char orig_sccsid[] = "@(#)enc_des.c 5.1 (Berkeley) 3/22/91";
#include <stdio.h>
#ifdef __STDC__
#include <stdlib.h>
#include <string.h>
#endif
#include "encrypt.h"
#include "key-proto.h"
#include "misc-proto.h"
#include <des.h>
extern encrypt_debug_mode;
#define CFB 0
@@ -65,24 +67,26 @@ extern encrypt_debug_mode;
#define FAILED -1
struct stinfo {
des_cblock str_output;
des_cblock str_feed;
des_cblock str_iv;
des_cblock str_ikey;
des_key_schedule str_sched;
int str_index;
int str_flagshift;
};
struct fb {
Block krbdes_key;
Schedule krbdes_sched;
Block temp_feed;
des_cblock krbdes_key;
des_key_schedule krbdes_sched;
des_cblock temp_feed;
unsigned char fb_feed[64];
int need_start;
int state[2];
int keyid[2];
int once;
struct stinfo {
Block str_output;
Block str_feed;
Block str_iv;
Block str_ikey;
Schedule str_sched;
int str_index;
int str_flagshift;
} streams[2];
struct stinfo streams[2];
};
static struct fb fb[2];
@@ -114,18 +118,16 @@ struct keyidlist {
#define FB64_IV_BAD 3
void fb64_stream_iv P((Block, struct stinfo *));
void fb64_stream_iv P((des_cblock, struct stinfo *));
void fb64_init P((struct fb *));
static int fb64_start P((struct fb *, int, int));
int fb64_is P((unsigned char *, int, struct fb *));
int fb64_reply P((unsigned char *, int, struct fb *));
static void fb64_session P((Session_Key *, int, struct fb *));
void fb64_stream_key P((Block, struct stinfo *));
void fb64_stream_key P((des_cblock, struct stinfo *));
int fb64_keyid P((int, unsigned char *, int *, struct fb *));
void
cfb64_init(server)
int server;
void cfb64_init(int server)
{
fb64_init(&fb[CFB]);
fb[CFB].fb_feed[4] = ENCTYPE_DES_CFB64;
@@ -133,9 +135,8 @@ cfb64_init(server)
fb[CFB].streams[1].str_flagshift = SHIFT_VAL(1, CFB);
}
void
ofb64_init(server)
int server;
void ofb64_init(int server)
{
fb64_init(&fb[OFB]);
fb[OFB].fb_feed[4] = ENCTYPE_DES_OFB64;
@@ -143,9 +144,7 @@ ofb64_init(server)
fb[CFB].streams[1].str_flagshift = SHIFT_VAL(1, OFB);
}
void
fb64_init(fbp)
register struct fb *fbp;
void fb64_init(struct fb *fbp)
{
memset((void *)fbp,0, sizeof(*fbp));
fbp->state[0] = fbp->state[1] = FAILED;
@@ -163,28 +162,18 @@ fb64_init(fbp)
* 2: Not yet. Other things (like getting the key from
* Kerberos) have to happen before we can continue.
*/
int
cfb64_start(dir, server)
int dir;
int server;
int cfb64_start(int dir, int server)
{
return(fb64_start(&fb[CFB], dir, server));
}
int
ofb64_start(dir, server)
int dir;
int server;
int ofb64_start(int dir, int server)
{
return(fb64_start(&fb[OFB], dir, server));
}
static int
fb64_start(fbp, dir, server)
struct fb *fbp;
int dir;
int server;
static int fb64_start(struct fb *fbp, int dir, int server)
{
Block b;
int x;
unsigned char *p;
register int state;
@@ -222,7 +211,7 @@ fb64_start(fbp, dir, server)
* Create a random feed and send it over.
*/
#ifndef OLD_DES_RANDOM_KEY
des_new_random_key(fbp->temp_feed);
des_new_random_key(&fbp->temp_feed);
#else
/*
* From des_cryp.man "If the des_check_key flag is non-zero,
@@ -234,13 +223,14 @@ fb64_start(fbp, dir, server)
des_set_odd_parity(fbp->temp_feed);
} while (des_is_weak_key(fbp->temp_feed));
#endif
des_ecb_encrypt(fbp->temp_feed, fbp->temp_feed,
des_ecb_encrypt(&fbp->temp_feed,
&fbp->temp_feed,
fbp->krbdes_sched, 1);
p = fbp->fb_feed + 3;
*p++ = ENCRYPT_IS;
p++;
*p++ = FB64_IV;
for (x = 0; x < sizeof(Block); ++x) {
for (x = 0; x < sizeof(des_cblock); ++x) {
if ((*p++ = fbp->temp_feed[x]) == IAC)
*p++ = IAC;
}
@@ -261,30 +251,21 @@ fb64_start(fbp, dir, server)
* 0: Successful, initial negotiation all done.
* 1: successful, negotiation not done yet.
*/
int
cfb64_is(data, cnt)
unsigned char *data;
int cnt;
int cfb64_is(unsigned char *data, int cnt)
{
return(fb64_is(data, cnt, &fb[CFB]));
}
int
ofb64_is(data, cnt)
unsigned char *data;
int cnt;
int ofb64_is(unsigned char *data, int cnt)
{
return(fb64_is(data, cnt, &fb[OFB]));
}
int
fb64_is(data, cnt, fbp)
unsigned char *data;
int cnt;
struct fb *fbp;
int fb64_is(unsigned char *data, int cnt, struct fb *fbp)
{
int x;
unsigned char *p;
Block b;
register int state = fbp->state[DIR_DECRYPT-1];
if (cnt-- < 1)
@@ -292,7 +273,7 @@ fb64_is(data, cnt, fbp)
switch (*data++) {
case FB64_IV:
if (cnt != sizeof(Block)) {
if (cnt != sizeof(des_cblock)) {
if (encrypt_debug_mode)
printf("CFB64: initial vector failed on size\r\n");
state = FAILED;
@@ -352,31 +333,20 @@ fb64_is(data, cnt, fbp)
* 0: Successful, initial negotiation all done.
* 1: successful, negotiation not done yet.
*/
int
cfb64_reply(data, cnt)
unsigned char *data;
int cnt;
int cfb64_reply(unsigned char *data, int cnt)
{
return(fb64_reply(data, cnt, &fb[CFB]));
}
int
ofb64_reply(data, cnt)
unsigned char *data;
int cnt;
int ofb64_reply(unsigned char *data, int cnt)
{
return(fb64_reply(data, cnt, &fb[OFB]));
}
int
fb64_reply(data, cnt, fbp)
unsigned char *data;
int cnt;
struct fb *fbp;
int fb64_reply(unsigned char *data, int cnt, struct fb *fbp)
{
int x;
unsigned char *p;
Block b;
register int state = fbp->state[DIR_ENCRYPT-1];
if (cnt-- < 1)
@@ -392,7 +362,7 @@ fb64_reply(data, cnt, fbp)
break;
case FB64_IV_BAD:
memset(fbp->temp_feed, 0, sizeof(Block));
memset(fbp->temp_feed, 0, sizeof(des_cblock));
fb64_stream_iv(fbp->temp_feed, &fbp->streams[DIR_ENCRYPT-1]);
state = FAILED;
break;
@@ -411,27 +381,17 @@ fb64_reply(data, cnt, fbp)
return(fbp->state[DIR_ENCRYPT-1] = state);
}
void
cfb64_session(key, server)
Session_Key *key;
int server;
void cfb64_session(Session_Key *key, int server)
{
fb64_session(key, server, &fb[CFB]);
}
void
ofb64_session(key, server)
Session_Key *key;
int server;
void ofb64_session(Session_Key *key, int server)
{
fb64_session(key, server, &fb[OFB]);
}
static void
fb64_session(key, server, fbp)
Session_Key *key;
int server;
struct fb *fbp;
static void fb64_session(Session_Key *key, int server, struct fb *fbp)
{
if (!key || key->type != SK_DES) {
@@ -440,18 +400,18 @@ fb64_session(key, server, fbp)
key ? key->type : -1, SK_DES);
return;
}
memcpy((void *)fbp->krbdes_key, (void *)key->data, sizeof(Block));
memcpy((void *)fbp->krbdes_key, (void *)key->data, sizeof(des_cblock));
fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_ENCRYPT-1]);
fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_DECRYPT-1]);
if (fbp->once == 0) {
#ifndef OLD_DES_RANDOM_KEY
des_init_random_number_generator(fbp->krbdes_key);
des_init_random_number_generator(&fbp->krbdes_key);
#endif
fbp->once = 1;
}
des_key_sched(fbp->krbdes_key, fbp->krbdes_sched);
des_key_sched(&fbp->krbdes_key, fbp->krbdes_sched);
/*
* Now look to see if krbdes_start() was was waiting for
* the key to show up. If so, go ahead an call it now
@@ -467,27 +427,18 @@ fb64_session(key, server, fbp)
* We only accept a keyid of 0. If we get a keyid of
* 0, then mark the state as SUCCESS.
*/
int
cfb64_keyid(dir, kp, lenp)
int dir, *lenp;
unsigned char *kp;
int cfb64_keyid(int dir, unsigned char *kp, int *lenp)
{
return(fb64_keyid(dir, kp, lenp, &fb[CFB]));
}
int
ofb64_keyid(dir, kp, lenp)
int dir, *lenp;
unsigned char *kp;
int ofb64_keyid(int dir, unsigned char *kp, int *lenp)
{
return(fb64_keyid(dir, kp, lenp, &fb[OFB]));
}
int
fb64_keyid(dir, kp, lenp, fbp)
int dir, *lenp;
unsigned char *kp;
struct fb *fbp;
int fb64_keyid(int dir, unsigned char *kp, int *lenp, struct fb *fbp)
{
register int state = fbp->state[dir-1];
@@ -504,10 +455,8 @@ fb64_keyid(dir, kp, lenp, fbp)
return(fbp->state[dir-1] = state);
}
void
fb64_printsub(data, cnt, buf, buflen, type)
unsigned char *data, *buf, *type;
int cnt, buflen;
void fb64_printsub(unsigned char *data, int cnt,
unsigned char *buf, int buflen, char *type)
{
char lbuf[32];
register int i;
@@ -547,47 +496,37 @@ fb64_printsub(data, cnt, buf, buflen, type)
}
}
void
cfb64_printsub(data, cnt, buf, buflen)
unsigned char *data, *buf;
int cnt, buflen;
void cfb64_printsub(unsigned char *data, int cnt,
unsigned char *buf, int buflen)
{
fb64_printsub(data, cnt, buf, buflen, "CFB64");
}
void
ofb64_printsub(data, cnt, buf, buflen)
unsigned char *data, *buf;
int cnt, buflen;
void ofb64_printsub(unsigned char *data, int cnt,
unsigned char *buf, int buflen)
{
fb64_printsub(data, cnt, buf, buflen, "OFB64");
}
void
fb64_stream_iv(seed, stp)
Block seed;
register struct stinfo *stp;
void fb64_stream_iv(des_cblock seed, struct stinfo *stp)
{
memcpy((void *)stp->str_iv, (void *)seed,sizeof(Block));
memcpy((void *)stp->str_output, (void *)seed, sizeof(Block));
memcpy((void *)stp->str_iv, (void *)seed,sizeof(des_cblock));
memcpy((void *)stp->str_output, (void *)seed, sizeof(des_cblock));
des_key_sched(stp->str_ikey, stp->str_sched);
des_key_sched(&stp->str_ikey, stp->str_sched);
stp->str_index = sizeof(Block);
stp->str_index = sizeof(des_cblock);
}
void
fb64_stream_key(key, stp)
Block key;
register struct stinfo *stp;
void fb64_stream_key(des_cblock key, register struct stinfo *stp)
{
memcpy((void *)stp->str_ikey, (void *)key, sizeof(Block));
des_key_sched(key, stp->str_sched);
memcpy((void *)stp->str_ikey, (void *)key, sizeof(des_cblock));
des_key_sched((des_cblock*)key, stp->str_sched);
memcpy((void *)stp->str_output, (void *)stp->str_iv, sizeof(Block));
memcpy((void *)stp->str_output, (void *)stp->str_iv, sizeof(des_cblock));
stp->str_index = sizeof(Block);
stp->str_index = sizeof(des_cblock);
}
/*
@@ -612,20 +551,17 @@ fb64_stream_key(key, stp)
* V(n+1) = DES(On, key)
*/
void
cfb64_encrypt(s, c)
register unsigned char *s;
int c;
void cfb64_encrypt(unsigned char *s, int c)
{
register struct stinfo *stp = &fb[CFB].streams[DIR_ENCRYPT-1];
register int index;
index = stp->str_index;
while (c-- > 0) {
if (index == sizeof(Block)) {
Block b;
des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1);
memcpy((void *)stp->str_feed, (void *)b, sizeof(Block));
if (index == sizeof(des_cblock)) {
des_cblock b;
des_ecb_encrypt(&stp->str_output, &b,stp->str_sched, 1);
memcpy((void *)stp->str_feed, (void *)b, sizeof(des_cblock));
index = 0;
}
@@ -637,9 +573,7 @@ cfb64_encrypt(s, c)
stp->str_index = index;
}
int
cfb64_decrypt(data)
int data;
int cfb64_decrypt(int data)
{
register struct stinfo *stp = &fb[CFB].streams[DIR_DECRYPT-1];
int index;
@@ -656,10 +590,10 @@ cfb64_decrypt(data)
}
index = stp->str_index++;
if (index == sizeof(Block)) {
Block b;
des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1);
memcpy((void *)stp->str_feed, (void *)b, sizeof(Block));
if (index == sizeof(des_cblock)) {
des_cblock b;
des_ecb_encrypt(&stp->str_output,&b, stp->str_sched, 1);
memcpy((void *)stp->str_feed, (void *)b, sizeof(des_cblock));
stp->str_index = 1; /* Next time will be 1 */
index = 0; /* But now use 0 */
}
@@ -688,20 +622,18 @@ cfb64_decrypt(data)
* V(n+1) = DES(Vn, key)
* On = Dn ^ Vn
*/
void
ofb64_encrypt(s, c)
register unsigned char *s;
int c;
void ofb64_encrypt(unsigned char *s, int c)
{
register struct stinfo *stp = &fb[OFB].streams[DIR_ENCRYPT-1];
register int index;
index = stp->str_index;
while (c-- > 0) {
if (index == sizeof(Block)) {
Block b;
des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1);
memcpy((void *)stp->str_feed, (void *)b, sizeof(Block));
if (index == sizeof(des_cblock)) {
des_cblock b;
des_ecb_encrypt(&stp->str_feed,&b, stp->str_sched, 1);
memcpy((void *)stp->str_feed, (void *)b, sizeof(des_cblock));
index = 0;
}
*s++ ^= stp->str_feed[index];
@@ -710,9 +642,7 @@ ofb64_encrypt(s, c)
stp->str_index = index;
}
int
ofb64_decrypt(data)
int data;
int ofb64_decrypt(int data)
{
register struct stinfo *stp = &fb[OFB].streams[DIR_DECRYPT-1];
int index;
@@ -729,10 +659,10 @@ ofb64_decrypt(data)
}
index = stp->str_index++;
if (index == sizeof(Block)) {
Block b;
des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1);
memcpy((void *)stp->str_feed, (void *)b, sizeof(Block));
if (index == sizeof(des_cblock)) {
des_cblock b;
des_ecb_encrypt(&stp->str_feed,&b,stp->str_sched, 1);
memcpy((void *)stp->str_feed, (void *)b, sizeof(des_cblock));
stp->str_index = 1; /* Next time will be 1 */
index = 0; /* But now use 0 */
}

View File

@@ -581,7 +581,7 @@ encrypt_is(data, cnt)
} else {
ret = (*ep->is)(data, cnt);
if (encrypt_debug_mode)
printf("(*ep->is)(%x, %d) returned %s(%d)\n", data, cnt,
printf("(*ep->is)(%p, %d) returned %s(%d)\n", data, cnt,
(ret < 0) ? "FAIL " :
(ret == 0) ? "SUCCESS " : "MORE_TO_DO ", ret);
}
@@ -625,7 +625,7 @@ encrypt_reply(data, cnt)
} else {
ret = (*ep->reply)(data, cnt);
if (encrypt_debug_mode)
printf("(*ep->reply)(%x, %d) returned %s(%d)\n",
printf("(*ep->reply)(%p, %d) returned %s(%d)\n",
data, cnt,
(ret < 0) ? "FAIL " :
(ret == 0) ? "SUCCESS " : "MORE_TO_DO ", ret);
@@ -741,27 +741,9 @@ encrypt_request_start(data, cnt)
static unsigned char str_keyid[(MAXKEYLEN*2)+5] = { IAC, SB, TELOPT_ENCRYPT };
encrypt_enc_keyid(keyid, len)
unsigned char *keyid;
int len;
{
encrypt_keyid(&ki[1], keyid, len);
}
encrypt_dec_keyid(keyid, len)
unsigned char *keyid;
int len;
{
encrypt_keyid(&ki[0], keyid, len);
}
encrypt_keyid(kp, keyid, len)
struct key_info *kp;
unsigned char *keyid;
int len;
void encrypt_keyid(struct key_info *kp, unsigned char *keyid, int len)
{
Encryptions *ep;
unsigned char *strp, *cp;
int dir = kp->dir;
register int ret = 0;
@@ -798,12 +780,18 @@ encrypt_keyid(kp, keyid, len)
encrypt_send_keyid(dir, kp->keyid, kp->keylen, 0);
}
void
encrypt_send_keyid(dir, keyid, keylen, saveit)
int dir;
unsigned char *keyid;
int keylen;
int saveit;
void encrypt_enc_keyid(unsigned char *keyid, int len)
{
encrypt_keyid(&ki[1], keyid, len);
}
void encrypt_dec_keyid(unsigned char *keyid, int len)
{
encrypt_keyid(&ki[0], keyid, len);
}
void encrypt_send_keyid(int dir, unsigned char *keyid, int keylen, int saveit)
{
unsigned char *strp;
@@ -954,10 +942,9 @@ encrypt_send_request_end()
printf(">>>%s: Request input to be clear text\r\n", Name);
}
void
encrypt_wait()
void encrypt_wait(void)
{
register int encrypt, decrypt;
if (encrypt_debug_mode)
printf(">>>%s: in encrypt_wait\r\n", Name);
if (!havesessionkey || !(I_SUPPORT_ENCRYPT & remote_supports_decrypt))
@@ -974,10 +961,8 @@ encrypt_debug(mode)
encrypt_debug_mode = mode;
}
void
encrypt_gen_printsub(data, cnt, buf, buflen)
unsigned char *data, *buf;
int cnt, buflen;
void encrypt_gen_printsub(unsigned char *data, int cnt,
unsigned char *buf, int buflen)
{
char tbuf[16], *cp;

View File

@@ -62,14 +62,10 @@
#define DIR_DECRYPT 1
#define DIR_ENCRYPT 2
typedef unsigned char Block[8];
typedef unsigned char *BlockT;
typedef struct { Block _B; } Schedule[16];
#define VALIDKEY(key) ( key[0] | key[1] | key[2] | key[3] | \
key[4] | key[5] | key[6] | key[7])
#define SAMEKEY(k1, k2) (!bcmp((void *)k1, (void *)k2, sizeof(Block)))
#define SAMEKEY(k1, k2) (!bcmp((void *)k1, (void *)k2, sizeof(des_cblock)))
typedef struct {
short type;

View File

@@ -45,11 +45,9 @@ static char sccsid[] = "@(#)genget.c 8.2 (Berkeley) 5/30/95";
* the length is returned. If *s1 is a prefix of *s2,
* the length of *s1 is returned.
*/
int
isprefix(s1, s2)
register char *s1, *s2;
int isprefix(char *s1, char *s2)
{
register int n = 0;
char *os1;
register char c1, c2;

View File

@@ -131,7 +131,7 @@ static krb5_authenticator authenticator;
#define Voidptr krb5_pointer
Block session_key;
des_cblock session_key;
static int
Data(ap, type, d, c)
@@ -430,12 +430,12 @@ kerberos5_is(ap, data, cnt)
authdat->authenticator->subkey->keytype == KEYTYPE_DES) {
memmove((Voidptr )session_key,
(Voidptr )authdat->authenticator->subkey->contents,
sizeof(Block));
sizeof(des_cblock));
} else if (authdat->ticket->enc_part2->session->keytype ==
KEYTYPE_DES) {
memmove((Voidptr )session_key,
(Voidptr )authdat->ticket->enc_part2->session->contents,
sizeof(Block));
sizeof(des_cblock));
} else
break;
@@ -518,7 +518,7 @@ kerberos5_reply(ap, data, cnt)
tmpkey.keytype = KEYTYPE_DES;
tmpkey.contents = session_key;
tmpkey.length = sizeof(Block);
tmpkey.length = sizeof(des_cblock);
if (r = krb5_rd_rep(&inbuf, &tmpkey, &reply)) {
printf("[ Mutual authentication failed: %s ]\n",

View File

@@ -1,71 +0,0 @@
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)key-proto.h 8.1 (Berkeley) 6/4/93
*/
/*
* Copyright (C) 1990 by the Massachusetts Institute of Technology
*
* Export of this software from the United States of America is assumed
* to require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*/
#ifndef __KEY_PROTO__
#define __KEY_PROTO__
#if !defined(P)
#ifdef __STDC__
#define P(x) x
#else
#define P(x) ()
#endif
#endif
int key_file_exists P((void));
void key_lookup P((unsigned char *, Block));
void key_stream_init P((Block, Block, int));
unsigned char key_stream P((int, int));
#endif

View File

@@ -113,7 +113,7 @@ static KTEXT_ST auth;
static char name[ANAME_SZ];
static char user_passwd[ANAME_SZ];
static AUTH_DAT adat = { 0 };
static Schedule sched;
static des_key_schedule sched;
static char challenge[REALM_SZ];
static int
@@ -157,7 +157,7 @@ krb4encpwd_init(ap, server)
int server;
{
char hostname[80], *cp, *realm;
C_Block skey;
des_clock skey;
if (server) {
str_data[3] = TELQUAL_REPLY;
@@ -202,7 +202,7 @@ krb4encpwd_is(ap, data, cnt)
int cnt;
{
Session_Key skey;
Block datablock;
des_cblock datablock;
char r_passwd[ANAME_SZ], r_user[ANAME_SZ];
char lhostname[ANAME_SZ], *cp;
int r;
@@ -232,7 +232,7 @@ krb4encpwd_is(ap, data, cnt)
return;
}
memmove((void *)session_key, (void *)adat.session, sizeof(Block));
memmove((void *)session_key, (void *)adat.session, sizeof(des_cblock));
Data(ap, KRB4_ENCPWD_ACCEPT, (void *)0, 0);
auth_finished(ap, AUTH_USER);
break;
@@ -242,7 +242,7 @@ krb4encpwd_is(ap, data, cnt)
* Take the received random challenge text and save
* for future authentication.
*/
memmove((void *)challenge, (void *)data, sizeof(Block));
memmove((void *)challenge, (void *)data, sizeof(des_cblock));
break;
@@ -280,7 +280,7 @@ krb4encpwd_reply(ap, data, cnt)
{
Session_Key skey;
KTEXT_ST krb_token;
Block enckey;
des_cblock enckey;
CREDENTIALS cred;
int r;
char randchal[REALM_SZ], instance[ANAME_SZ], *cp;

View File

@@ -200,7 +200,7 @@ rsaencpwd_is(ap, data, cnt)
int cnt;
{
Session_Key skey;
Block datablock;
des_cblock datablock;
char r_passwd[PWD_SZ], r_user[NAME_SZ];
char *cp, key[160];
char chalkey[160], *ptr;
@@ -321,7 +321,7 @@ rsaencpwd_reply(ap, data, cnt)
{
Session_Key skey;
KTEXT_ST token;
Block enckey;
des_cblock enckey;
int r, pubkey_len;
char randchal[CHAL_SZ], *cp;
char chalkey[160], pubkey[128], *ptr;

View File

@@ -100,8 +100,8 @@ static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION,
#define SPX_REJECT 1 /* Rejected (reason might follow) */
#define SPX_ACCEPT 2 /* Accepted */
static Schedule sched;
static Block challenge = { 0 };
static des_key_schedule sched;
static des_cblock challenge = { 0 };
/*******************************************************************/
@@ -200,7 +200,7 @@ spx_init(ap, server)
spx_send(ap)
Authenticator *ap;
{
Block enckey;
des_cblock enckey;
int r;
gss_OID actual_mech_type, output_name_type;
@@ -312,7 +312,7 @@ spx_is(ap, data, cnt)
int cnt;
{
Session_Key skey;
Block datablock;
des_cblock datablock;
int r;
if (cnt-- < 1)

View File

@@ -56,7 +56,7 @@ static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95";
#include <netdb.h>
#include <ctype.h>
#include <pwd.h>
#include <varargs.h>
#include <stdarg.h>
#include <errno.h>
#include <stdlib.h>
@@ -81,7 +81,7 @@ static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95";
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif MAXHOSTNAMELEN
#endif
#if defined(IPPROTO_IP) && defined(IP_TOS)
int tos = -1;
@@ -96,7 +96,8 @@ extern int isprefix();
extern char **genget();
extern int Ambiguous();
static call();
typedef int (*intrtn_t)(int, char**);
static int call(intrtn_t, ...);
typedef struct {
char *name; /* command name */
@@ -167,9 +168,7 @@ makeargv()
* Todo: 1. Could take random integers (12, 0x12, 012, 0b1).
*/
static
special(s)
register char *s;
static char special(char *s)
{
register char c;
char b;
@@ -289,14 +288,10 @@ static struct sendlist Sendlist[] = {
#define GETSEND(name) ((struct sendlist *) genget(name, (char **) Sendlist, \
sizeof(struct sendlist)))
static int
sendcmd(argc, argv)
int argc;
char **argv;
static int sendcmd(int argc, char **argv)
{
int count; /* how many bytes we are going to need to send */
int i;
int question = 0; /* was at least one argument a question */
struct sendlist *s; /* pointer to current command */
int success = 0;
int needconnect = 0;
@@ -1085,8 +1080,7 @@ unsetcmd(argc, argv)
#ifdef KLUDGELINEMODE
extern int kludgelinemode;
static int
dokludgemode()
static void dokludgemode(void)
{
kludgelinemode = 1;
send_wont(TELOPT_LINEMODE, 1);
@@ -1437,11 +1431,7 @@ shell(argc, argv)
extern int shell();
#endif /* !defined(TN3270) */
/*VARARGS*/
static
bye(argc, argv)
int argc; /* Number of arguments */
char *argv[]; /* arguments */
static int bye(int argc, char **argv)
{
extern int resettermname;
@@ -1464,11 +1454,10 @@ bye(argc, argv)
longjmp(toplevel, 1);
/* NOTREACHED */
}
return 1; /* Keep lint, etc., happy */
}
/*VARARGS*/
quit()
void quit(void)
{
(void) call(bye, "bye", "fromquit", 0);
Exit(0);
@@ -1533,10 +1522,7 @@ getslc(name)
genget(name, (char **) SlcList, sizeof(struct slclist));
}
static
slccmd(argc, argv)
int argc;
char *argv[];
static int slccmd(int argc, char **argv)
{
struct slclist *c;
@@ -1630,9 +1616,7 @@ getenvcmd(name)
genget(name, (char **) EnvList, sizeof(struct envlist));
}
env_cmd(argc, argv)
int argc;
char *argv[];
int env_cmd(int argc, char **argv)
{
struct envlist *c;
@@ -1854,7 +1838,7 @@ env_default(init, welldefined)
if (init) {
nep = &envlisthead;
return;
return NULL;
}
if (nep) {
while (nep = nep->next) {
@@ -1961,9 +1945,7 @@ auth_help()
return 0;
}
auth_cmd(argc, argv)
int argc;
char *argv[];
int auth_cmd(int argc, char **argv)
{
struct authlist *c;
@@ -2068,9 +2050,7 @@ EncryptHelp()
return 0;
}
encrypt_cmd(argc, argv)
int argc;
char *argv[];
int encrypt_cmd(int argc, char **argv)
{
struct encryptlist *c;
@@ -2148,11 +2128,8 @@ filestuff(fd)
/*
* Print status about the connection.
*/
/*ARGSUSED*/
static
status(argc, argv)
int argc;
char *argv[];
static int status(int argc, char **argv)
{
if (connected) {
printf("Connected to %s.\n", hostname);
@@ -2230,10 +2207,91 @@ ayt_status()
unsigned long inet_addr();
int
tn(argc, argv)
int argc;
char *argv[];
static char *rcname = 0;
static char rcbuf[128];
static Command *getcmd(char *name);
static void cmdrc(char *m1, char *m2)
{
register Command *c;
FILE *rcfile;
int gotmachine = 0;
int l1 = strlen(m1);
int l2 = strlen(m2);
char m1save[64];
if (skiprc)
return;
strcpy(m1save, m1);
m1 = m1save;
if (rcname == 0) {
rcname = getenv("HOME");
if (rcname)
strcpy(rcbuf, rcname);
else
rcbuf[0] = '\0';
strcat(rcbuf, "/.telnetrc");
rcname = rcbuf;
}
if ((rcfile = fopen(rcname, "r")) == 0) {
return;
}
for (;;) {
if (fgets(line, sizeof(line), rcfile) == NULL)
break;
if (line[0] == 0)
break;
if (line[0] == '#')
continue;
if (gotmachine) {
if (!isspace(line[0]))
gotmachine = 0;
}
if (gotmachine == 0) {
if (isspace(line[0]))
continue;
if (strncasecmp(line, m1, l1) == 0)
strncpy(line, &line[l1], sizeof(line) - l1);
else if (strncasecmp(line, m2, l2) == 0)
strncpy(line, &line[l2], sizeof(line) - l2);
else if (strncasecmp(line, "DEFAULT", 7) == 0)
strncpy(line, &line[7], sizeof(line) - 7);
else
continue;
if (line[0] != ' ' && line[0] != '\t' && line[0] != '\n')
continue;
gotmachine = 1;
}
makeargv();
if (margv[0] == 0)
continue;
c = getcmd(margv[0]);
if (Ambiguous(c)) {
printf("?Ambiguous command: %s\n", margv[0]);
continue;
}
if (c == 0) {
printf("?Invalid command: %s\n", margv[0]);
continue;
}
/*
* This should never happen...
*/
if (c->needconnect && !connected) {
printf("?Need to be connected first for %s.\n", margv[0]);
continue;
}
(*c->handler)(margc, margv);
}
fclose(rcfile);
}
int tn(int argc, char **argv)
{
register struct hostent *host = 0;
struct sockaddr_in sin;
@@ -2444,7 +2502,7 @@ tn(argc, argv)
user = getenv("USER");
if (user == NULL ||
(pw = getpwnam(user)) && pw->pw_uid != getuid()) {
((pw = getpwnam(user)) && pw->pw_uid != getuid())) {
if (pw = getpwuid(getuid()))
user = pw->pw_name;
else
@@ -2528,7 +2586,7 @@ static Command cmdtab[] = {
#endif
{ "environ", envhelp, env_cmd, 0 },
{ "?", helphelp, help, 0 },
0
{ 0, 0, 0, 0 }
};
static char crmodhelp[] = "deprecated command -- use 'toggle crmod' instead";
@@ -2538,7 +2596,7 @@ static Command cmdtab2[] = {
{ "help", 0, help, 0 },
{ "escape", escapehelp, setescape, 0 },
{ "crmod", crmodhelp, togcrmod, 0 },
0
{ 0, 0, 0, 0 }
};
@@ -2546,30 +2604,20 @@ static Command cmdtab2[] = {
* Call routine with argc, argv set from args (terminated by 0).
*/
/*VARARGS1*/
static
call(va_alist)
va_dcl
static int call(intrtn_t routine, ...)
{
va_list ap;
typedef int (*intrtn_t)();
intrtn_t routine;
char *args[100];
int argno = 0;
va_start(ap);
routine = (va_arg(ap, intrtn_t));
while ((args[argno++] = va_arg(ap, char *)) != 0) {
;
}
va_start(ap, routine);
while ((args[argno++] = va_arg(ap, char *)) != 0);
va_end(ap);
return (*routine)(argno-1, args);
}
static Command *
getcmd(name)
char *name;
static Command *getcmd(char *name)
{
Command *cm;
@@ -2662,10 +2710,7 @@ command(top, tbuf, cnt)
/*
* Help command.
*/
static
help(argc, argv)
int argc;
char *argv[];
static int help(int argc, char **argv)
{
register Command *c;
@@ -2692,88 +2737,6 @@ help(argc, argv)
return 0;
}
static char *rcname = 0;
static char rcbuf[128];
cmdrc(m1, m2)
char *m1, *m2;
{
register Command *c;
FILE *rcfile;
int gotmachine = 0;
int l1 = strlen(m1);
int l2 = strlen(m2);
char m1save[64];
if (skiprc)
return;
strcpy(m1save, m1);
m1 = m1save;
if (rcname == 0) {
rcname = getenv("HOME");
if (rcname)
strcpy(rcbuf, rcname);
else
rcbuf[0] = '\0';
strcat(rcbuf, "/.telnetrc");
rcname = rcbuf;
}
if ((rcfile = fopen(rcname, "r")) == 0) {
return;
}
for (;;) {
if (fgets(line, sizeof(line), rcfile) == NULL)
break;
if (line[0] == 0)
break;
if (line[0] == '#')
continue;
if (gotmachine) {
if (!isspace(line[0]))
gotmachine = 0;
}
if (gotmachine == 0) {
if (isspace(line[0]))
continue;
if (strncasecmp(line, m1, l1) == 0)
strncpy(line, &line[l1], sizeof(line) - l1);
else if (strncasecmp(line, m2, l2) == 0)
strncpy(line, &line[l2], sizeof(line) - l2);
else if (strncasecmp(line, "DEFAULT", 7) == 0)
strncpy(line, &line[7], sizeof(line) - 7);
else
continue;
if (line[0] != ' ' && line[0] != '\t' && line[0] != '\n')
continue;
gotmachine = 1;
}
makeargv();
if (margv[0] == 0)
continue;
c = getcmd(margv[0]);
if (Ambiguous(c)) {
printf("?Ambiguous command: %s\n", margv[0]);
continue;
}
if (c == 0) {
printf("?Invalid command: %s\n", margv[0]);
continue;
}
/*
* This should never happen...
*/
if (c->needconnect && !connected) {
printf("?Need to be connected first for %s.\n", margv[0]);
continue;
}
(*c->handler)(margc, margv);
}
fclose(rcfile);
}
#if defined(IP_OPTIONS) && defined(IPPROTO_IP)

View File

@@ -138,7 +138,7 @@ extern int
crmod,
netdata, /* Print out network data flow */
prettydump, /* Print "netdata" output in user readable format */
#if defined(unix)
#if defined(unix) || defined(__unix__) || defined(__unix)
#if defined(TN3270)
cursesdata, /* Print out curses data flow */
apitrace, /* Trace API transactions */
@@ -310,6 +310,8 @@ extern int
extern cc_t
*tcval P((int));
extern void quit P((void));
#ifndef USE_TERMIO
extern struct tchars ntc;

View File

@@ -101,10 +101,7 @@ static u_long ring_clock = 0;
/* Buffer state transition routines */
ring_init(ring, buffer, count)
Ring *ring;
unsigned char *buffer;
int count;
int ring_init(Ring *ring, unsigned char *buffer, int count)
{
memset((char *)ring, 0, sizeof *ring);

View File

@@ -1432,7 +1432,7 @@ startslave(host, autologin, autoname)
#ifdef ENCRYPTION
if (encrypt_output == 0 || decrypt_input == 0)
#endif
writenet(tbuf, strlen(tbuf));
writenet((unsigned char*)tbuf, strlen(tbuf));
}
#ifndef NEWINIT
# ifdef PARENT_DOES_UTMP

View File

@@ -165,8 +165,9 @@ char valid_opts[] = {
'\0'
};
main(argc, argv)
char *argv[];
void doit(struct sockaddr_in*);
int main(int argc, char **argv)
{
struct sockaddr_in from;
int on = 1, fromlen;
@@ -787,8 +788,7 @@ extern void telnet P((int, int, char *));
/*
* Get a pty, scan input lines.
*/
doit(who)
struct sockaddr_in *who;
void doit(struct sockaddr_in *who)
{
char *host, *inet_ntoa();
int t;

View File

@@ -978,7 +978,6 @@ printsub(direction, pointer, length)
break;
default:
def_case:
if (isprint(pointer[i]) && pointer[i] != '"') {
if (noquote) {
*nfrontp++ = '"';

View File

@@ -34,13 +34,13 @@ SOURCES = cbc_cksm.c cbc_enc.c ecb_enc.c pcbc_enc.c \
qud_cksm.c read_pwd.c set_key.c str2key.c \
cfb_enc.c \
3ecb_enc.c ofb_enc.c 3cbc_enc.c rnd_keys.c key_par.c \
enc_read.c enc_writ.c gethostid.c fcrypt.c
enc_read.c enc_writ.c fcrypt.c
OBJECTS = cbc_cksm.o cbc_enc.o ecb_enc.o pcbc_enc.o \
qud_cksm.o read_pwd.o set_key.o str2key.o \
cfb_enc.o \
3ecb_enc.o ofb_enc.o 3cbc_enc.o rnd_keys.o key_par.o \
enc_read.o enc_writ.o gethostid.o fcrypt.o
enc_read.o enc_writ.o fcrypt.o
all: $(LIB)

View File

@@ -1,31 +0,0 @@
/*
*
* Some systems doesn't have gethostid(2) (e.g Solaris if you don't
* link with libucb - and we don't want that...
*
* $Id$
*
*/
#include "config.h"
#ifndef HAVE_GETHOSTID
#include <stdio.h>
#include <sys/systeminfo.h>
long gethostid(void)
{
static int flag=0;
static long hostid;
if(!flag){
char s[32];
sysinfo(SI_HW_SERIAL, s, 32);
sscanf(s, "%u", &hostid);
flag=1;
}
return hostid;
}
#endif

View File

@@ -72,6 +72,25 @@ des_new_random_key(des_cblock *key)
return(0);
}
/* this is for broken Solaris */
#ifndef HAVE_GETHOSTID
#include <sys/systeminfo.h>
static long gethostid(void)
{
static int flag=0;
static long hostid;
if(!flag){
char s[32];
sysinfo(SI_HW_SERIAL, s, 32);
sscanf(s, "%u", &hostid);
flag=1;
}
return hostid;
}
#endif
/*
* des_init_random_number_generator:
*