Apply patch: ncpfs-hg-commit-431.patch
This commit is contained in:
@@ -144,51 +144,46 @@ shuffle1(buf32 temp, unsigned char *target)
|
||||
|
||||
|
||||
void
|
||||
shuffle(const unsigned char *lon, const unsigned char *buf, int buflen,
|
||||
shuffle(const unsigned char *lon, const void *ibuf, size_t buflen,
|
||||
unsigned char *target)
|
||||
{
|
||||
int b2, d, s;
|
||||
size_t b2, d;
|
||||
unsigned int s;
|
||||
buf32 temp;
|
||||
const unsigned char* buf = ibuf;
|
||||
|
||||
while ((buflen > 0)
|
||||
&& (buf[buflen - 1] == 0))
|
||||
{
|
||||
&& (buf[buflen - 1] == 0)) {
|
||||
buflen = buflen - 1;
|
||||
}
|
||||
|
||||
for (s = 0; s < 32; s++)
|
||||
{
|
||||
for (s = 0; s < 32; s++) {
|
||||
temp[s] = 0;
|
||||
}
|
||||
|
||||
d = 0;
|
||||
while (buflen >= 32)
|
||||
{
|
||||
for (s = 0; s <= 31; ++s)
|
||||
{
|
||||
temp[s] = temp[s] ^ buf[d];
|
||||
while (buflen >= 32) {
|
||||
for (s = 0; s < 32; ++s) {
|
||||
temp[s] ^= buf[d];
|
||||
d = d + 1;
|
||||
}
|
||||
buflen = buflen - 32;
|
||||
}
|
||||
b2 = d;
|
||||
if (buflen > 0)
|
||||
{
|
||||
for (s = 0; s <= 31; ++s)
|
||||
{
|
||||
if (d + buflen == b2)
|
||||
{
|
||||
if (buflen > 0) {
|
||||
for (s = 0; s < 32; ++s) {
|
||||
if (d + buflen == b2) {
|
||||
b2 = d;
|
||||
temp[s] = temp[s] ^ encryptkeys[s];
|
||||
} else
|
||||
{
|
||||
temp[s] = temp[s] ^ buf[b2];
|
||||
temp[s] ^= encryptkeys[s];
|
||||
} else {
|
||||
temp[s] ^= buf[b2];
|
||||
b2 = b2 + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (s = 0; s <= 31; ++s)
|
||||
temp[s] = temp[s] ^ lon[s & 3];
|
||||
for (s = 0; s < 32; ++s) {
|
||||
temp[s] ^= lon[s & 3];
|
||||
}
|
||||
|
||||
shuffle1(temp, target);
|
||||
}
|
||||
@@ -200,16 +195,18 @@ nw_encrypt(const unsigned char *fra,
|
||||
unsigned char *til)
|
||||
{
|
||||
buf32 k;
|
||||
int s;
|
||||
unsigned int s;
|
||||
|
||||
shuffle(&(fra[0]), buf, 16, &(k[0]));
|
||||
shuffle(&(fra[4]), buf, 16, &(k[16]));
|
||||
|
||||
for (s = 0; s <= 15; ++s)
|
||||
k[s] = k[s] ^ k[31 - s];
|
||||
for (s = 0; s < 16; ++s) {
|
||||
k[s] ^= k[31 - s];
|
||||
}
|
||||
|
||||
for (s = 0; s <= 7; ++s)
|
||||
for (s = 0; s < 8; ++s) {
|
||||
til[s] = k[s] ^ k[15 - s];
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -230,8 +227,8 @@ nw_encrypt(const unsigned char *fra,
|
||||
old internal password) ^ (second byte of old internal password)
|
||||
*/
|
||||
|
||||
static char
|
||||
newshuffle[256 + 16] =
|
||||
static unsigned char
|
||||
newshuffle[256] =
|
||||
{
|
||||
0x0f, 0x08, 0x05, 0x07, 0x0c, 0x02, 0x0e, 0x09,
|
||||
0x00, 0x01, 0x06, 0x0d, 0x03, 0x04, 0x0b, 0x0a,
|
||||
@@ -272,7 +269,9 @@ static char
|
||||
0x0d, 0x0b, 0x0c, 0x02, 0x00, 0x0f, 0x06, 0x0a,
|
||||
0x09, 0x0a, 0x0b, 0x0d, 0x05, 0x03, 0x0f, 0x00,
|
||||
0x01, 0x0c, 0x08, 0x07, 0x06, 0x04, 0x0e, 0x02,
|
||||
};
|
||||
|
||||
static const unsigned char final_shuffle[16] = {
|
||||
0x03, 0x0e, 0x0f, 0x02, 0x0d, 0x0c, 0x04, 0x05,
|
||||
0x09, 0x06, 0x00, 0x01, 0x0b, 0x07, 0x0a, 0x08,
|
||||
};
|
||||
@@ -303,17 +302,17 @@ static char
|
||||
*/
|
||||
|
||||
static void
|
||||
newpassencrypt(char *old, char *new, char *out)
|
||||
newpassencrypt(unsigned char *old, unsigned char *npwd)
|
||||
{
|
||||
char *p, *bx;
|
||||
char copy[8];
|
||||
int i, di, ax;
|
||||
char cl, dl, ch;
|
||||
int i;
|
||||
|
||||
memcpy(copy, new, 8);
|
||||
for (i = 0; i < 16; i++) {
|
||||
int di, ax;
|
||||
unsigned char *p, *bx;
|
||||
unsigned char cl, dl, ch;
|
||||
unsigned char copy[8];
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
memcpy(copy, npwd, 8);
|
||||
for (di = 0, ax = 0, p = old; di < 8; di++, ax += 0x20, p++)
|
||||
{
|
||||
cl = newshuffle[(((copy[di] ^ *p) >> 4) & 0x0f) + ax + 0x10] << 4;
|
||||
@@ -328,17 +327,16 @@ newpassencrypt(char *old, char *new, char *out)
|
||||
}
|
||||
*old = ((ch >> 4) & 0x0f) | (*old) << 4;
|
||||
|
||||
memset(out, '\0', 8);
|
||||
memset(npwd, 0, 8);
|
||||
|
||||
for (di = 0; di < 16; di++)
|
||||
{
|
||||
if (newshuffle[di + 0x100] & 1)
|
||||
ch = ((copy[newshuffle[di + 0x100] / 2] >> 4) & 0x0f);
|
||||
if (final_shuffle[di] & 1)
|
||||
ch = ((copy[final_shuffle[di] / 2] >> 4) & 0x0f);
|
||||
else
|
||||
ch = copy[newshuffle[di + 0x100] / 2] & 0x0f;
|
||||
out[di / 2] |= ((di & 1) ? ch << 4 : ch);
|
||||
ch = copy[final_shuffle[di] / 2] & 0x0f;
|
||||
npwd[di / 2] |= ((di & 1) ? ch << 4 : ch);
|
||||
}
|
||||
memcpy(copy, out, 8);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user