hw/misc: implement ESP32-C3 HMAC

Added an internal HMAC implementation using the existing internal SHA APIs
This commit is contained in:
harshal.patil
2023-07-11 15:43:11 +05:30
committed by Ivan Grokhotkov
parent e23b18cfc2
commit f7ade96f03
3 changed files with 61 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
/*
* ESP32-C3 HMAC 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/esp32c3_hmac.h"
static void esp32c3_hmac_class_init(ObjectClass *klass, void *data)
{
ESPHmacClass *class = ESP_HMAC_CLASS(klass);
class->date = ESP32C3_HMAC_DATE_REG_VALUE;
}
static const TypeInfo esp32c3_hmac_info = {
.name = TYPE_ESP32C3_HMAC,
.parent = TYPE_ESP_HMAC,
.instance_size = sizeof(ESP32C3HmacState),
.class_init = esp32c3_hmac_class_init,
.class_size = sizeof(ESP32C3HmacClass)
};
static void esp32c3_hmac_register_types(void)
{
type_register_static(&esp32c3_hmac_info);
}
type_init(esp32c3_hmac_register_types)
+2
View File
@@ -154,6 +154,8 @@ system_ss.add(when: 'CONFIG_RISCV_ESP32C3', if_true: files(
'esp32c3_sha.c',
'esp32c3_jtag.c',
'esp32c3_rtc_cntl.c',
'esp_hmac.c',
'esp32c3_hmac.c'
))
if gcrypt.found()
system_ss.add(when: [gcrypt, 'CONFIG_XTENSA_ESP32'], if_true: files(
+26
View File
@@ -0,0 +1,26 @@
/*
* ESP32-C3 HMAC 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.
*/
#pragma once
#include "hw/misc/esp_hmac.h"
#define TYPE_ESP32C3_HMAC "misc.esp32c3.hmac"
#define ESP32C3_HMAC(obj) OBJECT_CHECK(ESP32C3HmacState, (obj), TYPE_ESP32C3_HMAC)
#define ESP32C3_HMAC_DATE_REG_VALUE 0x20200618
typedef struct ESP32C3HmacState {
ESPHmacState parent;
} ESP32C3HmacState;
typedef struct ESP32C3HmacClass {
ESPHmacClass parent_class;
} ESP32C3HmacClass;