Skip to content

Commit

Permalink
Reuse aegis_blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Nov 13, 2024
1 parent bc73ebf commit 79c41cc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/aegis128l/aegis128l_common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#define RATE 32
#define ALIGNMENT 32

typedef aes_block_t aegis_blocks[8];

static void
aegis128l_init(const uint8_t *key, const uint8_t *nonce, aes_block_t *const state)
{
Expand Down Expand Up @@ -146,7 +148,7 @@ static int
encrypt_detached(uint8_t *c, uint8_t *mac, size_t maclen, const uint8_t *m, size_t mlen,
const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k)
{
aes_block_t state[8];
aegis_blocks state;
CRYPTO_ALIGN(ALIGNMENT) uint8_t src[RATE];
CRYPTO_ALIGN(ALIGNMENT) uint8_t dst[RATE];
size_t i;
Expand Down Expand Up @@ -180,7 +182,7 @@ static int
decrypt_detached(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *mac, size_t maclen,
const uint8_t *ad, size_t adlen, const uint8_t *npub, const uint8_t *k)
{
aes_block_t state[8];
aegis_blocks state;
CRYPTO_ALIGN(ALIGNMENT) uint8_t src[RATE];
CRYPTO_ALIGN(ALIGNMENT) uint8_t dst[RATE];
CRYPTO_ALIGN(16) uint8_t computed_mac[32];
Expand Down Expand Up @@ -232,7 +234,7 @@ decrypt_detached(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *mac,
static void
stream(uint8_t *out, size_t len, const uint8_t *npub, const uint8_t *k)
{
aes_block_t state[8];
aegis_blocks state;
CRYPTO_ALIGN(ALIGNMENT) uint8_t src[RATE];
CRYPTO_ALIGN(ALIGNMENT) uint8_t dst[RATE];
size_t i;
Expand All @@ -257,7 +259,7 @@ static void
encrypt_unauthenticated(uint8_t *c, const uint8_t *m, size_t mlen, const uint8_t *npub,
const uint8_t *k)
{
aes_block_t state[8];
aegis_blocks state;
CRYPTO_ALIGN(ALIGNMENT) uint8_t src[RATE];
CRYPTO_ALIGN(ALIGNMENT) uint8_t dst[RATE];
size_t i;
Expand All @@ -279,7 +281,7 @@ static void
decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t *npub,
const uint8_t *k)
{
aes_block_t state[8];
aegis_blocks state;
const size_t mlen = clen;
size_t i;

Expand All @@ -293,8 +295,6 @@ decrypt_unauthenticated(uint8_t *m, const uint8_t *c, size_t clen, const uint8_t
}
}

typedef aes_block_t aegis_blocks[8];

typedef struct _aegis128l_state {
aegis_blocks blocks;
uint8_t buf[RATE];
Expand Down

0 comments on commit 79c41cc

Please sign in to comment.