Quake II RTX doxygen
1.0 dev
|
|
Go to the documentation of this file.
19 #include "shared/shared.h"
20 #include "common/mdfour.h"
32 static struct mdfour *
m;
34 #define F(X,Y,Z) (((X)&(Y)) | ((~(X))&(Z)))
35 #define G(X,Y,Z) (((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z)))
36 #define H(X,Y,Z) ((X)^(Y)^(Z))
38 #define lshift(x,s) ((((x)<<(s))&0xFFFFFFFF) | (((x)>>(32-(s)))&0xFFFFFFFF))
40 #define lshift(x,s) (((x)<<(s)) | ((x)>>(32-(s))))
43 #define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s)
44 #define ROUND2(a,b,c,d,k,s) a = lshift(a + G(b,c,d) + X[k] + 0x5A827999,s)
45 #define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + 0x6ED9EBA1,s)
51 uint32_t AA, BB, CC, DD;
55 for (j = 0; j < 16; j++)
58 A =
m->A;
B =
m->B; C =
m->C; D =
m->D;
59 AA = A; BB =
B; CC = C; DD = D;
61 ROUND1(A,
B, C, D, 0, 3);
ROUND1(D, A,
B, C, 1, 7);
62 ROUND1(C, D, A,
B, 2, 11);
ROUND1(
B, C, D, A, 3, 19);
63 ROUND1(A,
B, C, D, 4, 3);
ROUND1(D, A,
B, C, 5, 7);
64 ROUND1(C, D, A,
B, 6, 11);
ROUND1(
B, C, D, A, 7, 19);
65 ROUND1(A,
B, C, D, 8, 3);
ROUND1(D, A,
B, C, 9, 7);
66 ROUND1(C, D, A,
B, 10, 11);
ROUND1(
B, C, D, A, 11, 19);
67 ROUND1(A,
B, C, D, 12, 3);
ROUND1(D, A,
B, C, 13, 7);
68 ROUND1(C, D, A,
B, 14, 11);
ROUND1(
B, C, D, A, 15, 19);
70 ROUND2(A,
B, C, D, 0, 3);
ROUND2(D, A,
B, C, 4, 5);
71 ROUND2(C, D, A,
B, 8, 9);
ROUND2(
B, C, D, A, 12, 13);
72 ROUND2(A,
B, C, D, 1, 3);
ROUND2(D, A,
B, C, 5, 5);
73 ROUND2(C, D, A,
B, 9, 9);
ROUND2(
B, C, D, A, 13, 13);
74 ROUND2(A,
B, C, D, 2, 3);
ROUND2(D, A,
B, C, 6, 5);
75 ROUND2(C, D, A,
B, 10, 9);
ROUND2(
B, C, D, A, 14, 13);
76 ROUND2(A,
B, C, D, 3, 3);
ROUND2(D, A,
B, C, 7, 5);
77 ROUND2(C, D, A,
B, 11, 9);
ROUND2(
B, C, D, A, 15, 13);
79 ROUND3(A,
B, C, D, 0, 3);
ROUND3(D, A,
B, C, 8, 9);
80 ROUND3(C, D, A,
B, 4, 11);
ROUND3(
B, C, D, A, 12, 15);
81 ROUND3(A,
B, C, D, 2, 3);
ROUND3(D, A,
B, C, 10, 9);
82 ROUND3(C, D, A,
B, 6, 11);
ROUND3(
B, C, D, A, 14, 15);
83 ROUND3(A,
B, C, D, 1, 3);
ROUND3(D, A,
B, C, 9, 9);
84 ROUND3(C, D, A,
B, 5, 11);
ROUND3(
B, C, D, A, 13, 15);
85 ROUND3(A,
B, C, D, 3, 3);
ROUND3(D, A,
B, C, 11, 9);
86 ROUND3(C, D, A,
B, 7, 11);
ROUND3(
B, C, D, A, 15, 15);
88 A += AA;
B += BB; C += CC; D += DD;
91 A &= 0xFFFFFFFF;
B &= 0xFFFFFFFF;
92 C &= 0xFFFFFFFF; D &= 0xFFFFFFFF;
95 for (j = 0; j < 16; j++)
98 m->A = A;
m->B =
B;
m->C = C;
m->D = D;
101 static void copy64(uint32_t *M, uint8_t *in)
105 for (i = 0; i < 16; i++)
106 M[i] = (in[i * 4 + 3] << 24) | (in[i * 4 + 2] << 16) |
107 (in[i * 4 + 1] << 8) | (in[i * 4 + 0] << 0);
110 static void copy4(uint8_t *out, uint32_t x)
113 out[1] = (x >> 8) & 0xFF;
114 out[2] = (x >> 16) & 0xFF;
115 out[3] = (x >> 24) & 0xFF;
139 if (n) memcpy(buf, in, n);
197 val = digest[0] ^ digest[1] ^ digest[2] ^ digest[3];
#define ROUND2(a, b, c, d, k, s)
static void mdfour64(uint32_t *M)
uint32_t Com_BlockChecksum(void *buffer, size_t len)
static void copy64(uint32_t *M, uint8_t *in)
void mdfour_result(struct mdfour *md, uint8_t *out)
#define ROUND3(a, b, c, d, k, s)
#define ROUND1(a, b, c, d, k, s)
static void mdfour_tail(uint8_t *in, size_t n)
static void copy4(uint8_t *out, uint32_t x)
void mdfour_update(struct mdfour *md, uint8_t *in, size_t n)
void mdfour_begin(struct mdfour *md)