]> git.pld-linux.org Git - packages/busybox.git/blob - busybox-1.18.0-sha.patch
- up to 1.18.0
[packages/busybox.git] / busybox-1.18.0-sha.patch
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
4 @@ -3,7 +3,7 @@
5   */
6  
7  /* Prefix for optional rounds specification.  */
8 -static const char str_rounds[] = "rounds=%u$";
9 +static const char str_rounds[] ALIGN1 = "rounds=%u$";
10  
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)
15  {
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;
21         int _32or64;
22  
23         char *result, *resptr;
24 @@ -103,40 +103,40 @@ sha_crypt(/*const*/ char *key_data, /*co
25  
26         /* Add KEY, SALT.  */
27         sha_begin(&ctx);
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);
32  
33         /* Compute alternate SHA sum with input KEY, SALT, and KEY.
34            The final result will be added to the first context.  */
35         sha_begin(&alt_ctx);
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);
44  
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);
52  
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)
56                 if ((cnt & 1) != 0)
57 -                       sha_hash(alt_result, _32or64, &ctx);
58 +                       sha_hash(&ctx, alt_result, _32or64);
59                 else
60 -                       sha_hash(key_data, key_len, &ctx);
61 +                       sha_hash(&ctx, key_data, key_len);
62  
63         /* Create intermediate result.  */
64 -       sha_end(alt_result, &ctx);
65 +       sha_end(&ctx, alt_result);
66  
67         /* Start computation of P byte sequence.  */
68         /* For every character in the password add the entire password.  */
69         sha_begin(&alt_ctx);
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);
75  
76         /* NB: past this point, raw key_data is not used anymore */
77  
78 @@ -153,8 +153,8 @@ sha_crypt(/*const*/ char *key_data, /*co
79         /* For every character in the password add the entire password.  */
80         sha_begin(&alt_ctx);
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);
86  
87         /* NB: past this point, raw salt_data is not used anymore */
88  
89 @@ -174,22 +174,22 @@ sha_crypt(/*const*/ char *key_data, /*co
90  
91                 /* Add key or last result.  */
92                 if ((cnt & 1) != 0)
93 -                       sha_hash(p_bytes, key_len, &ctx);
94 +                       sha_hash(&ctx, p_bytes, key_len);
95                 else
96 -                       sha_hash(alt_result, _32or64, &ctx);
97 +                       sha_hash(&ctx, alt_result, _32or64);
98                 /* Add salt for numbers not divisible by 3.  */
99                 if (cnt % 3 != 0)
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.  */
103                 if (cnt % 7 != 0)
104 -                       sha_hash(p_bytes, key_len, &ctx);
105 +                       sha_hash(&ctx, p_bytes, key_len);
106                 /* Add key or last result.  */
107                 if ((cnt & 1) != 0)
108 -                       sha_hash(alt_result, _32or64, &ctx);
109 +                       sha_hash(&ctx, alt_result, _32or64);
110                 else
111 -                       sha_hash(p_bytes, key_len, &ctx);
112 +                       sha_hash(&ctx, p_bytes, key_len);
113  
114 -               sha_end(alt_result, &ctx);
115 +               sha_end(&ctx, alt_result);
116         }
117  
118         /* Append encrypted password to result buffer */
This page took 0.303972 seconds and 3 git commands to generate.