Skip to content

Commit

Permalink
aegis*_mac(): use uint64_t for the message and ad sizes
Browse files Browse the repository at this point in the history
This is useful on 32-bit machines, if the streaming API is used
with very large inputs.
  • Loading branch information
jedisct1 committed Dec 4, 2024
1 parent cf0bf0e commit 479326a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/aegis128l/aegis128l_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ aegis128l_init(const uint8_t *key, const uint8_t *nonce, aes_block_t *const stat
}

static void
aegis128l_mac(uint8_t *mac, size_t maclen, size_t adlen, size_t mlen, aes_block_t *const state)
aegis128l_mac(uint8_t *mac, size_t maclen, uint64_t adlen, uint64_t mlen, aes_block_t *const state)
{
aes_block_t tmp;
int i;

tmp = AES_BLOCK_LOAD_64x2(((uint64_t) mlen) << 3, ((uint64_t) adlen) << 3);
tmp = AES_BLOCK_LOAD_64x2(mlen << 3, adlen << 3);
tmp = AES_BLOCK_XOR(tmp, state[2]);

for (i = 0; i < 7; i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/aegis128x2/aegis128x2_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ aegis128x2_init(const uint8_t *key, const uint8_t *nonce, aes_block_t *const sta
}

static void
aegis128x2_mac(uint8_t *mac, size_t maclen, size_t adlen, size_t mlen, aes_block_t *const state)
aegis128x2_mac(uint8_t *mac, size_t maclen, uint64_t adlen, uint64_t mlen, aes_block_t *const state)
{
uint8_t mac_multi_0[AES_BLOCK_LENGTH];
uint8_t mac_multi_1[AES_BLOCK_LENGTH];
aes_block_t tmp;
int i;

tmp = AES_BLOCK_LOAD_64x2(((uint64_t) mlen) << 3, ((uint64_t) adlen) << 3);
tmp = AES_BLOCK_LOAD_64x2(mlen << 3, adlen << 3);
tmp = AES_BLOCK_XOR(tmp, state[2]);

for (i = 0; i < 7; i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/aegis128x4/aegis128x4_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ aegis128x4_init(const uint8_t *key, const uint8_t *nonce, aes_block_t *const sta
}

static void
aegis128x4_mac(uint8_t *mac, size_t maclen, size_t adlen, size_t mlen, aes_block_t *const state)
aegis128x4_mac(uint8_t *mac, size_t maclen, uint64_t adlen, uint64_t mlen, aes_block_t *const state)
{
uint8_t mac_multi_0[AES_BLOCK_LENGTH];
uint8_t mac_multi_1[AES_BLOCK_LENGTH];
aes_block_t tmp;
int i;

tmp = AES_BLOCK_LOAD_64x2(((uint64_t) mlen) << 3, ((uint64_t) adlen) << 3);
tmp = AES_BLOCK_LOAD_64x2(mlen << 3, adlen << 3);
tmp = AES_BLOCK_XOR(tmp, state[2]);

for (i = 0; i < 7; i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/aegis256/aegis256_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ aegis256_init(const uint8_t *key, const uint8_t *nonce, aes_block_t *const state
}

static void
aegis256_mac(uint8_t *mac, size_t maclen, size_t adlen, size_t mlen, aes_block_t *const state)
aegis256_mac(uint8_t *mac, size_t maclen, uint64_t adlen, uint64_t mlen, aes_block_t *const state)
{
aes_block_t tmp;
int i;

tmp = AES_BLOCK_LOAD_64x2(((uint64_t) mlen) << 3, ((uint64_t) adlen) << 3);
tmp = AES_BLOCK_LOAD_64x2(mlen << 3, adlen << 3);
tmp = AES_BLOCK_XOR(tmp, state[3]);

for (i = 0; i < 7; i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/aegis256x2/aegis256x2_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ aegis256x2_init(const uint8_t *key, const uint8_t *nonce, aes_block_t *const sta
}

static void
aegis256x2_mac(uint8_t *mac, size_t maclen, size_t adlen, size_t mlen, aes_block_t *const state)
aegis256x2_mac(uint8_t *mac, size_t maclen, uint64_t adlen, uint64_t mlen, aes_block_t *const state)
{
uint8_t mac_multi_0[AES_BLOCK_LENGTH];
uint8_t mac_multi_1[AES_BLOCK_LENGTH];
aes_block_t tmp;
int i;

tmp = AES_BLOCK_LOAD_64x2(((uint64_t) mlen) << 3, ((uint64_t) adlen) << 3);
tmp = AES_BLOCK_LOAD_64x2(mlen << 3, adlen << 3);
tmp = AES_BLOCK_XOR(tmp, state[3]);

for (i = 0; i < 7; i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/aegis256x4/aegis256x4_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ aegis256x4_init(const uint8_t *key, const uint8_t *nonce, aes_block_t *const sta
}

static void
aegis256x4_mac(uint8_t *mac, size_t maclen, size_t adlen, size_t mlen, aes_block_t *const state)
aegis256x4_mac(uint8_t *mac, size_t maclen, uint64_t adlen, uint64_t mlen, aes_block_t *const state)
{
uint8_t mac_multi_0[AES_BLOCK_LENGTH];
uint8_t mac_multi_1[AES_BLOCK_LENGTH];
aes_block_t tmp;
int i;

tmp = AES_BLOCK_LOAD_64x2(((uint64_t) mlen) << 3, ((uint64_t) adlen) << 3);
tmp = AES_BLOCK_LOAD_64x2(mlen << 3, adlen << 3);
tmp = AES_BLOCK_XOR(tmp, state[3]);

for (i = 0; i < 7; i++) {
Expand Down

0 comments on commit 479326a

Please sign in to comment.