util: Add AES ShiftRows and InvShiftRows Tables
authorTom Musta <tommusta@gmail.com>
Thu, 13 Mar 2014 14:13:26 +0000 (09:13 -0500)
committerAlexander Graf <agraf@suse.de>
Mon, 16 Jun 2014 11:24:33 +0000 (13:24 +0200)
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 <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
include/qemu/aes.h
util/aes.c

index a4044f52c786894be8253bb8332857499e010436..c45bc5746776388aa02d2645fcc4d9179a609cda 100644 (file)
@@ -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];
index eeb644b6ca94fb0ed765f1c65e5690379f9b9da5..c26cf55f593dc374a83378b91be4927a3b850201 100644 (file)
@@ -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];