hw/vmapple/aes: Introduce aes engine

VMApple contains an "aes" engine device that it uses to encrypt and
decrypt its nvram. It has trivial hard coded keys it uses for that
purpose.

Add device emulation for this device model.

Signed-off-by: Alexander Graf <graf@amazon.com>
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-ID: <20241223221645.29911-10-phil@philjordan.eu>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
Alexander Graf 2023-06-14 22:56:25 +00:00 committed by Philippe Mathieu-Daudé
parent 11fa056e79
commit c960b38955
7 changed files with 650 additions and 0 deletions

View file

@ -15,6 +15,7 @@
#include "qemu/osdep.h"
#include "qemu/cutils.h"
#include "qemu/host-utils.h"
static inline char hexdump_nibble(unsigned x)
{
@ -97,3 +98,20 @@ void qemu_hexdump(FILE *fp, const char *prefix,
}
}
void qemu_hexdump_to_buffer(char *restrict buffer, size_t buffer_size,
const uint8_t *restrict data, size_t data_size)
{
size_t i;
uint64_t required_buffer_size;
bool overflow = umul64_overflow(data_size, 2, &required_buffer_size);
overflow |= uadd64_overflow(required_buffer_size, 1, &required_buffer_size);
assert(!overflow && buffer_size >= required_buffer_size);
for (i = 0; i < data_size; i++) {
uint8_t val = data[i];
*(buffer++) = hexdump_nibble(val >> 4);
*(buffer++) = hexdump_nibble(val & 0xf);
}
*buffer = '\0';
}