Skip to content

Commit c8dacba

Browse files
committed
Merge branch 'jn/block-sha1' into maint
* jn/block-sha1: Makefile: BLK_SHA1 does not require fast htonl() and unaligned loads block-sha1: put expanded macro parameters in parentheses block-sha1: avoid pointer conversion that violates alignment constraints
2 parents dbf64e1 + f200197 commit c8dacba

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ all::
127127
# specify your own (or DarwinPort's) include directories and
128128
# library directories by defining CFLAGS and LDFLAGS appropriately.
129129
#
130-
# Define BLK_SHA1 environment variable if you want the C version
131-
# of the SHA1 that assumes you can do unaligned 32-bit loads and
132-
# have a fast htonl() function.
130+
# Define BLK_SHA1 environment variable to make use of the bundled
131+
# optimized C SHA1 routine.
133132
#
134133
# Define PPC_SHA1 environment variable when running make to make use of
135134
# a bundled SHA1 routine optimized for PowerPC.

block-sha1/sha1.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@
101101
* Where do we get the source from? The first 16 iterations get it from
102102
* the input data, the next mix it from the 512-bit array.
103103
*/
104-
#define SHA_SRC(t) get_be32(data + t)
105-
#define SHA_MIX(t) SHA_ROL(W(t+13) ^ W(t+8) ^ W(t+2) ^ W(t), 1)
104+
#define SHA_SRC(t) get_be32((unsigned char *) block + (t)*4)
105+
#define SHA_MIX(t) SHA_ROL(W((t)+13) ^ W((t)+8) ^ W((t)+2) ^ W(t), 1);
106106

107107
#define SHA_ROUND(t, input, fn, constant, A, B, C, D, E) do { \
108108
unsigned int TEMP = input(t); setW(t, TEMP); \
@@ -115,7 +115,7 @@
115115
#define T_40_59(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, ((B&C)+(D&(B^C))) , 0x8f1bbcdc, A, B, C, D, E )
116116
#define T_60_79(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0xca62c1d6, A, B, C, D, E )
117117

118-
static void blk_SHA1_Block(blk_SHA_CTX *ctx, const unsigned int *data)
118+
static void blk_SHA1_Block(blk_SHA_CTX *ctx, const void *block)
119119
{
120120
unsigned int A,B,C,D,E;
121121
unsigned int array[16];
@@ -126,7 +126,7 @@ static void blk_SHA1_Block(blk_SHA_CTX *ctx, const unsigned int *data)
126126
D = ctx->H[3];
127127
E = ctx->H[4];
128128

129-
/* Round 1 - iterations 0-16 take their input from 'data' */
129+
/* Round 1 - iterations 0-16 take their input from 'block' */
130130
T_0_15( 0, A, B, C, D, E);
131131
T_0_15( 1, E, A, B, C, D);
132132
T_0_15( 2, D, E, A, B, C);

0 commit comments

Comments
 (0)