aboutsummaryrefslogtreecommitdiff
path: root/include/libbb.h
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-10-18 14:48:30 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-10-18 14:48:30 +0200
commitc48a5c607d8bdb422224a9767925a30d486a1109 (patch)
tree3d06212aaa3096fc0f5c6e36dffb3dd8ddd8fe40 /include/libbb.h
parentb5aa1d95a158683d936ea41eed0513aa20ed2e74 (diff)
downloadbusybox-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.h46
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};
1516void FAST_FUNC read_base64(FILE *src_stream, FILE *dst_stream, int flags); 1516void FAST_FUNC read_base64(FILE *src_stream, FILE *dst_stream, int flags);
1517 1517
1518typedef 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;
1524void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC;
1525void sha1_hash(sha1_ctx_t *ctx, const void *data, size_t length) FAST_FUNC;
1526void sha1_end(sha1_ctx_t *ctx, void *resbuf) FAST_FUNC;
1527typedef struct sha1_ctx_t sha256_ctx_t;
1528void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC;
1529#define sha256_hash sha1_hash
1530#define sha256_end sha1_end
1531typedef 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;
1536void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC;
1537void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC;
1538void sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC;
1539#if 1 1518#if 1
1540typedef struct md5_ctx_t { 1519typedef 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 {
1556void md5_begin(md5_ctx_t *ctx) FAST_FUNC; 1535void md5_begin(md5_ctx_t *ctx) FAST_FUNC;
1557void md5_hash(md5_ctx_t *ctx, const void *data, size_t length) FAST_FUNC; 1536void md5_hash(md5_ctx_t *ctx, const void *data, size_t length) FAST_FUNC;
1558void md5_end(md5_ctx_t *ctx, void *resbuf) FAST_FUNC; 1537void md5_end(md5_ctx_t *ctx, void *resbuf) FAST_FUNC;
1538typedef 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;
1544void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC;
1545void sha1_hash(sha1_ctx_t *ctx, const void *data, size_t length) FAST_FUNC;
1546void sha1_end(sha1_ctx_t *ctx, void *resbuf) FAST_FUNC;
1547typedef struct sha1_ctx_t sha256_ctx_t;
1548void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC;
1549#define sha256_hash sha1_hash
1550#define sha256_end sha1_end
1551typedef 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;
1556void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC;
1557void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC;
1558void sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC;
1559 1559
1560 1560
1561uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC; 1561uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC;