On 17.06.26 11:48, Harald Freudenberger wrote:
Support the subfunctions CPACF_KMCTR_AES_128, CPACF_KMCTR_AES_192
and CPACF_KMCTR_AES_256 for the cpacf kmctr instruction.
Signed-off-by: Harald Freudenberger <[email protected]>
With the one typo fixed:
Reviewed-by: Finn Callies <[email protected]>
---
target/s390x/gen-features.c | 3 ++
target/s390x/tcg/cpacf.h | 5 +++
target/s390x/tcg/cpacf_aes.c | 76 ++++++++++++++++++++++++++++++++
target/s390x/tcg/crypto_helper.c | 24 ++++++++++
4 files changed, 108 insertions(+)
[ snip ]
diff --git a/target/s390x/tcg/cpacf_aes.c b/target/s390x/tcg/cpacf_aes.c
index 6412cc187d..e200a9a87a 100644
--- a/target/s390x/tcg/cpacf_aes.c
+++ b/target/s390x/tcg/cpacf_aes.c
@@ -213,3 +213,79 @@ int cpacf_aes_cbc(CPUS390XState *env, const int mmu_idx,
uintptr_t ra,
[ snip ]
+ /* process up to MAX_BLOCKS_PER_RUN aes blocks */
+ for (i = 0; i < MAX_BLOCKS_PER_RUN && len >= AES_BLOCK_SIZE; i++) {
+ /* read in nonce/ctr => ctr */
+ aes_read_block(env, mmu_idx, *ctr_ptr_reg + done, ctr, ra);
+ /* encrypt ctr => buf */
+ AES_encrypt(ctr, buf, &exkey);
+ /* read in one block of input data => in */
+ aes_read_block(env, mmu_idx, *src_ptr_reg + done, in, ra);
+ /* exor input data with encrypted ctr => out */
typo: exor -> xor
+ aes_xor(in, buf, out);
+ /* write out the processed block */
+ aes_write_block(env, mmu_idx, *dst_ptr_reg + done, out, ra);
+ len -= AES_BLOCK_SIZE, done += AES_BLOCK_SIZE;
+ }
[ snip ]