22 #include "runtime.hpp"
27 #include "algorithm.hpp"
31 namespace STL = STL_NAMESPACE;
38 digest_[0] = 0x67452301L;
39 digest_[1] = 0xefcdab89L;
40 digest_[2] = 0x98badcfeL;
41 digest_[3] = 0x10325476L;
49 MD4::MD4(
const MD4& that) : HASHwithTransform(DIGEST_SIZE / sizeof(word32),
52 buffLen_ = that.buffLen_;
56 memcpy(digest_, that.digest_, DIGEST_SIZE);
57 memcpy(buffer_, that.buffer_, BLOCK_SIZE);
60 MD4& MD4::operator= (
const MD4& that)
69 void MD4::Swap(MD4& other)
71 STL::swap(loLen_, other.loLen_);
72 STL::swap(hiLen_, other.hiLen_);
73 STL::swap(buffLen_, other.buffLen_);
75 memcpy(digest_, other.digest_, DIGEST_SIZE);
76 memcpy(buffer_, other.buffer_, BLOCK_SIZE);
82 #define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
83 #define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
84 #define H(x, y, z) ((x) ^ (y) ^ (z))
93 #define function(a,b,c,d,k,s) a=rotlFixed(a+F(b,c,d)+buffer_[k],s);
94 function(A,B,C,D, 0, 3);
95 function(D,A,B,C, 1, 7);
96 function(C,D,A,B, 2,11);
97 function(B,C,D,A, 3,19);
98 function(A,B,C,D, 4, 3);
99 function(D,A,B,C, 5, 7);
100 function(C,D,A,B, 6,11);
101 function(B,C,D,A, 7,19);
102 function(A,B,C,D, 8, 3);
103 function(D,A,B,C, 9, 7);
104 function(C,D,A,B,10,11);
105 function(B,C,D,A,11,19);
106 function(A,B,C,D,12, 3);
107 function(D,A,B,C,13, 7);
108 function(C,D,A,B,14,11);
109 function(B,C,D,A,15,19);
112 #define function(a,b,c,d,k,s) a=rotlFixed(a+G(b,c,d)+buffer_[k]+0x5a827999,s);
113 function(A,B,C,D, 0, 3);
114 function(D,A,B,C, 4, 5);
115 function(C,D,A,B, 8, 9);
116 function(B,C,D,A,12,13);
117 function(A,B,C,D, 1, 3);
118 function(D,A,B,C, 5, 5);
119 function(C,D,A,B, 9, 9);
120 function(B,C,D,A,13,13);
121 function(A,B,C,D, 2, 3);
122 function(D,A,B,C, 6, 5);
123 function(C,D,A,B,10, 9);
124 function(B,C,D,A,14,13);
125 function(A,B,C,D, 3, 3);
126 function(D,A,B,C, 7, 5);
127 function(C,D,A,B,11, 9);
128 function(B,C,D,A,15,13);
131 #define function(a,b,c,d,k,s) a=rotlFixed(a+H(b,c,d)+buffer_[k]+0x6ed9eba1,s);
132 function(A,B,C,D, 0, 3);
133 function(D,A,B,C, 8, 9);
134 function(C,D,A,B, 4,11);
135 function(B,C,D,A,12,15);
136 function(A,B,C,D, 2, 3);
137 function(D,A,B,C,10, 9);
138 function(C,D,A,B, 6,11);
139 function(B,C,D,A,14,15);
140 function(A,B,C,D, 1, 3);
141 function(D,A,B,C, 9, 9);
142 function(C,D,A,B, 5,11);
143 function(B,C,D,A,13,15);
144 function(A,B,C,D, 3, 3);
145 function(D,A,B,C,11, 9);
146 function(C,D,A,B, 7,11);
147 function(B,C,D,A,15,15);