diff options
author | tholo <> | 1997-04-30 05:57:05 +0000 |
---|---|---|
committer | tholo <> | 1997-04-30 05:57:05 +0000 |
commit | 338dd5e3bd9186a615bf2c0e20ef71f54d963318 (patch) | |
tree | 2c4da3faa35998f7804562a16df674b6b3f82af8 /src/lib/libc/crypt | |
parent | 37e5d720409522b387b468b7718497edd2b859a9 (diff) | |
download | openbsd-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.c | 28 | ||||
-rw-r--r-- | src/lib/libc/crypt/blowfish.c | 34 |
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__ | ||
99 | static void | ||
100 | decode_base64(u_int8_t *buffer, u_int16_t len, u_int8_t *data) | ||
101 | #else | ||
98 | static void | 102 | static void |
99 | decode_base64(buffer, len, data) | 103 | decode_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__ | ||
142 | static void | ||
143 | encode_salt(char *salt, u_int8_t *csalt, u_int16_t clen, u_int8_t logr) | ||
144 | #else | ||
136 | static void | 145 | static void |
137 | encode_salt(salt, csalt, clen, logr) | 146 | encode_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 | ||
156 | char * | 166 | #if __STDC__ |
167 | char * | ||
168 | bcrypt_gensalt(u_int8_t log_rounds) | ||
169 | #else | ||
170 | char * | ||
157 | bcrypt_gensalt(log_rounds) | 171 | bcrypt_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 | ||
180 | char * | 195 | char * |
181 | bcrypt(key, salt) | 196 | bcrypt(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__ | ||
275 | static void | ||
276 | encode_base64(u_int8_t *buffer, u_int8_t *data, u_int16_t len) | ||
277 | #else | ||
259 | static void | 278 | static void |
260 | encode_base64(buffer, data, len) | 279 | encode_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__ | ||
445 | u_int32_t | ||
446 | Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes, u_int16_t *current) | ||
447 | #else | ||
444 | u_int32_t | 448 | u_int32_t |
445 | Blowfish_stream2word(data, databytes, current) | 449 | Blowfish_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__ | ||
473 | void | ||
474 | Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes) | ||
475 | #else | ||
467 | void | 476 | void |
468 | Blowfish_expand0state(c, key, keybytes) | 477 | Blowfish_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__ | ||
520 | void | ||
521 | Blowfish_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 | ||
509 | void | 524 | void |
510 | Blowfish_expandstate(c, data, databytes, key, keybytes) | 525 | Blowfish_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__ | ||
573 | void | ||
574 | blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len) | ||
575 | #else | ||
556 | void | 576 | void |
557 | blf_key(c, k, len) | 577 | blf_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__ | ||
591 | void | ||
592 | blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks) | ||
593 | #else | ||
569 | void | 594 | void |
570 | blf_enc(c, data, blocks) | 595 | blf_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__ | ||
612 | void | ||
613 | blf_dec(blf_ctx *c, u_int32_t *data, u_int16_t blocks) | ||
614 | #else | ||
584 | void | 615 | void |
585 | blf_dec(c, data, blocks) | 616 | blf_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; |