Differences From Artifact [2ed1eeca9f]:
- File src/OFMD5Hash.m — part of check-in [8892ae9fcc] at 2012-07-12 01:28:46 on branch trunk — Don't access isa directly. (user: js, size: 6827) [annotate] [blame] [check-ins using]
To Artifact [233d143bc4]:
- File
src/OFMD5Hash.m
— part of check-in
[1cb8fee5c3]
at
2012-10-13 21:06:59
on branch trunk
— of_bswap* -> OF_BSWAP*.
This makes it clear that multiple evaluation of parameters is possible. (user: js, size: 7035) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f, w, x, y, z, data, s) \
(w += f(x, y, z) + data, w = w << s | w >> (32 - s), w += x)
static void
md5_transform(uint32_t buffer[4], const uint32_t in[16])
{
register uint32_t a, b, c, d;
a = buffer[0];
| > > > > > > > > > > > > > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f, w, x, y, z, data, s) \
(w += f(x, y, z) + data, w = w << s | w >> (32 - s), w += x)
#ifdef OF_BIG_ENDIAN
static OF_INLINE void
BSWAP32_VEC_IF_BE(uint32_t *buffer, size_t length)
{
while (length--) {
*buffer = OF_BSWAP32(*buffer);
buffer++;
}
}
#else
# define BSWAP32_VEC_IF_BE(buffer, length)
#endif
static void
md5_transform(uint32_t buffer[4], const uint32_t in[16])
{
register uint32_t a, b, c, d;
a = buffer[0];
|
| ︙ | ︙ | |||
173 174 175 176 177 178 179 |
if (length < t) {
memcpy(p, buffer_, length);
return;
}
memcpy(p, buffer_, t);
| | | | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
if (length < t) {
memcpy(p, buffer_, length);
return;
}
memcpy(p, buffer_, t);
BSWAP32_VEC_IF_BE(in.u32, 16);
md5_transform(buffer, in.u32);
buffer_ += t;
length -= t;
}
/* Process data in 64-byte chunks */
while (length >= 64) {
memcpy(in.u8, buffer_, 64);
BSWAP32_VEC_IF_BE(in.u32, 16);
md5_transform(buffer, in.u32);
buffer_ += 64;
length -= 64;
}
/* Handle any remaining bytes of data. */
|
| ︙ | ︙ | |||
219 220 221 222 223 224 225 |
/* Bytes of padding needed to make 64 bytes */
count = 64 - 1 - count;
/* Pad out to 56 mod 64 */
if (count < 8) {
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
| | | | | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
/* Bytes of padding needed to make 64 bytes */
count = 64 - 1 - count;
/* Pad out to 56 mod 64 */
if (count < 8) {
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
BSWAP32_VEC_IF_BE(in.u32, 16);
md5_transform(buffer, in.u32);
/* Now fill the next block with 56 bytes */
memset(in.u8, 0, 56);
} else {
/* Pad block to 56 bytes */
memset(p, 0, count - 8);
}
BSWAP32_VEC_IF_BE(in.u32, 14);
/* Append length in bits and transform */
in.u32[14] = bits[0];
in.u32[15] = bits[1];
md5_transform(buffer, in.u32);
BSWAP32_VEC_IF_BE(buffer, 4);
calculated = YES;
return (uint8_t*)buffer;
}
@end
|