Skip to content

Commit

Permalink
crypto: Add aesdec_ISB_ISR_AK_IMC
Browse files Browse the repository at this point in the history
Add a primitive for InvSubBytes + InvShiftRows +
AddRoundKey + InvMixColumns.

Acked-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Jul 8, 2023
1 parent 15ff159 commit 28e9147
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crypto/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,20 @@ 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 *ret, const AESState *st,
const AESState *rk)
{
aesdec_ISB_ISR_AK_gen(ret, st, rk);
aesdec_IMC_gen(ret, ret);
}

void aesdec_ISB_ISR_AK_IMC_genrev(AESState *ret, const AESState *st,
const AESState *rk)
{
aesdec_ISB_ISR_AK_genrev(ret, st, rk);
aesdec_IMC_genrev(ret, ret);
}

/**
* Expand the cipher key into the encryption key schedule.
*/
Expand Down
3 changes: 3 additions & 0 deletions host/include/generic/host/crypto/aes-round.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ void aesdec_IMC_accel(AESState *, const AESState *, bool)
void aesdec_ISB_ISR_AK_accel(AESState *, const 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");
Expand Down
21 changes: 21 additions & 0 deletions include/crypto/aes-round.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,27 @@ static inline void aesdec_ISB_ISR_AK(AESState *r, const AESState *st,
}
}

/*
* 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.
*/
Expand Down

0 comments on commit 28e9147

Please sign in to comment.