1 diff -urpN busybox-1.18.0/libbb/pw_encrypt_sha.c busybox-1.18.0-sha/libbb/pw_encrypt_sha.c
2 --- busybox-1.18.0/libbb/pw_encrypt_sha.c 2010-11-22 21:43:22.000000000 +0100
3 +++ busybox-1.18.0-sha/libbb/pw_encrypt_sha.c 2010-12-01 13:56:24.372704380 +0100
7 /* Prefix for optional rounds specification. */
8 -static const char str_rounds[] = "rounds=%u$";
9 +static const char str_rounds[] ALIGN1 = "rounds=%u$";
11 /* Maximum salt string length. */
12 #define SALT_LEN_MAX 16
13 @@ -19,8 +19,8 @@ NOINLINE
14 sha_crypt(/*const*/ char *key_data, /*const*/ char *salt_data)
16 void (*sha_begin)(void *ctx) FAST_FUNC;
17 - void (*sha_hash)(const void *buffer, size_t len, void *ctx) FAST_FUNC;
18 - void (*sha_end)(void *resbuf, void *ctx) FAST_FUNC;
19 + void (*sha_hash)(void *ctx, const void *buffer, size_t len) FAST_FUNC;
20 + void (*sha_end)(void *ctx, void *resbuf) FAST_FUNC;
23 char *result, *resptr;
24 @@ -103,40 +103,40 @@ sha_crypt(/*const*/ char *key_data, /*co
28 - sha_hash(key_data, key_len, &ctx);
29 - sha_hash(salt_data, salt_len, &ctx);
30 + sha_hash(&ctx, key_data, key_len);
31 + sha_hash(&ctx, salt_data, salt_len);
33 /* Compute alternate SHA sum with input KEY, SALT, and KEY.
34 The final result will be added to the first context. */
36 - sha_hash(key_data, key_len, &alt_ctx);
37 - sha_hash(salt_data, salt_len, &alt_ctx);
38 - sha_hash(key_data, key_len, &alt_ctx);
39 - sha_end(alt_result, &alt_ctx);
40 + sha_hash(&alt_ctx, key_data, key_len);
41 + sha_hash(&alt_ctx, salt_data, salt_len);
42 + sha_hash(&alt_ctx, key_data, key_len);
43 + sha_end(&alt_ctx, alt_result);
45 /* Add result of this to the other context. */
46 /* Add for any character in the key one byte of the alternate sum. */
47 for (cnt = key_len; cnt > _32or64; cnt -= _32or64)
48 - sha_hash(alt_result, _32or64, &ctx);
49 - sha_hash(alt_result, cnt, &ctx);
50 + sha_hash(&ctx, alt_result, _32or64);
51 + sha_hash(&ctx, alt_result, cnt);
53 /* Take the binary representation of the length of the key and for every
54 1 add the alternate sum, for every 0 the key. */
55 for (cnt = key_len; cnt != 0; cnt >>= 1)
57 - sha_hash(alt_result, _32or64, &ctx);
58 + sha_hash(&ctx, alt_result, _32or64);
60 - sha_hash(key_data, key_len, &ctx);
61 + sha_hash(&ctx, key_data, key_len);
63 /* Create intermediate result. */
64 - sha_end(alt_result, &ctx);
65 + sha_end(&ctx, alt_result);
67 /* Start computation of P byte sequence. */
68 /* For every character in the password add the entire password. */
70 for (cnt = 0; cnt < key_len; ++cnt)
71 - sha_hash(key_data, key_len, &alt_ctx);
72 - sha_end(temp_result, &alt_ctx);
73 + sha_hash(&alt_ctx, key_data, key_len);
74 + sha_end(&alt_ctx, temp_result);
76 /* NB: past this point, raw key_data is not used anymore */
78 @@ -153,8 +153,8 @@ sha_crypt(/*const*/ char *key_data, /*co
79 /* For every character in the password add the entire password. */
81 for (cnt = 0; cnt < 16 + alt_result[0]; ++cnt)
82 - sha_hash(salt_data, salt_len, &alt_ctx);
83 - sha_end(temp_result, &alt_ctx);
84 + sha_hash(&alt_ctx, salt_data, salt_len);
85 + sha_end(&alt_ctx, temp_result);
87 /* NB: past this point, raw salt_data is not used anymore */
89 @@ -174,22 +174,22 @@ sha_crypt(/*const*/ char *key_data, /*co
91 /* Add key or last result. */
93 - sha_hash(p_bytes, key_len, &ctx);
94 + sha_hash(&ctx, p_bytes, key_len);
96 - sha_hash(alt_result, _32or64, &ctx);
97 + sha_hash(&ctx, alt_result, _32or64);
98 /* Add salt for numbers not divisible by 3. */
100 - sha_hash(s_bytes, salt_len, &ctx);
101 + sha_hash(&ctx, s_bytes, salt_len);
102 /* Add key for numbers not divisible by 7. */
104 - sha_hash(p_bytes, key_len, &ctx);
105 + sha_hash(&ctx, p_bytes, key_len);
106 /* Add key or last result. */
108 - sha_hash(alt_result, _32or64, &ctx);
109 + sha_hash(&ctx, alt_result, _32or64);
111 - sha_hash(p_bytes, key_len, &ctx);
112 + sha_hash(&ctx, p_bytes, key_len);
114 - sha_end(alt_result, &ctx);
115 + sha_end(&ctx, alt_result);
118 /* Append encrypted password to result buffer */