Browse Source

Be more careful about possible type promotion

OPENBSD_2_1
tholo 28 years ago
parent
commit
d945fdda5b
2 changed files with 57 additions and 5 deletions
  1. +24
    -4
      src/lib/libc/crypt/bcrypt.c
  2. +33
    -1
      src/lib/libc/crypt/blowfish.c

+ 24
- 4
src/lib/libc/crypt/bcrypt.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: bcrypt.c,v 1.4 1997/03/27 01:09:38 provos Exp $ */
/* $OpenBSD: bcrypt.c,v 1.5 1997/04/30 05:57:04 tholo Exp $ */
/*
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
* All rights reserved.
@ -95,11 +95,16 @@ const static u_int8_t index_64[128] =
};
#define CHAR64(c) ( (c) > 127 ? 255 : index_64[(c)])
#if __STDC__
static void
decode_base64(u_int8_t *buffer, u_int16_t len, u_int8_t *data)
#else
static void
decode_base64(buffer, len, data)
u_int8_t *buffer;
u_int16_t len;
u_int8_t *data;
#endif
{
u_int8_t *bp = buffer;
u_int8_t *p = data;
@ -133,12 +138,17 @@ decode_base64(buffer, len, data)
}
}
#if __STDC__
static void
encode_salt(char *salt, u_int8_t *csalt, u_int16_t clen, u_int8_t logr)
#else
static void
encode_salt(salt, csalt, clen, logr)
char *salt;
u_int8_t *csalt;
u_int16_t clen;
u_int8_t logr;
#endif
{
salt[0] = '$';
salt[1] = BCRYPT_VERSION;
@ -153,9 +163,14 @@ encode_salt(salt, csalt, clen, logr)
seems sensible.
*/
char *
#if __STDC__
char *
bcrypt_gensalt(u_int8_t log_rounds)
#else
char *
bcrypt_gensalt(log_rounds)
u_int8_t log_rounds;
#endif
{
u_int8_t csalt[BCRYPT_MAXSALT];
u_int16_t i;
@ -179,8 +194,8 @@ bcrypt_gensalt(log_rounds)
char *
bcrypt(key, salt)
char *key;
char *salt;
const char *key;
const char *salt;
{
blf_ctx state;
u_int32_t rounds, i, k;
@ -256,11 +271,16 @@ bcrypt(key, salt)
return encrypted;
}
#if __STDC__
static void
encode_base64(u_int8_t *buffer, u_int8_t *data, u_int16_t len)
#else
static void
encode_base64(buffer, data, len)
u_int8_t *buffer;
u_int8_t *data;
u_int16_t len;
#endif
{
u_int8_t *bp = buffer;
u_int8_t *p = data;


+ 33
- 1
src/lib/libc/crypt/blowfish.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: blowfish.c,v 1.3 1997/02/16 20:58:17 provos Exp $ */
/* $OpenBSD: blowfish.c,v 1.4 1997/04/30 05:57:05 tholo Exp $ */
/*
* Blowfish block cipher for OpenBSD
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
@ -441,11 +441,16 @@ Blowfish_initstate(c)
}
#if __STDC__
u_int32_t
Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes, u_int16_t *current)
#else
u_int32_t
Blowfish_stream2word(data, databytes, current)
const u_int8_t *data;
u_int16_t databytes;
u_int16_t *current;
#endif
{
u_int8_t i;
u_int16_t j;
@ -464,11 +469,16 @@ Blowfish_stream2word(data, databytes, current)
return temp;
}
#if __STDC__
void
Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes)
#else
void
Blowfish_expand0state(c, key, keybytes)
blf_ctx *c;
const u_int8_t *key;
u_int16_t keybytes;
#endif
{
u_int16_t i;
u_int16_t j;
@ -506,6 +516,11 @@ Blowfish_expand0state(c, key, keybytes)
}
#if __STDC__
void
Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes,
const u_int8_t *key, u_int16_t keybytes)
#else
void
Blowfish_expandstate(c, data, databytes, key, keybytes)
blf_ctx *c;
@ -513,6 +528,7 @@ Blowfish_expandstate(c, data, databytes, key, keybytes)
u_int16_t databytes;
const u_int8_t *key;
u_int16_t keybytes;
#endif
{
u_int16_t i;
u_int16_t j;
@ -553,11 +569,16 @@ Blowfish_expandstate(c, data, databytes, key, keybytes)
}
#if __STDC__
void
blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len)
#else
void
blf_key(c, k, len)
blf_ctx *c;
const u_int8_t *k;
u_int16_t len;
#endif
{
/* Initalize S-boxes and subkeys with Pi */
Blowfish_initstate(c);
@ -566,11 +587,16 @@ blf_key(c, k, len)
Blowfish_expand0state(c, k, len);
}
#if __STDC__
void
blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
#else
void
blf_enc(c, data, blocks)
blf_ctx *c;
u_int32_t *data;
u_int16_t blocks;
#endif
{
u_int32_t *d;
u_int16_t i;
@ -581,11 +607,17 @@ blf_enc(c, data, blocks)
d += 2;
}
}
#if __STDC__
void
blf_dec(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
#else
void
blf_dec(c, data, blocks)
blf_ctx *c;
u_int32_t *data;
u_int16_t blocks;
#endif
{
u_int32_t *d;
u_int16_t i;


Loading…
Cancel
Save