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/blowfish.c | |
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/blowfish.c')
-rw-r--r-- | src/lib/libc/crypt/blowfish.c | 34 |
1 files changed, 33 insertions, 1 deletions
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; |