diff options
author | markm <markm@FreeBSD.org> | 1996-10-26 17:20:52 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 1996-10-26 17:20:52 +0000 |
commit | 2389c0e613ea4ad0155e725d3ceb2c997a0d3e95 (patch) | |
tree | ea4788a781e37dff97f6a4cf0d86698c4106ba7c /eBones/lib | |
parent | 664237b984c18289c0002ec470b19333e03dbd67 (diff) | |
download | FreeBSD-src-2389c0e613ea4ad0155e725d3ceb2c997a0d3e95.zip FreeBSD-src-2389c0e613ea4ad0155e725d3ceb2c997a0d3e95.tar.gz |
First round of moving secure telnet (AKA kerberised telnet) to its new home
in eBones/. Peter has already (ages ago) done the repository copy. These
are mainly -Wall cleanups. The makefile changes will follow in a day or so.
Diffstat (limited to 'eBones/lib')
-rw-r--r-- | eBones/lib/libtelnet/auth-proto.h | 4 | ||||
-rw-r--r-- | eBones/lib/libtelnet/auth.c | 11 | ||||
-rw-r--r-- | eBones/lib/libtelnet/enc-proto.h | 12 | ||||
-rw-r--r-- | eBones/lib/libtelnet/enc_des.c | 30 | ||||
-rw-r--r-- | eBones/lib/libtelnet/encrypt.c | 36 | ||||
-rw-r--r-- | eBones/lib/libtelnet/genget.c | 7 | ||||
-rw-r--r-- | eBones/lib/libtelnet/kerberos.c | 17 | ||||
-rw-r--r-- | eBones/lib/libtelnet/misc.c | 6 |
8 files changed, 73 insertions, 50 deletions
diff --git a/eBones/lib/libtelnet/auth-proto.h b/eBones/lib/libtelnet/auth-proto.h index 111033d..bdcb030 100644 --- a/eBones/lib/libtelnet/auth-proto.h +++ b/eBones/lib/libtelnet/auth-proto.h @@ -75,6 +75,10 @@ void auth_finished P((Authenticator *, int)); int auth_wait P((char *)); void auth_disable_name P((char *)); void auth_gen_printsub P((unsigned char *, int, unsigned char *, int)); +void auth_name P((unsigned char *, int)); +void auth_printsub P((unsigned char *, int, unsigned char *, int)); +int auth_sendname P((unsigned char *, int)); +void auth_encrypt_user P((char *)); #ifdef KRB4 int kerberos4_init P((Authenticator *, int)); diff --git a/eBones/lib/libtelnet/auth.c b/eBones/lib/libtelnet/auth.c index 64f5ce9..624baa1 100644 --- a/eBones/lib/libtelnet/auth.c +++ b/eBones/lib/libtelnet/auth.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)auth.c 8.3 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)auth.c 8.3 (Berkeley) 5/30/95"; #endif /* not lint */ /* @@ -64,6 +64,7 @@ static char sccsid[] = "@(#)auth.c 8.3 (Berkeley) 5/30/95"; #include <arpa/telnet.h> #ifdef __STDC__ #include <stdlib.h> +#include <unistd.h> #endif #ifdef NO_STRING_H #include <strings.h> @@ -106,6 +107,9 @@ static unsigned char _auth_send_data[256]; static unsigned char *auth_send_data; static int auth_send_cnt = 0; +int auth_onoff(char *type, int on); +void auth_encrypt_user(char *name); + /* * Authentication types supported. Plese note that these are stored * in priority order, i.e. try the first one first. @@ -500,7 +504,7 @@ auth_is(data, cnt) return; } - if (ap = findauthenticator(data[0], data[1])) { + if ((ap = findauthenticator(data[0], data[1]))) { if (ap->is) (*ap->is)(ap, data+2, cnt-2); } else if (auth_debug_mode) @@ -518,7 +522,7 @@ auth_reply(data, cnt) if (cnt < 2) return; - if (ap = findauthenticator(data[0], data[1])) { + if ((ap = findauthenticator(data[0], data[1]))) { if (ap->reply) (*ap->reply)(ap, data+2, cnt-2); } else if (auth_debug_mode) @@ -531,7 +535,6 @@ auth_name(data, cnt) unsigned char *data; int cnt; { - Authenticator *ap; unsigned char savename[256]; if (cnt < 1) { diff --git a/eBones/lib/libtelnet/enc-proto.h b/eBones/lib/libtelnet/enc-proto.h index 0c0d89c..8e15ffd 100644 --- a/eBones/lib/libtelnet/enc-proto.h +++ b/eBones/lib/libtelnet/enc-proto.h @@ -79,11 +79,17 @@ void encrypt_send_end P((void)); void encrypt_wait P((void)); void encrypt_send_support P((void)); void encrypt_send_keyid P((int, unsigned char *, int, int)); +void encrypt_start P((unsigned char *, int)); +void encrypt_end P((void)); +void encrypt_support P((unsigned char *, int)); +void encrypt_request_start P((unsigned char *, int)); +void encrypt_request_end P((void)); +void encrypt_enc_keyid P((unsigned char *, int)); +void encrypt_dec_keyid P((unsigned char *, int)); +void encrypt_printsub P((unsigned char *, int, unsigned char *, int)); int net_write P((unsigned char *, int)); -#ifdef TELENTD -void encrypt_wait P((void)); -#else +#ifndef TELENTD int encrypt_cmd P((int, char **)); void encrypt_display P((void)); #endif diff --git a/eBones/lib/libtelnet/enc_des.c b/eBones/lib/libtelnet/enc_des.c index d6886fd..8e4b9a7 100644 --- a/eBones/lib/libtelnet/enc_des.c +++ b/eBones/lib/libtelnet/enc_des.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)enc_des.c 8.3 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)enc_des.c 8.3 (Berkeley) 5/30/95"; #endif /* not lint */ #ifdef ENCRYPTION @@ -44,6 +44,8 @@ static char sccsid[] = "@(#)enc_des.c 8.3 (Berkeley) 5/30/95"; #include <stdlib.h> #endif +#include <des.h> +#include <string.h> #include "encrypt.h" #include "key-proto.h" #include "misc-proto.h" @@ -180,7 +182,6 @@ fb64_start(fbp, dir, server) int dir; int server; { - Block b; int x; unsigned char *p; register int state; @@ -215,8 +216,8 @@ fb64_start(fbp, dir, server) /* * Create a random feed and send it over. */ - des_new_random_key(fbp->temp_feed); - des_ecb_encrypt(fbp->temp_feed, fbp->temp_feed, + des_new_random_key((Block *)fbp->temp_feed); + des_ecb_encrypt((Block *)fbp->temp_feed, (Block *)fbp->temp_feed, fbp->krbdes_sched, 1); p = fbp->fb_feed + 3; *p++ = ENCRYPT_IS; @@ -264,9 +265,7 @@ fb64_is(data, cnt, fbp) int cnt; struct fb *fbp; { - int x; unsigned char *p; - Block b; register int state = fbp->state[DIR_DECRYPT-1]; if (cnt-- < 1) @@ -356,9 +355,6 @@ fb64_reply(data, cnt, fbp) int cnt; struct fb *fbp; { - int x; - unsigned char *p; - Block b; register int state = fbp->state[DIR_ENCRYPT-1]; if (cnt-- < 1) @@ -428,10 +424,10 @@ fb64_session(key, server, fbp) fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_DECRYPT-1]); if (fbp->once == 0) { - des_set_random_generator_seed(fbp->krbdes_key); + des_set_random_generator_seed((Block *)fbp->krbdes_key); fbp->once = 1; } - des_key_sched(fbp->krbdes_key, fbp->krbdes_sched); + des_key_sched((Block *)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 @@ -552,7 +548,7 @@ fb64_stream_iv(seed, stp) memmove((void *)stp->str_iv, (void *)seed, sizeof(Block)); memmove((void *)stp->str_output, (void *)seed, sizeof(Block)); - des_key_sched(stp->str_ikey, stp->str_sched); + des_key_sched((Block *)stp->str_ikey, stp->str_sched); stp->str_index = sizeof(Block); } @@ -563,7 +559,7 @@ fb64_stream_key(key, stp) register struct stinfo *stp; { memmove((void *)stp->str_ikey, (void *)key, sizeof(Block)); - des_key_sched(key, stp->str_sched); + des_key_sched((Block *)key, stp->str_sched); memmove((void *)stp->str_output, (void *)stp->str_iv, sizeof(Block)); @@ -604,7 +600,7 @@ cfb64_encrypt(s, c) while (c-- > 0) { if (index == sizeof(Block)) { Block b; - des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1); + des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1); memmove((void *)stp->str_feed, (void *)b, sizeof(Block)); index = 0; } @@ -638,7 +634,7 @@ cfb64_decrypt(data) index = stp->str_index++; if (index == sizeof(Block)) { Block b; - des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1); + des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1); memmove((void *)stp->str_feed, (void *)b, sizeof(Block)); stp->str_index = 1; /* Next time will be 1 */ index = 0; /* But now use 0 */ @@ -680,7 +676,7 @@ ofb64_encrypt(s, c) while (c-- > 0) { if (index == sizeof(Block)) { Block b; - des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1); + des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1); memmove((void *)stp->str_feed, (void *)b, sizeof(Block)); index = 0; } @@ -711,7 +707,7 @@ ofb64_decrypt(data) index = stp->str_index++; if (index == sizeof(Block)) { Block b; - des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1); + des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1); memmove((void *)stp->str_feed, (void *)b, sizeof(Block)); stp->str_index = 1; /* Next time will be 1 */ index = 0; /* But now use 0 */ diff --git a/eBones/lib/libtelnet/encrypt.c b/eBones/lib/libtelnet/encrypt.c index 432df0c..41dd5cc 100644 --- a/eBones/lib/libtelnet/encrypt.c +++ b/eBones/lib/libtelnet/encrypt.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)encrypt.c 8.2 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)encrypt.c 8.2 (Berkeley) 5/30/95"; #endif /* not lint */ /* @@ -58,6 +58,7 @@ static char sccsid[] = "@(#)encrypt.c 8.2 (Berkeley) 5/30/95"; #ifdef ENCRYPTION #define ENCRYPT_NAMES +#include <stdio.h> #include <arpa/telnet.h> #include "encrypt.h" @@ -79,6 +80,18 @@ static char sccsid[] = "@(#)encrypt.c 8.2 (Berkeley) 5/30/95"; void (*encrypt_output) P((unsigned char *, int)); int (*decrypt_input) P((int)); +int EncryptType(char *type, char *mode); +int EncryptStart(char *mode); +int EncryptStop(char *mode); +int EncryptStartInput(void); +int EncryptStartOutput(void); +int EncryptStopInput(void); +int EncryptStopOutput(void); + +int Ambiguous(char **s); +int isprefix(char *s1, char *s2); +char **genget(char *name, char **table, int stlen); + int encrypt_debug_mode = 0; static int decrypt_mode = 0; static int encrypt_mode = 0; @@ -174,6 +187,8 @@ static struct key_info { { { 0 }, 0, DIR_DECRYPT, &decrypt_mode, finddecryption }, }; +static void encrypt_keyid(struct key_info *kp, unsigned char *keyid, int len); + void encrypt_init(name, server) char *name; @@ -248,10 +263,10 @@ EncryptDisable(type, mode) if (isprefix(type, "help") || isprefix(type, "?")) { printf("Usage: encrypt disable <type> [input|output]\n"); encrypt_list_types(); - } else if ((ep = (Encryptions *)genget(type, encryptions, + } else if ((ep = (Encryptions *)genget(type, (char **)encryptions, sizeof(Encryptions))) == 0) { printf("%s: invalid encryption type\n", type); - } else if (Ambiguous(ep)) { + } else if (Ambiguous((char **)ep)) { printf("Ambiguous type '%s'\n", type); } else { if ((mode == 0) || (isprefix(mode, "input") ? 1 : 0)) { @@ -283,10 +298,10 @@ EncryptType(type, mode) if (isprefix(type, "help") || isprefix(type, "?")) { printf("Usage: encrypt type <type> [input|output]\n"); encrypt_list_types(); - } else if ((ep = (Encryptions *)genget(type, encryptions, + } else if ((ep = (Encryptions *)genget(type, (char **)encryptions, sizeof(Encryptions))) == 0) { printf("%s: invalid encryption type\n", type); - } else if (Ambiguous(ep)) { + } else if (Ambiguous((char **)ep)) { printf("Ambiguous type '%s'\n", type); } else { if ((mode == 0) || isprefix(mode, "input")) { @@ -559,7 +574,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); } @@ -603,7 +618,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); @@ -641,7 +656,7 @@ encrypt_start(data, cnt) return; } - if (ep = finddecryption(decrypt_mode)) { + if ((ep = finddecryption(decrypt_mode))) { decrypt_input = ep->input; if (encrypt_verbose) printf("[ Input is now decrypted with type %s ]\r\n", @@ -725,6 +740,7 @@ encrypt_request_start(data, cnt) static unsigned char str_keyid[(MAXKEYLEN*2)+5] = { IAC, SB, TELOPT_ENCRYPT }; + void encrypt_enc_keyid(keyid, len) unsigned char *keyid; int len; @@ -732,6 +748,7 @@ encrypt_enc_keyid(keyid, len) encrypt_keyid(&ki[1], keyid, len); } + void encrypt_dec_keyid(keyid, len) unsigned char *keyid; int len; @@ -739,13 +756,13 @@ encrypt_dec_keyid(keyid, len) encrypt_keyid(&ki[0], keyid, len); } + void encrypt_keyid(kp, keyid, len) struct key_info *kp; unsigned char *keyid; int len; { Encryptions *ep; - unsigned char *strp, *cp; int dir = kp->dir; register int ret = 0; @@ -942,7 +959,6 @@ encrypt_send_request_end() void encrypt_wait() { - register int encrypt, decrypt; if (encrypt_debug_mode) printf(">>>%s: in encrypt_wait\r\n", Name); if (!havesessionkey || !(I_SUPPORT_ENCRYPT & remote_supports_decrypt)) diff --git a/eBones/lib/libtelnet/genget.c b/eBones/lib/libtelnet/genget.c index f87fcf0..de3048e 100644 --- a/eBones/lib/libtelnet/genget.c +++ b/eBones/lib/libtelnet/genget.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)genget.c 8.2 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)genget.c 8.2 (Berkeley) 5/30/95"; #endif /* not lint */ @@ -49,7 +49,6 @@ static char sccsid[] = "@(#)genget.c 8.2 (Berkeley) 5/30/95"; isprefix(s1, s2) register char *s1, *s2; { - register int n = 0; char *os1; register char c1, c2; @@ -99,7 +98,7 @@ genget(name, table, stlen) */ int Ambiguous(s) - char *s; + char **s; { - return((char **)s == &ambiguous); + return(s == &ambiguous); } diff --git a/eBones/lib/libtelnet/kerberos.c b/eBones/lib/libtelnet/kerberos.c index f0c8b8a..d876597 100644 --- a/eBones/lib/libtelnet/kerberos.c +++ b/eBones/lib/libtelnet/kerberos.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)kerberos.c 8.3 (Berkeley) 5/30/95"; +static const char sccsid[] = "@(#)kerberos.c 8.3 (Berkeley) 5/30/95"; #endif /* not lint */ /* @@ -81,8 +81,6 @@ extern auth_debug_mode; static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, AUTHTYPE_KERBEROS_V4, }; -static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION, - TELQUAL_NAME, }; #define KRB_AUTH 0 /* Authentication data follows */ #define KRB_REJECT 1 /* Rejected (reason might follow) */ @@ -162,9 +160,6 @@ kerberos4_send(ap) Authenticator *ap; { KTEXT_ST auth; -#ifdef ENCRYPTION - Block enckey; -#endif /* ENCRYPTION */ char instance[INST_SZ]; char *realm; char *krb_realmofhost(); @@ -182,7 +177,7 @@ kerberos4_send(ap) memset(instance, 0, sizeof(instance)); - if (realm = krb_get_phost(RemoteHostName)) + if ((realm = krb_get_phost(RemoteHostName))) strncpy(instance, realm, sizeof(instance)); instance[sizeof(instance)-1] = '\0'; @@ -193,11 +188,11 @@ kerberos4_send(ap) printf("Kerberos V4: no realm for %s\r\n", RemoteHostName); return(0); } - if (r = krb_mk_req(&auth, KRB_SERVICE_NAME, instance, realm, 0L)) { + if ((r = krb_mk_req(&auth, KRB_SERVICE_NAME, instance, realm, 0L))) { printf("mk_req failed: %s\r\n", krb_err_txt[r]); return(0); } - if (r = krb_get_cred(KRB_SERVICE_NAME, instance, realm, &cred)) { + if ((r = krb_get_cred(KRB_SERVICE_NAME, instance, realm, &cred))) { printf("get_cred failed: %s\r\n", krb_err_txt[r]); return(0); } @@ -283,8 +278,8 @@ kerberos4_is(ap, data, cnt) printf("\r\n"); } instance[0] = '*'; instance[1] = 0; - if (r = krb_rd_req(&auth, KRB_SERVICE_NAME, - instance, 0, &adat, "")) { + if ((r = krb_rd_req(&auth, KRB_SERVICE_NAME, + instance, 0, &adat, ""))) { if (auth_debug_mode) printf("Kerberos failed him as %s\r\n", name); Data(ap, KRB_REJECT, (void *)krb_err_txt[r], -1); diff --git a/eBones/lib/libtelnet/misc.c b/eBones/lib/libtelnet/misc.c index 9565900..4f8f8d5 100644 --- a/eBones/lib/libtelnet/misc.c +++ b/eBones/lib/libtelnet/misc.c @@ -32,10 +32,14 @@ */ #ifndef lint -static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/4/93"; +static const char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ +#include <stdio.h> +#include <stdlib.h> #include "misc.h" +#include "auth.h" +#include "encrypt.h" char *RemoteHostName; char *LocalHostName; |