[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 28/35] crypto: Add aesdec_ISB_ISR_AK_IMC
From: |
Richard Henderson |
Subject: |
[PATCH 28/35] crypto: Add aesdec_ISB_ISR_AK_IMC |
Date: |
Fri, 2 Jun 2023 19:34:19 -0700 |
Add a primitive for InvSubBytes + InvShiftRows +
AddRoundKey + InvMixColumns.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
host/include/generic/host/aes-round.h | 4 ++++
include/crypto/aes-round.h | 21 +++++++++++++++++++++
crypto/aes.c | 20 ++++++++++++++++++++
3 files changed, 45 insertions(+)
diff --git a/host/include/generic/host/aes-round.h
b/host/include/generic/host/aes-round.h
index 848436379d..84f82e53d8 100644
--- a/host/include/generic/host/aes-round.h
+++ b/host/include/generic/host/aes-round.h
@@ -25,6 +25,10 @@ void aesdec_IMC_accel(AESState *, const AESState *, bool)
void aesdec_ISB_ISR_accel(AESState *, const AESState *, bool)
QEMU_ERROR("unsupported accel");
+void aesdec_ISB_ISR_AK_IMC_accel(AESState *, const AESState *,
+ const AESState *, bool)
+ QEMU_ERROR("unsupported accel");
+
void aesdec_ISB_ISR_IMC_AK_accel(AESState *, const AESState *,
const AESState *, bool)
QEMU_ERROR("unsupported accel");
diff --git a/include/crypto/aes-round.h b/include/crypto/aes-round.h
index 352687ce11..b48b87671c 100644
--- a/include/crypto/aes-round.h
+++ b/include/crypto/aes-round.h
@@ -113,6 +113,27 @@ static inline void aesdec_IMC(AESState *r, const AESState
*st, bool be)
}
}
+/*
+ * Perform InvSubBytes + InvShiftRows + AddRoundKey + InvMixColumns.
+ */
+
+void aesdec_ISB_ISR_AK_IMC_gen(AESState *ret, const AESState *st,
+ const AESState *rk);
+void aesdec_ISB_ISR_AK_IMC_genrev(AESState *ret, const AESState *st,
+ const AESState *rk);
+
+static inline void aesdec_ISB_ISR_AK_IMC(AESState *r, const AESState *st,
+ const AESState *rk, bool be)
+{
+ if (HAVE_AES_ACCEL) {
+ aesdec_ISB_ISR_AK_IMC_accel(r, st, rk, be);
+ } else if (HOST_BIG_ENDIAN == be) {
+ aesdec_ISB_ISR_AK_IMC_gen(r, st, rk);
+ } else {
+ aesdec_ISB_ISR_AK_IMC_genrev(r, st, rk);
+ }
+}
+
/*
* Perform InvSubBytes + InvShiftRows + InvMixColumns + AddRoundKey.
*/
diff --git a/crypto/aes.c b/crypto/aes.c
index 1696086868..c0e4bc5580 100644
--- a/crypto/aes.c
+++ b/crypto/aes.c
@@ -1571,6 +1571,26 @@ void aesdec_ISB_ISR_IMC_AK_genrev(AESState *r, const
AESState *st,
aesdec_ISB_ISR_IMC_AK_swap(r, st, rk, true);
}
+void aesdec_ISB_ISR_AK_IMC_gen(AESState *r, const AESState *st,
+ const AESState *rk)
+{
+ AESState t;
+
+ aesdec_ISB_ISR_gen(&t, st);
+ t.v ^= rk->v;
+ aesdec_IMC_gen(r, &t);
+}
+
+void aesdec_ISB_ISR_AK_IMC_genrev(AESState *r, const AESState *st,
+ const AESState *rk)
+{
+ AESState t;
+
+ aesdec_ISB_ISR_genrev(&t, st);
+ t.v ^= rk->v;
+ aesdec_IMC_genrev(r, &t);
+}
+
/**
* Expand the cipher key into the encryption key schedule.
*/
--
2.34.1
- Re: [PATCH 31/35] host/include/aarch64: Implement aes-round.h, (continued)
- [PATCH 16/35] target/arm: Use aesenc_MC, Richard Henderson, 2023/06/02
- [PATCH 34/35] crypto: Remove AES_imc, Richard Henderson, 2023/06/02
- [PATCH 35/35] crypto: Unexport AES_*_rot, AES_TeN, AES_TdN, Richard Henderson, 2023/06/02
- [PATCH 18/35] target/i386: Use aesdec_IMC, Richard Henderson, 2023/06/02
- [PATCH 20/35] target/riscv: Use aesdec_IMC, Richard Henderson, 2023/06/02
- [PATCH 22/35] target/i386: Use aesenc_SB_SR_MC_AK, Richard Henderson, 2023/06/02
- [PATCH 19/35] target/arm: Use aesdec_IMC, Richard Henderson, 2023/06/02
- [PATCH 29/35] target/ppc: Use aesdec_ISB_ISR_AK_IMC, Richard Henderson, 2023/06/02
- [PATCH 32/35] crypto: Remove AES_shifts, AES_ishifts, Richard Henderson, 2023/06/02
- [PATCH 28/35] crypto: Add aesdec_ISB_ISR_AK_IMC,
Richard Henderson <=
- [PATCH 33/35] crypto: Implement aesdec_IMC with AES_imc_rot, Richard Henderson, 2023/06/02
- Re: [PATCH 00/35] crypto: Provide aes-round.h and host accel, Ard Biesheuvel, 2023/06/03