comparison dcrypt/crypto/hashes/MD5.d @ 23:4589f8c5eb3c

Replaced dcrypt.crypto.Util with dcrypt.misc.Bitwise and dcrypt.misc.ByteConverter. Altered all dependent files to reflect changes.
author Thomas Dixon <reikon@reikon.us>
date Sat, 14 Feb 2009 19:58:20 -0500
parents cd376996cdb3
children 176c933827a8
comparison
equal deleted inserted replaced
22:74303a717032 23:4589f8c5eb3c
62 } 62 }
63 63
64 void transform(ubyte[] input) { 64 void transform(ubyte[] input) {
65 uint[] w = new uint[16]; 65 uint[] w = new uint[16];
66 66
67 for (int i = 0, j = 0; i < 16; i++,j+=4) 67 for (int i = 0, j = 0; i < 16; i++,j+=int.sizeof)
68 w[i] = Util.ubytesToUintLittle(input, j); 68 w[i] = ByteConverter.LittleEndian.to!(uint)(input[j..j+int.sizeof]);
69 69
70 uint a = h0, 70 uint a = h0,
71 b = h1, 71 b = h1,
72 c = h2, 72 c = h2,
73 d = h3; 73 d = h3;
169 } 169 }
170 170
171 private void ff(ref uint a, uint b, uint c, 171 private void ff(ref uint a, uint b, uint c,
172 uint d, uint x, uint s, uint ac) { 172 uint d, uint x, uint s, uint ac) {
173 a += f(b, c, d) + x + ac; 173 a += f(b, c, d) + x + ac;
174 a = Util.rotateLeft(a, s); 174 a = Bitwise.rotateLeft(a, s);
175 a += b; 175 a += b;
176 } 176 }
177 177
178 private void gg(ref uint a, uint b, uint c, 178 private void gg(ref uint a, uint b, uint c,
179 uint d, uint x, uint s, uint ac) { 179 uint d, uint x, uint s, uint ac) {
180 a += g(b, c, d) + x + ac; 180 a += g(b, c, d) + x + ac;
181 a = Util.rotateLeft(a, s); 181 a = Bitwise.rotateLeft(a, s);
182 a += b; 182 a += b;
183 } 183 }
184 184
185 private void hh(ref uint a, uint b, uint c, 185 private void hh(ref uint a, uint b, uint c,
186 uint d, uint x, uint s, uint ac) { 186 uint d, uint x, uint s, uint ac) {
187 a += h(b, c, d) + x + ac; 187 a += h(b, c, d) + x + ac;
188 a = Util.rotateLeft(a, s); 188 a = Bitwise.rotateLeft(a, s);
189 a += b; 189 a += b;
190 } 190 }
191 191
192 private void ii(ref uint a, uint b, uint c, 192 private void ii(ref uint a, uint b, uint c,
193 uint d, uint x, uint s, uint ac) { 193 uint d, uint x, uint s, uint ac) {
194 a += i(b, c, d) + x + ac; 194 a += i(b, c, d) + x + ac;
195 a = Util.rotateLeft(a, s); 195 a = Bitwise.rotateLeft(a, s);
196 a += b; 196 a += b;
197 } 197 }
198 198
199 ubyte[] digest() { 199 ubyte[] digest() {
200 padMessage(MODE_MD); 200 padMessage(MODE_MD);
201 ubyte[] result = new ubyte[digestSize]; 201 ubyte[] result = new ubyte[digestSize];
202 202
203 Util.uintToUbytesLittle(h0, result, 0); 203 result[0..4] = ByteConverter.LittleEndian.from!(uint)(h0);
204 Util.uintToUbytesLittle(h1, result, 4); 204 result[4..8] = ByteConverter.LittleEndian.from!(uint)(h1);
205 Util.uintToUbytesLittle(h2, result, 8); 205 result[8..12] = ByteConverter.LittleEndian.from!(uint)(h2);
206 Util.uintToUbytesLittle(h3, result, 12); 206 result[12..16] = ByteConverter.LittleEndian.from!(uint)(h3);
207 207
208 reset(); 208 reset();
209 return result; 209 return result;
210 } 210 }
211 211