summaryrefslogtreecommitdiff
path: root/src/ae-common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ae-common.h')
-rw-r--r--src/ae-common.h19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/ae-common.h b/src/ae-common.h
index da5d04d..561854e 100644
--- a/src/ae-common.h
+++ b/src/ae-common.h
@@ -65,26 +65,23 @@ static inline void pad10(size_t X_len, const uint8_t X[X_len], uint8_t padded[BL
}
}
-static inline void _fill_ad_tweak(
+static inline void fill_index_tweak(
uint8_t prefix,
- uint64_t block_nb,
+ uint64_t block_index,
uint8_t tweak[TWEAK_BYTES]
)
{
/* The t-bit tweak is filled as follows:
*
- * - bits [ 1, t-4]: block number
- * [ 1, 64]: actual 64-bit block number
+ * - bits [ 1, t-4]: block index
+ * [ 1, 64]: actual 64-bit block index
* [ 65, t-4]: 0-padding
* - bits [t-3, t]: constant 4-bit prefix
*/
- for (size_t i=0; i<sizeof(block_nb); i++)
+ for (size_t i=0; i<sizeof(block_index); i++)
{
- uint64_t mask = (uint64_t)0xff << 8*i;
- uint8_t b = (mask & block_nb) >> 8*i;
-
- tweak[i] = b;
+ tweak[i] = block_index >> 8*i & 0xff;
}
/* Assume padding bytes have already been memset to 0. */
@@ -110,7 +107,7 @@ static void process_associated_data(
for (size_t i=0; i<l_a; i++)
{
- _fill_ad_tweak(0x2, i, tweak);
+ fill_index_tweak(0x2, i, tweak);
encrypt(key, tweak, &A[i*BLOCK_BYTES], Ek_Ai);
xor_into(Auth, Ek_Ai);
}
@@ -119,7 +116,7 @@ static void process_associated_data(
{
uint8_t A_rest[BLOCK_BYTES];
pad10(rest, &A[l_a*BLOCK_BYTES], A_rest);
- _fill_ad_tweak(0x6, l_a, tweak);
+ fill_index_tweak(0x6, l_a, tweak);
encrypt(key, tweak, A_rest, Ek_Ai);
xor_into(Auth, Ek_Ai);
}