aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-03-15 02:56:00 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-03-15 02:56:00 +0000
commit8ec8d5e3db47398d4799f1a7c6aa0ced043c3e5f (patch)
tree3d732930b270efaa77493cafb90c1690d6e85c95
parente9afc468fac07f02c6e4ce160150e737928f8f07 (diff)
downloadbusybox-w32-8ec8d5e3db47398d4799f1a7c6aa0ced043c3e5f.tar.gz
busybox-w32-8ec8d5e3db47398d4799f1a7c6aa0ced043c3e5f.tar.bz2
busybox-w32-8ec8d5e3db47398d4799f1a7c6aa0ced043c3e5f.zip
sha: fix thinko in sha512; add FAST_FUNC to sha1/sha256
function old new delta sha512_process_block128 1334 1336 +2 sha1_hash 112 111 -1 sha256_process_block64 446 440 -6 sha1_process_block64 494 484 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 2/-17) Total: -15 bytes
-rw-r--r--include/libbb.h2
-rw-r--r--libbb/sha1.c8
2 files changed, 5 insertions, 5 deletions
diff --git a/include/libbb.h b/include/libbb.h
index b6eab6f24..bc47ce7ba 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1324,7 +1324,7 @@ typedef struct sha1_ctx_t {
1324 uint32_t hash[8]; /* 5, +3 elements for sha256 */ 1324 uint32_t hash[8]; /* 5, +3 elements for sha256 */
1325 uint64_t total64; 1325 uint64_t total64;
1326 uint8_t wbuffer[64]; /* NB: always correctly aligned for uint64_t */ 1326 uint8_t wbuffer[64]; /* NB: always correctly aligned for uint64_t */
1327 void (*process_block)(struct sha1_ctx_t*); 1327 void (*process_block)(struct sha1_ctx_t*) FAST_FUNC;
1328} sha1_ctx_t; 1328} sha1_ctx_t;
1329void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC; 1329void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC;
1330void sha1_hash(const void *data, size_t length, sha1_ctx_t *ctx) FAST_FUNC; 1330void sha1_hash(const void *data, size_t length, sha1_ctx_t *ctx) FAST_FUNC;
diff --git a/libbb/sha1.c b/libbb/sha1.c
index 8ecf71a9d..ccc317667 100644
--- a/libbb/sha1.c
+++ b/libbb/sha1.c
@@ -56,7 +56,7 @@ static inline uint64_t hton64(uint64_t v)
56#define SHA1_BLOCK_SIZE 64 56#define SHA1_BLOCK_SIZE 64
57#define SHA1_MASK (SHA1_BLOCK_SIZE - 1) 57#define SHA1_MASK (SHA1_BLOCK_SIZE - 1)
58 58
59static void sha1_process_block64(sha1_ctx_t *ctx) 59static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx)
60{ 60{
61 unsigned i; 61 unsigned i;
62 uint32_t w[80], a, b, c, d, e, t; 62 uint32_t w[80], a, b, c, d, e, t;
@@ -203,7 +203,7 @@ static const uint32_t K512_lo[80] = {
203 203
204/* Process LEN bytes of BUFFER, accumulating context into CTX. 204/* Process LEN bytes of BUFFER, accumulating context into CTX.
205 LEN is rounded _down_ to 64. */ 205 LEN is rounded _down_ to 64. */
206static void sha256_process_block64(sha256_ctx_t *ctx) 206static void FAST_FUNC sha256_process_block64(sha256_ctx_t *ctx)
207{ 207{
208 unsigned t; 208 unsigned t;
209 uint32_t W[64]; 209 uint32_t W[64];
@@ -266,7 +266,7 @@ static void sha256_process_block64(sha256_ctx_t *ctx)
266} 266}
267/* Process LEN bytes of BUFFER, accumulating context into CTX. 267/* Process LEN bytes of BUFFER, accumulating context into CTX.
268 LEN is rounded _down_ to 128. */ 268 LEN is rounded _down_ to 128. */
269static void sha512_process_block128(sha512_ctx_t *ctx) 269static void FAST_FUNC sha512_process_block128(sha512_ctx_t *ctx)
270{ 270{
271 unsigned t; 271 unsigned t;
272 uint64_t W[80]; 272 uint64_t W[80];
@@ -278,7 +278,7 @@ static void sha512_process_block128(sha512_ctx_t *ctx)
278 uint64_t f = ctx->hash[5]; 278 uint64_t f = ctx->hash[5];
279 uint64_t g = ctx->hash[6]; 279 uint64_t g = ctx->hash[6];
280 uint64_t h = ctx->hash[7]; 280 uint64_t h = ctx->hash[7];
281 const uint32_t *words = (uint32_t*) ctx->wbuffer; 281 const uint64_t *words = (uint64_t*) ctx->wbuffer;
282 282
283 /* Operators defined in FIPS 180-2:4.1.2. */ 283 /* Operators defined in FIPS 180-2:4.1.2. */
284#define Ch(x, y, z) ((x & y) ^ (~x & z)) 284#define Ch(x, y, z) ((x & y) ^ (~x & z))