From 2c26651938e33161c763968f7a2de5c3c2461737 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Wed, 1 Mar 2023 11:18:20 +0800 Subject: [PATCH] Improve comments for key expansion Signed-off-by: Jerry Yu --- library/aesce.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/aesce.c b/library/aesce.c index 011c989979..e236d865ad 100644 --- a/library/aesce.c +++ b/library/aesce.c @@ -212,14 +212,14 @@ static void aesce_setkey_enc(unsigned char *rk, 0x20, 0x40, 0x80, 0x1b, 0x36 }; /* See https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197.pdf * - Section 5, Nr = Nk + 6 - * - Section 5.2, the key expansion size is Nb*(Nr+1) + * - Section 5.2, the length of round keys is Nb*(Nr+1) */ const uint32_t key_len_in_words = key_bit_length / 32; /* Nk */ const size_t round_key_len_in_words = 4; /* Nb */ - const size_t round_keys_needed = key_len_in_words + 6; /* Nr */ - const size_t key_expansion_size_in_words = - round_key_len_in_words * (round_keys_needed + 1); /* Nb*(Nr+1) */ - const uint32_t *rko_end = (uint32_t *) rk + key_expansion_size_in_words; + const size_t rounds_needed = key_len_in_words + 6; /* Nr */ + const size_t round_keys_len_in_words = + round_key_len_in_words * (rounds_needed + 1); /* Nb*(Nr+1) */ + const uint32_t *rko_end = (uint32_t *) rk + round_keys_len_in_words; memcpy(rk, key, key_len_in_words * 4);