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))
#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + 0x6ED9EBA1,s)
/* this applies md4 to 64 byte chunks */
-static void mdfour64(uint32 *M)
+static void mdfour64(struct mdfour *md, uint32 *M)
{
int j;
uint32 AA, BB, CC, DD;
for (j=0;j<16;j++)
X[j] = M[j];
- A = m->A; B = m->B; C = m->C; D = m->D;
+ A = md->A; B = md->B; C = md->C; D = md->D;
AA = A; BB = B; CC = C; DD = D;
ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7);
for (j=0;j<16;j++)
X[j] = 0;
- m->A = A; m->B = B; m->C = C; m->D = D;
+ md->A = A; md->B = B; md->C = C; md->D = D;
}
static void copy64(uint32 *M, const unsigned char *in)
}
-static void mdfour_tail(const unsigned char *in, int n)
+static void mdfour_tail(struct mdfour *md, const unsigned char *in, int n)
{
unsigned char buf[128];
uint32 M[16];
uint32 b;
- m->totalN += n;
+ md->totalN += n;
- b = m->totalN * 8;
+ b = md->totalN * 8;
memset(buf, 0, 128);
if (n) memcpy(buf, in, n);
// if (n == 0) mdfour_tail(in, n);
// end of edit by Forest 'LordHavoc' Hale
- m = md;
-
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);
}
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);
}