diff options
Diffstat (limited to 'libbb/pw_encrypt_md5.c')
-rw-r--r-- | libbb/pw_encrypt_md5.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/libbb/pw_encrypt_md5.c b/libbb/pw_encrypt_md5.c index 6c94d2d29..8d0a516cf 100644 --- a/libbb/pw_encrypt_md5.c +++ b/libbb/pw_encrypt_md5.c | |||
@@ -101,7 +101,6 @@ static const unsigned char __md5__magic[] = MD5_MAGIC_STR; | |||
101 | * __md5_Encodes input (uint32_t) into output (unsigned char). Assumes len is | 101 | * __md5_Encodes input (uint32_t) into output (unsigned char). Assumes len is |
102 | * a multiple of 4. | 102 | * a multiple of 4. |
103 | */ | 103 | */ |
104 | |||
105 | static void | 104 | static void |
106 | __md5_Encode(unsigned char *output, uint32_t *input, unsigned int len) | 105 | __md5_Encode(unsigned char *output, uint32_t *input, unsigned int len) |
107 | { | 106 | { |
@@ -119,7 +118,6 @@ __md5_Encode(unsigned char *output, uint32_t *input, unsigned int len) | |||
119 | * __md5_Decodes input (unsigned char) into output (uint32_t). Assumes len is | 118 | * __md5_Decodes input (unsigned char) into output (uint32_t). Assumes len is |
120 | * a multiple of 4. | 119 | * a multiple of 4. |
121 | */ | 120 | */ |
122 | |||
123 | static void | 121 | static void |
124 | __md5_Decode(uint32_t *output, const unsigned char *input, unsigned int len) | 122 | __md5_Decode(uint32_t *output, const unsigned char *input, unsigned int len) |
125 | { | 123 | { |
@@ -166,7 +164,6 @@ __md5_Decode(uint32_t *output, const unsigned char *input, unsigned int len) | |||
166 | } | 164 | } |
167 | 165 | ||
168 | /* MD5 initialization. Begins an MD5 operation, writing a new context. */ | 166 | /* MD5 initialization. Begins an MD5 operation, writing a new context. */ |
169 | |||
170 | static void __md5_Init(struct MD5Context *context) | 167 | static void __md5_Init(struct MD5Context *context) |
171 | { | 168 | { |
172 | context->count[0] = context->count[1] = 0; | 169 | context->count[0] = context->count[1] = 0; |
@@ -183,7 +180,6 @@ static void __md5_Init(struct MD5Context *context) | |||
183 | * operation, processing another message block, and updating the | 180 | * operation, processing another message block, and updating the |
184 | * context. | 181 | * context. |
185 | */ | 182 | */ |
186 | |||
187 | static void __md5_Update(struct MD5Context *context, const unsigned char *input, unsigned int inputLen) | 183 | static void __md5_Update(struct MD5Context *context, const unsigned char *input, unsigned int inputLen) |
188 | { | 184 | { |
189 | unsigned int i, idx, partLen; | 185 | unsigned int i, idx, partLen; |
@@ -218,7 +214,6 @@ static void __md5_Update(struct MD5Context *context, const unsigned char *input, | |||
218 | /* | 214 | /* |
219 | * MD5 padding. Adds padding followed by original length. | 215 | * MD5 padding. Adds padding followed by original length. |
220 | */ | 216 | */ |
221 | |||
222 | static void __md5_Pad(struct MD5Context *context) | 217 | static void __md5_Pad(struct MD5Context *context) |
223 | { | 218 | { |
224 | unsigned char bits[8]; | 219 | unsigned char bits[8]; |
@@ -244,7 +239,6 @@ static void __md5_Pad(struct MD5Context *context) | |||
244 | * MD5 finalization. Ends an MD5 message-digest operation, writing the | 239 | * MD5 finalization. Ends an MD5 message-digest operation, writing the |
245 | * the message digest and zeroizing the context. | 240 | * the message digest and zeroizing the context. |
246 | */ | 241 | */ |
247 | |||
248 | static void __md5_Final(unsigned char digest[16], struct MD5Context *context) | 242 | static void __md5_Final(unsigned char digest[16], struct MD5Context *context) |
249 | { | 243 | { |
250 | /* Do padding. */ | 244 | /* Do padding. */ |
@@ -258,7 +252,6 @@ static void __md5_Final(unsigned char digest[16], struct MD5Context *context) | |||
258 | } | 252 | } |
259 | 253 | ||
260 | /* MD5 basic transformation. Transforms state based on block. */ | 254 | /* MD5 basic transformation. Transforms state based on block. */ |
261 | |||
262 | static void __md5_Transform(uint32_t state[4], const unsigned char block[64]) | 255 | static void __md5_Transform(uint32_t state[4], const unsigned char block[64]) |
263 | { | 256 | { |
264 | uint32_t a, b, c, d, x[16]; | 257 | uint32_t a, b, c, d, x[16]; |
@@ -517,16 +510,15 @@ __md5_to64(char *s, unsigned v, int n) | |||
517 | * Use MD5 for what it is best at... | 510 | * Use MD5 for what it is best at... |
518 | */ | 511 | */ |
519 | #define MD5_OUT_BUFSIZE 36 | 512 | #define MD5_OUT_BUFSIZE 36 |
520 | |||
521 | static char * | 513 | static char * |
522 | md5_crypt(char passwd[120], const unsigned char *pw, const unsigned char *salt) | 514 | NOINLINE |
515 | md5_crypt(char passwd[MD5_OUT_BUFSIZE], const unsigned char *pw, const unsigned char *salt) | ||
523 | { | 516 | { |
524 | const unsigned char *sp, *ep; | 517 | const unsigned char *sp, *ep; |
525 | char *p; | 518 | char *p; |
526 | unsigned char final[17]; /* final[16] exists only to aid in looping */ | 519 | unsigned char final[17]; /* final[16] exists only to aid in looping */ |
527 | int sl, pl, i, pw_len; | 520 | int sl, pl, i, pw_len; |
528 | struct MD5Context ctx, ctx1; | 521 | struct MD5Context ctx, ctx1; |
529 | unsigned long l; | ||
530 | 522 | ||
531 | /* Refine the Salt first */ | 523 | /* Refine the Salt first */ |
532 | sp = salt; | 524 | sp = salt; |
@@ -612,11 +604,10 @@ md5_crypt(char passwd[120], const unsigned char *pw, const unsigned char *salt) | |||
612 | /* Add 5*4+2 = 22 bytes of hash, + NUL byte. */ | 604 | /* Add 5*4+2 = 22 bytes of hash, + NUL byte. */ |
613 | final[16] = final[5]; | 605 | final[16] = final[5]; |
614 | for (i = 0; i < 5; i++) { | 606 | for (i = 0; i < 5; i++) { |
615 | l = (final[i] << 16) | (final[i+6] << 8) | final[i+12]; | 607 | unsigned l = (final[i] << 16) | (final[i+6] << 8) | final[i+12]; |
616 | p = __md5_to64(p, l, 4); | 608 | p = __md5_to64(p, l, 4); |
617 | } | 609 | } |
618 | l = final[11]; | 610 | p = __md5_to64(p, final[11], 2); |
619 | p = __md5_to64(p, l, 2); | ||
620 | *p = '\0'; | 611 | *p = '\0'; |
621 | 612 | ||
622 | /* Don't leave anything around in vm they could use. */ | 613 | /* Don't leave anything around in vm they could use. */ |