Commit b6e2c05c authored by Niels Möller's avatar Niels Möller
Browse files

* aes-internal.h (AES_SMALL): New macro.

Rev: src/nettle/aes-internal.h:1.3
Rev: src/nettle/aes-tables.c:1.3
parent 8bcb01bf
...@@ -28,6 +28,11 @@ ...@@ -28,6 +28,11 @@
#include "aes.h" #include "aes.h"
/* Define to use only small tables. */
#ifndef AES_SMALL
# define AES_SMALL 1
#endif
/* Macros */ /* Macros */
#define ROTBYTE(x) (((x) >> 8) | (((x) & 0xff) << 24)) #define ROTBYTE(x) (((x) >> 8) | (((x) & 0xff) << 24))
#define ROTRBYTE(x) (((x) << 8) | (((x) >> 24) & 0xff)) #define ROTRBYTE(x) (((x) << 8) | (((x) >> 24) & 0xff))
...@@ -37,13 +42,20 @@ ...@@ -37,13 +42,20 @@
((box)[(((x) >> 24) & 0xff)] << 24)) ((box)[(((x) >> 24) & 0xff)] << 24))
/* Don't pollute global namespace too much */ /* Don't pollute global namespace too much */
#define dtbl _aes_dtbl #if AES_SMALL
# define dtbl _aes_dtbl_small
# define _AES_TABLE_SIZE 1
#else
# define dtbl _aes_dtbl
# define _AES_TABLE_SIZE 4
#endif
#define itbl _aes_itbl #define itbl _aes_itbl
#define sbox _aes_sbox #define sbox _aes_sbox
#define isbox _aes_isbox #define isbox _aes_isbox
/* Internal tables */ /* Internal tables */
extern const uint32_t dtbl[4][0x100]; extern const uint32_t dtbl[_AES_TABLE_SIZE][0x100];
extern const uint32_t itbl[]; extern const uint32_t itbl[];
extern const uint8_t sbox[0x100]; extern const uint8_t sbox[0x100];
extern const uint8_t isbox[0x100]; extern const uint8_t isbox[0x100];
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
* consistent with the row numbering. */ * consistent with the row numbering. */
const uint32_t const uint32_t
dtbl[4][0x100] = dtbl[_AES_TABLE_SIZE][0x100] =
{ {
{ {
0xa56363c6,0x847c7cf8,0x997777ee,0x8d7b7bf6, 0xa56363c6,0x847c7cf8,0x997777ee,0x8d7b7bf6,
...@@ -106,7 +106,9 @@ dtbl[4][0x100] = ...@@ -106,7 +106,9 @@ dtbl[4][0x100] =
0xdabfbf65,0x31e6e6d7,0xc6424284,0xb86868d0, 0xdabfbf65,0x31e6e6d7,0xc6424284,0xb86868d0,
0xc3414182,0xb0999929,0x772d2d5a,0x110f0f1e, 0xc3414182,0xb0999929,0x772d2d5a,0x110f0f1e,
0xcbb0b07b,0xfc5454a8,0xd6bbbb6d,0x3a16162c, 0xcbb0b07b,0xfc5454a8,0xd6bbbb6d,0x3a16162c,
},{ },
#if !AES_SMALL
{
0x6363c6a5,0x7c7cf884,0x7777ee99,0x7b7bf68d, 0x6363c6a5,0x7c7cf884,0x7777ee99,0x7b7bf68d,
0xf2f2ff0d,0x6b6bd6bd,0x6f6fdeb1,0xc5c59154, 0xf2f2ff0d,0x6b6bd6bd,0x6f6fdeb1,0xc5c59154,
0x30306050,0x01010203,0x6767cea9,0x2b2b567d, 0x30306050,0x01010203,0x6767cea9,0x2b2b567d,
...@@ -302,6 +304,7 @@ dtbl[4][0x100] = ...@@ -302,6 +304,7 @@ dtbl[4][0x100] =
0x82c34141,0x29b09999,0x5a772d2d,0x1e110f0f, 0x82c34141,0x29b09999,0x5a772d2d,0x1e110f0f,
0x7bcbb0b0,0xa8fc5454,0x6dd6bbbb,0x2c3a1616, 0x7bcbb0b0,0xa8fc5454,0x6dd6bbbb,0x2c3a1616,
}, },
#endif /* !AES_SMALL */
}; };
/* These tables combine both the S-boxes and the mixcolumn /* These tables combine both the S-boxes and the mixcolumn
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment