aboutsummaryrefslogtreecommitdiff
path: root/riscv/insns/aes64esm.h
diff options
context:
space:
mode:
Diffstat (limited to 'riscv/insns/aes64esm.h')
-rw-r--r--riscv/insns/aes64esm.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/riscv/insns/aes64esm.h b/riscv/insns/aes64esm.h
new file mode 100644
index 0000000..a41667b
--- /dev/null
+++ b/riscv/insns/aes64esm.h
@@ -0,0 +1,29 @@
+
+#include "aes_common.h"
+
+require_rv64;
+require_extension('K');
+
+uint64_t temp = AES_SHIFROWS_LO(RS1,RS2);
+
+ temp = (
+ ((uint64_t)AES_ENC_SBOX[(temp >> 0) & 0xFF] << 0) |
+ ((uint64_t)AES_ENC_SBOX[(temp >> 8) & 0xFF] << 8) |
+ ((uint64_t)AES_ENC_SBOX[(temp >> 16) & 0xFF] << 16) |
+ ((uint64_t)AES_ENC_SBOX[(temp >> 24) & 0xFF] << 24) |
+ ((uint64_t)AES_ENC_SBOX[(temp >> 32) & 0xFF] << 32) |
+ ((uint64_t)AES_ENC_SBOX[(temp >> 40) & 0xFF] << 40) |
+ ((uint64_t)AES_ENC_SBOX[(temp >> 48) & 0xFF] << 48) |
+ ((uint64_t)AES_ENC_SBOX[(temp >> 56) & 0xFF] << 56)
+);
+
+uint32_t col_0 = temp & 0xFFFFFFFF;
+uint32_t col_1 = temp >> 32 ;
+
+ col_0 = AES_MIXCOLUMN(col_0);
+ col_1 = AES_MIXCOLUMN(col_1);
+
+uint64_t result= ((uint64_t)col_1 << 32) | col_0;
+
+WRITE_RD(result);
+