]> git.proxmox.com Git - mirror_qemu.git/blob - include/crypto/aes-round.h
crypto: Add aesdec_ISB_ISR_AK
[mirror_qemu.git] / include / crypto / aes-round.h
1 /*
2 * AES round fragments, generic version
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 *
5 * Copyright (C) 2023 Linaro, Ltd.
6 */
7
8 #ifndef CRYPTO_AES_ROUND_H
9 #define CRYPTO_AES_ROUND_H
10
11 /* Hosts with acceleration will usually need a 16-byte vector type. */
12 typedef uint8_t AESStateVec __attribute__((vector_size(16)));
13
14 typedef union {
15 uint8_t b[16];
16 uint32_t w[4];
17 uint64_t d[2];
18 AESStateVec v;
19 } AESState;
20
21 #include "host/crypto/aes-round.h"
22
23 /*
24 * Perform SubBytes + ShiftRows + AddRoundKey.
25 */
26
27 void aesenc_SB_SR_AK_gen(AESState *ret, const AESState *st,
28 const AESState *rk);
29 void aesenc_SB_SR_AK_genrev(AESState *ret, const AESState *st,
30 const AESState *rk);
31
32 static inline void aesenc_SB_SR_AK(AESState *r, const AESState *st,
33 const AESState *rk, bool be)
34 {
35 if (HAVE_AES_ACCEL) {
36 aesenc_SB_SR_AK_accel(r, st, rk, be);
37 } else if (HOST_BIG_ENDIAN == be) {
38 aesenc_SB_SR_AK_gen(r, st, rk);
39 } else {
40 aesenc_SB_SR_AK_genrev(r, st, rk);
41 }
42 }
43
44 /*
45 * Perform InvSubBytes + InvShiftRows + AddRoundKey.
46 */
47
48 void aesdec_ISB_ISR_AK_gen(AESState *ret, const AESState *st,
49 const AESState *rk);
50 void aesdec_ISB_ISR_AK_genrev(AESState *ret, const AESState *st,
51 const AESState *rk);
52
53 static inline void aesdec_ISB_ISR_AK(AESState *r, const AESState *st,
54 const AESState *rk, bool be)
55 {
56 if (HAVE_AES_ACCEL) {
57 aesdec_ISB_ISR_AK_accel(r, st, rk, be);
58 } else if (HOST_BIG_ENDIAN == be) {
59 aesdec_ISB_ISR_AK_gen(r, st, rk);
60 } else {
61 aesdec_ISB_ISR_AK_genrev(r, st, rk);
62 }
63 }
64
65 #endif /* CRYPTO_AES_ROUND_H */