sha2.c.diff

Hiroshi Nakamura, 07/14/2011 06:47 PM

Download (1.54 KB)

View differences:

ext/digest/sha2/sha2.c (working copy)
59 59
 *
60 60
 */
61 61

  
62
/*
63
 * #if condition from regint.h - XXX there must exist a nicer way
64
 */
65
#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
66
    (defined(__ppc__) && defined(__APPLE__)) || \
67
    defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD86) || \
68
    defined(__mc68020__)
69
#define PLATFORM_UNALIGNED_WORD_ACCESS
70
#endif
62 71

  
72

  
63 73
/*** SHA-256/384/512 Machine Architecture Definitions *****************/
64 74
/*
65 75
 * BYTE_ORDER NOTE:
......
559 569
	}
560 570
	while (len >= SHA256_BLOCK_LENGTH) {
561 571
		/* Process as many complete blocks as we can */
572
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
562 573
		SHA256_Transform(context, (sha2_word32*)data);
574
#else
575
		MEMCPY_BCOPY(context->buffer, data, SHA256_BLOCK_LENGTH);
576
		SHA256_Transform(context, (sha2_word32*)context->buffer);
577
#endif
563 578
		context->bitcount += SHA256_BLOCK_LENGTH << 3;
564 579
		len -= SHA256_BLOCK_LENGTH;
565 580
		data += SHA256_BLOCK_LENGTH;
......
880 895
	}
881 896
	while (len >= SHA512_BLOCK_LENGTH) {
882 897
		/* Process as many complete blocks as we can */
898
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
883 899
		SHA512_Transform(context, (sha2_word64*)data);
900
#else
901
		MEMCPY_BCOPY(context->buffer, data, SHA512_BLOCK_LENGTH);
902
		SHA512_Transform(context, (sha2_word64*)context->buffer);
903
#endif
884 904
		ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3);
885 905
		len -= SHA512_BLOCK_LENGTH;
886 906
		data += SHA512_BLOCK_LENGTH;