diff --git a/aes-decrypt-table.c b/aes-decrypt-table.c index a20ec7cc1bf519003fd7c338b8d83fd2bfbd5ed3..e2f1efe895147f2acdc50efc3f63489bceae536c 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 1dea352eba1a8fa77dde81ed970fe464bcf6b3d5..73d592058901ba0c60a01491a054ec0bef3069f8 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 f063ff6594a0e5be2e4ebb2eb25367a022331865..0fa8ed00d6b22fc0401cbd02d673d3d98a532c5a 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 c3ab4d7b0e252e5bfe836795ab293ac74c4ba100..36936c150e23d90311e9efba168812238b7453fd 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)