Module Name: othersrc
Committed By: agc
Date: Thu Aug 22 06:37:29 UTC 2013
Modified Files:
othersrc/external/bsd/multigest/dist: keccak.c
Log Message:
minor whitespace differences - no functional change
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/multigest/dist/keccak.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: othersrc/external/bsd/multigest/dist/keccak.c
diff -u othersrc/external/bsd/multigest/dist/keccak.c:1.3 othersrc/external/bsd/multigest/dist/keccak.c:1.4
--- othersrc/external/bsd/multigest/dist/keccak.c:1.3 Thu Aug 22 06:32:29 2013
+++ othersrc/external/bsd/multigest/dist/keccak.c Thu Aug 22 06:37:29 2013
@@ -47,9 +47,9 @@ fromBytesToWords(uint64_t *stateAsWords,
{
unsigned int i, j;
- for(i = 0; i < (KECCAK_PERMUTATION_SIZE_BITS / 64); i++) {
+ for (i = 0; i < (KECCAK_PERMUTATION_SIZE_BITS / 64); i++) {
stateAsWords[i] = 0;
- for(j = 0; j < (64/8); j++) {
+ for (j = 0; j < (64/8); j++) {
stateAsWords[i] |= (uint64_t)(state[i*(64/8)+j]) << (8*j);
}
}
@@ -60,8 +60,8 @@ fromWordsToBytes(uint8_t *state, const u
{
unsigned int i, j;
- for(i = 0; i < (KECCAK_PERMUTATION_SIZE_BITS / 64); i++) {
- for(j = 0; j < (64/8); j++) {
+ for (i = 0; i < (KECCAK_PERMUTATION_SIZE_BITS / 64); i++) {
+ for (j = 0; j < (64/8); j++) {
state[i*(64/8)+j] = (uint8_t)(stateAsWords[i] >> (8*j)) & 0xFF;
}
}
@@ -70,86 +70,86 @@ fromWordsToBytes(uint8_t *state, const u
#define INDEX(x, y) (((x)%5)+5*((y)%5))
#define ROL64(a, offset) (/*CONSTCOND*/(offset != 0) ? ((((uint64_t)a) << offset) ^ (((uint64_t)a) >> (64-offset))) : a)
-static void
+static inline void
theta(uint64_t *A)
{
unsigned int x, y;
uint64_t C[5], D[5];
- for(x = 0; x < 5; x++) {
+ for (x = 0; x < 5; x++) {
C[x] = 0;
- for(y = 0; y < 5; y++) {
+ for (y = 0; y < 5; y++) {
C[x] ^= A[INDEX(x, y)];
}
}
- for(x = 0; x < 5; x++) {
+ for (x = 0; x < 5; x++) {
D[x] = ROL64(C[(x+1)%5], 1) ^ C[(x+4)%5];
}
- for(x = 0; x < 5; x++) {
- for(y = 0; y < 5; y++) {
+ for (x = 0; x < 5; x++) {
+ for (y = 0; y < 5; y++) {
A[INDEX(x, y)] ^= D[x];
}
}
}
-static void
+static inline void
rho(KECCAK_CTX *ctx, uint64_t *A)
{
unsigned int x, y;
- for(x = 0; x < 5; x++) {
- for(y = 0; y < 5; y++) {
+ for (x = 0; x < 5; x++) {
+ for (y = 0; y < 5; y++) {
A[INDEX(x, y)] = ROL64(A[INDEX(x, y)], ctx->RhoOffsets[INDEX(x, y)]);
}
}
}
-static void
+static inline void
pi(uint64_t *A)
{
unsigned int x, y;
uint64_t tempA[25];
- for(x = 0; x < 5; x++) {
- for(y = 0; y < 5; y++) {
+ for (x = 0; x < 5; x++) {
+ for (y = 0; y < 5; y++) {
tempA[INDEX(x, y)] = A[INDEX(x, y)];
}
}
- for(x = 0; x < 5; x++) {
- for(y = 0; y < 5; y++) {
+ for (x = 0; x < 5; x++) {
+ for (y = 0; y < 5; y++) {
A[INDEX(0*x+1*y, 2*x+3*y)] = tempA[INDEX(x, y)];
}
}
}
-static void
+static inline void
chi(uint64_t *A)
{
- unsigned int x, y;
- uint64_t C[5];
+ unsigned int x, y;
+ uint64_t C[5];
- for(y = 0; y < 5; y++) {
- for(x = 0; x < 5; x++) {
+ for (y = 0; y < 5; y++) {
+ for (x = 0; x < 5; x++) {
C[x] = A[INDEX(x, y)] ^ ((~A[INDEX(x+1, y)]) & A[INDEX(x+2, y)]);
}
- for(x = 0; x < 5; x++) {
+ for (x = 0; x < 5; x++) {
A[INDEX(x, y)] = C[x];
}
}
}
-static void
+static inline void
iota(KECCAK_CTX *ctx, uint64_t *A, unsigned int indexRound)
{
A[INDEX(0, 0)] ^= ctx->RoundConstants[indexRound];
}
-static void
+static inline void
KeccakPermutationOnWords(KECCAK_CTX *ctx, uint64_t *st)
{
- unsigned int i;
+ unsigned int i;
- for(i = 0; i < KECCAK_NUM_ROUNDS; i++) {
+ for (i = 0; i < KECCAK_NUM_ROUNDS; i++) {
theta(st);
rho(ctx, st);
pi(st);
@@ -162,7 +162,7 @@ static void
keccak_permutation(KECCAK_CTX *ctx)
{
const int indian = 1;
- uint64_t stateAsWords[KECCAK_PERMUTATION_SIZE_BITS/64];
+ uint64_t stateAsWords[KECCAK_PERMUTATION_SIZE_BITS/64];
if (*(const char *)(const void *)&indian) {
/* little endian */
@@ -177,9 +177,9 @@ keccak_permutation(KECCAK_CTX *ctx)
static void
KeccakPermutationAfterXor(KECCAK_CTX *ctx, uint8_t *state, const uint8_t *data, unsigned int dataLengthInBytes)
{
- unsigned int i;
+ unsigned int i;
- for(i = 0; i < dataLengthInBytes; i++) {
+ for (i = 0; i < dataLengthInBytes; i++) {
state[i] ^= data[i];
}
keccak_permutation(ctx);
@@ -188,7 +188,7 @@ KeccakPermutationAfterXor(KECCAK_CTX *ct
static int
LFSR86540(uint8_t *LFSR)
{
- int result = ((*LFSR) & 0x01) != 0;
+ int result = ((*LFSR) & 0x01) != 0;
if (((*LFSR) & 0x80) != 0) {
/* Primitive polynomial over GF(2): x^8+x^6+x^5+x^4+1 */
@@ -202,12 +202,12 @@ LFSR86540(uint8_t *LFSR)
static void
keccak_initialise_RoundConstants(KECCAK_CTX *ctx)
{
- uint8_t LFSRstate = 0x01;
- unsigned int i, j, bitPosition;
+ uint8_t LFSRstate = 0x01;
+ unsigned int i, j, bitPosition;
- for(i = 0; i < KECCAK_NUM_ROUNDS; i++) {
+ for (i = 0; i < KECCAK_NUM_ROUNDS; i++) {
ctx->RoundConstants[i] = 0;
- for(j = 0; j < 7; j++) {
+ for (j = 0; j < 7; j++) {
bitPosition = (1<<j)-1; /*2^j-1 */
if (LFSR86540(&LFSRstate)) {
ctx->RoundConstants[i] ^= (uint64_t)1<<bitPosition;
@@ -219,12 +219,12 @@ keccak_initialise_RoundConstants(KECCAK_
static void
keccak_initialise_RhoOffsets(KECCAK_CTX *ctx)
{
- unsigned int x, y, t, newX, newY;
+ unsigned int x, y, t, newX, newY;
ctx->RhoOffsets[INDEX(0, 0)] = 0;
x = 1;
y = 0;
- for(t = 0; t < 24; t++) {
+ for (t = 0; t < 24; t++) {
ctx->RhoOffsets[INDEX(x, y)] = ((t+1)*(t+2)/2) % 64;
newX = (0*x+1*y) % 5;
newY = (2*x+3*y) % 5;
@@ -255,7 +255,7 @@ init_sponge(KECCAK_CTX *ctx, unsigned in
return 0;
}
-static void
+static inline void
absorb_queue(KECCAK_CTX *ctx)
{
/* state->bitsInQueue is assumed to be equal to state->rate */
@@ -280,7 +280,7 @@ absorb(KECCAK_CTX *ctx, const uint8_t *d
if ((ctx->bitsInQueue == 0) && (databitlen >= ctx->rate) && (i <= (databitlen-ctx->rate))) {
wholeBlocks = (databitlen-i)/ctx->rate;
curData = &data[(long)i/8];
- for(j=0; j<wholeBlocks; j++, curData+=ctx->rate/8) {
+ for (j=0; j<wholeBlocks; j++, curData+=ctx->rate/8) {
KeccakPermutationAfterXor(ctx, ctx->state, curData, ctx->rate / 8);
}
i += wholeBlocks*ctx->rate;