More fixes for big-endian architectures

This commit is contained in:
Frank Denis 2013-09-21 19:43:39 -07:00
parent c19b0128e2
commit c43440f01c

View File

@ -78,7 +78,7 @@ ECRYPT_keysetup(ECRYPT_ctx* ctx, const u8* key, u32 keysize, u32 ivsize)
for (i = 0; i <= Nr; i++) { for (i = 0; i <= Nr; i++) {
for (j = 0; j < Nb; j++) { for (j = 0; j < Nb; j++) {
ctx->round_key[i][j] = w[(i<<2)+j]; ctx->round_key[i][j] = SWP32(w[(i<<2)+j]);
} }
} }
} }
@ -151,9 +151,9 @@ ECRYPT_process_bytes(int action, ECRYPT_ctx* ctx, const u8* input, u8* output,
((u32*)output)[2] = UNALIGNED_U32_READ(input, 2) ^ ((u32*)keystream)[2] ^ ctx->round_key[Nr][2]; ((u32*)output)[2] = UNALIGNED_U32_READ(input, 2) ^ ((u32*)keystream)[2] ^ ctx->round_key[Nr][2];
((u32*)output)[3] = UNALIGNED_U32_READ(input, 3) ^ ((u32*)keystream)[3] ^ ctx->round_key[Nr][3]; ((u32*)output)[3] = UNALIGNED_U32_READ(input, 3) ^ ((u32*)keystream)[3] ^ ctx->round_key[Nr][3];
ctx->counter[0]++; ctx->counter[0] = SWP32(SWP32(ctx->counter[0]) + 1);
if ((ctx->counter[0] & 0xff)== 0) { if ((ctx->counter[0] & SWP32(0xff))== 0) {
partial_precompute_tworounds(ctx); partial_precompute_tworounds(ctx);
} }
} }