diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-15 20:59:32 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-15 20:59:32 +0100 |
commit | 16e7f697f8064a4e5fc2f8e181fe6a7b9602b1b3 (patch) | |
tree | e9bf4f43c76904ffa299915541eec40e9a5ce8e4 | |
parent | b8935d00b0a60be24ee9073349c2a185cebbacd4 (diff) |
libbb: eliminate redundant variable in sha_crypt
function old new delta
sha_crypt 1136 1130 -6
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/pw_encrypt_sha.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/libbb/pw_encrypt_sha.c b/libbb/pw_encrypt_sha.c index 8aeaacad6..72e37e485 100644 --- a/libbb/pw_encrypt_sha.c +++ b/libbb/pw_encrypt_sha.c @@ -47,16 +47,17 @@ sha_crypt(/*const*/ char *key_data, /*const*/ char *salt_data) unsigned cnt; unsigned rounds; char *cp; - char is_sha512; /* Analyze salt, construct already known part of result */ cnt = strlen(salt_data) + 1 + 43 + 1; - is_sha512 = salt_data[1]; - if (is_sha512 == '6') + _32or64 = 32; + if (salt_data[1] == '6') { /* sha512 */ + _32or64 *= 2; /*64*/ cnt += 43; + } result = resptr = xzalloc(cnt); /* will provide NUL terminator */ *resptr++ = '$'; - *resptr++ = is_sha512; + *resptr++ = salt_data[1]; *resptr++ = '$'; rounds = ROUNDS_DEFAULT; salt_data += 3; @@ -93,12 +94,10 @@ sha_crypt(/*const*/ char *key_data, /*const*/ char *salt_data) sha_begin = (void*)sha256_begin; sha_hash = (void*)sha256_hash; sha_end = (void*)sha256_end; - _32or64 = 32; - if (is_sha512 == '6') { + if (_32or64 != 32) { sha_begin = (void*)sha512_begin; sha_hash = (void*)sha512_hash; sha_end = (void*)sha512_end; - _32or64 = 64; } /* Add KEY, SALT. */ @@ -200,7 +199,7 @@ do { \ unsigned w = ((B2) << 16) | ((B1) << 8) | (B0); \ resptr = to64(resptr, w, N); \ } while (0) - if (is_sha512 == '5') { + if (_32or64 == 32) { /* sha256 */ unsigned i = 0; while (1) { unsigned j = i + 10; |