mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[util] Fix a local variable address warning
Despite mdfour claiming not to be fast, it tried to avoid passing a pointer around via a global instead of parameters. Long obsolete and iffy to boot.
This commit is contained in:
parent
dbd3d6502a
commit
db889e5e54
1 changed files with 13 additions and 19 deletions
|
@ -42,8 +42,6 @@
|
|||
It assumes that a int is at least 32 bits long
|
||||
*/
|
||||
|
||||
static struct mdfour *m;
|
||||
|
||||
#define F(X,Y,Z) (((X)&(Y)) | ((~(X))&(Z)))
|
||||
#define G(X,Y,Z) (((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z)))
|
||||
#define H(X,Y,Z) ((X)^(Y)^(Z))
|
||||
|
@ -61,7 +59,7 @@ static struct mdfour *m;
|
|||
|
||||
/* this applies md4 to 64 byte chunks */
|
||||
static void
|
||||
mdfour64 (uint32_t * M)
|
||||
mdfour64 (struct mdfour *m, uint32_t * M)
|
||||
{
|
||||
int j;
|
||||
uint32_t AA, BB, CC, DD;
|
||||
|
@ -182,7 +180,7 @@ mdfour_begin (struct mdfour *md)
|
|||
}
|
||||
|
||||
static void
|
||||
mdfour_tail (const unsigned char *in, int n)
|
||||
mdfour_tail (struct mdfour *m, const unsigned char *in, int n)
|
||||
{
|
||||
unsigned char buf[128];
|
||||
uint32_t M[16];
|
||||
|
@ -200,13 +198,13 @@ mdfour_tail (const unsigned char *in, int n)
|
|||
if (n <= 55) {
|
||||
copy4 (buf + 56, b);
|
||||
copy64 (M, buf);
|
||||
mdfour64 (M);
|
||||
mdfour64 (m, M);
|
||||
} else {
|
||||
copy4 (buf + 120, b);
|
||||
copy64 (M, buf);
|
||||
mdfour64 (M);
|
||||
mdfour64 (m, M);
|
||||
copy64 (M, buf + 64);
|
||||
mdfour64 (M);
|
||||
mdfour64 (m, M);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,30 +214,26 @@ mdfour_update (struct mdfour *md, const unsigned char *in, int n)
|
|||
uint32_t M[16];
|
||||
|
||||
if (n == 0)
|
||||
mdfour_tail (in, n);
|
||||
|
||||
m = md;
|
||||
mdfour_tail (md, in, n);
|
||||
|
||||
while (n >= 64) {
|
||||
copy64 (M, in);
|
||||
mdfour64 (M);
|
||||
mdfour64 (md, M);
|
||||
in += 64;
|
||||
n -= 64;
|
||||
m->totalN += 64;
|
||||
md->totalN += 64;
|
||||
}
|
||||
|
||||
mdfour_tail (in, n);
|
||||
mdfour_tail (md, in, n);
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
mdfour_result (struct mdfour *md, unsigned char *out)
|
||||
{
|
||||
m = md;
|
||||
|
||||
copy4 (out, m->A);
|
||||
copy4 (out + 4, m->B);
|
||||
copy4 (out + 8, m->C);
|
||||
copy4 (out + 12, m->D);
|
||||
copy4 (out, md->A);
|
||||
copy4 (out + 4, md->B);
|
||||
copy4 (out + 8, md->C);
|
||||
copy4 (out + 12, md->D);
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
|
|
Loading…
Reference in a new issue