ObjFW  Diff

Differences From Artifact [a7bb9e72ee]:

To Artifact [11feb3bb82]:


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#import "OFHashes.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

int _OFHashing_reference;

/*******
 * MD5 *
 *******/

/* The four MD5 core functions - F1 is optimized somewhat */
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#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))








|
|
|







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#import "OFHashes.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

int _OFHashing_reference;

/*
 * MD5
 */

/* The four MD5 core functions - F1 is optimized somewhat */
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#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))

244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260

#undef F1
#undef F2
#undef F3
#undef F4
#undef MD5STEP

/********
 * SHA1 *
 ********/

/* blk0() and blk() perform the initial expand. */
#ifndef OF_BIG_ENDIAN
#define blk0(i)							\
	(block->l[i] = (OF_ROL(block->l[i], 24) & 0xFF00FF00) |	\
	    (OF_ROL(block->l[i], 8) & 0x00FF00FF))
#else







|
|
|







244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260

#undef F1
#undef F2
#undef F3
#undef F4
#undef MD5STEP

/*
 * SHA1
 */

/* blk0() and blk() perform the initial expand. */
#ifndef OF_BIG_ENDIAN
#define blk0(i)							\
	(block->l[i] = (OF_ROL(block->l[i], 24) & 0xFF00FF00) |	\
	    (OF_ROL(block->l[i], 8) & 0x00FF00FF))
#else
406
407
408
409
410
411
412
413
414
415


416
417
418
419
420
421
422
	sha1_update(state, &count, buffer, "\200", 1);

	while ((count & 504) != 448)
		sha1_update(state, &count, buffer, "\0", 1);
	/* Should cause a sha1_transform() */
	sha1_update(state, &count, buffer, finalcount, 8);

	for (i = 0; i < SHA1_DIGEST_SIZE; i++)
		digest[i] = (char)((state[i >> 2] >>
		    ((3 - (i & 3)) * 8)) & 255);



	return digest;
}
@end

#undef blk0
#undef blk







|


>
>







406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
	sha1_update(state, &count, buffer, "\200", 1);

	while ((count & 504) != 448)
		sha1_update(state, &count, buffer, "\0", 1);
	/* Should cause a sha1_transform() */
	sha1_update(state, &count, buffer, finalcount, 8);

	for (i = 0; i < OF_SHA1_DIGEST_SIZE; i++)
		digest[i] = (char)((state[i >> 2] >>
		    ((3 - (i & 3)) * 8)) & 255);

	calculated = YES;

	return digest;
}
@end

#undef blk0
#undef blk