From: Niels Möller Date: Fri, 15 Feb 2002 13:20:09 +0000 (+0100) Subject: (struct aes_table): New subtable idx_shift. X-Git-Tag: nettle_1.6_release_20021003~305 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3833d1e0e2d021a545a7ed7bb064f2d51cbf2dd;p=thirdparty%2Fnettle.git (struct aes_table): New subtable idx_shift. Updated tables in aes_encrypt.c and aes_decrypt.c. Rev: src/nettle/aes-decrypt.c:1.2 Rev: src/nettle/aes-encrypt.c:1.2 Rev: src/nettle/aes-internal.h:1.6 --- diff --git a/aes-decrypt.c b/aes-decrypt.c index a81987a7..ac5d0f41 100644 --- a/aes-decrypt.c +++ b/aes-decrypt.c @@ -68,6 +68,10 @@ _aes_decrypt_table = { 3, 0, 1, 2 }, { 2, 3, 0, 1 }, { 1, 2, 3, 0 } }, + { /* idx_shift */ + { 3 * IDX_FACTOR, 0 * IDX_FACTOR, 1 * IDX_FACTOR, 2 * IDX_FACTOR }, + { 2 * IDX_FACTOR, 3 * IDX_FACTOR, 0 * IDX_FACTOR, 1 * IDX_FACTOR }, + { 1 * IDX_FACTOR, 2 * IDX_FACTOR, 3 * IDX_FACTOR, 0 * IDX_FACTOR } }, { /* itable */ { 0x50a7f451,0x5365417e,0xc3a4171a,0x965e273a, diff --git a/aes-encrypt.c b/aes-encrypt.c index 940b9f3d..30511793 100644 --- a/aes-encrypt.c +++ b/aes-encrypt.c @@ -79,6 +79,10 @@ _aes_encrypt_table = { 1, 2, 3, 0 }, { 2, 3, 0, 1 }, { 3, 0, 1, 2 } }, + { /* idx_shift */ + { 1 * IDX_FACTOR, 2 * IDX_FACTOR, 3 * IDX_FACTOR, 0 * IDX_FACTOR }, + { 2 * IDX_FACTOR, 3 * IDX_FACTOR, 0 * IDX_FACTOR, 1 * IDX_FACTOR }, + { 3 * IDX_FACTOR, 0 * IDX_FACTOR, 1 * IDX_FACTOR, 2 * IDX_FACTOR } }, { /* dtable */ { 0xa56363c6,0x847c7cf8,0x997777ee,0x8d7b7bf6, diff --git a/aes-internal.h b/aes-internal.h index da1dacdf..f063ff65 100644 --- a/aes-internal.h +++ b/aes-internal.h @@ -39,10 +39,15 @@ # define AES_TABLE_SIZE 4 #endif +#define IDX_FACTOR 4 struct aes_table { uint8_t sbox[0x100]; unsigned idx[3][4]; + + /* Preshifted indices, multiplied by IDX_FACTOR */ + unsigned idx_shift[3][4]; + uint32_t table[AES_TABLE_SIZE][0x100]; };