diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-14 22:11:29 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-14 22:11:29 +0000 |
commit | e235285c3a36c0e4efe21ec336e7015cd3cf3c62 (patch) | |
tree | 3ea4c906634a6a3c5e30ba691b82a56a57d2510d /libbb/pw_encrypt_des.c | |
parent | 7a762f9dbf80b406fd1ec21966a9de3c3057fd25 (diff) | |
download | busybox-w32-e235285c3a36c0e4efe21ec336e7015cd3cf3c62.tar.gz busybox-w32-e235285c3a36c0e4efe21ec336e7015cd3cf3c62.tar.bz2 busybox-w32-e235285c3a36c0e4efe21ec336e7015cd3cf3c62.zip |
crypt: code shrink
function old new delta
des_crypt - 1682 +1682
md5_crypt - 627 +627
pw_encrypt 3608 1036 -2572
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/1 up/down: 2309/-2572) Total: -263 bytes
Diffstat (limited to 'libbb/pw_encrypt_des.c')
-rw-r--r-- | libbb/pw_encrypt_des.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/libbb/pw_encrypt_des.c b/libbb/pw_encrypt_des.c index ab217d8e9..66e607955 100644 --- a/libbb/pw_encrypt_des.c +++ b/libbb/pw_encrypt_des.c | |||
@@ -400,7 +400,6 @@ des_init(struct des_ctx *ctx, const struct const_des_ctx *cctx) | |||
400 | static void | 400 | static void |
401 | setup_salt(struct des_ctx *ctx, uint32_t salt) | 401 | setup_salt(struct des_ctx *ctx, uint32_t salt) |
402 | { | 402 | { |
403 | // const struct const_des_ctx *cctx = const_ctx; | ||
404 | uint32_t obit, saltbit; | 403 | uint32_t obit, saltbit; |
405 | int i; | 404 | int i; |
406 | 405 | ||
@@ -422,7 +421,6 @@ setup_salt(struct des_ctx *ctx, uint32_t salt) | |||
422 | static void | 421 | static void |
423 | des_setkey(struct des_ctx *ctx, const char *key) | 422 | des_setkey(struct des_ctx *ctx, const char *key) |
424 | { | 423 | { |
425 | // const struct const_des_ctx *cctx = const_ctx; | ||
426 | uint32_t k0, k1, rawkey0, rawkey1; | 424 | uint32_t k0, k1, rawkey0, rawkey1; |
427 | int shifts, round; | 425 | int shifts, round; |
428 | 426 | ||
@@ -498,7 +496,7 @@ des_setkey(struct des_ctx *ctx, const char *key) | |||
498 | } | 496 | } |
499 | 497 | ||
500 | 498 | ||
501 | static int | 499 | static void |
502 | do_des(struct des_ctx *ctx, uint32_t l_in, uint32_t r_in, uint32_t *l_out, uint32_t *r_out, int count) | 500 | do_des(struct des_ctx *ctx, uint32_t l_in, uint32_t r_in, uint32_t *l_out, uint32_t *r_out, int count) |
503 | { | 501 | { |
504 | const struct const_des_ctx *cctx = const_ctx; | 502 | const struct const_des_ctx *cctx = const_ctx; |
@@ -602,12 +600,12 @@ do_des(struct des_ctx *ctx, uint32_t l_in, uint32_t r_in, uint32_t *l_out, uint3 | |||
602 | | fp_maskr[5][(r >> 16) & 0xff] | 600 | | fp_maskr[5][(r >> 16) & 0xff] |
603 | | fp_maskr[6][(r >> 8) & 0xff] | 601 | | fp_maskr[6][(r >> 8) & 0xff] |
604 | | fp_maskr[7][r & 0xff]; | 602 | | fp_maskr[7][r & 0xff]; |
605 | return 0; | ||
606 | } | 603 | } |
607 | 604 | ||
608 | #define DES_OUT_BUFSIZE 21 | 605 | #define DES_OUT_BUFSIZE 21 |
609 | 606 | ||
610 | static char * | 607 | static char * |
608 | NOINLINE | ||
611 | des_crypt(struct des_ctx *ctx, char output[21], const unsigned char *key, const unsigned char *setting) | 609 | des_crypt(struct des_ctx *ctx, char output[21], const unsigned char *key, const unsigned char *setting) |
612 | { | 610 | { |
613 | uint32_t salt, l, r0, r1, keybuf[2]; | 611 | uint32_t salt, l, r0, r1, keybuf[2]; |
@@ -618,10 +616,11 @@ des_crypt(struct des_ctx *ctx, char output[21], const unsigned char *key, const | |||
618 | * and padding with zeros. | 616 | * and padding with zeros. |
619 | */ | 617 | */ |
620 | q = (uint8_t *)keybuf; | 618 | q = (uint8_t *)keybuf; |
621 | while (q - (uint8_t *)keybuf - 8) { | 619 | while (q - (uint8_t *)keybuf != 8) { |
622 | *q++ = *key << 1; | 620 | *q = *key << 1; |
623 | if (*(q - 1)) | 621 | if (*q) |
624 | key++; | 622 | key++; |
623 | q++; | ||
625 | } | 624 | } |
626 | des_setkey(ctx, (char *)keybuf); | 625 | des_setkey(ctx, (char *)keybuf); |
627 | 626 | ||
@@ -658,7 +657,7 @@ des_crypt(struct des_ctx *ctx, char output[21], const unsigned char *key, const | |||
658 | *p++ = ascii64[(l >> 6) & 0x3f]; | 657 | *p++ = ascii64[(l >> 6) & 0x3f]; |
659 | *p++ = ascii64[l & 0x3f]; | 658 | *p++ = ascii64[l & 0x3f]; |
660 | 659 | ||
661 | l = (r0 << 16) | ((r1 >> 16) & 0xffff); | 660 | l = ((r0 << 16) | (r1 >> 16)); |
662 | *p++ = ascii64[(l >> 18) & 0x3f]; | 661 | *p++ = ascii64[(l >> 18) & 0x3f]; |
663 | *p++ = ascii64[(l >> 12) & 0x3f]; | 662 | *p++ = ascii64[(l >> 12) & 0x3f]; |
664 | *p++ = ascii64[(l >> 6) & 0x3f]; | 663 | *p++ = ascii64[(l >> 6) & 0x3f]; |