summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkokke <spam@rowdy.dk>2017-07-13 10:38:03 +0200
committerGitHub <noreply@github.com>2017-07-13 10:38:03 +0200
commit268d40d97c9866778e0ce6b844b26b288c6f0909 (patch)
treefd07538abe2ebe634a3553194ba7f070e1429ba9
parentUpdate README.md (diff)
downloadtiny-AES-c-268d40d97c9866778e0ce6b844b26b288c6f0909.tar
tiny-AES-c-268d40d97c9866778e0ce6b844b26b288c6f0909.tar.gz
tiny-AES-c-268d40d97c9866778e0ce6b844b26b288c6f0909.tar.bz2
tiny-AES-c-268d40d97c9866778e0ce6b844b26b288c6f0909.tar.lz
tiny-AES-c-268d40d97c9866778e0ce6b844b26b288c6f0909.tar.xz
tiny-AES-c-268d40d97c9866778e0ce6b844b26b288c6f0909.tar.zst
tiny-AES-c-268d40d97c9866778e0ce6b844b26b288c6f0909.zip
-rw-r--r--aes.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/aes.c b/aes.c
index b550ff6..c609c1f 100644
--- a/aes.c
+++ b/aes.c
@@ -131,6 +131,21 @@ static const uint8_t rsbox[256] = {
// The round constant word array, Rcon[i], contains the values given by
// x to th e power (i-1) being powers of x (x is denoted as {02}) in the field GF(2^8)
+static const uint8_t Rcon[11] = {
+ 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 };
+
+/*
+ * Jordan Goulder points out in PR #12 (https://github.com/kokke/tiny-AES128-C/pull/12),
+ * that you can remove most of the elements in the Rcon array, because they are unused.
+ *
+ * From Wikipedia's article on the Rijndael key schedule @ https://en.wikipedia.org/wiki/Rijndael_key_schedule#Rcon
+ *
+ * "Only the first some of these constants are actually used – up to rcon[10] for AES-128 (as 11 round keys are needed),
+ * up to rcon[8] for AES-192, up to rcon[7] for AES-256. rcon[0] is not used in AES algorithm."
+ *
+ * ... which is why the full array below has been 'disabled' below.
+ */
+#if 0
static const uint8_t Rcon[256] = {
0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a,
0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39,
@@ -148,7 +163,7 @@ static const uint8_t Rcon[256] = {
0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63,
0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd,
0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d };
-
+#endif
/*****************************************************************************/
/* Private functions: */