From d9a78842f6679d85103feebd86dc88b50c272e32 Mon Sep 17 00:00:00 2001 From: bing Date: Sat, 29 Jun 2024 20:03:01 +0800 Subject: [PATCH] doc comment for key expansion --- src/encryption/symmetric/aes/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/encryption/symmetric/aes/mod.rs b/src/encryption/symmetric/aes/mod.rs index 69efb8a..ae8007e 100644 --- a/src/encryption/symmetric/aes/mod.rs +++ b/src/encryption/symmetric/aes/mod.rs @@ -237,6 +237,13 @@ where [(); N / 8]: word } + /// Generates a key schedule based on a given cipher key `Key`, generating a total of + /// `Nb * (Nr + 1)` words, where Nb = size of block (in words), and Nr = number of rounds. + /// Nr is determined by the size `N` of the key. Every 4-word chunk from this output + /// is used as a round key. + /// + /// Key expansion ensures that each key used per round is different, introducing additional + /// complexity and diffusion. fn key_expansion(key: Key, expanded_key: &mut Vec, key_len: usize, num_rounds: usize) { let block_num_words = 128 / 32;