diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-10-18 14:48:30 +0200 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-10-18 14:48:30 +0200 |
commit | c48a5c607d8bdb422224a9767925a30d486a1109 (patch) | |
tree | 3d06212aaa3096fc0f5c6e36dffb3dd8ddd8fe40 /include/libbb.h | |
parent | b5aa1d95a158683d936ea41eed0513aa20ed2e74 (diff) | |
download | busybox-w32-c48a5c607d8bdb422224a9767925a30d486a1109.tar.gz busybox-w32-c48a5c607d8bdb422224a9767925a30d486a1109.tar.bz2 busybox-w32-c48a5c607d8bdb422224a9767925a30d486a1109.zip |
hash_md5_sha: use common finalization routine for MD5 and sha1/256. -15 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'include/libbb.h')
-rw-r--r-- | include/libbb.h | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/include/libbb.h b/include/libbb.h index c161ed7e2..3c8764b5c 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1515,35 +1515,14 @@ 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 | typedef struct sha1_ctx_t { | ||
1519 | uint32_t hash[8]; /* 5, +3 elements for sha256 */ | ||
1520 | uint64_t total64; /* must be directly after hash[] */ | ||
1521 | uint8_t wbuffer[64]; /* NB: always correctly aligned for uint64_t */ | ||
1522 | void (*process_block)(struct sha1_ctx_t*) FAST_FUNC; | ||
1523 | } sha1_ctx_t; | ||
1524 | void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC; | ||
1525 | void sha1_hash(sha1_ctx_t *ctx, const void *data, size_t length) FAST_FUNC; | ||
1526 | void sha1_end(sha1_ctx_t *ctx, void *resbuf) FAST_FUNC; | ||
1527 | typedef struct sha1_ctx_t sha256_ctx_t; | ||
1528 | void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC; | ||
1529 | #define sha256_hash sha1_hash | ||
1530 | #define sha256_end sha1_end | ||
1531 | typedef struct sha512_ctx_t { | ||
1532 | uint64_t hash[8]; | ||
1533 | uint64_t total64[2]; /* must be directly after hash[] */ | ||
1534 | uint8_t wbuffer[128]; /* NB: always correctly aligned for uint64_t */ | ||
1535 | } sha512_ctx_t; | ||
1536 | void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC; | ||
1537 | void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; | ||
1538 | void sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC; | ||
1539 | #if 1 | 1518 | #if 1 |
1540 | typedef struct md5_ctx_t { | 1519 | typedef struct md5_ctx_t { |
1520 | char wbuffer[64]; /* NB: always correctly aligned for uint64_t */ | ||
1521 | uint64_t total64; | ||
1541 | uint32_t A; | 1522 | uint32_t A; |
1542 | uint32_t B; | 1523 | uint32_t B; |
1543 | uint32_t C; | 1524 | uint32_t C; |
1544 | uint32_t D; | 1525 | uint32_t D; |
1545 | uint64_t total64; | ||
1546 | char wbuffer[64]; /* NB: always correctly aligned for uint64_t */ | ||
1547 | } md5_ctx_t; | 1526 | } md5_ctx_t; |
1548 | #else | 1527 | #else |
1549 | /* libbb/md5prime.c uses a bit different one: */ | 1528 | /* libbb/md5prime.c uses a bit different one: */ |
@@ -1556,6 +1535,27 @@ typedef struct md5_ctx_t { | |||
1556 | void md5_begin(md5_ctx_t *ctx) FAST_FUNC; | 1535 | void md5_begin(md5_ctx_t *ctx) FAST_FUNC; |
1557 | void md5_hash(md5_ctx_t *ctx, const void *data, size_t length) FAST_FUNC; | 1536 | void md5_hash(md5_ctx_t *ctx, const void *data, size_t length) FAST_FUNC; |
1558 | void md5_end(md5_ctx_t *ctx, void *resbuf) FAST_FUNC; | 1537 | 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; | ||
1545 | void sha1_hash(sha1_ctx_t *ctx, const void *data, size_t length) FAST_FUNC; | ||
1546 | 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; | ||
1549 | #define sha256_hash sha1_hash | ||
1550 | #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; | ||
1557 | 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; | ||
1559 | 1559 | ||
1560 | 1560 | ||
1561 | uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC; | 1561 | uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC; |