projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix struct layout mismatch in sound ioctl time32 fallback conversion
[musl]
/
src
/
crypt
/
crypt_des.c
diff --git
a/src/crypt/crypt_des.c
b/src/crypt/crypt_des.c
index
4454a13
..
338a8f3
100644
(file)
--- a/
src/crypt/crypt_des.c
+++ b/
src/crypt/crypt_des.c
@@
-56,9
+56,7
@@
#include <stdint.h>
#include <string.h>
#include <stdint.h>
#include <string.h>
-struct expanded_key {
- uint32_t l[16], r[16];
-};
+#include "crypt_des.h"
#define _PASSWORD_EFMT1 '_'
#define _PASSWORD_EFMT1 '_'
@@
-692,7
+690,7
@@
static uint32_t setup_salt(uint32_t salt)
return saltbits;
}
return saltbits;
}
-
static void
des_setkey(const unsigned char *key, struct expanded_key *ekey)
+
void __
des_setkey(const unsigned char *key, struct expanded_key *ekey)
{
uint32_t k0, k1, rawkey0, rawkey1;
unsigned int shifts, round, i, ibit;
{
uint32_t k0, k1, rawkey0, rawkey1;
unsigned int shifts, round, i, ibit;
@@
-753,7
+751,7
@@
static void des_setkey(const unsigned char *key, struct expanded_key *ekey)
/*
* l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format.
*/
/*
* l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format.
*/
-
static void
do_des(uint32_t l_in, uint32_t r_in,
+
void __
do_des(uint32_t l_in, uint32_t r_in,
uint32_t *l_out, uint32_t *r_out,
uint32_t count, uint32_t saltbits, const struct expanded_key *ekey)
{
uint32_t *l_out, uint32_t *r_out,
uint32_t count, uint32_t saltbits, const struct expanded_key *ekey)
{
@@
-862,7
+860,7
@@
static void des_cipher(const unsigned char *in, unsigned char *out,
((uint32_t)in[5] << 16) |
((uint32_t)in[4] << 24);
((uint32_t)in[5] << 16) |
((uint32_t)in[4] << 24);
- do_des(rawl, rawr, &l_out, &r_out, count, saltbits, ekey);
+
__
do_des(rawl, rawr, &l_out, &r_out, count, saltbits, ekey);
out[0] = l_out >> 24;
out[1] = l_out >> 16;
out[0] = l_out >> 24;
out[1] = l_out >> 16;
@@
-879,10
+877,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;
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;
unsigned char *p, *q;
uint32_t count, salt, l, r0, r1;
unsigned int i;
@@
-891,13
+886,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.
*/
* 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++;
}
*q++ = *key << 1;
if (*key)
key++;
}
-
des_setkey(keybuf.c
, &ekey);
+
__des_setkey(keybuf
, &ekey);
if (*setting == _PASSWORD_EFMT1) {
/*
if (*setting == _PASSWORD_EFMT1) {
/*
@@
-925,14
+920,14
@@
static char *_crypt_extended_r_uut(const char *_key, const char *_setting, char
/*
* Encrypt the key with itself.
*/
/*
* 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.
*/
/*
* 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;
*q++ ^= *key++ << 1;
-
des_setkey(keybuf.c
, &ekey);
+
__des_setkey(keybuf
, &ekey);
}
memcpy(output, setting, 9);
}
memcpy(output, setting, 9);
@@
-960,7
+955,7
@@
static char *_crypt_extended_r_uut(const char *_key, const char *_setting, char
/*
* Do it.
*/
/*
* Do it.
*/
- do_des(0, 0, &r0, &r1, count, setup_salt(salt), &ekey);
+
__
do_des(0, 0, &r0, &r1, count, setup_salt(salt), &ekey);
/*
* Now encode the result...
/*
* Now encode the result...