Received: from eggs.gnu.org ([2001:4830:134:3::10]:52954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsAZJ-0007sV-KH for qemu-devel@nongnu.org; Wed, 04 Jun 2014 08:45:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsAYx-0008Kv-JE for qemu-devel@nongnu.org; Wed, 04 Jun 2014 08:45:25 -0400 From: Alexander Graf Date: Wed, 4 Jun 2014 14:43:55 +0200 Message-Id: <1401885899-16524-55-git-send-email-agraf@suse.de> In-Reply-To: <1401885899-16524-1-git-send-email-agraf@suse.de> References: <1401885899-16524-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PULL 054/118] util: Add AES ShiftRows and InvShiftRows Tables List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-ppc@nongnu.org Cc: Tom Musta , qemu-devel@nongnu.org From: Tom Musta This patch adds tables that implement the Advanced Encryption Standard (AES) ShiftRows and InvShiftRows transformations. These are commonly used in instruction models. Signed-off-by: Tom Musta Reviewed-by: Richard Henderson Signed-off-by: Alexander Graf --- include/qemu/aes.h | 4 ++++ util/aes.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/include/qemu/aes.h b/include/qemu/aes.h index a4044f5..c45bc57 100644 --- a/include/qemu/aes.h +++ b/include/qemu/aes.h @@ -26,6 +26,10 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, extern const uint8_t AES_sbox[256]; extern const uint8_t AES_isbox[256]; +/* AES ShiftRows and InvShiftRows */ +extern const uint8_t AES_shifts[16]; +extern const uint8_t AES_ishifts[16]; + /* AES_Te0[x] = S [x].[02, 01, 01, 03]; AES_Te1[x] = S [x].[03, 02, 01, 01]; diff --git a/util/aes.c b/util/aes.c index eeb644b..c26cf55 100644 --- a/util/aes.c +++ b/util/aes.c @@ -108,6 +108,14 @@ const uint8_t AES_isbox[256] = { 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D, }; +const uint8_t AES_shifts[16] = { + 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11 +}; + +const uint8_t AES_ishifts[16] = { + 0, 13, 10, 7, 4, 1, 14, 11, 8, 5, 2, 15, 12, 9, 6, 3 +}; + /* AES_Te0[x] = S [x].[02, 01, 01, 03]; AES_Te1[x] = S [x].[03, 02, 01, 01]; -- 1.8.1.4