diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-10-16 20:45:27 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-10-16 20:45:27 +0200 |
commit | c0683acce88efc1fe15d9a4332428b5a9fdc6c2e (patch) | |
tree | cb0f5bb99b5e5f4490be175238d3a877115bc468 /libbb/pw_encrypt_md5.c | |
parent | 1a5e11c874a1f53c5205140a9d675b7e6404bbc9 (diff) | |
download | busybox-w32-c0683acce88efc1fe15d9a4332428b5a9fdc6c2e.tar.gz busybox-w32-c0683acce88efc1fe15d9a4332428b5a9fdc6c2e.tar.bz2 busybox-w32-c0683acce88efc1fe15d9a4332428b5a9fdc6c2e.zip |
*: pass md5/shaN context pointer as 1st arg, not last
function old new delta
md5_hash_block 458 459 +1
filter_rename_config 252 250 -2
md5_crypt 591 587 -4
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/pw_encrypt_md5.c')
-rw-r--r-- | libbb/pw_encrypt_md5.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/libbb/pw_encrypt_md5.c b/libbb/pw_encrypt_md5.c index 58964b567..889e09cab 100644 --- a/libbb/pw_encrypt_md5.c +++ b/libbb/pw_encrypt_md5.c | |||
@@ -92,10 +92,10 @@ md5_crypt(char result[MD5_OUT_BUFSIZE], const unsigned char *pw, const unsigned | |||
92 | /* Hash. the password first, since that is what is most unknown */ | 92 | /* Hash. the password first, since that is what is most unknown */ |
93 | md5_begin(&ctx); | 93 | md5_begin(&ctx); |
94 | pw_len = strlen((char*)pw); | 94 | pw_len = strlen((char*)pw); |
95 | md5_hash(pw, pw_len, &ctx); | 95 | md5_hash(&ctx, pw, pw_len); |
96 | 96 | ||
97 | /* Then the salt including "$1$" */ | 97 | /* Then the salt including "$1$" */ |
98 | md5_hash(salt, sl, &ctx); | 98 | md5_hash(&ctx, salt, sl); |
99 | 99 | ||
100 | /* Copy salt to result; skip "$1$" */ | 100 | /* Copy salt to result; skip "$1$" */ |
101 | memcpy(result, salt, sl); | 101 | memcpy(result, salt, sl); |
@@ -105,19 +105,19 @@ md5_crypt(char result[MD5_OUT_BUFSIZE], const unsigned char *pw, const unsigned | |||
105 | 105 | ||
106 | /* Then just as many characters of the MD5(pw, salt, pw) */ | 106 | /* Then just as many characters of the MD5(pw, salt, pw) */ |
107 | md5_begin(&ctx1); | 107 | md5_begin(&ctx1); |
108 | md5_hash(pw, pw_len, &ctx1); | 108 | md5_hash(&ctx1, pw, pw_len); |
109 | md5_hash(salt, sl, &ctx1); | 109 | md5_hash(&ctx1, salt, sl); |
110 | md5_hash(pw, pw_len, &ctx1); | 110 | md5_hash(&ctx1, pw, pw_len); |
111 | md5_end(final, &ctx1); | 111 | md5_end(&ctx1, final); |
112 | for (pl = pw_len; pl > 0; pl -= 16) | 112 | for (pl = pw_len; pl > 0; pl -= 16) |
113 | md5_hash(final, pl > 16 ? 16 : pl, &ctx); | 113 | md5_hash(&ctx, final, pl > 16 ? 16 : pl); |
114 | 114 | ||
115 | /* Then something really weird... */ | 115 | /* Then something really weird... */ |
116 | memset(final, 0, sizeof(final)); | 116 | memset(final, 0, sizeof(final)); |
117 | for (i = pw_len; i; i >>= 1) { | 117 | for (i = pw_len; i; i >>= 1) { |
118 | md5_hash(((i & 1) ? final : (const unsigned char *) pw), 1, &ctx); | 118 | md5_hash(&ctx, ((i & 1) ? final : (const unsigned char *) pw), 1); |
119 | } | 119 | } |
120 | md5_end(final, &ctx); | 120 | md5_end(&ctx, final); |
121 | 121 | ||
122 | /* And now, just to make sure things don't run too fast. | 122 | /* And now, just to make sure things don't run too fast. |
123 | * On a 60 Mhz Pentium this takes 34 msec, so you would | 123 | * On a 60 Mhz Pentium this takes 34 msec, so you would |
@@ -126,21 +126,21 @@ md5_crypt(char result[MD5_OUT_BUFSIZE], const unsigned char *pw, const unsigned | |||
126 | for (i = 0; i < 1000; i++) { | 126 | for (i = 0; i < 1000; i++) { |
127 | md5_begin(&ctx1); | 127 | md5_begin(&ctx1); |
128 | if (i & 1) | 128 | if (i & 1) |
129 | md5_hash(pw, pw_len, &ctx1); | 129 | md5_hash(&ctx1, pw, pw_len); |
130 | else | 130 | else |
131 | md5_hash(final, 16, &ctx1); | 131 | md5_hash(&ctx1, final, 16); |
132 | 132 | ||
133 | if (i % 3) | 133 | if (i % 3) |
134 | md5_hash(salt, sl, &ctx1); | 134 | md5_hash(&ctx1, salt, sl); |
135 | 135 | ||
136 | if (i % 7) | 136 | if (i % 7) |
137 | md5_hash(pw, pw_len, &ctx1); | 137 | md5_hash(&ctx1, pw, pw_len); |
138 | 138 | ||
139 | if (i & 1) | 139 | if (i & 1) |
140 | md5_hash(final, 16, &ctx1); | 140 | md5_hash(&ctx1, final, 16); |
141 | else | 141 | else |
142 | md5_hash(pw, pw_len, &ctx1); | 142 | md5_hash(&ctx1, pw, pw_len); |
143 | md5_end(final, &ctx1); | 143 | md5_end(&ctx1, final); |
144 | } | 144 | } |
145 | 145 | ||
146 | p = result + sl + 4; /* 12 bytes max (sl is up to 8 bytes) */ | 146 | p = result + sl + 4; /* 12 bytes max (sl is up to 8 bytes) */ |