aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/Config.src4
-rw-r--r--libbb/hash_md5_sha.c32
-rw-r--r--libbb/hash_md5prime.c26
3 files changed, 31 insertions, 31 deletions
diff --git a/libbb/Config.src b/libbb/Config.src
index f6f88b9ce..f45e43b04 100644
--- a/libbb/Config.src
+++ b/libbb/Config.src
@@ -14,9 +14,9 @@ config PASSWORD_MINLEN
help
Minimum allowable password length.
-config MD5_SIZE_VS_SPEED
+config MD5_SMALL
int "MD5: Trade bytes for speed (0:fast, 3:slow)"
- default 2
+ default 1
range 0 3
help
Trade binary size versus speed for the md5sum algorithm.
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c
index b87d1dde8..a313c2a65 100644
--- a/libbb/hash_md5_sha.c
+++ b/libbb/hash_md5_sha.c
@@ -104,12 +104,12 @@ static void FAST_FUNC common64_end(md5_ctx_t *ctx, int swap_needed)
*/
/* 0: fastest, 3: smallest */
-#if CONFIG_MD5_SIZE_VS_SPEED < 0
-# define MD5_SIZE_VS_SPEED 0
-#elif CONFIG_MD5_SIZE_VS_SPEED > 3
-# define MD5_SIZE_VS_SPEED 3
+#if CONFIG_MD5_SMALL < 0
+# define MD5_SMALL 0
+#elif CONFIG_MD5_SMALL > 3
+# define MD5_SMALL 3
#else
-# define MD5_SIZE_VS_SPEED CONFIG_MD5_SIZE_VS_SPEED
+# define MD5_SMALL CONFIG_MD5_SMALL
#endif
/* These are the four functions used in the four steps of the MD5 algorithm
@@ -129,7 +129,7 @@ static void FAST_FUNC common64_end(md5_ctx_t *ctx, int swap_needed)
/* Hash a single block, 64 bytes long and 4-byte aligned */
static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx)
{
-#if MD5_SIZE_VS_SPEED > 0
+#if MD5_SMALL > 0
/* Before we start, one word to the strange constants.
They are defined in RFC 1321 as
T[i] = (int)(4294967296.0 * fabs(sin(i))), i=1..64
@@ -157,7 +157,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx)
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
};
static const char P_array[] ALIGN1 = {
-# if MD5_SIZE_VS_SPEED > 1
+# if MD5_SMALL > 1
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 1 */
# endif
1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, /* 2 */
@@ -171,7 +171,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx)
uint32_t C = ctx->hash[2];
uint32_t D = ctx->hash[3];
-#if MD5_SIZE_VS_SPEED >= 2 /* 2 or 3 */
+#if MD5_SMALL >= 2 /* 2 or 3 */
static const char S_array[] ALIGN1 = {
7, 12, 17, 22,
@@ -190,7 +190,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx)
words[i] = SWAP_LE32(words[i]);
# endif
-# if MD5_SIZE_VS_SPEED == 3
+# if MD5_SMALL == 3
pc = C_array;
pp = P_array;
ps = S_array - 4;
@@ -220,7 +220,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx)
C = B;
B = temp;
}
-# else /* MD5_SIZE_VS_SPEED == 2 */
+# else /* MD5_SMALL == 2 */
pc = C_array;
pp = P_array;
ps = S_array;
@@ -271,13 +271,13 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx)
ctx->hash[2] += C;
ctx->hash[3] += D;
-#else /* MD5_SIZE_VS_SPEED == 0 or 1 */
+#else /* MD5_SMALL == 0 or 1 */
uint32_t A_save = A;
uint32_t B_save = B;
uint32_t C_save = C;
uint32_t D_save = D;
-# if MD5_SIZE_VS_SPEED == 1
+# if MD5_SMALL == 1
const uint32_t *pc;
const char *pp;
int i;
@@ -299,7 +299,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx)
} while (0)
/* Round 1 */
-# if MD5_SIZE_VS_SPEED == 1
+# if MD5_SMALL == 1
pc = C_array;
for (i = 0; i < 4; i++) {
OP(A, B, C, D, 7, *pc++);
@@ -339,7 +339,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx)
} while (0)
/* Round 2 */
-# if MD5_SIZE_VS_SPEED == 1
+# if MD5_SMALL == 1
pp = P_array;
for (i = 0; i < 4; i++) {
OP(FG, A, B, C, D, (int) (*pp++), 5, *pc++);
@@ -367,7 +367,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx)
# endif
/* Round 3 */
-# if MD5_SIZE_VS_SPEED == 1
+# if MD5_SMALL == 1
for (i = 0; i < 4; i++) {
OP(FH, A, B, C, D, (int) (*pp++), 4, *pc++);
OP(FH, D, A, B, C, (int) (*pp++), 11, *pc++);
@@ -394,7 +394,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx)
# endif
/* Round 4 */
-# if MD5_SIZE_VS_SPEED == 1
+# if MD5_SMALL == 1
for (i = 0; i < 4; i++) {
OP(FI, A, B, C, D, (int) (*pp++), 6, *pc++);
OP(FI, D, A, B, C, (int) (*pp++), 10, *pc++);
diff --git a/libbb/hash_md5prime.c b/libbb/hash_md5prime.c
index 7986f4d29..e089a15f5 100644
--- a/libbb/hash_md5prime.c
+++ b/libbb/hash_md5prime.c
@@ -59,7 +59,7 @@
* Completely removed static PADDING array.
*
* Reintroduced the loop unrolling in md5_transform and added the
- * MD5_SIZE_VS_SPEED option for configurability. Define below as:
+ * MD5_SMALL option for configurability. Define below as:
* 0 fully unrolled loops
* 1 partially unrolled (4 ops per loop)
* 2 no unrolling -- introduces the need to swap 4 variables (slow)
@@ -75,12 +75,12 @@
#include "libbb.h"
/* 1: fastest, 3: smallest */
-#if CONFIG_MD5_SIZE_VS_SPEED < 1
-# define MD5_SIZE_VS_SPEED 1
-#elif CONFIG_MD5_SIZE_VS_SPEED > 3
-# define MD5_SIZE_VS_SPEED 3
+#if CONFIG_MD5_SMALL < 1
+# define MD5_SMALL 1
+#elif CONFIG_MD5_SMALL > 3
+# define MD5_SMALL 3
#else
-# define MD5_SIZE_VS_SPEED CONFIG_MD5_SIZE_VS_SPEED
+# define MD5_SMALL CONFIG_MD5_SMALL
#endif
#if BB_LITTLE_ENDIAN
@@ -152,7 +152,7 @@ memcpy32_le2cpu(uint32_t *output, const unsigned char *input, unsigned len)
static void md5_transform(uint32_t state[4], const unsigned char block[64])
{
uint32_t a, b, c, d, x[16];
-#if MD5_SIZE_VS_SPEED > 1
+#if MD5_SMALL > 1
uint32_t temp;
const unsigned char *ps;
@@ -162,9 +162,9 @@ static void md5_transform(uint32_t state[4], const unsigned char block[64])
4, 11, 16, 23,
6, 10, 15, 21
};
-#endif /* MD5_SIZE_VS_SPEED > 1 */
+#endif /* MD5_SMALL > 1 */
-#if MD5_SIZE_VS_SPEED > 0
+#if MD5_SMALL > 0
const uint32_t *pc;
const unsigned char *pp;
int i;
@@ -198,7 +198,7 @@ static void md5_transform(uint32_t state[4], const unsigned char block[64])
0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9 /* 4 */
};
-#endif /* MD5_SIZE_VS_SPEED > 0 */
+#endif /* MD5_SMALL > 0 */
memcpy32_le2cpu(x, block, 64);
@@ -207,7 +207,7 @@ static void md5_transform(uint32_t state[4], const unsigned char block[64])
c = state[2];
d = state[3];
-#if MD5_SIZE_VS_SPEED > 2
+#if MD5_SMALL > 2
pc = C;
pp = P;
ps = S - 4;
@@ -233,7 +233,7 @@ static void md5_transform(uint32_t state[4], const unsigned char block[64])
temp += b;
a = d; d = c; c = b; b = temp;
}
-#elif MD5_SIZE_VS_SPEED > 1
+#elif MD5_SMALL > 1
pc = C;
pp = P;
ps = S;
@@ -260,7 +260,7 @@ static void md5_transform(uint32_t state[4], const unsigned char block[64])
II(a, b, c, d, x[*pp], ps[i & 0x3], *pc); pp++; pc++;
temp = d; d = c; c = b; b = a; a = temp;
}
-#elif MD5_SIZE_VS_SPEED > 0
+#elif MD5_SMALL > 0
pc = C;
pp = P;
/* Round 1 */