mirror of
https://git.savannah.gnu.org/git/inetutils.git
synced 2026-01-12 00:19:39 +08:00
Small code clean-up.
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
||||
2013-05-01 Mats Erik Andersson <gnu@gisladisker.se>
|
||||
|
||||
* libtelnet/enc_des.c: Convert K&R style declarations
|
||||
to ISO C89. Do assignments before return statements.
|
||||
(fb64_stream_iv, fb64_init, fb64_is, fb64_reply)
|
||||
(fb64_stream_key, fb64_keyid): Declare as static.
|
||||
(shishi_des_ecb_encrypt) [SHISHI]: Declare as static.
|
||||
Declare all three string arguments using `unsigned char'.
|
||||
When calling shishi_des(), cast third and sixth arguments
|
||||
as `const char *'.
|
||||
(fb64_start): Remove variable B. Change X to size_t.
|
||||
(fb64_is): Remove B and X.
|
||||
(fb64_reply): Remove B, P, and X.
|
||||
|
||||
2013-04-30 Mats Erik Andersson <gnu@gisladisker.se>
|
||||
|
||||
ftpd: Account expiration.
|
||||
|
||||
@@ -73,8 +73,8 @@ extern int encrypt_debug_mode;
|
||||
# define NO_RECV_IV 2
|
||||
# define NO_KEYID 4
|
||||
# define IN_PROGRESS (NO_SEND_IV|NO_RECV_IV|NO_KEYID)
|
||||
# define SUCCESS 0
|
||||
# define FAILED -1
|
||||
# define SUCCESS 0
|
||||
# define FAILED -1
|
||||
|
||||
|
||||
# include <string.h>
|
||||
@@ -127,7 +127,7 @@ struct keyidlist
|
||||
|
||||
# define SHIFT_VAL(a,b) (KEYFLAG_SHIFT*((a)+((b)*2)))
|
||||
|
||||
# define FB64_IV 1
|
||||
# define FB64_IV 1
|
||||
# define FB64_IV_OK 2
|
||||
# define FB64_IV_BAD 3
|
||||
|
||||
@@ -135,31 +135,31 @@ struct keyidlist
|
||||
/* Callback from consumer. */
|
||||
extern void printsub (char, unsigned char *, int);
|
||||
|
||||
void fb64_stream_iv (Block, struct stinfo *);
|
||||
void fb64_init (struct fb *);
|
||||
static void fb64_stream_iv (Block, struct stinfo *);
|
||||
static void fb64_init (struct fb *);
|
||||
static int fb64_start (struct fb *, int, int);
|
||||
int fb64_is (unsigned char *, int, struct fb *);
|
||||
int fb64_reply (unsigned char *, int, struct fb *);
|
||||
static int fb64_is (unsigned char *, int, struct fb *);
|
||||
static int fb64_reply (unsigned char *, int, struct fb *);
|
||||
static void fb64_session (Session_Key *, int, struct fb *);
|
||||
void fb64_stream_key (Block, struct stinfo *);
|
||||
int fb64_keyid (int, unsigned char *, int *, struct fb *);
|
||||
static void fb64_stream_key (Block, struct stinfo *);
|
||||
static int fb64_keyid (int, unsigned char *, int *, struct fb *);
|
||||
|
||||
# ifdef SHISHI
|
||||
void
|
||||
shishi_des_ecb_encrypt (Shishi * h, const char key[8], const char *in,
|
||||
char *out)
|
||||
static void
|
||||
shishi_des_ecb_encrypt (Shishi * h, const unsigned char key[8],
|
||||
const unsigned char *in, unsigned char *out)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
shishi_des (h, 0, key, NULL, NULL, in, 8, &tmp);
|
||||
shishi_des (h, 0, (const char *) key, NULL, NULL,
|
||||
(const char *) in, 8, &tmp);
|
||||
memcpy (out, tmp, 8);
|
||||
free (tmp);
|
||||
}
|
||||
# endif
|
||||
|
||||
void
|
||||
cfb64_init (server)
|
||||
int server;
|
||||
cfb64_init (int server)
|
||||
{
|
||||
fb64_init (&fb[CFB]);
|
||||
fb[CFB].fb_feed[4] = ENCTYPE_DES_CFB64;
|
||||
@@ -169,8 +169,7 @@ cfb64_init (server)
|
||||
|
||||
# ifdef ENCTYPE_DES_OFB64
|
||||
void
|
||||
ofb64_init (server)
|
||||
int server;
|
||||
ofb64_init (int server)
|
||||
{
|
||||
fb64_init (&fb[OFB]);
|
||||
fb[OFB].fb_feed[4] = ENCTYPE_DES_OFB64;
|
||||
@@ -179,9 +178,8 @@ ofb64_init (server)
|
||||
}
|
||||
# endif /* ENCTYPE_DES_OFB64 */
|
||||
|
||||
void
|
||||
fb64_init (fbp)
|
||||
register struct fb *fbp;
|
||||
static void
|
||||
fb64_init (register struct fb *fbp)
|
||||
{
|
||||
memset ((void *) fbp, 0, sizeof (*fbp));
|
||||
fbp->state[0] = fbp->state[1] = FAILED;
|
||||
@@ -200,31 +198,23 @@ fb64_init (fbp)
|
||||
* Kerberos) have to happen before we can continue.
|
||||
*/
|
||||
int
|
||||
cfb64_start (dir, server)
|
||||
int dir;
|
||||
int server;
|
||||
cfb64_start (int dir, int server)
|
||||
{
|
||||
return (fb64_start (&fb[CFB], dir, server));
|
||||
}
|
||||
|
||||
# ifdef ENCTYPE_DES_OFB64
|
||||
int
|
||||
ofb64_start (dir, server)
|
||||
int dir;
|
||||
int server;
|
||||
ofb64_start (int dir, int server)
|
||||
{
|
||||
return (fb64_start (&fb[OFB], dir, server));
|
||||
}
|
||||
# endif /* ENCTYPE_DES_OFB64 */
|
||||
|
||||
static int
|
||||
fb64_start (fbp, dir, server)
|
||||
struct fb *fbp;
|
||||
int dir;
|
||||
int server;
|
||||
fb64_start (struct fb *fbp, int dir, int server)
|
||||
{
|
||||
Block b;
|
||||
int x;
|
||||
size_t x;
|
||||
unsigned char *p;
|
||||
register int state;
|
||||
|
||||
@@ -285,7 +275,10 @@ fb64_start (fbp, dir, server)
|
||||
default:
|
||||
return (FAILED);
|
||||
}
|
||||
return (fbp->state[dir - 1] = state);
|
||||
|
||||
fbp->state[dir - 1] = state;
|
||||
|
||||
return (state);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -295,32 +288,23 @@ fb64_start (fbp, dir, server)
|
||||
* 1: successful, negotiation not done yet.
|
||||
*/
|
||||
int
|
||||
cfb64_is (data, cnt)
|
||||
unsigned char *data;
|
||||
int cnt;
|
||||
cfb64_is (unsigned char *data, int cnt)
|
||||
{
|
||||
return (fb64_is (data, cnt, &fb[CFB]));
|
||||
}
|
||||
|
||||
# ifdef ENCTYPE_DES_OFB64
|
||||
int
|
||||
ofb64_is (data, cnt)
|
||||
unsigned char *data;
|
||||
int cnt;
|
||||
ofb64_is (unsigned char *data, int cnt)
|
||||
{
|
||||
return (fb64_is (data, cnt, &fb[OFB]));
|
||||
}
|
||||
# endif /* ENCTYPE_DES_OFB64 */
|
||||
|
||||
int
|
||||
fb64_is (data, cnt, fbp)
|
||||
unsigned char *data;
|
||||
int cnt;
|
||||
struct fb *fbp;
|
||||
static 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)
|
||||
@@ -382,7 +366,10 @@ fb64_is (data, cnt, fbp)
|
||||
|
||||
break;
|
||||
}
|
||||
return (fbp->state[DIR_DECRYPT - 1] = state);
|
||||
|
||||
fbp->state[DIR_DECRYPT - 1] = state;
|
||||
|
||||
return (state);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -392,33 +379,23 @@ fb64_is (data, cnt, fbp)
|
||||
* 1: successful, negotiation not done yet.
|
||||
*/
|
||||
int
|
||||
cfb64_reply (data, cnt)
|
||||
unsigned char *data;
|
||||
int cnt;
|
||||
cfb64_reply (unsigned char *data, int cnt)
|
||||
{
|
||||
return (fb64_reply (data, cnt, &fb[CFB]));
|
||||
}
|
||||
|
||||
# ifdef ENCTYPE_DES_OFB64
|
||||
int
|
||||
ofb64_reply (data, cnt)
|
||||
unsigned char *data;
|
||||
int cnt;
|
||||
ofb64_reply (unsigned char *data, int cnt)
|
||||
{
|
||||
return (fb64_reply (data, cnt, &fb[OFB]));
|
||||
}
|
||||
# endif /* ENCTYPE_DES_OFB64 */
|
||||
|
||||
|
||||
int
|
||||
fb64_reply (data, cnt, fbp)
|
||||
unsigned char *data;
|
||||
int cnt;
|
||||
struct fb *fbp;
|
||||
static 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)
|
||||
@@ -452,32 +429,28 @@ fb64_reply (data, cnt, fbp)
|
||||
state = FAILED;
|
||||
break;
|
||||
}
|
||||
return (fbp->state[DIR_ENCRYPT - 1] = state);
|
||||
|
||||
fbp->state[DIR_ENCRYPT - 1] = state;
|
||||
|
||||
return (state);
|
||||
}
|
||||
|
||||
void
|
||||
cfb64_session (key, server)
|
||||
Session_Key *key;
|
||||
int server;
|
||||
cfb64_session (Session_Key *key, int server)
|
||||
{
|
||||
fb64_session (key, server, &fb[CFB]);
|
||||
}
|
||||
|
||||
# ifdef ENCTYPE_DES_OFB64
|
||||
void
|
||||
ofb64_session (key, server)
|
||||
Session_Key *key;
|
||||
int server;
|
||||
ofb64_session (Session_Key *key, int server)
|
||||
{
|
||||
fb64_session (key, server, &fb[OFB]);
|
||||
}
|
||||
# endif /* ENCTYPE_DES_OFB64 */
|
||||
|
||||
static void
|
||||
fb64_session (key, server, fbp)
|
||||
Session_Key *key;
|
||||
int server;
|
||||
struct fb *fbp;
|
||||
fb64_session (Session_Key *key, int server, struct fb *fbp)
|
||||
{
|
||||
|
||||
if (!key || key->type != SK_DES)
|
||||
@@ -486,8 +459,9 @@ fb64_session (key, server, fbp)
|
||||
if (encrypt_debug_mode)
|
||||
printf ("Can't set krbdes's session key (%d != %d)\r\n",
|
||||
key ? key->type : -1, SK_DES);
|
||||
return;
|
||||
return; /* XXX: Causes a segfault. */
|
||||
}
|
||||
|
||||
memmove ((void *) fbp->krbdes_key, (void *) key->data, sizeof (Block));
|
||||
|
||||
fb64_stream_key (fbp->krbdes_key, &fbp->streams[DIR_ENCRYPT - 1]);
|
||||
@@ -504,8 +478,8 @@ fb64_session (key, server, fbp)
|
||||
des_key_sched (fbp->krbdes_key, fbp->krbdes_sched);
|
||||
# endif
|
||||
/*
|
||||
* Now look to see if krbdes_start() was was waiting for
|
||||
* the key to show up. If so, go ahead an call it now
|
||||
* Now look to see if krbdes_start() was waiting for
|
||||
* the key to show up. If so, go ahead and call it now
|
||||
* that we have the key.
|
||||
*/
|
||||
if (fbp->need_start)
|
||||
@@ -520,28 +494,21 @@ fb64_session (key, server, fbp)
|
||||
* 0, then mark the state as SUCCESS.
|
||||
*/
|
||||
int
|
||||
cfb64_keyid (dir, kp, lenp)
|
||||
int dir, *lenp;
|
||||
unsigned char *kp;
|
||||
cfb64_keyid (int dir, unsigned char *kp, int *lenp)
|
||||
{
|
||||
return (fb64_keyid (dir, kp, lenp, &fb[CFB]));
|
||||
}
|
||||
|
||||
# ifdef ENCTYPE_DES_OFB64
|
||||
int
|
||||
ofb64_keyid (dir, kp, lenp)
|
||||
int dir, *lenp;
|
||||
unsigned char *kp;
|
||||
ofb64_keyid (int dir, unsigned char *kp, int *lenp)
|
||||
{
|
||||
return (fb64_keyid (dir, kp, lenp, &fb[OFB]));
|
||||
}
|
||||
# endif /* ENCTYPE_DES_OFB64 */
|
||||
|
||||
int
|
||||
fb64_keyid (dir, kp, lenp, fbp)
|
||||
int dir, *lenp;
|
||||
unsigned char *kp;
|
||||
struct fb *fbp;
|
||||
static int
|
||||
fb64_keyid (int dir, unsigned char *kp, int *lenp, struct fb *fbp)
|
||||
{
|
||||
register int state = fbp->state[dir - 1];
|
||||
|
||||
@@ -556,13 +523,15 @@ fb64_keyid (dir, kp, lenp, fbp)
|
||||
|
||||
state &= ~NO_KEYID;
|
||||
|
||||
return (fbp->state[dir - 1] = state);
|
||||
fbp->state[dir - 1] = state;
|
||||
|
||||
return (state);
|
||||
}
|
||||
|
||||
void
|
||||
fb64_printsub (data, cnt, buf, buflen, type)
|
||||
unsigned char *data, *buf, *type;
|
||||
int cnt, buflen;
|
||||
static void
|
||||
fb64_printsub (unsigned char *data, int cnt,
|
||||
unsigned char *buf, int buflen,
|
||||
const char *type)
|
||||
{
|
||||
char lbuf[32];
|
||||
register int i;
|
||||
@@ -605,27 +574,23 @@ fb64_printsub (data, cnt, buf, buflen, type)
|
||||
}
|
||||
|
||||
void
|
||||
cfb64_printsub (data, cnt, buf, buflen)
|
||||
unsigned char *data, *buf;
|
||||
int cnt, buflen;
|
||||
cfb64_printsub (unsigned char *data, int cnt,
|
||||
unsigned char *buf, int buflen)
|
||||
{
|
||||
fb64_printsub (data, cnt, buf, buflen, "CFB64");
|
||||
}
|
||||
|
||||
# ifdef ENCTYPE_DES_OFB64
|
||||
void
|
||||
ofb64_printsub (data, cnt, buf, buflen)
|
||||
unsigned char *data, *buf;
|
||||
int cnt, buflen;
|
||||
ofb64_printsub (unsigned char *data, int cnt,
|
||||
unsigned char *buf, int buflen)
|
||||
{
|
||||
fb64_printsub (data, cnt, buf, buflen, "OFB64");
|
||||
}
|
||||
# endif /* ENCTYPE_DES_OFB64 */
|
||||
|
||||
void
|
||||
fb64_stream_iv (seed, stp)
|
||||
Block seed;
|
||||
register struct stinfo *stp;
|
||||
static void
|
||||
fb64_stream_iv (Block seed, register struct stinfo *stp)
|
||||
{
|
||||
|
||||
memmove ((void *) stp->str_iv, (void *) seed, sizeof (Block));
|
||||
@@ -638,10 +603,8 @@ fb64_stream_iv (seed, stp)
|
||||
stp->str_index = sizeof (Block);
|
||||
}
|
||||
|
||||
void
|
||||
fb64_stream_key (key, stp)
|
||||
Block key;
|
||||
register struct stinfo *stp;
|
||||
static void
|
||||
fb64_stream_key (Block key, register struct stinfo *stp)
|
||||
{
|
||||
memmove ((void *) stp->str_ikey, (void *) key, sizeof (Block));
|
||||
# ifndef SHISHI
|
||||
@@ -675,9 +638,7 @@ fb64_stream_key (key, stp)
|
||||
*/
|
||||
|
||||
void
|
||||
cfb64_encrypt (s, c)
|
||||
register unsigned char *s;
|
||||
int c;
|
||||
cfb64_encrypt (register unsigned char *s, int c)
|
||||
{
|
||||
register struct stinfo *stp = &fb[CFB].streams[DIR_ENCRYPT - 1];
|
||||
register int index;
|
||||
@@ -707,8 +668,7 @@ cfb64_encrypt (s, c)
|
||||
}
|
||||
|
||||
int
|
||||
cfb64_decrypt (data)
|
||||
int data;
|
||||
cfb64_decrypt (int data)
|
||||
{
|
||||
register struct stinfo *stp = &fb[CFB].streams[DIR_DECRYPT - 1];
|
||||
int index;
|
||||
@@ -742,6 +702,7 @@ cfb64_decrypt (data)
|
||||
|
||||
/* On decryption we store (data) which is cypher. */
|
||||
stp->str_output[index] = data;
|
||||
|
||||
return (data ^ stp->str_feed[index]);
|
||||
}
|
||||
|
||||
@@ -766,9 +727,7 @@ cfb64_decrypt (data)
|
||||
*/
|
||||
# ifdef ENCTYPE_DES_OFB64
|
||||
void
|
||||
ofb64_encrypt (s, c)
|
||||
register unsigned char *s;
|
||||
int c;
|
||||
ofb64_encrypt (register unsigned char *s, int c)
|
||||
{
|
||||
register struct stinfo *stp = &fb[OFB].streams[DIR_ENCRYPT - 1];
|
||||
register int index;
|
||||
@@ -795,8 +754,7 @@ ofb64_encrypt (s, c)
|
||||
}
|
||||
|
||||
int
|
||||
ofb64_decrypt (data)
|
||||
int data;
|
||||
ofb64_decrypt (int data)
|
||||
{
|
||||
register struct stinfo *stp = &fb[OFB].streams[DIR_DECRYPT - 1];
|
||||
int index;
|
||||
|
||||
Reference in New Issue
Block a user