From 153537437bb5b940b26afb2e1261aff3e704dbbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Wed, 15 May 2002 22:17:35 +0200 Subject: [PATCH] * aes-internal.h (struct aes_table): Renamed the shift_idx field to sparc_idx, as it will be tweaked to improve the sparc code. Also reduced its size to [2][4]. (IDX_FACTOR): Deleted constant. * aes-encrypt-table.c (_aes_encrypt_table): Adapted initializer of sparc_idx. * aes-decrypt-table.c (_aes_decrypt_table): Likewise. * asm.m4: Deleted AES_SIDX2, to match struct aes_table. Rev: src/nettle/aes-decrypt-table.c:1.2 Rev: src/nettle/aes-encrypt-table.c:1.2 Rev: src/nettle/aes-internal.h:1.7 Rev: src/nettle/asm.m4:1.9 --- aes-decrypt-table.c | 7 +++---- aes-encrypt-table.c | 7 +++---- aes-internal.h | 6 +++--- asm.m4 | 1 - 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/aes-decrypt-table.c b/aes-decrypt-table.c index a20ec7cc..e2f1efe8 100644 --- a/aes-decrypt-table.c +++ b/aes-decrypt-table.c @@ -66,10 +66,9 @@ _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 } }, + { /* sparc_idx, IDX1 and IDX3 shifted by the size of a word */ + { 12, 0, 4, 8 }, + { 4, 8, 12, 0 } }, { /* itable */ { 0x50a7f451,0x5365417e,0xc3a4171a,0x965e273a, diff --git a/aes-encrypt-table.c b/aes-encrypt-table.c index 1dea352e..73d59205 100644 --- a/aes-encrypt-table.c +++ b/aes-encrypt-table.c @@ -77,10 +77,9 @@ _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 } }, + { /* sparc_idx, IDX1 and IDX3 shifted by the size of a word */ + { 4, 8, 12, 0 }, + { 12, 0, 4, 8 } }, { /* dtable */ { 0xa56363c6,0x847c7cf8,0x997777ee,0x8d7b7bf6, diff --git a/aes-internal.h b/aes-internal.h index f063ff65..0fa8ed00 100644 --- a/aes-internal.h +++ b/aes-internal.h @@ -39,14 +39,14 @@ # 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]; + /* Variant of the idx array suitable for the sparc + * assembler code. */ + unsigned sparc_idx [2][4]; uint32_t table[AES_TABLE_SIZE][0x100]; }; diff --git a/asm.m4 b/asm.m4 index c3ab4d7b..36936c15 100644 --- a/asm.m4 +++ b/asm.m4 @@ -41,7 +41,6 @@ STRUCTURE(AES) STRUCT(IDX3, AES_IDX_SIZE) STRUCT(SIDX1, AES_IDX_SIZE) - STRUCT(SIDX2, AES_IDX_SIZE) STRUCT(SIDX3, AES_IDX_SIZE) STRUCT(TABLE0, AES_TABLE_SIZE) -- GitLab