diff --git a/hw/misc/esp32s3_ds.c b/hw/misc/esp32s3_ds.c new file mode 100644 index 0000000000..7cc7ff36dd --- /dev/null +++ b/hw/misc/esp32s3_ds.c @@ -0,0 +1,34 @@ +/* + * ESP32S3 Digital Signature emulation + * + * Copyright (c) 2023 Espressif Systems (Shanghai) Co. Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 or + * (at your option) any later version. + */ + +#include "qemu/osdep.h" +#include "hw/misc/esp32s3_ds.h" + +static void esp32s3_ds_class_init(ObjectClass *klass, void *data) +{ + ESPDsClass* class = ESP_DS_CLASS(klass); + class->mem_blk_size = ESP32S3_DS_MEM_BLK_SIZE; + class->date = ESP32S3_DS_DATE_REG_VALUE; +} + +static const TypeInfo esp32s3_ds_info = { + .name = TYPE_ESP32S3_DS, + .parent = TYPE_ESP_DS, + .instance_size = sizeof(ESP32S3DsState), + .class_init = esp32s3_ds_class_init, + .class_size = sizeof(ESP32S3DsClass) +}; + +static void esp32s3_ds_register_types(void) +{ + type_register_static(&esp32s3_ds_info); +} + +type_init(esp32s3_ds_register_types) diff --git a/hw/misc/meson.build b/hw/misc/meson.build index a09d3be2ac..d27517c868 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -189,6 +189,8 @@ if gcrypt.found() 'esp32s3_aes.c', 'esp_rsa.c', 'esp32s3_rsa.c', + 'esp_ds.c', + 'esp32s3_ds.c', )) endif diff --git a/include/hw/misc/esp32s3_ds.h b/include/hw/misc/esp32s3_ds.h new file mode 100644 index 0000000000..9753852595 --- /dev/null +++ b/include/hw/misc/esp32s3_ds.h @@ -0,0 +1,39 @@ +/* + * ESP32-C3 Digital Signature accelerator + * + * Copyright (c) 2023 Espressif Systems (Shanghai) Co. Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 or + * (at your option) any later version. + */ + +#pragma once + +#include "hw/misc/esp_ds.h" + +#define TYPE_ESP32S3_DS "misc.esp32s3.ds" +#define ESP32S3_DS(obj) OBJECT_CHECK(ESP32S3DsState, (obj), TYPE_ESP32S3_DS) + +#define ESP32S3_DS_MEM_BLK_SIZE 512 +#define ESP32S3_DS_DATE_REG_VALUE 0x20191217 + +#define ESP32S3_DS_CIPHERTEXT_SIZE (ESP32S3_DS_MEM_BLK_SIZE + \ + ESP32S3_DS_MEM_BLK_SIZE + \ + ESP32S3_DS_MEM_BLK_SIZE + \ + ESP_DS_BOX_MEM_BLK_SIZE) + +#define ESP32S3_DS_CALC_MD_SIZE (ESP32S3_DS_MEM_BLK_SIZE + \ + ESP32S3_DS_MEM_BLK_SIZE + \ + ESP32S3_DS_MEM_BLK_SIZE + \ + ESP_DS_MPRIME_SIZE + \ + ESP_DS_L_SIZE + \ + ESP_DS_IV_SIZE) + +typedef struct ESP32S3DsState { + ESPDsState parent; +} ESP32S3DsState; + +typedef struct ESP32S3DsClass { + ESPDsClass parent_class; +} ESP32S3DsClass;