mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 10:40:47 +03:00
change(esp_key_mgr): Store key_len field in the key_info
- Update the Key Manager key types to be generic - Define a new enum to determine the length of the keys - Refactor the Key Manager driver support generic key types and key lengths - Also store key deployment mode in the key recovery info
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@@ -92,7 +92,8 @@ static void key_mgr_test_xts_aes_128_aes_mode(void)
|
||||
memcpy(key_config.k1_encrypted, (uint8_t*) test_data_xts_aes_128.k1_encrypted, KEY_MGR_K1_ENCRYPTED_SIZE);
|
||||
memcpy(key_config.sw_init_key, (uint8_t*) test_data_xts_aes_128.init_key, KEY_MGR_SW_INIT_KEY_SIZE);
|
||||
key_config.use_pre_generated_sw_init_key = 1;
|
||||
key_config.key_type = ESP_KEY_MGR_XTS_AES_128_KEY;
|
||||
key_config.key_type = ESP_KEY_MGR_FLASH_XTS_AES_KEY;
|
||||
key_config.key_len = ESP_KEY_MGR_XTS_AES_LEN_128;
|
||||
|
||||
static esp_key_mgr_key_recovery_info_t key_recovery_info;
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_aes_mode(&key_config, &key_recovery_info));
|
||||
@@ -105,7 +106,8 @@ static void key_mgr_test_xts_aes_128_ecdh0_mode(void)
|
||||
{
|
||||
static esp_key_mgr_ecdh0_key_config_t key_config;
|
||||
memcpy(key_config.k1_G[0], (uint8_t*) test_data_ecdh0.k1_G[0], KEY_MGR_ECDH0_INFO_SIZE);
|
||||
key_config.key_type = ESP_KEY_MGR_XTS_AES_128_KEY;
|
||||
key_config.key_type = ESP_KEY_MGR_FLASH_XTS_AES_KEY;
|
||||
key_config.key_len = ESP_KEY_MGR_XTS_AES_LEN_128;
|
||||
|
||||
static esp_key_mgr_key_recovery_info_t key_recovery_info;
|
||||
static esp_key_mgr_ecdh0_info_t ecdh0_info;
|
||||
@@ -128,7 +130,8 @@ static void key_mgr_test_xts_aes_256_aes_mode(void)
|
||||
memcpy(key_config.k1_encrypted[1], (uint8_t*) test_data_xts_aes_256.k1_encrypted[1], KEY_MGR_K1_ENCRYPTED_SIZE);
|
||||
memcpy(key_config.sw_init_key, (uint8_t*) test_data_xts_aes_256.init_key, KEY_MGR_SW_INIT_KEY_SIZE);
|
||||
key_config.use_pre_generated_sw_init_key = 1;
|
||||
key_config.key_type = ESP_KEY_MGR_XTS_AES_256_KEY;
|
||||
key_config.key_type = ESP_KEY_MGR_FLASH_XTS_AES_KEY;
|
||||
key_config.key_len = ESP_KEY_MGR_XTS_AES_LEN_256;
|
||||
|
||||
static esp_key_mgr_key_recovery_info_t key_recovery_info;
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_aes_mode(&key_config, &key_recovery_info));
|
||||
@@ -142,7 +145,8 @@ static void key_mgr_test_xts_aes_256_ecdh0_mode(void)
|
||||
static esp_key_mgr_ecdh0_key_config_t key_config;
|
||||
memcpy(key_config.k1_G[0], (uint8_t*) test_data_ecdh0.k1_G[0], KEY_MGR_ECDH0_INFO_SIZE);
|
||||
memcpy(key_config.k1_G[1], (uint8_t*) test_data_ecdh0.k1_G[1], KEY_MGR_ECDH0_INFO_SIZE);
|
||||
key_config.key_type = ESP_KEY_MGR_XTS_AES_256_KEY;
|
||||
key_config.key_type = ESP_KEY_MGR_FLASH_XTS_AES_KEY;
|
||||
key_config.key_len = ESP_KEY_MGR_XTS_AES_LEN_256;
|
||||
|
||||
static esp_key_mgr_key_recovery_info_t key_recovery_info;
|
||||
static esp_key_mgr_ecdh0_info_t ecdh0_info;
|
||||
@@ -177,7 +181,8 @@ static void test_xts_aes_key_random_mode(void)
|
||||
static void key_mgr_test_xts_aes_128_random_mode(void)
|
||||
{
|
||||
static esp_key_mgr_random_key_config_t key_config;
|
||||
key_config.key_type = ESP_KEY_MGR_XTS_AES_128_KEY;
|
||||
key_config.key_type = ESP_KEY_MGR_FLASH_XTS_AES_KEY;
|
||||
key_config.key_len = ESP_KEY_MGR_XTS_AES_LEN_128;
|
||||
|
||||
static esp_key_mgr_key_recovery_info_t key_recovery_info;
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_random_mode(&key_config, &key_recovery_info));
|
||||
@@ -191,7 +196,8 @@ static void key_mgr_test_xts_aes_128_random_mode(void)
|
||||
static void key_mgr_test_xts_aes_256_random_mode(void)
|
||||
{
|
||||
static esp_key_mgr_random_key_config_t key_config;
|
||||
key_config.key_type = ESP_KEY_MGR_XTS_AES_256_KEY;
|
||||
key_config.key_type = ESP_KEY_MGR_FLASH_XTS_AES_KEY;
|
||||
key_config.key_len = ESP_KEY_MGR_XTS_AES_LEN_256;
|
||||
|
||||
static esp_key_mgr_key_recovery_info_t key_recovery_info;
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_random_mode(&key_config, &key_recovery_info));
|
||||
@@ -257,7 +263,8 @@ static void key_mgr_test_ecdsa_p256_aes_mode(void)
|
||||
memcpy(key_config.k1_encrypted, (uint8_t*) test_data_ecdsa.k1_encrypted, KEY_MGR_K1_ENCRYPTED_SIZE);
|
||||
memcpy(key_config.sw_init_key, (uint8_t*) test_data_ecdsa.init_key, KEY_MGR_SW_INIT_KEY_SIZE);
|
||||
key_config.use_pre_generated_sw_init_key = 1;
|
||||
key_config.key_type = ESP_KEY_MGR_ECDSA_256_KEY;
|
||||
key_config.key_type = ESP_KEY_MGR_ECDSA_KEY;
|
||||
key_config.key_len = ESP_KEY_MGR_ECDSA_LEN_256;
|
||||
|
||||
static esp_key_mgr_key_recovery_info_t key_recovery_info;
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_aes_mode(&key_config, &key_recovery_info));
|
||||
@@ -274,7 +281,8 @@ static void key_mgr_test_ecdsa_ecdh0_mode(void)
|
||||
{
|
||||
static esp_key_mgr_ecdh0_key_config_t key_config;
|
||||
memcpy(key_config.k1_G[0], (uint8_t*) test_data_ecdh0.k1_G[0], KEY_MGR_ECDH0_INFO_SIZE);
|
||||
key_config.key_type = ESP_KEY_MGR_ECDSA_256_KEY;
|
||||
key_config.key_type = ESP_KEY_MGR_ECDSA_KEY;
|
||||
key_config.key_len = ESP_KEY_MGR_ECDSA_LEN_256;
|
||||
|
||||
static esp_key_mgr_key_recovery_info_t key_recovery_info;
|
||||
static esp_key_mgr_ecdh0_info_t ecdh0_info;
|
||||
@@ -292,7 +300,8 @@ static void key_mgr_test_ecdsa_ecdh0_mode(void)
|
||||
static void key_mgr_test_ecdsa_random_mode(void)
|
||||
{
|
||||
static esp_key_mgr_random_key_config_t key_config;
|
||||
key_config.key_type = ESP_KEY_MGR_ECDSA_256_KEY;
|
||||
key_config.key_type = ESP_KEY_MGR_ECDSA_KEY;
|
||||
key_config.key_len = ESP_KEY_MGR_ECDSA_LEN_256;
|
||||
|
||||
static esp_key_mgr_key_recovery_info_t key_recovery_info;
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_random_mode(&key_config, &key_recovery_info));
|
||||
|
||||
Reference in New Issue
Block a user