summaryrefslogtreecommitdiff
path: root/src/lib/libc/crypt
diff options
context:
space:
mode:
authortholo <>1997-04-30 05:57:05 +0000
committertholo <>1997-04-30 05:57:05 +0000
commit338dd5e3bd9186a615bf2c0e20ef71f54d963318 (patch)
tree2c4da3faa35998f7804562a16df674b6b3f82af8 /src/lib/libc/crypt
parent37e5d720409522b387b468b7718497edd2b859a9 (diff)
downloadopenbsd-338dd5e3bd9186a615bf2c0e20ef71f54d963318.tar.gz
openbsd-338dd5e3bd9186a615bf2c0e20ef71f54d963318.tar.bz2
openbsd-338dd5e3bd9186a615bf2c0e20ef71f54d963318.zip
Be more careful about possible type promotion
Diffstat (limited to 'src/lib/libc/crypt')
-rw-r--r--src/lib/libc/crypt/bcrypt.c28
-rw-r--r--src/lib/libc/crypt/blowfish.c34
2 files changed, 57 insertions, 5 deletions
diff --git a/src/lib/libc/crypt/bcrypt.c b/src/lib/libc/crypt/bcrypt.c
index d47100cec8..f626c2f453 100644
--- a/src/lib/libc/crypt/bcrypt.c
+++ b/src/lib/libc/crypt/bcrypt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bcrypt.c,v 1.4 1997/03/27 01:09:38 provos Exp $ */ 1/* $OpenBSD: bcrypt.c,v 1.5 1997/04/30 05:57:04 tholo Exp $ */
2/* 2/*
3 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> 3 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
4 * All rights reserved. 4 * All rights reserved.
@@ -95,11 +95,16 @@ const static u_int8_t index_64[128] =
95}; 95};
96#define CHAR64(c) ( (c) > 127 ? 255 : index_64[(c)]) 96#define CHAR64(c) ( (c) > 127 ? 255 : index_64[(c)])
97 97
98#if __STDC__
99static void
100decode_base64(u_int8_t *buffer, u_int16_t len, u_int8_t *data)
101#else
98static void 102static void
99decode_base64(buffer, len, data) 103decode_base64(buffer, len, data)
100 u_int8_t *buffer; 104 u_int8_t *buffer;
101 u_int16_t len; 105 u_int16_t len;
102 u_int8_t *data; 106 u_int8_t *data;
107#endif
103{ 108{
104 u_int8_t *bp = buffer; 109 u_int8_t *bp = buffer;
105 u_int8_t *p = data; 110 u_int8_t *p = data;
@@ -133,12 +138,17 @@ decode_base64(buffer, len, data)
133 } 138 }
134} 139}
135 140
141#if __STDC__
142static void
143encode_salt(char *salt, u_int8_t *csalt, u_int16_t clen, u_int8_t logr)
144#else
136static void 145static void
137encode_salt(salt, csalt, clen, logr) 146encode_salt(salt, csalt, clen, logr)
138 char *salt; 147 char *salt;
139 u_int8_t *csalt; 148 u_int8_t *csalt;
140 u_int16_t clen; 149 u_int16_t clen;
141 u_int8_t logr; 150 u_int8_t logr;
151#endif
142{ 152{
143 salt[0] = '$'; 153 salt[0] = '$';
144 salt[1] = BCRYPT_VERSION; 154 salt[1] = BCRYPT_VERSION;
@@ -153,9 +163,14 @@ encode_salt(salt, csalt, clen, logr)
153 seems sensible. 163 seems sensible.
154 */ 164 */
155 165
156char * 166#if __STDC__
167char *
168bcrypt_gensalt(u_int8_t log_rounds)
169#else
170char *
157bcrypt_gensalt(log_rounds) 171bcrypt_gensalt(log_rounds)
158 u_int8_t log_rounds; 172 u_int8_t log_rounds;
173#endif
159{ 174{
160 u_int8_t csalt[BCRYPT_MAXSALT]; 175 u_int8_t csalt[BCRYPT_MAXSALT];
161 u_int16_t i; 176 u_int16_t i;
@@ -179,8 +194,8 @@ bcrypt_gensalt(log_rounds)
179 194
180char * 195char *
181bcrypt(key, salt) 196bcrypt(key, salt)
182 char *key; 197 const char *key;
183 char *salt; 198 const char *salt;
184{ 199{
185 blf_ctx state; 200 blf_ctx state;
186 u_int32_t rounds, i, k; 201 u_int32_t rounds, i, k;
@@ -256,11 +271,16 @@ bcrypt(key, salt)
256 return encrypted; 271 return encrypted;
257} 272}
258 273
274#if __STDC__
275static void
276encode_base64(u_int8_t *buffer, u_int8_t *data, u_int16_t len)
277#else
259static void 278static void
260encode_base64(buffer, data, len) 279encode_base64(buffer, data, len)
261 u_int8_t *buffer; 280 u_int8_t *buffer;
262 u_int8_t *data; 281 u_int8_t *data;
263 u_int16_t len; 282 u_int16_t len;
283#endif
264{ 284{
265 u_int8_t *bp = buffer; 285 u_int8_t *bp = buffer;
266 u_int8_t *p = data; 286 u_int8_t *p = data;
diff --git a/src/lib/libc/crypt/blowfish.c b/src/lib/libc/crypt/blowfish.c
index 21c492209d..46568d2318 100644
--- a/src/lib/libc/crypt/blowfish.c
+++ b/src/lib/libc/crypt/blowfish.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: blowfish.c,v 1.3 1997/02/16 20:58:17 provos Exp $ */ 1/* $OpenBSD: blowfish.c,v 1.4 1997/04/30 05:57:05 tholo Exp $ */
2/* 2/*
3 * Blowfish block cipher for OpenBSD 3 * Blowfish block cipher for OpenBSD
4 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> 4 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
@@ -441,11 +441,16 @@ Blowfish_initstate(c)
441 441
442} 442}
443 443
444#if __STDC__
445u_int32_t
446Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes, u_int16_t *current)
447#else
444u_int32_t 448u_int32_t
445Blowfish_stream2word(data, databytes, current) 449Blowfish_stream2word(data, databytes, current)
446 const u_int8_t *data; 450 const u_int8_t *data;
447 u_int16_t databytes; 451 u_int16_t databytes;
448 u_int16_t *current; 452 u_int16_t *current;
453#endif
449{ 454{
450 u_int8_t i; 455 u_int8_t i;
451 u_int16_t j; 456 u_int16_t j;
@@ -464,11 +469,16 @@ Blowfish_stream2word(data, databytes, current)
464 return temp; 469 return temp;
465} 470}
466 471
472#if __STDC__
473void
474Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes)
475#else
467void 476void
468Blowfish_expand0state(c, key, keybytes) 477Blowfish_expand0state(c, key, keybytes)
469 blf_ctx *c; 478 blf_ctx *c;
470 const u_int8_t *key; 479 const u_int8_t *key;
471 u_int16_t keybytes; 480 u_int16_t keybytes;
481#endif
472{ 482{
473 u_int16_t i; 483 u_int16_t i;
474 u_int16_t j; 484 u_int16_t j;
@@ -506,6 +516,11 @@ Blowfish_expand0state(c, key, keybytes)
506} 516}
507 517
508 518
519#if __STDC__
520void
521Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes,
522 const u_int8_t *key, u_int16_t keybytes)
523#else
509void 524void
510Blowfish_expandstate(c, data, databytes, key, keybytes) 525Blowfish_expandstate(c, data, databytes, key, keybytes)
511 blf_ctx *c; 526 blf_ctx *c;
@@ -513,6 +528,7 @@ Blowfish_expandstate(c, data, databytes, key, keybytes)
513 u_int16_t databytes; 528 u_int16_t databytes;
514 const u_int8_t *key; 529 const u_int8_t *key;
515 u_int16_t keybytes; 530 u_int16_t keybytes;
531#endif
516{ 532{
517 u_int16_t i; 533 u_int16_t i;
518 u_int16_t j; 534 u_int16_t j;
@@ -553,11 +569,16 @@ Blowfish_expandstate(c, data, databytes, key, keybytes)
553 569
554} 570}
555 571
572#if __STDC__
573void
574blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len)
575#else
556void 576void
557blf_key(c, k, len) 577blf_key(c, k, len)
558 blf_ctx *c; 578 blf_ctx *c;
559 const u_int8_t *k; 579 const u_int8_t *k;
560 u_int16_t len; 580 u_int16_t len;
581#endif
561{ 582{
562 /* Initalize S-boxes and subkeys with Pi */ 583 /* Initalize S-boxes and subkeys with Pi */
563 Blowfish_initstate(c); 584 Blowfish_initstate(c);
@@ -566,11 +587,16 @@ blf_key(c, k, len)
566 Blowfish_expand0state(c, k, len); 587 Blowfish_expand0state(c, k, len);
567} 588}
568 589
590#if __STDC__
591void
592blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
593#else
569void 594void
570blf_enc(c, data, blocks) 595blf_enc(c, data, blocks)
571 blf_ctx *c; 596 blf_ctx *c;
572 u_int32_t *data; 597 u_int32_t *data;
573 u_int16_t blocks; 598 u_int16_t blocks;
599#endif
574{ 600{
575 u_int32_t *d; 601 u_int32_t *d;
576 u_int16_t i; 602 u_int16_t i;
@@ -581,11 +607,17 @@ blf_enc(c, data, blocks)
581 d += 2; 607 d += 2;
582 } 608 }
583} 609}
610
611#if __STDC__
612void
613blf_dec(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
614#else
584void 615void
585blf_dec(c, data, blocks) 616blf_dec(c, data, blocks)
586 blf_ctx *c; 617 blf_ctx *c;
587 u_int32_t *data; 618 u_int32_t *data;
588 u_int16_t blocks; 619 u_int16_t blocks;
620#endif
589{ 621{
590 u_int32_t *d; 622 u_int32_t *d;
591 u_int16_t i; 623 u_int16_t i;