diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-07 19:17:01 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-07 19:17:01 +0200 |
| commit | 305958dbd456d463a92c1fa4c85ceb69a8c7db32 (patch) | |
| tree | 19883229c6fa77b663c00ad27a33ef2bb946de10 /libbb | |
| parent | ec046f74a31e4315f4546ec5602f56e7d467082d (diff) | |
| download | busybox-w32-305958dbd456d463a92c1fa4c85ceb69a8c7db32.tar.gz busybox-w32-305958dbd456d463a92c1fa4c85ceb69a8c7db32.tar.bz2 busybox-w32-305958dbd456d463a92c1fa4c85ceb69a8c7db32.zip | |
md5sum: code shrink
For CONFIG_MD5_SMALL=1:
function old new delta
md5_process_block64 925 881 -44
For CONFIG_MD5_SMALL=0:
function old new delta
md5_process_block64 1603 1586 -17
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
| -rw-r--r-- | libbb/hash_md5_sha.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c index 1f63ccdee..d08c6b2f7 100644 --- a/libbb/hash_md5_sha.c +++ b/libbb/hash_md5_sha.c | |||
| @@ -137,7 +137,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
| 137 | #if MD5_SMALL > 0 | 137 | #if MD5_SMALL > 0 |
| 138 | /* Before we start, one word to the strange constants. | 138 | /* Before we start, one word to the strange constants. |
| 139 | They are defined in RFC 1321 as | 139 | They are defined in RFC 1321 as |
| 140 | T[i] = (int)(4294967296.0 * fabs(sin(i))), i=1..64 | 140 | T[i] = (int)(2^32 * fabs(sin(i))), i=1..64 |
| 141 | */ | 141 | */ |
| 142 | static const uint32_t C_array[] = { | 142 | static const uint32_t C_array[] = { |
| 143 | /* round 1 */ | 143 | /* round 1 */ |
| @@ -213,7 +213,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
| 213 | case 2: | 213 | case 2: |
| 214 | temp += FH(B, C, D); | 214 | temp += FH(B, C, D); |
| 215 | break; | 215 | break; |
| 216 | case 3: | 216 | default: /* case 3 */ |
| 217 | temp += FI(B, C, D); | 217 | temp += FI(B, C, D); |
| 218 | } | 218 | } |
| 219 | temp += words[(int) (*pp++)] + *pc++; | 219 | temp += words[(int) (*pp++)] + *pc++; |
| @@ -277,10 +277,6 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
| 277 | 277 | ||
| 278 | #else /* MD5_SMALL == 0 or 1 */ | 278 | #else /* MD5_SMALL == 0 or 1 */ |
| 279 | 279 | ||
| 280 | uint32_t A_save = A; | ||
| 281 | uint32_t B_save = B; | ||
| 282 | uint32_t C_save = C; | ||
| 283 | uint32_t D_save = D; | ||
| 284 | # if MD5_SMALL == 1 | 280 | # if MD5_SMALL == 1 |
| 285 | const uint32_t *pc; | 281 | const uint32_t *pc; |
| 286 | const char *pp; | 282 | const char *pp; |
| @@ -425,10 +421,10 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
| 425 | # undef OP | 421 | # undef OP |
| 426 | # endif | 422 | # endif |
| 427 | /* Add checksum to the starting values */ | 423 | /* Add checksum to the starting values */ |
| 428 | ctx->hash[0] = A_save + A; | 424 | ctx->hash[0] += A; |
| 429 | ctx->hash[1] = B_save + B; | 425 | ctx->hash[1] += B; |
| 430 | ctx->hash[2] = C_save + C; | 426 | ctx->hash[2] += C; |
| 431 | ctx->hash[3] = D_save + D; | 427 | ctx->hash[3] += D; |
| 432 | #endif | 428 | #endif |
| 433 | } | 429 | } |
| 434 | #undef FF | 430 | #undef FF |
