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 | |
parent | b5aa1d95a158683d936ea41eed0513aa20ed2e74 (diff) |
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')
-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 { }; void FAST_FUNC read_base64(FILE *src_stream, FILE *dst_stream, int flags); -typedef struct sha1_ctx_t { - uint32_t hash[8]; /* 5, +3 elements for sha256 */ - uint64_t total64; /* must be directly after hash[] */ - uint8_t wbuffer[64]; /* NB: always correctly aligned for uint64_t */ - void (*process_block)(struct sha1_ctx_t*) FAST_FUNC; -} sha1_ctx_t; -void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC; -void sha1_hash(sha1_ctx_t *ctx, const void *data, size_t length) FAST_FUNC; -void sha1_end(sha1_ctx_t *ctx, void *resbuf) FAST_FUNC; -typedef struct sha1_ctx_t sha256_ctx_t; -void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC; -#define sha256_hash sha1_hash -#define sha256_end sha1_end -typedef struct sha512_ctx_t { - uint64_t hash[8]; - uint64_t total64[2]; /* must be directly after hash[] */ - uint8_t wbuffer[128]; /* NB: always correctly aligned for uint64_t */ -} sha512_ctx_t; -void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC; -void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; -void sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC; #if 1 typedef struct md5_ctx_t { + char wbuffer[64]; /* NB: always correctly aligned for uint64_t */ + uint64_t total64; uint32_t A; uint32_t B; uint32_t C; uint32_t D; - uint64_t total64; - char wbuffer[64]; /* NB: always correctly aligned for uint64_t */ } md5_ctx_t; #else /* libbb/md5prime.c uses a bit different one: */ @@ -1556,6 +1535,27 @@ typedef struct md5_ctx_t { void md5_begin(md5_ctx_t *ctx) FAST_FUNC; void md5_hash(md5_ctx_t *ctx, const void *data, size_t length) FAST_FUNC; void md5_end(md5_ctx_t *ctx, void *resbuf) FAST_FUNC; +typedef struct sha1_ctx_t { + uint8_t wbuffer[64]; /* NB: always correctly aligned for uint64_t */ + uint64_t total64; /* must be directly before hash[] */ + uint32_t hash[8]; /* 5, +3 elements for sha256 */ + void (*process_block)(struct sha1_ctx_t*) FAST_FUNC; +} sha1_ctx_t; +void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC; +void sha1_hash(sha1_ctx_t *ctx, const void *data, size_t length) FAST_FUNC; +void sha1_end(sha1_ctx_t *ctx, void *resbuf) FAST_FUNC; +typedef struct sha1_ctx_t sha256_ctx_t; +void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC; +#define sha256_hash sha1_hash +#define sha256_end sha1_end +typedef struct sha512_ctx_t { + uint64_t total64[2]; /* must be directly before hash[] */ + uint64_t hash[8]; + uint8_t wbuffer[128]; /* NB: always correctly aligned for uint64_t */ +} sha512_ctx_t; +void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC; +void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC; +void sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC; uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC; |