diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-10-19 02:16:12 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-10-19 02:16:12 +0200 |
commit | 302ad1450e104460abd3aae60b7f40d8a88f43df (patch) | |
tree | 0558bb8533889fa16d820e4466d3b72da083b9f6 /include/libbb.h | |
parent | d982da79deb36185c420f94417b57e7b8a4af04c (diff) | |
download | busybox-w32-302ad1450e104460abd3aae60b7f40d8a88f43df.tar.gz busybox-w32-302ad1450e104460abd3aae60b7f40d8a88f43df.tar.bz2 busybox-w32-302ad1450e104460abd3aae60b7f40d8a88f43df.zip |
libbb/hash_md5_sha: use common ctx and code for md5 and sha1/256
function old new delta
sha256_process_block64 421 433 +12
md5_crypt 578 587 +9
md5_begin 43 50 +7
md5_hash 99 97 -2
sha1_end 85 82 -3
md5_end 36 31 -5
common64_end 93 86 -7
sha1_hash 97 - -97
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'include/libbb.h')
-rw-r--r-- | include/libbb.h | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/include/libbb.h b/include/libbb.h index 3c8764b5c..01dc33e63 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1515,44 +1515,28 @@ enum { | |||
1515 | }; | 1515 | }; |
1516 | void FAST_FUNC read_base64(FILE *src_stream, FILE *dst_stream, int flags); | 1516 | void FAST_FUNC read_base64(FILE *src_stream, FILE *dst_stream, int flags); |
1517 | 1517 | ||
1518 | #if 1 | ||
1519 | typedef struct md5_ctx_t { | 1518 | typedef struct md5_ctx_t { |
1520 | char wbuffer[64]; /* NB: always correctly aligned for uint64_t */ | 1519 | uint8_t wbuffer[64]; /* always correctly aligned for uint64_t */ |
1521 | uint64_t total64; | 1520 | void (*process_block)(struct md5_ctx_t*) FAST_FUNC; |
1522 | uint32_t A; | 1521 | uint64_t total64; /* must be directly before hash[] */ |
1523 | uint32_t B; | 1522 | uint32_t hash[8]; /* 4 elements for md5, 5 for sha1, 8 for sha256 */ |
1524 | uint32_t C; | ||
1525 | uint32_t D; | ||
1526 | } md5_ctx_t; | ||
1527 | #else | ||
1528 | /* libbb/md5prime.c uses a bit different one: */ | ||
1529 | typedef struct md5_ctx_t { | ||
1530 | uint32_t state[4]; /* state (ABCD) */ | ||
1531 | uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ | ||
1532 | unsigned char buffer[64]; /* input buffer */ | ||
1533 | } md5_ctx_t; | 1523 | } md5_ctx_t; |
1534 | #endif | 1524 | typedef struct md5_ctx_t sha1_ctx_t; |
1525 | typedef struct md5_ctx_t sha256_ctx_t; | ||
1526 | typedef struct sha512_ctx_t { | ||
1527 | uint64_t total64[2]; /* must be directly before hash[] */ | ||
1528 | uint64_t hash[8]; | ||
1529 | uint8_t wbuffer[128]; /* always correctly aligned for uint64_t */ | ||
1530 | } sha512_ctx_t; | ||
1535 | void md5_begin(md5_ctx_t *ctx) FAST_FUNC; | 1531 | void md5_begin(md5_ctx_t *ctx) FAST_FUNC; |
1536 | void md5_hash(md5_ctx_t *ctx, const void *data, size_t length) FAST_FUNC; | 1532 | void md5_hash(md5_ctx_t *ctx, const void *data, size_t length) FAST_FUNC; |
1537 | void md5_end(md5_ctx_t *ctx, void *resbuf) FAST_FUNC; | 1533 | void md5_end(md5_ctx_t *ctx, void *resbuf) FAST_FUNC; |
1538 | typedef struct sha1_ctx_t { | ||
1539 | uint8_t wbuffer[64]; /* NB: always correctly aligned for uint64_t */ | ||
1540 | uint64_t total64; /* must be directly before hash[] */ | ||
1541 | uint32_t hash[8]; /* 5, +3 elements for sha256 */ | ||
1542 | void (*process_block)(struct sha1_ctx_t*) FAST_FUNC; | ||
1543 | } sha1_ctx_t; | ||
1544 | void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC; | 1534 | void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC; |
1545 | void sha1_hash(sha1_ctx_t *ctx, const void *data, size_t length) FAST_FUNC; | 1535 | #define sha1_hash md5_hash |
1546 | void sha1_end(sha1_ctx_t *ctx, void *resbuf) FAST_FUNC; | 1536 | void sha1_end(sha1_ctx_t *ctx, void *resbuf) FAST_FUNC; |
1547 | typedef struct sha1_ctx_t sha256_ctx_t; | ||
1548 | void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC; | 1537 | void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC; |
1549 | #define sha256_hash sha1_hash | 1538 | #define sha256_hash md5_hash |
1550 | #define sha256_end sha1_end | 1539 | #define sha256_end sha1_end |
1551 | typedef struct sha512_ctx_t { | ||
1552 | uint64_t total64[2]; /* must be directly before hash[] */ | ||
1553 | uint64_t hash[8]; | ||
1554 | uint8_t wbuffer[128]; /* NB: always correctly aligned for uint64_t */ | ||
1555 | } sha512_ctx_t; | ||
1556 | void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC; | 1540 | void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC; |
1557 | void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; | 1541 | void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; |
1558 | void sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC; | 1542 | void sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC; |