aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-03-15 02:28:05 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-03-15 02:28:05 +0000
commite9afc468fac07f02c6e4ce160150e737928f8f07 (patch)
treea07c2491896901b6c2132ef7236ce90eba95c02a /include
parent7241e6d37781dc7e72e2b8b809f2643b98b66c25 (diff)
downloadbusybox-e9afc468fac07f02c6e4ce160150e737928f8f07.tar.gz
sha: merge sha1/sha256 handling (they are similar enough for this),
shrink sha215 code function old new delta sha1_end 129 142 +13 sha1_process_block64 486 494 +8 sha256_begin 37 44 +7 sha1_begin 49 56 +7 sha1_hash 108 112 +4 ... sha512_end 204 184 -20 sha512_process_block128 1405 1334 -71 sha256_process_block64 520 446 -74 sha256_end 147 - -147 sha512_hash 297 130 -167 sha256_hash 260 - -260 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 11/9 up/down: 59/-752) Total: -693 bytes
Diffstat (limited to 'include')
-rw-r--r--include/libbb.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/include/libbb.h b/include/libbb.h
index b04488a54..b6eab6f24 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1321,24 +1321,21 @@ 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 hash[8]; /* 5, +3 elements for sha256 */
uint64_t total64;
uint8_t wbuffer[64]; /* NB: always correctly aligned for uint64_t */
- uint32_t hash[5];
+ void (*process_block)(struct sha1_ctx_t*);
} 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 {
- uint64_t total64;
- uint32_t hash[8];
- uint8_t wbuffer[64]; /* NB: always correctly aligned for uint64_t */
-} sha256_ctx_t;
+typedef struct sha1_ctx_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;
+#define sha256_hash sha1_hash
+#define sha256_end sha1_end
typedef struct sha512_ctx_t {
- uint64_t total64[2];
uint64_t hash[8];
+ uint64_t total64[2];
uint8_t wbuffer[128]; /* NB: always correctly aligned for uint64_t */
} sha512_ctx_t;
void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC;