Reindent
This commit is contained in:
parent
77d96e79b7
commit
6ec9828b9f
@ -13,22 +13,15 @@
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* key setup for AES-256*/
|
||||
static void ECRYPT_keysetup(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* key,
|
||||
u32 keysize,
|
||||
u32 ivsize)
|
||||
static void
|
||||
ECRYPT_keysetup(ECRYPT_ctx* ctx, const u8* key, u32 keysize, u32 ivsize)
|
||||
{
|
||||
unsigned int w[Nk*(Nr+1)], temp;
|
||||
|
||||
int i, j;
|
||||
|
||||
(void) sizeof(char[sizeof *ctx == crypto_stream_BEFORENMBYTES ? 1 : -1]);
|
||||
|
||||
i = 0;
|
||||
|
||||
for( i = 0; i < Nk; i++ )
|
||||
{
|
||||
for( i = 0; i < Nk; i++ ) {
|
||||
w[i] = key[(i << 2)];
|
||||
w[i] |= key[(i << 2)+1] << 8;
|
||||
w[i] |= key[(i << 2)+2] << 16;
|
||||
@ -37,8 +30,7 @@ static void ECRYPT_keysetup(
|
||||
|
||||
i = Nk;
|
||||
|
||||
while( i < Nb*(Nr+1) )
|
||||
{
|
||||
while( i < Nb*(Nr+1) ) {
|
||||
temp = w[i-1];
|
||||
|
||||
temp = Sbox[ temp & 0xFF] << 24 ^
|
||||
@ -82,19 +74,17 @@ static void ECRYPT_keysetup(
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i <= Nr; i++)
|
||||
for (j = 0; j < Nb; j++)
|
||||
for (i = 0; i <= Nr; i++) {
|
||||
for (j = 0; j < Nb; j++) {
|
||||
ctx->round_key[i][j] = w[(i<<2)+j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
static void ECRYPT_ivsetup(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* iv)
|
||||
static void
|
||||
ECRYPT_ivsetup(ECRYPT_ctx* ctx, const u8* iv)
|
||||
{
|
||||
(void) sizeof(char[(sizeof ctx->counter) == crypto_stream_NONCEBYTES ? 1 : -1]);
|
||||
memcpy(ctx->counter, iv, crypto_stream_NONCEBYTES);
|
||||
@ -102,20 +92,17 @@ static void ECRYPT_ivsetup(
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void ECRYPT_process_bytes(
|
||||
int action,
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* input,
|
||||
u8* output,
|
||||
static void
|
||||
ECRYPT_process_bytes(int action, ECRYPT_ctx* ctx, const u8* input, u8* output,
|
||||
u32 msglen)
|
||||
{
|
||||
u8 keystream[16];
|
||||
u32 i;
|
||||
|
||||
memset(keystream, 0, sizeof keystream);
|
||||
partial_precompute_tworounds(ctx);
|
||||
|
||||
for ( ; msglen >= 16; msglen -= 16, input += 16, output += 16)
|
||||
{
|
||||
for ( ; msglen >= 16; msglen -= 16, input += 16, output += 16) {
|
||||
aes256_enc_block(ctx->counter, keystream, ctx);
|
||||
|
||||
((u32*)output)[0] = ((u32*)input)[0] ^ ((u32*)keystream)[0] ^ ctx->round_key[Nr][0];
|
||||
@ -125,23 +112,24 @@ static void ECRYPT_process_bytes(
|
||||
|
||||
ctx->counter[0]++;
|
||||
|
||||
if ((ctx->counter[0] & 0xff)== 0) partial_precompute_tworounds(ctx);
|
||||
if ((ctx->counter[0] & 0xff)== 0) {
|
||||
partial_precompute_tworounds(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
if (msglen > 0)
|
||||
{
|
||||
if (msglen > 0) {
|
||||
aes256_enc_block(ctx->counter, keystream, ctx);
|
||||
((u32*)keystream)[0] ^= ctx->round_key[Nr][0];
|
||||
((u32*)keystream)[1] ^= ctx->round_key[Nr][1];
|
||||
((u32*)keystream)[2] ^= ctx->round_key[Nr][2];
|
||||
((u32*)keystream)[3] ^= ctx->round_key[Nr][3];
|
||||
|
||||
for (i = 0; i < msglen; i ++)
|
||||
for (i = 0; i < msglen; i ++) {
|
||||
output[i] = input[i] ^ keystream[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#include "ecrypt-sync.h"
|
||||
|
Loading…
Reference in New Issue
Block a user