diff --git a/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c b/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c index 609d2864..4983a172 100644 --- a/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c +++ b/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c @@ -78,7 +78,7 @@ ECRYPT_keysetup(ECRYPT_ctx* ctx, const u8* key, u32 keysize, u32 ivsize) for (i = 0; i <= Nr; i++) { 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)[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); } }