summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2013-01-13 23:54:48 +0100
committerSzabolcs Nagy <nsz@port70.net>2013-01-13 23:54:48 +0100
commit9724defdb72fdb2ae4e8a60e928d40d84fe04800 (patch)
tree6e9c7575488d21459b62066c65ea54474b6a7e0d
parent30779ee1aa7601eb4bd7409809a8a4f06d2a4360 (diff)
downloadmusl-9724defdb72fdb2ae4e8a60e928d40d84fe04800.tar.gz
in crypt_des change unnecessary union keybuf into unsigned char[]
original FreeSec code accessed keybuf as uint32* and uint8* as well (incorrectly), this got fixed with an union, but then it seems the uint32* access is no longer needed so the code can be simplified
-rw-r--r--src/crypt/crypt_des.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/crypt/crypt_des.c b/src/crypt/crypt_des.c
index 4454a130..dc95dcaa 100644
--- a/src/crypt/crypt_des.c
+++ b/src/crypt/crypt_des.c
@@ -879,10 +879,7 @@ static char *_crypt_extended_r_uut(const char *_key, const char *_setting, char
const unsigned char *key = (const unsigned char *)_key;
const unsigned char *setting = (const unsigned char *)_setting;
struct expanded_key ekey;
- union {
- unsigned char c[8];
- uint32_t i[2];
- } keybuf;
+ unsigned char keybuf[8];
unsigned char *p, *q;
uint32_t count, salt, l, r0, r1;
unsigned int i;
@@ -891,13 +888,13 @@ static char *_crypt_extended_r_uut(const char *_key, const char *_setting, char
* Copy the key, shifting each character left by one bit and padding
* with zeroes.
*/
- q = keybuf.c;
- while (q <= &keybuf.c[sizeof(keybuf.c) - 1]) {
+ q = keybuf;
+ while (q <= &keybuf[sizeof(keybuf) - 1]) {
*q++ = *key << 1;
if (*key)
key++;
}
- des_setkey(keybuf.c, &ekey);
+ des_setkey(keybuf, &ekey);
if (*setting == _PASSWORD_EFMT1) {
/*
@@ -925,14 +922,14 @@ static char *_crypt_extended_r_uut(const char *_key, const char *_setting, char
/*
* Encrypt the key with itself.
*/
- des_cipher(keybuf.c, keybuf.c, 1, 0, &ekey);
+ des_cipher(keybuf, keybuf, 1, 0, &ekey);
/*
* And XOR with the next 8 characters of the key.
*/
- q = keybuf.c;
- while (q <= &keybuf.c[sizeof(keybuf.c) - 1] && *key)
+ q = keybuf;
+ while (q <= &keybuf[sizeof(keybuf) - 1] && *key)
*q++ ^= *key++ << 1;
- des_setkey(keybuf.c, &ekey);
+ des_setkey(keybuf, &ekey);
}
memcpy(output, setting, 9);