Apply patch: ncpfs-hg-commit-431.patch

This commit is contained in:
Mario Fetka
2026-04-28 20:56:03 +02:00
parent b417a518c5
commit 4d94ea705a
96 changed files with 3398 additions and 431 deletions

View File

@@ -111,7 +111,7 @@ static unsigned char nwhashdata[256] =
0x4C,0xFF,0x43,0xAB};
void nwencrypt(const unsigned short *cryptbuf, const char *in, char *out) {
void nwencrypt(const unsigned short *cryptbuf, const unsigned char *in, unsigned char *out) {
int i, j;
register unsigned int i1, i2, i3, i4;
const unsigned short *p;
@@ -141,7 +141,7 @@ void nwencrypt(const unsigned short *cryptbuf, const char *in, char *out) {
WSET_LH(out, 6, i4);
}
void nwdecrypt(const unsigned short *cryptbuf, const char *in, char *out) {
void nwdecrypt(const unsigned short *cryptbuf, const unsigned char *in, unsigned char *out) {
int i, j;
const unsigned short *p;
register unsigned int i1, i2, i3, i4;
@@ -171,26 +171,25 @@ void nwdecrypt(const unsigned short *cryptbuf, const char *in, char *out) {
WSET_LH(out, 6, i4);
}
void nwcryptinit(unsigned short *scryptbuf, const char *key) {
void nwcryptinit(unsigned short *scryptbuf, const unsigned char *key) {
int i;
unsigned char cryptbuf[128], *p;
memcpy(cryptbuf, key, 8);
for (i = 0; i < 120; i++)
cryptbuf[i + 8] =
nwcryptdata[(unsigned char)(cryptbuf[i] + cryptbuf[i + 7]) & 255];
cryptbuf[128 - 8] = nwcryptdata[(unsigned char)cryptbuf[128 - 8] & 255];
nwcryptdata[(cryptbuf[i] + cryptbuf[i + 7]) & 255];
cryptbuf[128 - 8] = nwcryptdata[cryptbuf[128 - 8]];
for (i = 127 - 8; i >= 0; i--)
cryptbuf[i] = nwcryptdata[(unsigned char)cryptbuf[i + 1] ^
(unsigned char)cryptbuf[i + 8]];
cryptbuf[i] = nwcryptdata[cryptbuf[i + 1] ^ cryptbuf[i + 8]];
for (i = 0, p = cryptbuf; i < 64; i++, p += 2)
scryptbuf[i] = (*p) | (*(p+1)) << 8;
}
void nwencryptblock(const char *cryptkey, const char *buf, int buflen,
char *outbuf) {
void nwencryptblock(const unsigned char *cryptkey, const unsigned char *buf, int buflen,
unsigned char *outbuf) {
int i;
char nhash[8];
unsigned char nhash[8];
unsigned short cryptbuf[64];
nwcryptinit(cryptbuf, cryptkey);
@@ -206,10 +205,10 @@ void nwencryptblock(const char *cryptkey, const char *buf, int buflen,
memset(cryptbuf, 0, sizeof(cryptbuf));
}
void nwdecryptblock(const char *cryptkey, const char *buf, int buflen,
char *outbuf) {
void nwdecryptblock(const unsigned char *cryptkey, const unsigned char *buf, int buflen,
unsigned char *outbuf) {
int i;
char nhash[16], *p;
unsigned char nhash[16], *p;
unsigned short cryptbuf[64];
nwcryptinit(cryptbuf, cryptkey);
@@ -227,30 +226,30 @@ void nwdecryptblock(const char *cryptkey, const char *buf, int buflen,
memset(cryptbuf, 0, sizeof(cryptbuf));
}
void nwhash1(char *hash, int hashlen, const char *data, int datalen) {
void nwhash1(unsigned char *hash, int hashlen, const unsigned char *data, int datalen) {
unsigned char *hp, *hp1, *hend, c;
const unsigned char *dp;
hp1 = (hp = (unsigned char *)hash) + 1;
hp1 = (hp = hash) + 1;
hend = hp + hashlen;
dp = (const unsigned char *)data;
dp = data;
while (datalen--) {
*hp = nwhashdata[*hp1 ^ *hp] ^ *dp++;
hp = hp1++;
if (hp1 == hend)
hp1 = (unsigned char *)hash;
hp1 = hash;
}
while (hp-- > (unsigned char *)hash) {
hp1 = (unsigned char *)hash;
while (hp-- > hash) {
hp1 = hash;
c = *hp1++;
while (*(hp1 - 1) = *hp1, ++hp1 < (unsigned char *)hash + hashlen);
while (*(hp1 - 1) = *hp1, ++hp1 < hash + hashlen);
*(hp1 - 1) = c;
}
}
void nwhash2(char *hashbuf, char c) {
void nwhash2(unsigned char *hashbuf, unsigned char c) {
int i, j;
char *p = hashbuf + hashbuf[0x40];
unsigned char *p = hashbuf + hashbuf[0x40];
p[0x20] = p[0x00] ^ (p[0x10] = c);
hashbuf[0x41] = (p[0x30] ^= nwhashdata[(unsigned char)(c ^ hashbuf[0x41])]);
@@ -262,12 +261,12 @@ void nwhash2(char *hashbuf, char c) {
}
}
void nwhash2block(char *hashbuf, const char *data, int datalen) {
void nwhash2block(unsigned char *hashbuf, const unsigned char *data, size_t datalen) {
while (datalen--)
nwhash2(hashbuf, *data++);
}
void nwhash2end(char *hashbuf) {
void nwhash2end(unsigned char *hashbuf) {
int i, j;
for(j = i = 16 - hashbuf[0x40]; j; j--)