From 98c87f75755c1b53c8bd84f487e4bc7cba359b3e Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Wed, 11 Mar 2009 21:15:51 +0000 Subject: sha256/512: code shrink. Run-tested. function old new delta sha512_process_block128 - 1444 +1444 sha1_process_block64 - 542 +542 sha256_process_block64 - 529 +529 K512_lo - 320 +320 K256 - 320 +320 init512_lo - 32 +32 init256 - 32 +32 sha1_hash 99 128 +29 sha256_end 160 135 -25 sha1_end 189 160 -29 sha512_end 237 204 -33 sha256_begin 77 44 -33 sha512_begin 154 88 -66 sha256_hash 338 259 -79 sha512_hash 358 262 -96 sha1_compile 542 - -542 sha256_process_block 594 - -594 static.K 896 - -896 sha512_process_block 1861 - -1861 ------------------------------------------------------------------------------ (add/remove: 7/4 grow/shrink: 1/7 up/down: 3248/-4254) Total: -1006 bytes text data bss dec hex filename 808013 468 7856 816337 c74d1 busybox_old 807007 468 7856 815331 c70e3 busybox_unstripped --- include/libbb.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'include/libbb.h') diff --git a/include/libbb.h b/include/libbb.h index 80a1c912c..4c9901027 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1321,27 +1321,27 @@ extern const char bb_uuenc_tbl_std[]; void bb_uuencode(char *store, const void *s, int length, const char *tbl) FAST_FUNC; typedef struct sha1_ctx_t { - uint32_t count[2]; + uint64_t total64; + uint32_t wbuffer[16]; /* NB: always correctly aligned for uint64_t */ uint32_t hash[5]; - uint32_t wbuf[16]; } sha1_ctx_t; void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC; void sha1_hash(const void *data, size_t length, sha1_ctx_t *ctx) FAST_FUNC; void sha1_end(void *resbuf, sha1_ctx_t *ctx) FAST_FUNC; typedef struct sha256_ctx_t { + unsigned wbuflen; uint32_t H[8]; - uint32_t total[2]; /* rename to "count"? */ - uint32_t buflen; - char buffer[128]; /* NB: always correctly aligned for uint32_t */ + uint64_t total64; + char wbuffer[64*2]; /* NB: always correctly aligned for uint64_t */ } sha256_ctx_t; void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC; void sha256_hash(const void *buffer, size_t len, sha256_ctx_t *ctx) FAST_FUNC; void sha256_end(void *resbuf, sha256_ctx_t *ctx) FAST_FUNC; typedef struct sha512_ctx_t { + unsigned wbuflen; uint64_t H[8]; - uint64_t total[2]; - uint64_t buflen; - char buffer[256]; /* NB: always correctly aligned for uint64_t */ + uint64_t total64[2]; + char wbuffer[128*2]; /* NB: always correctly aligned for uint64_t */ } sha512_ctx_t; void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC; void sha512_hash(const void *buffer, size_t len, sha512_ctx_t *ctx) FAST_FUNC; -- cgit v1.2.3