aboutsummaryrefslogtreecommitdiff
path: root/include/libbb.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libbb.h')
-rw-r--r--include/libbb.h54
1 files changed, 19 insertions, 35 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 0ea7700f2..99bfe085c 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1532,47 +1532,31 @@ enum {
1532}; 1532};
1533void FAST_FUNC read_base64(FILE *src_stream, FILE *dst_stream, int flags); 1533void FAST_FUNC read_base64(FILE *src_stream, FILE *dst_stream, int flags);
1534 1534
1535typedef struct sha1_ctx_t { 1535typedef struct md5_ctx_t {
1536 uint32_t hash[8]; /* 5, +3 elements for sha256 */ 1536 uint8_t wbuffer[64]; /* always correctly aligned for uint64_t */
1537 uint64_t total64; /* must be directly after hash[] */ 1537 void (*process_block)(struct md5_ctx_t*) FAST_FUNC;
1538 uint8_t wbuffer[64]; /* NB: always correctly aligned for uint64_t */ 1538 uint64_t total64; /* must be directly before hash[] */
1539 void (*process_block)(struct sha1_ctx_t*) FAST_FUNC; 1539 uint32_t hash[8]; /* 4 elements for md5, 5 for sha1, 8 for sha256 */
1540} sha1_ctx_t; 1540} md5_ctx_t;
1541void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC; 1541typedef struct md5_ctx_t sha1_ctx_t;
1542void sha1_hash(sha1_ctx_t *ctx, const void *data, size_t length) FAST_FUNC; 1542typedef struct md5_ctx_t sha256_ctx_t;
1543void sha1_end(sha1_ctx_t *ctx, void *resbuf) FAST_FUNC;
1544typedef struct sha1_ctx_t sha256_ctx_t;
1545void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC;
1546#define sha256_hash sha1_hash
1547#define sha256_end sha1_end
1548typedef struct sha512_ctx_t { 1543typedef struct sha512_ctx_t {
1544 uint64_t total64[2]; /* must be directly before hash[] */
1549 uint64_t hash[8]; 1545 uint64_t hash[8];
1550 uint64_t total64[2]; /* must be directly after hash[] */ 1546 uint8_t wbuffer[128]; /* always correctly aligned for uint64_t */
1551 uint8_t wbuffer[128]; /* NB: always correctly aligned for uint64_t */
1552} sha512_ctx_t; 1547} sha512_ctx_t;
1553void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC;
1554void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC;
1555void sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC;
1556#if 1
1557typedef struct md5_ctx_t {
1558 uint32_t A;
1559 uint32_t B;
1560 uint32_t C;
1561 uint32_t D;
1562 uint64_t total64;
1563 char wbuffer[64]; /* NB: always correctly aligned for uint64_t */
1564} md5_ctx_t;
1565#else
1566/* libbb/md5prime.c uses a bit different one: */
1567typedef struct md5_ctx_t {
1568 uint32_t state[4]; /* state (ABCD) */
1569 uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
1570 unsigned char buffer[64]; /* input buffer */
1571} md5_ctx_t;
1572#endif
1573void md5_begin(md5_ctx_t *ctx) FAST_FUNC; 1548void md5_begin(md5_ctx_t *ctx) FAST_FUNC;
1574void md5_hash(md5_ctx_t *ctx, const void *data, size_t length) FAST_FUNC; 1549void md5_hash(md5_ctx_t *ctx, const void *data, size_t length) FAST_FUNC;
1575void md5_end(md5_ctx_t *ctx, void *resbuf) FAST_FUNC; 1550void md5_end(md5_ctx_t *ctx, void *resbuf) FAST_FUNC;
1551void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC;
1552#define sha1_hash md5_hash
1553void sha1_end(sha1_ctx_t *ctx, void *resbuf) FAST_FUNC;
1554void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC;
1555#define sha256_hash md5_hash
1556#define sha256_end sha1_end
1557void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC;
1558void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC;
1559void sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC;
1576 1560
1577 1561
1578uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC; 1562uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC;