37 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
44 #if (MD4_SUPPORT == ENABLED)
47 #define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
48 #define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
49 #define H(x, y, z) ((x) ^ (y) ^ (z))
51 #define FF(a, b, c, d, x, s) a += F(b, c, d) + (x), a = ROL32(a, s)
52 #define GG(a, b, c, d, x, s) a += G(b, c, d) + (x) + 0x5A827999, a = ROL32(a, s)
53 #define HH(a, b, c, d, x, s) a += H(b, c, d) + (x) + 0x6ED9EBA1, a = ROL32(a, s)
56 static const uint8_t padding[64] =
58 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
65 const uint8_t
MD4_OID[8] = {0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x04};
96 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
109 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
124 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
142 context->
h[0] = 0x67452301;
143 context->
h[1] = 0xEFCDAB89;
144 context->
h[2] = 0x98BADCFE;
145 context->
h[3] = 0x10325476;
183 if(context->
size == 64)
210 if(context->
size < 56)
212 paddingSize = 56 - context->
size;
216 paddingSize = 64 + 56 - context->
size;
220 md4Update(context, padding, paddingSize);
223 context->
x[14] =
htole32((uint32_t) totalSize);
224 context->
x[15] =
htole32((uint32_t) (totalSize >> 32));
230 for(i = 0; i < 4; i++)
253 uint32_t
a = context->
h[0];
254 uint32_t
b = context->
h[1];
255 uint32_t
c = context->
h[2];
256 uint32_t d = context->
h[3];
259 uint32_t *
x = context->
x;
262 for(i = 0; i < 16; i++)
278 FF(
c, d,
a,
b,
x[10], 11);
279 FF(
b,
c, d,
a,
x[11], 19);
282 FF(
c, d,
a,
b,
x[14], 11);
283 FF(
b,
c, d,
a,
x[15], 19);
289 GG(
b,
c, d,
a,
x[12], 13);
293 GG(
b,
c, d,
a,
x[13], 13);
297 GG(
b,
c, d,
a,
x[14], 13);
301 GG(
b,
c, d,
a,
x[15], 13);
307 HH(
b,
c, d,
a,
x[12], 15);
311 HH(
b,
c, d,
a,
x[14], 15);
315 HH(
b,
c, d,
a,
x[13], 15);
319 HH(
b,
c, d,
a,
x[15], 15);