diff --git a/components/bootloader_support/src/esp32c5/flash_encryption_secure_features.c b/components/bootloader_support/src/esp32c5/flash_encryption_secure_features.c index bc1aa83e37..7ccb0ef4e7 100644 --- a/components/bootloader_support/src/esp32c5/flash_encryption_secure_features.c +++ b/components/bootloader_support/src/esp32c5/flash_encryption_secure_features.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -71,12 +71,9 @@ esp_err_t esp_flash_encryption_enable_secure_features(void) esp_err_t esp_flash_encryption_enable_key_mgr(void) { - // Enable and reset key manager - // To suppress build errors about spinlock's __DECLARE_RCC_ATOMIC_ENV - int __DECLARE_RCC_ATOMIC_ENV __attribute__ ((unused)); - key_mgr_ll_enable_bus_clock(true); - key_mgr_ll_enable_peripheral_clock(true); - key_mgr_ll_reset_register(); + _key_mgr_ll_enable_bus_clock(true); + _key_mgr_ll_enable_peripheral_clock(true); + _key_mgr_ll_reset_register(); while (key_mgr_ll_get_state() != ESP_KEY_MGR_STATE_IDLE) { }; diff --git a/components/bootloader_support/src/esp32p4/flash_encryption_secure_features.c b/components/bootloader_support/src/esp32p4/flash_encryption_secure_features.c index 57cdd84b31..264188e0c2 100644 --- a/components/bootloader_support/src/esp32p4/flash_encryption_secure_features.c +++ b/components/bootloader_support/src/esp32p4/flash_encryption_secure_features.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -53,12 +53,9 @@ esp_err_t esp_flash_encryption_enable_secure_features(void) esp_err_t esp_flash_encryption_enable_key_mgr(void) { - // Enable and reset key manager - // To suppress build errors about spinlock's __DECLARE_RCC_ATOMIC_ENV - int __DECLARE_RCC_ATOMIC_ENV __attribute__ ((unused)); - key_mgr_ll_enable_bus_clock(true); - key_mgr_ll_enable_peripheral_clock(true); - key_mgr_ll_reset_register(); + _key_mgr_ll_enable_bus_clock(true); + _key_mgr_ll_enable_peripheral_clock(true); + _key_mgr_ll_reset_register(); while (key_mgr_ll_get_state() != ESP_KEY_MGR_STATE_IDLE) { }; diff --git a/components/esp_hw_support/include/esp_crypto_lock.h b/components/esp_hw_support/include/esp_crypto_lock.h index c17333700e..b399686819 100644 --- a/components/esp_hw_support/include/esp_crypto_lock.h +++ b/components/esp_hw_support/include/esp_crypto_lock.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/components/esp_hw_support/include/esp_hmac.h b/components/esp_hw_support/include/esp_hmac.h index c663aef2c6..566deea0d6 100644 --- a/components/esp_hw_support/include/esp_hmac.h +++ b/components/esp_hw_support/include/esp_hmac.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,6 +9,7 @@ #include #include "esp_err.h" #include "soc/soc_caps.h" +#include "hal/hmac_types.h" #if !SOC_HMAC_SUPPORTED && !CI_HEADER_CHECK #error "HMAC peripheral is not supported for the selected target" @@ -18,19 +19,6 @@ extern "C" { #endif -/** - * The possible efuse keys for the HMAC peripheral - */ -typedef enum { - HMAC_KEY0 = 0, - HMAC_KEY1, - HMAC_KEY2, - HMAC_KEY3, - HMAC_KEY4, - HMAC_KEY5, - HMAC_KEY_MAX -} hmac_key_id_t; - /** * @brief * Calculate the HMAC of a given message. diff --git a/components/esp_rom/esp32c5/include/esp32c5/rom/key_mgr.h b/components/esp_rom/esp32c5/include/esp32c5/rom/key_mgr.h new file mode 100644 index 0000000000..15be126268 --- /dev/null +++ b/components/esp_rom/esp32c5/include/esp32c5/rom/key_mgr.h @@ -0,0 +1,115 @@ +/* + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "soc/soc_caps.h" + +#if SOC_KEY_MANAGER_SUPPORTED + +#include "rom/ets_sys.h" +#include "esp_attr.h" +#include +#include "rom/km.h" + +#if __cplusplus +extern "C" { +#endif + +// store huk info, occupy 96 words +struct huk_info { +// store huk info, occupy 165 words +#define HUK_INFO_LEN 660 + + uint8_t info[HUK_INFO_LEN]; + uint32_t crc; +} PACKED_ATTR; + +// store key info, occupy 512 bits +struct key_info { +#define KEY_INFO_LEN 64 + uint8_t info[KEY_INFO_LEN]; + uint32_t crc; +} PACKED_ATTR; + +struct huk_key_block { +#define KEY_HUK_SECTOR_MAGIC 0xDEA5CE5A + uint32_t magic; + uint32_t version; // for backward compatibility + uint8_t reserved[16]; + struct huk_info huk_info; + struct key_info key_info[2]; // at most 2 key info (XTS-512_1 and XTS-512_2), at least use 1 +} WORD_ALIGNED_ATTR PACKED_ATTR; + +/* + * We define two info sectors "active" and "backup" here + * Most rom code would rely only on the "active" sector for the key information + * + * But there could be a situation where the huk and key information must be regenerated + * based on ageing and other factors. For that scenario, we need a "backup" sector + */ +#define KEY_HUK_SECTOR_OFFSET(i) ((i)*0x1000) +#define ACTIVE_SECTOR_OFFSET KEY_HUK_SECTOR_OFFSET(0) +#define BACKUP_SECTOR_OFFSET KEY_HUK_SECTOR_OFFSET(1) + +#define KM_PERI_ECDSA (BIT(0)) +#define KM_PERI_XTS (BIT(1)) + +struct km_deploy_ops { +#define KM_KEY_PURPOSE_ECDSA_KEY_192 1 +#define KM_KEY_PURPOSE_ECDSA_KEY_256 2 +#define KM_KEY_PURPOSE_FLASH_XTS_256_1 3 +#define KM_KEY_PURPOSE_FLASH_XTS_256_2 4 +#define KM_KEY_PURPOSE_FLASH_XTS_128 5 +#define KM_KEY_PURPOSE_HMAC 6 +#define KM_KEY_PURPOSE_DS 7 +#define KM_KEY_PURPOSE_PSRAM_XTS_256_1 8 +#define KM_KEY_PURPOSE_PSRAM_XTS_256_2 9 +#define KM_KEY_PURPOSE_PSRAM_XTS_128 10 +#define KM_KEY_PURPOSE_ECDSA_KEY_384_L 11 +#define KM_KEY_PURPOSE_ECDSA_KEY_384_H 12 + int km_key_purpose; +#define KM_DEPLOY_MODE_RANDOM 0 +#define KM_DEPLOY_MODE_AES 1 +#define KM_DEPLOY_MODE_ECDH0 2 +#define KM_DEPLOY_MODE_ECDH1 3 +#define KM_DEPLOY_MODE_RECOVER 4 +#define KM_DEPLOY_MODE_EXPORT 5 + int deploy_mode; + uint8_t *init_key; // 256 bits, only used in aes and ecdh1 deploy mode + int deploy_only_once; + int force_use_km_key; + int km_use_efuse_key; + uint32_t efuse_km_rnd_switch_cycle; // 0 means use default + uint32_t km_rnd_switch_cycle; // 0 means use default + int km_use_sw_init_key; + struct huk_info *huk_info; + struct key_info *key_info; +}; + +/* state of km */ +#define KM_STATE_IDLE 0 +#define KM_STATE_LOAD 1 +#define KM_STATE_GAIN 2 +#define KM_STATE_BUSY 3 +#define KM_STATE_INVALID 4 + +/* state of huk generator + * values defined same as km + */ +#define HUK_STATE_IDLE 0 +#define HUK_STATE_LOAD 1 +#define HUK_STATE_GAIN 2 +#define HUK_STATE_BUSY 3 + +#define HUK_NOT_GENERATED 0 +#define HUK_GEN_VALID 1 +#define HUK_GEN_INVALID 2 + +#if __cplusplus +} +#endif +#endif diff --git a/components/esp_security/include/esp_key_mgr.h b/components/esp_security/include/esp_key_mgr.h index e32e2acada..8c7d995148 100644 --- a/components/esp_security/include/esp_key_mgr.h +++ b/components/esp_security/include/esp_key_mgr.h @@ -22,7 +22,7 @@ extern "C" { #define KEY_MGR_ASSIST_INFO_SIZE 64 #define KEY_MGR_KEY_RECOVERY_INFO_SIZE 64 -#define KEY_MGR_HUK_INFO_SIZE HUK_INFO_SIZE +#define KEY_MGR_HUK_INFO_SIZE HUK_INFO_LEN #define KEY_MGR_HUK_RISK_ALERT_LEVEL HUK_RISK_ALERT_LEVEL /* AES deploy mode */ diff --git a/components/esp_security/src/esp_crypto_periph_clk.c b/components/esp_security/src/esp_crypto_periph_clk.c index a21a0f6487..a62c804b35 100644 --- a/components/esp_security/src/esp_crypto_periph_clk.c +++ b/components/esp_security/src/esp_crypto_periph_clk.c @@ -80,7 +80,10 @@ void esp_crypto_mpi_enable_periph_clk(bool enable) MPI_RCC_ATOMIC() { mpi_ll_enable_bus_clock(enable); if (enable) { + mpi_ll_power_up(); mpi_ll_reset_register(); + } else { + mpi_ll_power_down(); } } } @@ -141,9 +144,12 @@ void esp_crypto_ecdsa_enable_periph_clk(bool enable) void esp_crypto_key_mgr_enable_periph_clk(bool enable) { KEY_MANAGER_RCC_ATOMIC() { + key_mgr_ll_power_up(); key_mgr_ll_enable_bus_clock(enable); key_mgr_ll_enable_peripheral_clock(enable); - key_mgr_ll_reset_register(); + if (enable) { + key_mgr_ll_reset_register(); + } } } #endif diff --git a/components/esp_security/src/esp_ds.c b/components/esp_security/src/esp_ds.c index 6bdcad3376..0ca22898ee 100644 --- a/components/esp_security/src/esp_ds.c +++ b/components/esp_security/src/esp_ds.c @@ -17,6 +17,7 @@ #include "esp_cpu.h" #endif +#include "soc/soc_caps.h" #include "esp_ds.h" #include "esp_crypto_lock.h" #include "esp_crypto_periph_clk.h" @@ -37,6 +38,10 @@ #include "hal/sha_ll.h" #endif /* !CONFIG_IDF_TARGET_ESP32S2 */ +#ifdef SOC_KEY_MANAGER_DS_KEY_DEPLOY +#include "hal/key_mgr_hal.h" +#endif + /** * The vtask delay \c esp_ds_sign() is using while waiting for completion of the signing operation. */ @@ -247,22 +252,16 @@ static void ds_acquire_enable(void) // We also enable SHA and HMAC here. SHA is used by HMAC, HMAC is used by DS. esp_crypto_hmac_enable_periph_clk(true); - esp_crypto_sha_enable_periph_clk(true); - + esp_crypto_mpi_enable_periph_clk(true); esp_crypto_ds_enable_periph_clk(true); - - hmac_hal_start(); } static void ds_disable_release(void) { - ds_hal_finish(); - esp_crypto_ds_enable_periph_clk(false); - + esp_crypto_mpi_enable_periph_clk(false); esp_crypto_sha_enable_periph_clk(false); - esp_crypto_hmac_enable_periph_clk(false); esp_crypto_ds_lock_release(); @@ -326,12 +325,24 @@ esp_err_t esp_ds_start_sign(const void *message, ds_acquire_enable(); - // initiate hmac - uint32_t conf_error = hmac_hal_configure(HMAC_OUTPUT_DS, key_id); - if (conf_error) { - ds_disable_release(); - return ESP_ERR_HW_CRYPTO_DS_HMAC_FAIL; +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY + if (key_id == HMAC_KEY_KM) { + key_mgr_hal_set_key_usage(ESP_KEY_MGR_DS_KEY, ESP_KEY_MGR_USE_OWN_KEY); + ds_hal_set_key_source(DS_KEY_SOURCE_KEY_MGR); + } else { + key_mgr_hal_set_key_usage(ESP_KEY_MGR_DS_KEY, ESP_KEY_MGR_USE_EFUSE_KEY); + ds_hal_set_key_source(DS_KEY_SOURCE_EFUSE); +#endif + // initiate hmac + hmac_hal_start(); + uint32_t conf_error = hmac_hal_configure(HMAC_OUTPUT_DS, key_id); + if (conf_error) { + ds_disable_release(); + return ESP_ERR_HW_CRYPTO_DS_HMAC_FAIL; + } +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY } +#endif ds_hal_start(); @@ -339,6 +350,7 @@ esp_err_t esp_ds_start_sign(const void *message, int64_t start_time = get_time_us(); while (ds_ll_busy() != 0) { if ((get_time_us() - start_time) > SOC_DS_KEY_CHECK_MAX_WAIT_US) { + ds_hal_finish(); ds_disable_release(); return ESP_ERR_HW_CRYPTO_DS_INVALID_KEY; } @@ -348,6 +360,7 @@ esp_err_t esp_ds_start_sign(const void *message, *esp_ds_ctx = malloc(sizeof(esp_ds_context_t)); #endif if (!*esp_ds_ctx) { + ds_hal_finish(); ds_disable_release(); return ESP_ERR_NO_MEM; } @@ -398,6 +411,7 @@ esp_err_t esp_ds_finish_sign(void *signature, esp_ds_context_t *esp_ds_ctx) #endif hmac_hal_clean(); + ds_hal_finish(); ds_disable_release(); diff --git a/components/esp_security/src/esp_key_mgr.c b/components/esp_security/src/esp_key_mgr.c index 275bd2d575..9977accdd6 100644 --- a/components/esp_security/src/esp_key_mgr.c +++ b/components/esp_security/src/esp_key_mgr.c @@ -4,53 +4,60 @@ * SPDX-License-Identifier: Apache-2.0 */ // The Hardware Support layer for Key manager +#include #include #include -#include "assert.h" #include "esp_key_mgr.h" #include "esp_crypto_periph_clk.h" #include "esp_crypto_lock.h" #include "esp_log.h" #include "esp_err.h" -#include "esp_random.h" #include "esp_heap_caps.h" #include "esp_rom_crc.h" #include "esp_efuse.h" -#include "freertos/FreeRTOS.h" -#include "freertos/semphr.h" #include "hal/key_mgr_types.h" #include "hal/key_mgr_hal.h" -#include "hal/key_mgr_ll.h" #include "hal/huk_types.h" #include "hal/huk_hal.h" #include "rom/key_mgr.h" -#if CONFIG_LOG_DEFAULT_LEVEL_VERBOSE -#include "soc/huk_reg.h" -#include "soc/keymng_reg.h" -#endif - static const char *TAG = "esp_key_mgr"; static _lock_t s_key_mgr_ecdsa_key_lock; static _lock_t s_key_mgr_xts_aes_key_lock; +static _lock_t s_key_mgr_hmac_key_lock; +static _lock_t s_key_mgr_ds_key_lock; +static _lock_t s_key_mgr_psram_key_lock; ESP_STATIC_ASSERT(sizeof(esp_key_mgr_key_recovery_info_t) == sizeof(struct huk_key_block), "Size of esp_key_mgr_key_recovery_info_t should match huk_key_block (from ROM)"); - ESP_STATIC_ASSERT(sizeof(esp_key_mgr_key_info_t) == sizeof(struct key_info), "Size of esp_key_mgr_key_info_t should match key_info (from ROM)"); - ESP_STATIC_ASSERT(sizeof(esp_key_mgr_huk_info_t) == sizeof(struct huk_info), "Size of esp_key_mgr_huk_info_t should match huk_info (from ROM)"); static void esp_key_mgr_acquire_key_lock(esp_key_mgr_key_type_t key_type) { switch (key_type) { - case ESP_KEY_MGR_ECDSA_KEY: + case ESP_KEY_MGR_ECDSA_192_KEY: + case ESP_KEY_MGR_ECDSA_256_KEY: + case ESP_KEY_MGR_ECDSA_384_KEY: _lock_acquire(&s_key_mgr_ecdsa_key_lock); break; case ESP_KEY_MGR_XTS_AES_128_KEY: case ESP_KEY_MGR_XTS_AES_256_KEY: _lock_acquire(&s_key_mgr_xts_aes_key_lock); break; + case ESP_KEY_MGR_HMAC_KEY: + _lock_acquire(&s_key_mgr_hmac_key_lock); + break; + case ESP_KEY_MGR_DS_KEY: + _lock_acquire(&s_key_mgr_ds_key_lock); + break; + case ESP_KEY_MGR_PSRAM_128_KEY: + case ESP_KEY_MGR_PSRAM_256_KEY: + _lock_acquire(&s_key_mgr_psram_key_lock); + break; + default: + ESP_LOGE(TAG, "Invalid key type"); + break; } ESP_LOGV(TAG, "Key lock acquired for key type %d", key_type); } @@ -58,13 +65,28 @@ static void esp_key_mgr_acquire_key_lock(esp_key_mgr_key_type_t key_type) static void esp_key_mgr_release_key_lock(esp_key_mgr_key_type_t key_type) { switch (key_type) { - case ESP_KEY_MGR_ECDSA_KEY: + case ESP_KEY_MGR_ECDSA_192_KEY: + case ESP_KEY_MGR_ECDSA_256_KEY: + case ESP_KEY_MGR_ECDSA_384_KEY: _lock_release(&s_key_mgr_ecdsa_key_lock); break; case ESP_KEY_MGR_XTS_AES_128_KEY: case ESP_KEY_MGR_XTS_AES_256_KEY: _lock_release(&s_key_mgr_xts_aes_key_lock); break; + case ESP_KEY_MGR_HMAC_KEY: + _lock_release(&s_key_mgr_hmac_key_lock); + break; + case ESP_KEY_MGR_DS_KEY: + _lock_release(&s_key_mgr_ds_key_lock); + break; + case ESP_KEY_MGR_PSRAM_128_KEY: + case ESP_KEY_MGR_PSRAM_256_KEY: + _lock_release(&s_key_mgr_psram_key_lock); + break; + default: + ESP_LOGE(TAG, "Invalid key type"); + break; } ESP_LOGV(TAG, "Key lock released for key type %d", key_type); } @@ -116,7 +138,7 @@ static void check_huk_risk_level(void) "It is recommended to immediately regenerate HUK in order" "to avoid permanently losing the deployed keys", huk_risk_level); } else { - ESP_LOGI(TAG, "HUK Risk level - %" PRId8 " within acceptable limit (%" PRIu32 ")", huk_risk_level, (uint32_t)KEY_MGR_HUK_RISK_ALERT_LEVEL); + ESP_LOGD(TAG, "HUK Risk level - %" PRId8 " within acceptable limit (%" PRIu32 ")", huk_risk_level, (uint32_t)KEY_MGR_HUK_RISK_ALERT_LEVEL); } } @@ -147,6 +169,30 @@ typedef struct { esp_key_mgr_huk_info_t *huk_recovery_info; } huk_deploy_config_t; +static esp_err_t configure_huk(esp_huk_mode_t huk_mode, uint8_t *huk_info) +{ + esp_err_t ret = huk_hal_configure(huk_mode, huk_info); + if (ret != ESP_OK) { + return ret; + } + +#if SOC_HUK_MEM_NEEDS_RECHARGE + if (!key_mgr_hal_is_huk_valid()) { + huk_hal_recharge_huk_memory(); + ret = huk_hal_configure(huk_mode, huk_info); + if (ret != ESP_OK) { + return ret; + } + } +#endif + + if (!key_mgr_hal_is_huk_valid()) { + return ESP_FAIL; + } + + return ESP_OK; +} + static esp_err_t deploy_huk(huk_deploy_config_t *config) { esp_err_t esp_ret = ESP_FAIL; @@ -157,41 +203,41 @@ static esp_err_t deploy_huk(huk_deploy_config_t *config) if (config->use_pre_generated_huk_info) { // If HUK info is provided then recover the HUK from given info check_huk_risk_level(); + if (!check_huk_info_validity(config->pre_generated_huk_info)) { ESP_LOGE(TAG, "HUK info is not valid"); heap_caps_free(huk_recovery_info); return ESP_ERR_INVALID_ARG; } + memcpy(huk_recovery_info, config->pre_generated_huk_info->info, KEY_MGR_HUK_INFO_SIZE); - ESP_LOGI(TAG, "Recovering HUK from given HUK recovery info"); - esp_ret = huk_hal_configure(ESP_HUK_MODE_RECOVERY, huk_recovery_info); + ESP_LOGD(TAG, "Recovering HUK from given HUK recovery info"); + + esp_ret = configure_huk(ESP_HUK_MODE_RECOVERY, huk_recovery_info); if (esp_ret != ESP_OK) { ESP_LOGE(TAG, "Failed to recover HUK"); heap_caps_free(huk_recovery_info); return esp_ret; } + // Copy the pre generated huk info in the output key recovery info memcpy(config->huk_recovery_info->info, huk_recovery_info, KEY_MGR_HUK_INFO_SIZE); config->huk_recovery_info->crc = config->pre_generated_huk_info->crc; } else { // Generate new HUK and corresponding HUK info - ESP_LOGI(TAG, "Generating new HUK"); - esp_ret = huk_hal_configure(ESP_HUK_MODE_GENERATION, huk_recovery_info); + ESP_LOGD(TAG, "Generating new HUK"); + + esp_ret = configure_huk(ESP_HUK_MODE_GENERATION, huk_recovery_info); if (esp_ret != ESP_OK) { ESP_LOGE(TAG, "Failed to generate HUK"); heap_caps_free(huk_recovery_info); return esp_ret; } + memcpy(config->huk_recovery_info->info, huk_recovery_info, KEY_MGR_HUK_INFO_SIZE); config->huk_recovery_info->crc = esp_rom_crc32_le(0, huk_recovery_info, KEY_MGR_HUK_INFO_SIZE); } - if (!key_mgr_hal_is_huk_valid()) { - ESP_LOGE(TAG, "HUK is invalid"); - heap_caps_free(huk_recovery_info); - return ESP_FAIL; - } - ESP_LOG_BUFFER_HEX_LEVEL("HUK INFO", huk_recovery_info, KEY_MGR_HUK_INFO_SIZE, ESP_LOG_DEBUG); // Free the local buffer for huk recovery info heap_caps_free(huk_recovery_info); @@ -202,8 +248,9 @@ static esp_err_t key_mgr_deploy_key_aes_mode(aes_deploy_config_t *config) { esp_err_t esp_ret = ESP_FAIL; key_mgr_wait_for_state(ESP_KEY_MGR_STATE_IDLE); + if ((!key_mgr_hal_is_huk_valid()) || (!config->huk_deployed)) { - // For purpose ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 this part shall be already executed + // For purpose ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 or ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_2 this part shall be already executed huk_deploy_config_t huk_deploy_config = {}; huk_deploy_config.use_pre_generated_huk_info = config->key_config->use_pre_generated_huk_info; huk_deploy_config.pre_generated_huk_info = &config->key_config->huk_info; @@ -212,7 +259,7 @@ static esp_err_t key_mgr_deploy_key_aes_mode(aes_deploy_config_t *config) if (esp_ret != ESP_OK) { return esp_ret; } - ESP_LOGI(TAG, "HUK deployed successfully"); + ESP_LOGD(TAG, "HUK deployed successfully"); } // STEP 1: Init Step @@ -223,61 +270,69 @@ static esp_err_t key_mgr_deploy_key_aes_mode(aes_deploy_config_t *config) if (!key_recovery_info) { return ESP_ERR_NO_MEM; } - // Set key purpose (XTS/ECDSA) + + // Set key purpose ESP_LOGD(TAG, "Key purpose = %d", config->key_purpose); key_mgr_hal_set_key_purpose(config->key_purpose); // Set key length for XTS-AES key esp_key_mgr_key_type_t key_type = (esp_key_mgr_key_type_t) config->key_config->key_type; - if (key_type == ESP_KEY_MGR_XTS_AES_128_KEY) { - key_mgr_hal_set_xts_aes_key_len(ESP_KEY_MGR_XTS_AES_LEN_256); - } else if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY) { - key_mgr_hal_set_xts_aes_key_len(ESP_KEY_MGR_XTS_AES_LEN_512); + if (key_type == ESP_KEY_MGR_XTS_AES_128_KEY || key_type == ESP_KEY_MGR_PSRAM_128_KEY) { + key_mgr_hal_set_xts_aes_key_len(key_type, ESP_KEY_MGR_XTS_AES_LEN_256); + } else if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY || key_type == ESP_KEY_MGR_PSRAM_256_KEY) { + key_mgr_hal_set_xts_aes_key_len(key_type, ESP_KEY_MGR_XTS_AES_LEN_512); } if (config->key_config->use_pre_generated_sw_init_key) { key_mgr_hal_use_sw_init_key(); - } else { - if (!esp_efuse_find_purpose(ESP_EFUSE_KEY_PURPOSE_KM_INIT_KEY, NULL)) { - ESP_LOGE(TAG, "Could not find key with purpose KM_INIT_KEY"); - heap_caps_free(key_recovery_info); - return ESP_FAIL; - } + } else if (!esp_efuse_find_purpose(ESP_EFUSE_KEY_PURPOSE_KM_INIT_KEY, NULL)) { + ESP_LOGE(TAG, "Could not find key with purpose KM_INIT_KEY"); + heap_caps_free(key_recovery_info); + return ESP_FAIL; } key_mgr_hal_start(); key_mgr_hal_continue(); + // Step 2: Load phase key_mgr_wait_for_state(ESP_KEY_MGR_STATE_LOAD); + if (config->key_config->use_pre_generated_sw_init_key) { key_mgr_hal_write_sw_init_key(config->key_config->sw_init_key, KEY_MGR_SW_INIT_KEY_SIZE); + ESP_LOG_BUFFER_HEX_LEVEL("SW_INIT_KEY", config->key_config->sw_init_key, KEY_MGR_SW_INIT_KEY_SIZE, ESP_LOG_DEBUG); } - ESP_LOG_BUFFER_HEX_LEVEL("SW_INIT_KEY", config->key_config->sw_init_key, KEY_MGR_SW_INIT_KEY_SIZE, ESP_LOG_DEBUG); ESP_LOGD(TAG, "Writing Information into Key Manager Registers"); + key_mgr_hal_write_assist_info(config->key_config->k2_info, KEY_MGR_K2_INFO_SIZE); ESP_LOG_BUFFER_HEX_LEVEL("K2_INFO", config->key_config->k2_info, KEY_MGR_K2_INFO_SIZE, ESP_LOG_DEBUG); + key_mgr_hal_write_public_info(config->k1_encrypted, KEY_MGR_K1_ENCRYPTED_SIZE); ESP_LOG_BUFFER_HEX_LEVEL("K1_ENCRYPTED", config->k1_encrypted, KEY_MGR_K1_ENCRYPTED_SIZE, ESP_LOG_DEBUG); + key_mgr_hal_continue(); + // Step 3: Gain phase key_mgr_wait_for_state(ESP_KEY_MGR_STATE_GAIN); + key_mgr_hal_read_public_info(key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); ESP_LOG_BUFFER_HEX_LEVEL("KEY_RECOVERY_INFO", key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE, ESP_LOG_DEBUG); - if (config->key_purpose != ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1) { + if (config->key_purpose != ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1 || config->key_purpose != ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_1) { if (!key_mgr_hal_is_key_deployment_valid(config->key_config->key_type)) { ESP_LOGE(TAG, "Key deployment is not valid"); heap_caps_free(key_recovery_info); return ESP_FAIL; } - ESP_LOGI(TAG, "Key deployment valid"); + ESP_LOGD(TAG, "Key deployment valid"); } + // Wait till Key Manager deployment is complete key_mgr_hal_continue(); key_mgr_wait_for_state(ESP_KEY_MGR_STATE_IDLE); - if (config->key_purpose == ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2) { + + if (config->key_purpose == ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 || config->key_purpose == ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_2) { memcpy(config->key_info->key_info[1].info, key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); config->key_info->key_info[1].crc = esp_rom_crc32_le(0, key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); @@ -285,6 +340,7 @@ static esp_err_t key_mgr_deploy_key_aes_mode(aes_deploy_config_t *config) memcpy(config->key_info->key_info[0].info, key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); config->key_info->key_info[0].crc = esp_rom_crc32_le(0, key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); } + heap_caps_free(key_recovery_info); config->key_info->key_type = config->key_config->key_type; config->key_info->magic = KEY_HUK_SECTOR_MAGIC; @@ -298,7 +354,7 @@ esp_err_t esp_key_mgr_deploy_key_in_aes_mode(const esp_key_mgr_aes_key_config_t return ESP_ERR_INVALID_ARG; } - ESP_LOGI(TAG, "Key deployment in AES mode"); + ESP_LOGD(TAG, "Key deployment in AES mode"); aes_deploy_config_t aes_deploy_config = {}; aes_deploy_config.key_config = key_config; @@ -306,13 +362,32 @@ esp_err_t esp_key_mgr_deploy_key_in_aes_mode(const esp_key_mgr_aes_key_config_t aes_deploy_config.k1_encrypted = key_config->k1_encrypted[0]; esp_key_mgr_key_type_t key_type = (esp_key_mgr_key_type_t) key_config->key_type; - if (key_type == ESP_KEY_MGR_ECDSA_KEY) { - aes_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_ECDSA; - } else if (key_type == ESP_KEY_MGR_XTS_AES_128_KEY) { + switch (key_type) { + case ESP_KEY_MGR_ECDSA_192_KEY: + aes_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_ECDSA_192; + break; + case ESP_KEY_MGR_ECDSA_256_KEY: + aes_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_ECDSA_256; + break; + case ESP_KEY_MGR_XTS_AES_128_KEY: aes_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_128; - } else if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY) { + break; + case ESP_KEY_MGR_XTS_AES_256_KEY: aes_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1; - } else { + break; + case ESP_KEY_MGR_HMAC_KEY: + aes_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_HMAC; + break; + case ESP_KEY_MGR_DS_KEY: + aes_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_DS; + break; + case ESP_KEY_MGR_PSRAM_128_KEY: + aes_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_PSRAM_128; + break; + case ESP_KEY_MGR_PSRAM_256_KEY: + aes_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_1; + break; + default: ESP_LOGE(TAG, "Invalid key type"); return ESP_ERR_INVALID_ARG; } @@ -322,21 +397,25 @@ esp_err_t esp_key_mgr_deploy_key_in_aes_mode(const esp_key_mgr_aes_key_config_t esp_err_t esp_ret = key_mgr_deploy_key_aes_mode(&aes_deploy_config); if (esp_ret != ESP_OK) { ESP_LOGE(TAG, "Key deployment in AES mode failed"); + goto cleanup; } + aes_deploy_config.huk_deployed = true; - if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY) { - aes_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2; + if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY || key_type == ESP_KEY_MGR_PSRAM_256_KEY) { + aes_deploy_config.key_purpose = key_type == ESP_KEY_MGR_XTS_AES_256_KEY ? ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 : ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_2; aes_deploy_config.k1_encrypted = key_config->k1_encrypted[1]; esp_ret = key_mgr_deploy_key_aes_mode(&aes_deploy_config); if (esp_ret != ESP_OK) { ESP_LOGE(TAG, "Key deployment in AES mode failed"); + goto cleanup; } } // Set the Key Manager Static Register to use own key for the respective key type key_mgr_hal_set_key_usage(key_type, ESP_KEY_MGR_USE_OWN_KEY); +cleanup: esp_key_mgr_release_hardware(true); return esp_ret; } @@ -358,17 +437,13 @@ static esp_err_t key_mgr_recover_key(key_recovery_config_t *config) if ((!key_mgr_hal_is_huk_valid()) || (!config->huk_recovered)) { check_huk_risk_level(); - esp_err_t esp_ret = huk_hal_configure(ESP_HUK_MODE_RECOVERY, config->key_recovery_info->huk_info.info); + esp_err_t esp_ret = configure_huk(ESP_HUK_MODE_RECOVERY, config->key_recovery_info->huk_info.info); if (esp_ret != ESP_OK) { ESP_LOGE(TAG, "Failed to recover HUK"); - return ESP_FAIL; + return esp_ret; } - if (!key_mgr_hal_is_huk_valid()) { - ESP_LOGE(TAG, "HUK is invalid"); - // TODO - define error code - return ESP_FAIL; - } - ESP_LOGI(TAG, "HUK recovered successfully"); + + ESP_LOGD(TAG, "HUK recovered successfully"); ESP_LOG_BUFFER_HEX_LEVEL("HUK INFO", config->key_recovery_info->huk_info.info, KEY_MGR_HUK_INFO_SIZE, ESP_LOG_DEBUG); config->huk_recovered = true; } @@ -377,17 +452,18 @@ static esp_err_t key_mgr_recover_key(key_recovery_config_t *config) // Set AES-XTS key len esp_key_mgr_key_type_t key_type = (esp_key_mgr_key_type_t) config->key_recovery_info->key_type; - if (key_type == ESP_KEY_MGR_XTS_AES_128_KEY) { - key_mgr_hal_set_xts_aes_key_len(ESP_KEY_MGR_XTS_AES_LEN_256); - } else if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY) { - key_mgr_hal_set_xts_aes_key_len(ESP_KEY_MGR_XTS_AES_LEN_512); + if (key_type == ESP_KEY_MGR_XTS_AES_128_KEY || key_type == ESP_KEY_MGR_PSRAM_128_KEY) { + key_mgr_hal_set_xts_aes_key_len(key_type, ESP_KEY_MGR_XTS_AES_LEN_256); + } else if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY || key_type == ESP_KEY_MGR_PSRAM_256_KEY) { + key_mgr_hal_set_xts_aes_key_len(key_type, ESP_KEY_MGR_XTS_AES_LEN_512); } key_mgr_hal_set_key_purpose(config->key_purpose); key_mgr_hal_start(); key_mgr_hal_continue(); key_mgr_wait_for_state(ESP_KEY_MGR_STATE_LOAD); - if (config->key_purpose == ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2) { + + if (config->key_purpose == ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 || config->key_purpose == ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_2) { if (!check_key_info_validity(&config->key_recovery_info->key_info[1])) { ESP_LOGE(TAG, "Key info not valid"); return ESP_FAIL; @@ -405,6 +481,7 @@ static esp_err_t key_mgr_recover_key(key_recovery_config_t *config) key_mgr_hal_continue(); key_mgr_wait_for_state(ESP_KEY_MGR_STATE_GAIN); + if (config->key_purpose != ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1) { if (!key_mgr_hal_is_key_deployment_valid(config->key_recovery_info->key_type)) { ESP_LOGD(TAG, "Key deployment is not valid"); @@ -412,6 +489,7 @@ static esp_err_t key_mgr_recover_key(key_recovery_config_t *config) } ESP_LOGD(TAG, "Key Recovery valid"); } + key_mgr_hal_continue(); key_mgr_wait_for_state(ESP_KEY_MGR_STATE_IDLE); return ESP_OK; @@ -423,60 +501,85 @@ esp_err_t esp_key_mgr_activate_key(esp_key_mgr_key_recovery_info_t *key_recovery return ESP_ERR_INVALID_ARG; } - esp_key_mgr_key_purpose_t key_purpose; ESP_LOGD(TAG, "Activating key of type %d", key_recovery_info->key_type); + esp_key_mgr_key_type_t key_type = (esp_key_mgr_key_type_t) key_recovery_info->key_type; - if (key_type == ESP_KEY_MGR_ECDSA_KEY) { - key_purpose = ESP_KEY_MGR_KEY_PURPOSE_ECDSA; - } else if (key_type == ESP_KEY_MGR_XTS_AES_128_KEY) { + esp_key_mgr_key_purpose_t key_purpose; + + switch (key_type) { + case ESP_KEY_MGR_ECDSA_192_KEY: + key_purpose = ESP_KEY_MGR_KEY_PURPOSE_ECDSA_192; + break; + case ESP_KEY_MGR_ECDSA_256_KEY: + key_purpose = ESP_KEY_MGR_KEY_PURPOSE_ECDSA_256; + break; + case ESP_KEY_MGR_XTS_AES_128_KEY: key_purpose = ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_128; - } else if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY) { + break; + case ESP_KEY_MGR_XTS_AES_256_KEY: key_purpose = ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1; - } else { + break; + case ESP_KEY_MGR_HMAC_KEY: + key_purpose = ESP_KEY_MGR_KEY_PURPOSE_HMAC; + break; + case ESP_KEY_MGR_DS_KEY: + key_purpose = ESP_KEY_MGR_KEY_PURPOSE_DS; + break; + case ESP_KEY_MGR_PSRAM_128_KEY: + key_purpose = ESP_KEY_MGR_KEY_PURPOSE_PSRAM_128; + break; + case ESP_KEY_MGR_PSRAM_256_KEY: + key_purpose = ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_1; + break; + default: ESP_LOGE(TAG, "Invalid key type"); return ESP_ERR_INVALID_ARG; } esp_err_t esp_ret = ESP_FAIL; esp_key_mgr_acquire_key_lock(key_type); - key_recovery_config_t key_recovery_config = {}; - key_recovery_config.key_recovery_info = key_recovery_info; - key_recovery_config.key_purpose = key_purpose; + key_recovery_config_t key_recovery_config = { + .key_recovery_info = key_recovery_info, + .key_purpose = key_purpose, + }; esp_key_mgr_acquire_hardware(false); esp_ret = key_mgr_recover_key(&key_recovery_config); if (esp_ret != ESP_OK) { ESP_LOGE(TAG, "Failed to recover key"); + esp_key_mgr_release_key_lock(key_type); goto cleanup; } - if (key_recovery_info->key_type == ESP_KEY_MGR_XTS_AES_256_KEY) { - key_recovery_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2; + if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY || key_type == ESP_KEY_MGR_PSRAM_256_KEY) { + key_recovery_config.key_purpose = key_type == ESP_KEY_MGR_XTS_AES_256_KEY ? ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 : ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_2; esp_ret = key_mgr_recover_key(&key_recovery_config); if (esp_ret != ESP_OK) { ESP_LOGE(TAG, "Failed to recover key"); + esp_key_mgr_release_key_lock(key_type); goto cleanup; } } // Set the Key Manager Static Register to use own key for the respective key type - key_mgr_hal_set_key_usage(key_recovery_info->key_type, ESP_KEY_MGR_USE_OWN_KEY); - ESP_LOGI(TAG, "Key activation for type %d successful", key_recovery_info->key_type); + key_mgr_hal_set_key_usage(key_type, ESP_KEY_MGR_USE_OWN_KEY); + esp_key_mgr_release_key_lock(key_type); + + ESP_LOGD(TAG, "Key activation for type %d successful", key_type); return ESP_OK; cleanup: - ESP_LOGI(TAG, "Key activation failed"); + ESP_LOGE(TAG, "Key activation failed"); esp_key_mgr_release_hardware(false); return esp_ret; } esp_err_t esp_key_mgr_deactivate_key(esp_key_mgr_key_type_t key_type) { - ESP_LOGD(TAG, "Deactivating key of type %d", key_type); esp_key_mgr_release_key_lock(key_type); esp_key_mgr_release_hardware(false); - ESP_LOGI(TAG, "Key deactivation successful"); + ESP_LOGD(TAG, "Key deactivation successful for type %d", key_type); return ESP_OK; } @@ -495,7 +598,7 @@ static esp_err_t key_mgr_deploy_key_ecdh0_mode(ecdh0_deploy_config_t *config) key_mgr_wait_for_state(ESP_KEY_MGR_STATE_IDLE); if ((!key_mgr_hal_is_huk_valid()) || (!config->huk_deployed)) { - // For purpose ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 this part shall be already executed + // For purpose ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 or ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_2 this part shall be already executed huk_deploy_config_t huk_deploy_config; huk_deploy_config.use_pre_generated_huk_info = config->key_config->use_pre_generated_huk_info; huk_deploy_config.pre_generated_huk_info = &config->key_config->huk_info; @@ -504,7 +607,7 @@ static esp_err_t key_mgr_deploy_key_ecdh0_mode(ecdh0_deploy_config_t *config) if (esp_ret != ESP_OK) { return esp_ret; } - ESP_LOGI(TAG, "HUK deployed successfully"); + ESP_LOGD(TAG, "HUK deployed successfully"); } uint8_t *key_recovery_info = (uint8_t *) heap_caps_calloc(1, KEY_MGR_KEY_RECOVERY_INFO_SIZE, MALLOC_CAP_INTERNAL); @@ -518,46 +621,50 @@ static esp_err_t key_mgr_deploy_key_ecdh0_mode(ecdh0_deploy_config_t *config) // Set AES-XTS key len esp_key_mgr_key_type_t key_type = (esp_key_mgr_key_type_t) config->key_config->key_type; - if (key_type == ESP_KEY_MGR_XTS_AES_128_KEY) { - key_mgr_hal_set_xts_aes_key_len(ESP_KEY_MGR_XTS_AES_LEN_256); - } else if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY) { - key_mgr_hal_set_xts_aes_key_len(ESP_KEY_MGR_XTS_AES_LEN_512); + if (key_type == ESP_KEY_MGR_XTS_AES_128_KEY || key_type == ESP_KEY_MGR_PSRAM_128_KEY) { + key_mgr_hal_set_xts_aes_key_len(key_type, ESP_KEY_MGR_XTS_AES_LEN_256); + } else if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY || key_type == ESP_KEY_MGR_PSRAM_256_KEY) { + key_mgr_hal_set_xts_aes_key_len(key_type, ESP_KEY_MGR_XTS_AES_LEN_512); } - // Set key purpose (XTS/ECDSA) + // Set key purpose key_mgr_hal_set_key_purpose(config->key_purpose); key_mgr_hal_start(); key_mgr_hal_continue(); // Step 2: Load phase key_mgr_wait_for_state(ESP_KEY_MGR_STATE_LOAD); + ESP_LOGD(TAG, "Writing Information into Key Manager Registers"); key_mgr_hal_write_public_info(config->k1_G, KEY_MGR_ECDH0_INFO_SIZE); + key_mgr_hal_continue(); // Step 3: Gain phase key_mgr_wait_for_state(ESP_KEY_MGR_STATE_GAIN); + key_mgr_hal_read_public_info(key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); key_mgr_hal_read_assist_info(config->ecdh0_key_info); ESP_LOG_BUFFER_HEX_LEVEL("KEY_MGR KEY INFO", key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE, ESP_LOG_DEBUG); - ESP_LOGI(TAG, "HUK deplpoyed is Valid"); + ESP_LOGD(TAG, "HUK deployed is valid"); - if (config->key_purpose != ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1) { + if (config->key_purpose != ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1 || config->key_purpose != ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_1) { if (!key_mgr_hal_is_key_deployment_valid(config->key_config->key_type)) { ESP_LOGE(TAG, "Key deployment is not valid"); heap_caps_free(key_recovery_info); return ESP_FAIL; } - ESP_LOGI(TAG, "Key deployment valid"); + ESP_LOGD(TAG, "Key deployment valid"); } + // Wait till Key Manager deployment is complete key_mgr_hal_continue(); key_mgr_wait_for_state(ESP_KEY_MGR_STATE_IDLE); - if (config->key_purpose == ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2) { + + if (config->key_purpose == ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 || config->key_purpose == ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_2) { memcpy(config->key_info->key_info[1].info, key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); config->key_info->key_info[1].crc = esp_rom_crc32_le(0, key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); - } else { memcpy(config->key_info->key_info[0].info, key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); config->key_info->key_info[0].crc = esp_rom_crc32_le(0, key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); @@ -576,25 +683,51 @@ esp_err_t esp_key_mgr_deploy_key_in_ecdh0_mode(const esp_key_mgr_ecdh0_key_confi if (key_config == NULL || key_info == NULL || ecdh0_key_info == NULL) { return ESP_ERR_INVALID_ARG; } - ESP_LOGI(TAG, "Key Deployment in ECDH0 mode"); - esp_key_mgr_key_purpose_t key_purpose; + + ESP_LOGD(TAG, "Key Deployment in ECDH0 mode"); + esp_key_mgr_key_type_t key_type = (esp_key_mgr_key_type_t) key_config->key_type; - ecdh0_deploy_config_t ecdh0_deploy_config = {}; - ecdh0_deploy_config.key_config = key_config; - ecdh0_deploy_config.key_info = key_info; - ecdh0_deploy_config.k1_G = key_config->k1_G[0]; + ecdh0_deploy_config_t ecdh0_deploy_config = { + .key_config = key_config, + .key_info = key_info, + .k1_G = key_config->k1_G[0], + }; - if (key_type == ESP_KEY_MGR_ECDSA_KEY) { - ecdh0_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_ECDSA; + switch (key_type) { + case ESP_KEY_MGR_ECDSA_192_KEY: + ecdh0_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_ECDSA_192; ecdh0_deploy_config.ecdh0_key_info = ecdh0_key_info->k2_G[0]; - } else if (key_type == ESP_KEY_MGR_XTS_AES_128_KEY) { + break; + case ESP_KEY_MGR_ECDSA_256_KEY: + ecdh0_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_ECDSA_256; + ecdh0_deploy_config.ecdh0_key_info = ecdh0_key_info->k2_G[0]; + break; + case ESP_KEY_MGR_XTS_AES_128_KEY: ecdh0_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_128; ecdh0_deploy_config.ecdh0_key_info = ecdh0_key_info->k2_G[0]; - } else if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY) { + break; + case ESP_KEY_MGR_XTS_AES_256_KEY: ecdh0_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1; ecdh0_deploy_config.ecdh0_key_info = ecdh0_key_info->k2_G[0]; - } else { + break; + case ESP_KEY_MGR_HMAC_KEY: + ecdh0_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_HMAC; + ecdh0_deploy_config.ecdh0_key_info = ecdh0_key_info->k2_G[0]; + break; + case ESP_KEY_MGR_DS_KEY: + ecdh0_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_DS; + ecdh0_deploy_config.ecdh0_key_info = ecdh0_key_info->k2_G[0]; + break; + case ESP_KEY_MGR_PSRAM_128_KEY: + ecdh0_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_PSRAM_128; + ecdh0_deploy_config.ecdh0_key_info = ecdh0_key_info->k2_G[0]; + break; + case ESP_KEY_MGR_PSRAM_256_KEY: + ecdh0_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_1; + ecdh0_deploy_config.ecdh0_key_info = ecdh0_key_info->k2_G[0]; + break; + default: ESP_LOGE(TAG, "Invalid key type"); return ESP_ERR_INVALID_ARG; } @@ -605,13 +738,12 @@ esp_err_t esp_key_mgr_deploy_key_in_ecdh0_mode(const esp_key_mgr_ecdh0_key_confi if (esp_ret != ESP_OK) { ESP_LOGE(TAG, "Failed to deploy key in ECDH0 mode"); } + ecdh0_deploy_config.huk_deployed = true; - if (key_config->key_type == ESP_KEY_MGR_XTS_AES_256_KEY) { - key_purpose = ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2; - ecdh0_deploy_config.key_purpose = key_purpose; + if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY || key_type == ESP_KEY_MGR_PSRAM_256_KEY) { + ecdh0_deploy_config.key_purpose = key_type == ESP_KEY_MGR_XTS_AES_256_KEY ? ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 : ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_2; ecdh0_deploy_config.k1_G = key_config->k1_G[1]; - ecdh0_deploy_config.ecdh0_key_info = ecdh0_key_info->k2_G[1]; esp_ret = key_mgr_deploy_key_ecdh0_mode(&ecdh0_deploy_config); if (esp_ret != ESP_OK) { @@ -637,17 +769,20 @@ static esp_err_t key_mgr_deploy_key_random_mode(random_deploy_config_t *config) { esp_err_t esp_ret = ESP_FAIL; key_mgr_wait_for_state(ESP_KEY_MGR_STATE_IDLE); + if ((!key_mgr_hal_is_huk_valid()) || (!config->huk_deployed)) { - // For purpose ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 this part shall be already executed - huk_deploy_config_t huk_deploy_config = {}; - huk_deploy_config.use_pre_generated_huk_info = config->key_config->use_pre_generated_huk_info; - huk_deploy_config.pre_generated_huk_info = &config->key_config->huk_info; - huk_deploy_config.huk_recovery_info = &config->key_info->huk_info; + // For purpose ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 or ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_2 this part shall be already executed + huk_deploy_config_t huk_deploy_config = { + .use_pre_generated_huk_info = config->key_config->use_pre_generated_huk_info, + .pre_generated_huk_info = &config->key_config->huk_info, + .huk_recovery_info = &config->key_info->huk_info, + }; + esp_ret = deploy_huk(&huk_deploy_config); if (esp_ret != ESP_OK) { return esp_ret; } - ESP_LOGI(TAG, "HUK deployed successfully"); + ESP_LOGD(TAG, "HUK deployed successfully"); } // Configure deployment mode to RANDOM @@ -655,10 +790,10 @@ static esp_err_t key_mgr_deploy_key_random_mode(random_deploy_config_t *config) // Set AES-XTS key len esp_key_mgr_key_type_t key_type = (esp_key_mgr_key_type_t) config->key_config->key_type; - if (key_type == ESP_KEY_MGR_XTS_AES_128_KEY) { - key_mgr_hal_set_xts_aes_key_len(ESP_KEY_MGR_XTS_AES_LEN_256); - } else if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY) { - key_mgr_hal_set_xts_aes_key_len(ESP_KEY_MGR_XTS_AES_LEN_512); + if (key_type == ESP_KEY_MGR_XTS_AES_128_KEY || key_type == ESP_KEY_MGR_PSRAM_128_KEY) { + key_mgr_hal_set_xts_aes_key_len(key_type, ESP_KEY_MGR_XTS_AES_LEN_256); + } else if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY || key_type == ESP_KEY_MGR_PSRAM_256_KEY) { + key_mgr_hal_set_xts_aes_key_len(key_type, ESP_KEY_MGR_XTS_AES_LEN_512); } uint8_t *key_recovery_info = (uint8_t *) heap_caps_calloc(1, KEY_MGR_KEY_RECOVERY_INFO_SIZE, MALLOC_CAP_INTERNAL); @@ -673,35 +808,37 @@ static esp_err_t key_mgr_deploy_key_random_mode(random_deploy_config_t *config) key_mgr_hal_continue(); key_mgr_wait_for_state(ESP_KEY_MGR_STATE_LOAD); key_mgr_hal_continue(); + // No configuration for Random deploy mode key_mgr_wait_for_state(ESP_KEY_MGR_STATE_GAIN); key_mgr_hal_read_public_info(key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); ESP_LOG_BUFFER_HEX_LEVEL("KEY_MGR KEY INFO", key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE, ESP_LOG_DEBUG); - if (config->key_purpose != ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1) { + if (config->key_purpose != ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1 || config->key_purpose != ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_1) { if (!key_mgr_hal_is_key_deployment_valid(config->key_config->key_type)) { ESP_LOGE(TAG, "Key deployment is not valid"); heap_caps_free(key_recovery_info); return ESP_FAIL; } - ESP_LOGI(TAG, "Key deployment valid"); + ESP_LOGD(TAG, "Key deployment valid"); } // Wait till Key Manager deployment is complete key_mgr_hal_continue(); key_mgr_wait_for_state(ESP_KEY_MGR_STATE_IDLE); - if (config->key_purpose == ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2) { + + if (config->key_purpose == ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 || config->key_purpose == ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_2) { memcpy(config->key_info->key_info[1].info, key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); config->key_info->key_info[1].crc = esp_rom_crc32_le(0, key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); - } else { memcpy(config->key_info->key_info[0].info, key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); config->key_info->key_info[0].crc = esp_rom_crc32_le(0, key_recovery_info, KEY_MGR_KEY_RECOVERY_INFO_SIZE); } + heap_caps_free(key_recovery_info); + config->key_info->key_type = config->key_config->key_type; config->key_info->magic = KEY_HUK_SECTOR_MAGIC; - return ESP_OK; } @@ -711,20 +848,41 @@ esp_err_t esp_key_mgr_deploy_key_in_random_mode(const esp_key_mgr_random_key_con return ESP_ERR_INVALID_ARG; } - ESP_LOGI(TAG, "Key deployment in Random mode"); + ESP_LOGD(TAG, "Key deployment in Random mode"); + + random_deploy_config_t random_deploy_config = { + .key_config = key_config, + .key_info = key_recovery_info, + }; - random_deploy_config_t random_deploy_config = {}; - random_deploy_config.key_config = key_config; - random_deploy_config.key_info = key_recovery_info; esp_key_mgr_key_type_t key_type = (esp_key_mgr_key_type_t) key_config->key_type; - if (key_type == ESP_KEY_MGR_ECDSA_KEY) { - random_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_ECDSA; - } else if (key_type == ESP_KEY_MGR_XTS_AES_128_KEY) { + switch (key_type) { + case ESP_KEY_MGR_ECDSA_192_KEY: + random_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_ECDSA_192; + break; + case ESP_KEY_MGR_ECDSA_256_KEY: + random_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_ECDSA_256; + break; + case ESP_KEY_MGR_XTS_AES_128_KEY: random_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_128; - } else if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY) { + break; + case ESP_KEY_MGR_XTS_AES_256_KEY: random_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1; - } else { + break; + case ESP_KEY_MGR_HMAC_KEY: + random_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_HMAC; + break; + case ESP_KEY_MGR_DS_KEY: + random_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_DS; + break; + case ESP_KEY_MGR_PSRAM_128_KEY: + random_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_PSRAM_128; + break; + case ESP_KEY_MGR_PSRAM_256_KEY: + random_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_1; + break; + default: ESP_LOGE(TAG, "Invalid key type"); return ESP_ERR_INVALID_ARG; } @@ -736,10 +894,11 @@ esp_err_t esp_key_mgr_deploy_key_in_random_mode(const esp_key_mgr_random_key_con ESP_LOGE(TAG, "Key deployment in Random mode failed"); return ESP_FAIL; } + random_deploy_config.huk_deployed = true; - if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY) { - random_deploy_config.key_purpose = ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2; + if (key_type == ESP_KEY_MGR_XTS_AES_256_KEY || key_type == ESP_KEY_MGR_PSRAM_256_KEY) { + random_deploy_config.key_purpose = key_type == ESP_KEY_MGR_XTS_AES_256_KEY ? ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 : ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_2; esp_ret = key_mgr_deploy_key_random_mode(&random_deploy_config); if (esp_ret != ESP_OK) { ESP_LOGE(TAG, "Key deployment in Random mode failed"); @@ -748,8 +907,9 @@ esp_err_t esp_key_mgr_deploy_key_in_random_mode(const esp_key_mgr_random_key_con } // Set the Key Manager Static Register to use own key for the respective key type - key_mgr_hal_set_key_usage(key_config->key_type, ESP_KEY_MGR_USE_OWN_KEY); + key_mgr_hal_set_key_usage(key_type, ESP_KEY_MGR_USE_OWN_KEY); esp_key_mgr_release_hardware(true); + return esp_ret; } diff --git a/components/esp_security/src/init.c b/components/esp_security/src/init.c index 26b99a94a2..14ede2dc0d 100644 --- a/components/esp_security/src/init.c +++ b/components/esp_security/src/init.c @@ -14,16 +14,20 @@ #include "esp_err.h" #include "hal/efuse_hal.h" -#if SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY || SOC_KEY_MANAGER_FE_KEY_DEPLOY -#include "hal/key_mgr_ll.h" +#if SOC_HUK_MEM_NEEDS_RECHARGE +#include "hal/huk_hal.h" #endif +#if SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT +#include "hal/key_mgr_ll.h" +#endif /* SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT */ + __attribute__((unused)) static const char *TAG = "esp_security"; static void esp_key_mgr_init(void) { // The following code initializes the key manager. -#if SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY || SOC_KEY_MANAGER_FE_KEY_DEPLOY +#if SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT // Enable key manager clock // Using ll APIs which do not require critical section _key_mgr_ll_enable_bus_clock(true); @@ -31,7 +35,7 @@ static void esp_key_mgr_init(void) _key_mgr_ll_reset_register(); while (key_mgr_ll_get_state() != ESP_KEY_MGR_STATE_IDLE) { }; -#endif /* SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY || SOC_KEY_MANAGER_FE_KEY_DEPLOY */ +#endif /* SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT */ } ESP_SYSTEM_INIT_FN(esp_security_init, SECONDARY, BIT(0), 103) diff --git a/components/esp_security/test_apps/crypto_drivers/main/hmac_key.bin b/components/esp_security/test_apps/crypto_drivers/main/hmac_key.bin new file mode 100644 index 0000000000..2ea3dec3e1 --- /dev/null +++ b/components/esp_security/test_apps/crypto_drivers/main/hmac_key.bin @@ -0,0 +1,2 @@ + +  \ No newline at end of file diff --git a/components/esp_security/test_apps/crypto_drivers/main/hmac_test_cases.h b/components/esp_security/test_apps/crypto_drivers/main/hmac_test_cases.h new file mode 100644 index 0000000000..4d6e80fceb --- /dev/null +++ b/components/esp_security/test_apps/crypto_drivers/main/hmac_test_cases.h @@ -0,0 +1,1200 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + * + */ +#include + +/* Allow testing varying message lengths (truncating the same message) + for various results */ +typedef struct { + int msglen; + uint8_t result[32]; +} hmac_result; + +static const uint8_t key_data[32] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32 +}; + +// Results calculated with Python: +// +// import hmac, hashlib, binascii +// key = b"".join([chr(x).encode() for x in range(1,33)]) +// ", ".join("0x%x" % x for x in hmac.HMAC(key, b"\x00" * 32, hashlib.sha256).digest() ) +static const uint8_t token_data[32] = { + 0xb2, 0xa4, 0x9b, 0x1c, 0xce, 0x1b, 0xe9, 0x22, 0xbb, 0x7e, 0x43, 0x12, 0x77, 0x41, 0x3e, 0x3e, + 0x8e, 0x6c, 0x3e, 0x8e, 0x6e, 0x17, 0x62, 0x5c, 0x50, 0xac, 0x66, 0xa9, 0xa8, 0x57, 0x94, 0x9b +}; + +// Produce the HMAC of various numbers of zeroes +// +// Results calculated with Python: +// +// import hmac, hashlib, binascii +// key = b"".join([chr(x).encode() for x in range(1,33)]) +// ", ".join("0x%x" % x for x in hmac.HMAC(key, b"\x00" * 128, hashlib.sha256).digest() ) + +static const hmac_result zero_results[] = { + { + .msglen = 64, + .result = { + 0x4f, 0x34, 0x31, 0x8a, 0x45, 0x74, 0x4d, 0x71, 0x53, 0xb7, 0x18, 0xf4, 0x78, 0x1c, 0xbb, 0x10, + 0x19, 0x60, 0xba, 0x9c, 0x8c, 0xe2, 0x3b, 0xc1, 0x1d, 0x79, 0xb6, 0x3c, 0xae, 0x0f, 0x30, 0xc8, + }, + }, + { + .msglen = 128, + .result = { + 0x40, 0xd5, 0xb9, 0xe6, 0x25, 0x8f, 0x3c, 0xd0, 0x3f, 0xb9, 0x6c, 0xa3, 0xa7, 0x2b, 0x84, 0xe3, + 0x1d, 0x4b, 0x4e, 0x65, 0xf8, 0x7b, 0x3e, 0x3, 0x26, 0x2, 0xcd, 0x49, 0x73, 0xf0, 0xac, 0x25 + }, + }, + { + .msglen = 48, + .result = { + 0x84, 0x4e, 0x45, 0xcd, 0xb3, 0x8f, 0xf8, 0x96, 0xe7, 0xe7, 0x80, 0x48, 0x31, 0x89, 0x79, 0xa7, + 0x5d, 0x80, 0xd1, 0xbf, 0x3, 0xca, 0x9b, 0x78, 0x4f, 0x3b, 0x42, 0x80, 0xb9, 0x6, 0x19, 0x7d + }, + }, + { + .msglen = 32, + .result = { + 0xb2, 0xa4, 0x9b, 0x1c, 0xce, 0x1b, 0xe9, 0x22, 0xbb, 0x7e, 0x43, 0x12, 0x77, 0x41, 0x3e, 0x3e, + 0x8e, 0x6c, 0x3e, 0x8e, 0x6e, 0x17, 0x62, 0x5c, 0x50, 0xac, 0x66, 0xa9, 0xa8, 0x57, 0x94, 0x9b + }, + }, + { + .msglen = 33, + .result = { + 0x98, 0xd7, 0x44, 0xab, 0xbb, 0x89, 0xca, 0x51, 0x3e, 0x2, 0x8e, 0x5c, 0xa1, 0x61, 0x25, 0xd2, + 0x93, 0x3e, 0x85, 0x4b, 0x9f, 0x73, 0x63, 0x57, 0xab, 0xbc, 0x7a, 0x66, 0x51, 0xd2, 0x39, 0xb9 + }, + }, + { + .msglen = 1, + .result = { + 0xab, 0x7d, 0x90, 0x85, 0x8, 0xb3, 0xf3, 0x7, 0x45, 0x6c, 0x85, 0x40, 0xbf, 0xcd, 0xb4, 0x52, + 0x54, 0x2c, 0x2, 0xe0, 0x53, 0xdc, 0x16, 0x12, 0x90, 0xf1, 0x5b, 0x5b, 0xf8, 0x71, 0x65, 0x44 + }, + }, + { + .msglen = 127, + .result = { + 0x19, 0x38, 0x88, 0xb, 0x30, 0xac, 0xef, 0x4e, 0xd, 0x38, 0x7d, 0x7e, 0x42, 0x5c, 0x90, 0xc4, + 0x9b, 0xc1, 0xbd, 0x9e, 0x30, 0xc6, 0x16, 0x1f, 0x36, 0x7e, 0x46, 0xcd, 0xb2, 0xd7, 0x37, 0x70 + }, + }, + { + .msglen = 126, + .result = { + 0xf, 0xa4, 0xb5, 0x16, 0x3b, 0xf5, 0xe8, 0x6e, 0xaf, 0x38, 0xc6, 0x27, 0x9a, 0xc, 0x88, 0xaf, + 0xb5, 0x10, 0x75, 0x3d, 0x4a, 0x85, 0x10, 0x4e, 0x60, 0xe4, 0x61, 0x30, 0x8, 0x46, 0x98, 0xc7 + }, + }, + { + .msglen = 125, + .result = { + 0x3f, 0x1a, 0x90, 0x47, 0xeb, 0x44, 0xcc, 0x27, 0xfa, 0x22, 0xb3, 0x5d, 0xa2, 0x22, 0x30, 0x54, + 0x61, 0x15, 0xe5, 0x54, 0x55, 0x13, 0x7c, 0xb8, 0xc7, 0xc0, 0x28, 0xa4, 0xd4, 0xbc, 0x1c, 0xad + }, + }, + { + .msglen = 124, + .result = { + 0x14, 0xdf, 0x13, 0xa2, 0xe4, 0xfd, 0xa3, 0xa8, 0x9b, 0x71, 0x78, 0x2e, 0x24, 0xb6, 0x61, 0x13, + 0xff, 0x6c, 0x6d, 0xe8, 0x95, 0xf9, 0x68, 0xb4, 0x92, 0x7c, 0xc9, 0xf7, 0x5e, 0x14, 0x44, 0x8 + }, + }, + { + .msglen = 123, + .result = { + 0x6, 0xd0, 0xe, 0xbe, 0x90, 0x3b, 0x52, 0x85, 0xd4, 0x25, 0x7e, 0xbe, 0x71, 0x92, 0xd0, 0xf0, + 0x6a, 0x99, 0x93, 0x64, 0xe6, 0x9a, 0x27, 0xfa, 0x57, 0xcb, 0x6f, 0x9f, 0x44, 0x30, 0xf5, 0xcc + }, + }, + { + .msglen = 122, + .result = { + 0x76, 0x7a, 0x86, 0x80, 0x1e, 0x54, 0x11, 0xef, 0x2f, 0x4e, 0xf9, 0x7, 0xda, 0x42, 0xd6, 0x71, + 0x3b, 0xb9, 0x92, 0xfb, 0x8, 0x1d, 0xf2, 0x41, 0x96, 0x5f, 0x28, 0x10, 0x20, 0x1a, 0x7b, 0xef + }, + }, + { + .msglen = 121, + .result = { + 0x59, 0xb0, 0xdb, 0x73, 0xee, 0x43, 0xb9, 0x63, 0x82, 0x36, 0x11, 0x5a, 0x6b, 0x46, 0x8, 0xbb, + 0x18, 0xdd, 0x74, 0x82, 0x8f, 0xf3, 0xb3, 0x5d, 0xd1, 0xad, 0xe, 0x8e, 0x77, 0x90, 0xde, 0x70 + }, + }, + { + .msglen = 120, + .result = { + 0xe0, 0x24, 0xc5, 0x2, 0x6b, 0xe, 0xe3, 0x9b, 0x1, 0x95, 0x6, 0x21, 0xc6, 0xad, 0x0, 0x72, + 0x36, 0x9, 0x75, 0xcd, 0x10, 0xa3, 0xf, 0xa2, 0xe5, 0xcd, 0x27, 0x6b, 0x95, 0x23, 0x6, 0x72 + }, + }, + { + .msglen = 119, + .result = { + 0x70, 0x4, 0x2c, 0x78, 0xc5, 0x40, 0x3f, 0xfb, 0x71, 0xfb, 0x3e, 0xbd, 0x9f, 0x4e, 0x2f, 0xf8, + 0x3c, 0x9b, 0xd1, 0xad, 0xee, 0xc8, 0x4f, 0x40, 0xec, 0x29, 0x5a, 0xb9, 0x9a, 0xa7, 0xe9, 0x51 + }, + }, + { + .msglen = 118, + .result = { + 0x1a, 0x4b, 0x49, 0xd3, 0x6, 0x1, 0x75, 0xca, 0x3, 0x12, 0x2e, 0x9a, 0xd4, 0xda, 0xb8, 0x23, + 0xf9, 0xa0, 0xa6, 0xbc, 0xbc, 0xcc, 0xa1, 0x6f, 0xd8, 0x3b, 0x2a, 0x37, 0xd3, 0xc3, 0xca, 0x5f + }, + }, + { + .msglen = 0, + .result = { + 0x46, 0x24, 0x76, 0xa8, 0x97, 0xdd, 0xfd, 0xbd, 0x40, 0xd1, 0x42, 0xe, 0x8, 0xa5, 0xbc, 0xfe, + 0xeb, 0x25, 0xc3, 0xe2, 0xad, 0xe6, 0xa0, 0xa9, 0x8, 0x3b, 0x32, 0x7b, 0x9e, 0xf9, 0xfc, 0xa1 + }, + }, +}; + +// 257 characters of pseudo-Latin from lipsum.com (not Copyright) +static const char *message = "Deleniti voluptas explicabo et assumenda. Sed et aliquid minus quis. Praesentium cupiditate quia nemo est. Laboriosam pariatur ut distinctio tenetur. Sunt architecto iure aspernatur soluta ut recusandae. Ut quibusdam occaecati ut qui sit dignissimos eaque.."; + +// 256 different HMAC results for different length portions of the above. Generated as follows: +// +// import hmac, hashlib, binascii +// key = b"".join([chr(x).encode() for x in range(1,33)]) +// assert len(message) == 257 +// for l in range(1, len(message)): +// print(" // %d" % l) +// mac = hmac.HMAC(key, message[:l], hashlib.sha256).digest() +// print("{ " + ", ".join("0x%x" % ord(x) for x in mac) + " }, ") +// +// (Note: the zero length case is handled in the other unit test.) +static const hmac_result results[] = { + { + .msglen = 1, + .result = { 0xf2, 0x1a, 0x8e, 0x60, 0xea, 0xd9, 0x36, 0xd1, 0xc2, 0x74, 0x24, 0xae, 0x6, 0x2d, 0x81, 0x28, 0x16, 0xa6, 0x33, 0xca, 0x9d, 0x55, 0xc0, 0x82, 0x28, 0xd9, 0x79, 0x8f, 0x5a, 0xaa, 0xfd, 0x25 }, + }, + { + .msglen = 2, + .result = { 0x1f, 0x6, 0xfc, 0x68, 0x5c, 0xa8, 0xbf, 0x3e, 0x57, 0x6d, 0x2, 0x56, 0x4a, 0x35, 0x31, 0xbd, 0xeb, 0xf4, 0x5d, 0xd5, 0x71, 0xf9, 0x65, 0x7d, 0xa9, 0x32, 0x1d, 0x68, 0x21, 0xd2, 0x9b, 0xaf }, + }, + { + .msglen = 3, + .result = { 0x2b, 0xb4, 0x4e, 0x80, 0x6e, 0xd2, 0xcb, 0xee, 0x4b, 0x40, 0xfb, 0xf9, 0x61, 0x76, 0x78, 0x2a, 0xb1, 0xc8, 0xea, 0xa3, 0x3e, 0xf7, 0x24, 0x86, 0xa0, 0x73, 0xda, 0xe, 0xaf, 0x98, 0xb, 0xf0 }, + }, + { + .msglen = 4, + .result = { 0xf, 0x39, 0xd1, 0x1a, 0x3a, 0xe9, 0xa9, 0xf8, 0xe9, 0x39, 0xed, 0x1b, 0x32, 0x3, 0xbc, 0x24, 0x32, 0xe8, 0x12, 0xd7, 0xc4, 0xed, 0x2a, 0x8a, 0xed, 0x46, 0xbf, 0xa7, 0x21, 0x31, 0x37, 0xb5 }, + }, + { + .msglen = 5, + .result = { 0x6c, 0xfc, 0xf8, 0x9a, 0x56, 0xce, 0xe6, 0x1, 0x36, 0xca, 0x36, 0x37, 0xa8, 0xb9, 0xca, 0x99, 0x3b, 0xb1, 0xf8, 0x24, 0xa5, 0xf6, 0x20, 0x4d, 0xff, 0x8c, 0x60, 0xd3, 0x9, 0x92, 0xef, 0xb3 }, + }, + { + .msglen = 6, + .result = { 0x86, 0x99, 0x7, 0xd7, 0x5b, 0xb3, 0x93, 0x95, 0x3a, 0x9e, 0xf5, 0x95, 0x9d, 0x5e, 0x7b, 0xaf, 0x9b, 0x4b, 0x19, 0x35, 0x31, 0x34, 0xba, 0x29, 0xa, 0x56, 0xb, 0xe4, 0xa4, 0xbf, 0xb8, 0x9f }, + }, + { + .msglen = 7, + .result = { 0xa9, 0x9, 0x85, 0x26, 0x7b, 0x92, 0x23, 0xe7, 0x3d, 0x44, 0xa1, 0xcc, 0xba, 0x5c, 0xda, 0xdb, 0x5a, 0xe2, 0x76, 0x78, 0xd7, 0x42, 0x77, 0x4a, 0x8e, 0x2b, 0x79, 0x73, 0x4c, 0x29, 0x6, 0x1c }, + }, + { + .msglen = 8, + .result = { 0x26, 0x15, 0x1f, 0xe3, 0x53, 0xd9, 0x8, 0xc5, 0xf0, 0x11, 0x7, 0x7, 0x5f, 0x8c, 0xf6, 0x61, 0xd2, 0x21, 0x16, 0xe4, 0xb9, 0x61, 0x29, 0x1c, 0x4d, 0x2b, 0x6d, 0x9a, 0x88, 0x8c, 0xdc, 0xa9 }, + }, + { + .msglen = 9, + .result = { 0x2, 0xf2, 0xe6, 0xc8, 0x9c, 0xdc, 0x1b, 0x64, 0xd6, 0x32, 0xc2, 0x48, 0x62, 0x51, 0x9c, 0x0, 0x90, 0xf4, 0xf1, 0x2a, 0x0, 0x2, 0xce, 0x32, 0xbb, 0x8f, 0x38, 0x9c, 0x8b, 0xaa, 0xdd, 0x5d }, + }, + { + .msglen = 10, + .result = { 0x44, 0x76, 0x8a, 0x53, 0xcf, 0xbb, 0xc1, 0xd0, 0x36, 0x96, 0xb5, 0xe9, 0xe, 0xfb, 0xce, 0xb3, 0x47, 0x21, 0xaa, 0xea, 0xac, 0x76, 0x54, 0x91, 0xc1, 0xcb, 0x88, 0x32, 0xb1, 0xea, 0xd5, 0x4c }, + }, + { + .msglen = 11, + .result = { 0x95, 0xf9, 0x78, 0x12, 0xe5, 0x7a, 0xf4, 0xc5, 0xee, 0x5e, 0x27, 0xe7, 0x5e, 0x8, 0x56, 0x60, 0x97, 0xc1, 0xee, 0xf, 0xf5, 0x24, 0x5c, 0x20, 0xbe, 0x95, 0x3c, 0xa2, 0xf5, 0x68, 0x69, 0x6f }, + }, + { + .msglen = 12, + .result = { 0x8e, 0x71, 0xa8, 0x23, 0x7a, 0x8, 0x6a, 0xf4, 0x2e, 0xab, 0x58, 0x56, 0x37, 0x55, 0x26, 0x57, 0x13, 0xc, 0x6b, 0x6b, 0x65, 0xb6, 0x4f, 0xec, 0xde, 0xc2, 0xe6, 0xb0, 0x34, 0xc0, 0x4a, 0xba }, + }, + { + .msglen = 13, + .result = { 0x75, 0xc8, 0x29, 0x60, 0x89, 0xb7, 0xba, 0xc7, 0x40, 0x18, 0x73, 0x8a, 0xa3, 0x92, 0xb2, 0x2c, 0x79, 0x74, 0x1c, 0xdc, 0xc0, 0x97, 0x14, 0xdb, 0x26, 0xcc, 0xad, 0x7f, 0x9d, 0x2f, 0xd, 0x5 }, + }, + { + .msglen = 14, + .result = { 0xe9, 0xf2, 0x97, 0x12, 0x4d, 0xc3, 0x22, 0xca, 0x7, 0xc, 0xac, 0xae, 0xcb, 0x63, 0xe2, 0x88, 0xa2, 0xf8, 0xb0, 0x94, 0xfc, 0x21, 0xf4, 0x69, 0x8e, 0xa0, 0x95, 0x3, 0x54, 0xa1, 0x61, 0xed }, + }, + { + .msglen = 15, + .result = { 0x34, 0xd4, 0x3e, 0xcd, 0xcc, 0xa, 0x5f, 0xaf, 0xf5, 0x3d, 0xb8, 0xaa, 0x18, 0x4a, 0x18, 0xef, 0x22, 0x75, 0x29, 0x17, 0x1b, 0x33, 0xf2, 0x50, 0x4e, 0x90, 0xd5, 0xa3, 0x10, 0xff, 0x79, 0xbc }, + }, + { + .msglen = 16, + .result = { 0xcf, 0x6, 0x59, 0x8d, 0x2d, 0x7b, 0xb, 0x3d, 0x1a, 0xa3, 0x9c, 0xfa, 0xa2, 0xf1, 0x88, 0x6, 0xd2, 0xb4, 0xb5, 0x2d, 0x4c, 0x56, 0x7, 0xf5, 0x20, 0xce, 0x9a, 0x79, 0x3a, 0x2e, 0x11, 0xfa }, + }, + { + .msglen = 17, + .result = { 0x55, 0x5f, 0x37, 0xd9, 0x7, 0x3a, 0x3a, 0x6b, 0x22, 0xf8, 0x1c, 0x8f, 0xd8, 0xf6, 0xf7, 0x18, 0x77, 0xf3, 0x52, 0x32, 0xc6, 0x9b, 0xe0, 0xc7, 0xa6, 0xf0, 0x6b, 0xb0, 0x6a, 0xad, 0xb2, 0x7e }, + }, + { + .msglen = 18, + .result = { 0xa0, 0x60, 0x25, 0x34, 0xd7, 0xe1, 0x66, 0x7e, 0xdd, 0xec, 0x8, 0x95, 0xb5, 0xd9, 0x2d, 0x4e, 0x29, 0x89, 0x39, 0xb9, 0xc1, 0xe4, 0xc1, 0x86, 0x10, 0x16, 0x5, 0x17, 0xd0, 0x6, 0x91, 0x2d }, + }, + { + .msglen = 19, + .result = { 0xb4, 0x45, 0xbc, 0xae, 0xb3, 0x5b, 0x61, 0xd3, 0x50, 0x8c, 0x38, 0x7a, 0x4c, 0x4c, 0xbc, 0x38, 0x89, 0x98, 0x75, 0x23, 0xa9, 0x92, 0xa4, 0xea, 0xfe, 0xe6, 0x88, 0x61, 0xb0, 0xf0, 0x8, 0x7b }, + }, + { + .msglen = 20, + .result = { 0x1d, 0x2e, 0x5c, 0x69, 0x7b, 0x2a, 0xa0, 0x9d, 0xe6, 0x5b, 0xc, 0x3, 0x53, 0x9, 0x66, 0x74, 0xd8, 0xf6, 0xe8, 0x87, 0x5d, 0xc7, 0x1, 0xf0, 0xce, 0xaf, 0xb1, 0x15, 0x34, 0x22, 0x8e, 0x83 }, + }, + { + .msglen = 21, + .result = { 0x8e, 0xd9, 0xb1, 0xc7, 0x99, 0x91, 0x1, 0x9a, 0xe, 0xfa, 0xd2, 0xed, 0xc4, 0xae, 0x47, 0xf2, 0xa2, 0x48, 0x53, 0xa8, 0x92, 0xff, 0xe4, 0xcc, 0x95, 0x5e, 0x25, 0x1a, 0x2a, 0x49, 0x6c, 0xfd }, + }, + { + .msglen = 22, + .result = { 0x14, 0xba, 0x32, 0xbe, 0x21, 0x6, 0x6e, 0x6a, 0x28, 0x2b, 0x4e, 0xfc, 0x97, 0xa5, 0x6, 0x32, 0x62, 0x7, 0xf3, 0x61, 0x41, 0x43, 0x5e, 0x34, 0x93, 0x0, 0xa8, 0xb3, 0x9, 0x55, 0x37, 0x3f }, + }, + { + .msglen = 23, + .result = { 0xa1, 0xf0, 0xe6, 0xf1, 0x9d, 0x5d, 0x30, 0x10, 0x17, 0xce, 0x39, 0x5e, 0x93, 0x2b, 0xe6, 0xeb, 0x6b, 0x5b, 0x64, 0x47, 0x65, 0xe8, 0x93, 0x2e, 0x39, 0x74, 0x6a, 0x71, 0xf3, 0xdb, 0xb6, 0x8d }, + }, + { + .msglen = 24, + .result = { 0xab, 0xf4, 0xe1, 0x78, 0xc1, 0x63, 0x95, 0xf2, 0x6c, 0x54, 0xc, 0xac, 0xce, 0x88, 0x17, 0xf6, 0x1c, 0x84, 0x5b, 0x26, 0xa3, 0x5c, 0xea, 0xf7, 0x66, 0xcb, 0x84, 0xed, 0xbe, 0x52, 0xd, 0x25 }, + }, + { + .msglen = 25, + .result = { 0xd8, 0x94, 0x77, 0xa7, 0x6c, 0x51, 0x30, 0x3c, 0xd7, 0x4f, 0xc4, 0x6e, 0x1a, 0x25, 0xf8, 0x87, 0x93, 0x49, 0x28, 0x6b, 0x1b, 0x3, 0x79, 0x5, 0x14, 0x15, 0xd1, 0xee, 0x51, 0x7b, 0x9f, 0x94 }, + }, + { + .msglen = 26, + .result = { 0xbb, 0x8a, 0x5f, 0x73, 0x8d, 0x4e, 0x8a, 0x11, 0x95, 0x5d, 0xf5, 0xcf, 0x25, 0xea, 0x79, 0x38, 0xc4, 0x4b, 0xb4, 0x6f, 0xa3, 0x1f, 0x18, 0x23, 0x73, 0x1e, 0x46, 0xcb, 0x5d, 0x97, 0xcf, 0x6c }, + }, + { + .msglen = 27, + .result = { 0xe2, 0xad, 0x4b, 0x4e, 0x43, 0xf1, 0x6d, 0x62, 0x1a, 0xb4, 0x65, 0xbb, 0xb3, 0x34, 0x8, 0xf7, 0x14, 0x14, 0xd2, 0x6f, 0x41, 0x8f, 0xa7, 0x6f, 0xab, 0x6e, 0x61, 0xe2, 0x5, 0x5b, 0x2a, 0xe6 }, + }, + { + .msglen = 28, + .result = { 0xd9, 0xea, 0x5, 0x72, 0x59, 0x12, 0xff, 0xb, 0x33, 0x87, 0x17, 0x9d, 0xb2, 0x9, 0x4f, 0xfc, 0xba, 0xd7, 0xc, 0x45, 0x3b, 0xbe, 0x6a, 0x12, 0x59, 0x38, 0x40, 0x30, 0x8c, 0xa4, 0xf, 0x7d }, + }, + { + .msglen = 29, + .result = { 0x29, 0xe, 0x6d, 0x59, 0x2a, 0xaf, 0x5f, 0x93, 0xc7, 0x97, 0xbb, 0x29, 0x92, 0x2c, 0xba, 0x6b, 0xa5, 0xcb, 0x7e, 0x88, 0x5b, 0xcd, 0xd4, 0xfe, 0xb4, 0xc7, 0x65, 0xae, 0x6b, 0x7f, 0x78, 0xb6 }, + }, + { + .msglen = 30, + .result = { 0x5e, 0xea, 0x58, 0xb5, 0x93, 0x4b, 0xb7, 0x32, 0x50, 0xcb, 0xc6, 0x6c, 0x63, 0x9d, 0x5d, 0xa9, 0x3f, 0x80, 0xc4, 0x91, 0xbc, 0xe3, 0x2a, 0xd6, 0x20, 0xfb, 0xf9, 0x43, 0x59, 0xcf, 0x86, 0x1d }, + }, + { + .msglen = 31, + .result = { 0x46, 0xee, 0x3a, 0x2a, 0x1, 0xf6, 0x43, 0xe, 0xbb, 0xc6, 0x90, 0x4f, 0x66, 0xa5, 0xe9, 0xd7, 0xa8, 0x29, 0x7e, 0x16, 0x4, 0x57, 0xee, 0x5c, 0xf4, 0x6c, 0xc8, 0x4a, 0x92, 0x27, 0x83, 0x42 }, + }, + { + .msglen = 32, + .result = { 0x82, 0x36, 0xe6, 0xf, 0xa, 0x37, 0x2d, 0x7b, 0x2, 0x75, 0xc4, 0x48, 0x36, 0xbf, 0xdf, 0x79, 0x35, 0xdf, 0xcb, 0x65, 0x25, 0xae, 0x11, 0x2c, 0xfa, 0x54, 0x4a, 0x99, 0xfe, 0x2a, 0x63, 0xbd }, + }, + { + .msglen = 33, + .result = { 0x9e, 0x35, 0xc8, 0x6c, 0xa7, 0xe8, 0x8b, 0xb2, 0x0, 0x4c, 0x41, 0x51, 0x5b, 0xd2, 0x4b, 0x9f, 0x10, 0xea, 0xfe, 0xd7, 0xc1, 0xd1, 0x36, 0xfb, 0x52, 0xd6, 0xe3, 0xe2, 0x23, 0xc9, 0x53, 0x33 }, + }, + { + .msglen = 34, + .result = { 0x52, 0xe9, 0x15, 0x90, 0x65, 0xb, 0x75, 0x89, 0xb3, 0xed, 0x7a, 0xb6, 0x12, 0xe6, 0xe, 0xeb, 0x7c, 0x25, 0xb4, 0xf3, 0x2a, 0xf6, 0xfe, 0x6a, 0x3c, 0xd9, 0xf0, 0x2a, 0xaf, 0xc7, 0x1b, 0xbc }, + }, + { + .msglen = 35, + .result = { 0xfc, 0xa5, 0xf1, 0x9a, 0xa0, 0xfa, 0x42, 0x7b, 0x49, 0xf, 0xd7, 0x76, 0xe0, 0xf9, 0x31, 0x17, 0x87, 0x70, 0x19, 0x90, 0x26, 0x96, 0xcd, 0xd6, 0xf, 0xa8, 0xb, 0x1f, 0x31, 0x45, 0x9c, 0xd0 }, + }, + { + .msglen = 36, + .result = { 0x85, 0x76, 0xf4, 0xfc, 0x96, 0xfb, 0x69, 0x31, 0x6, 0x5c, 0x6e, 0xd9, 0x75, 0xda, 0xf0, 0x14, 0xba, 0x4b, 0x74, 0x96, 0xf7, 0xe6, 0xd0, 0x3d, 0x36, 0x9b, 0x94, 0x8c, 0x1a, 0xb9, 0x7a, 0x88 }, + }, + { + .msglen = 37, + .result = { 0x8b, 0xc7, 0xad, 0xb8, 0xce, 0xc6, 0xd7, 0x8e, 0xd6, 0xfa, 0xa5, 0xd3, 0x59, 0x3d, 0x39, 0xdc, 0x74, 0x56, 0x3c, 0xd9, 0xc8, 0x0, 0xd2, 0xb0, 0x21, 0x7b, 0x93, 0xcb, 0x18, 0xec, 0x5f, 0xdd }, + }, + { + .msglen = 38, + .result = { 0x95, 0x7a, 0xf3, 0x9c, 0x5b, 0x40, 0x86, 0xdf, 0xa6, 0xf7, 0x34, 0x40, 0xb0, 0x7a, 0x34, 0x6c, 0xd5, 0x3d, 0x6, 0x9d, 0xc7, 0x9f, 0x11, 0x32, 0x98, 0x78, 0xee, 0xed, 0xb6, 0xb4, 0x1f, 0x34 }, + }, + { + .msglen = 39, + .result = { 0xf3, 0x50, 0x40, 0xd2, 0xbb, 0x54, 0xb3, 0xcf, 0x37, 0x55, 0xff, 0xc8, 0x41, 0x30, 0xde, 0x33, 0x2f, 0x4, 0xe3, 0xe7, 0x42, 0x31, 0x68, 0xe6, 0x6d, 0x5d, 0xdc, 0x14, 0x5a, 0x58, 0xf4, 0x46 }, + }, + { + .msglen = 40, + .result = { 0xda, 0x9d, 0xeb, 0xf7, 0xa7, 0xa1, 0x4, 0xd1, 0xfb, 0xe3, 0xd8, 0x11, 0x8d, 0x54, 0x88, 0x65, 0x42, 0x6e, 0x78, 0x7a, 0x8f, 0x1b, 0xc5, 0x13, 0x98, 0x53, 0x38, 0x26, 0xf3, 0x3d, 0xd2, 0xff }, + }, + { + .msglen = 41, + .result = { 0x9c, 0x23, 0x67, 0xa3, 0xeb, 0xed, 0xca, 0x21, 0x4b, 0x4c, 0x68, 0x95, 0xaf, 0xfb, 0x9b, 0x17, 0xf0, 0x2a, 0x5c, 0x78, 0x58, 0x65, 0xf1, 0x20, 0xfd, 0x3c, 0xd9, 0x66, 0x94, 0x66, 0x4d, 0xcc }, + }, + { + .msglen = 42, + .result = { 0xfa, 0x61, 0xf5, 0xd7, 0x58, 0xd2, 0x32, 0xb0, 0xb, 0x95, 0x88, 0xfc, 0x8a, 0x79, 0x15, 0x61, 0x1e, 0xa7, 0xf7, 0xf2, 0xf1, 0x91, 0xe7, 0xb3, 0x55, 0xa0, 0x65, 0x3c, 0xca, 0xf6, 0xac, 0x19 }, + }, + { + .msglen = 43, + .result = { 0xae, 0xc1, 0xb4, 0xa9, 0x88, 0xf3, 0x6d, 0xfe, 0xc2, 0x48, 0x19, 0x2a, 0x68, 0x41, 0x5e, 0x3f, 0xbe, 0x32, 0x20, 0xc7, 0x90, 0x6f, 0x23, 0x6d, 0x42, 0xaa, 0x38, 0xbb, 0xd5, 0x34, 0x7e, 0x21 }, + }, + { + .msglen = 44, + .result = { 0x12, 0xb0, 0xb, 0x1, 0xcf, 0xc9, 0x20, 0x8d, 0x59, 0xc1, 0xb7, 0xe9, 0x23, 0x53, 0x12, 0xd4, 0x41, 0x99, 0x7f, 0xb9, 0x57, 0x11, 0x5d, 0x9c, 0x60, 0xa8, 0x0, 0x3, 0x68, 0x9, 0x4d, 0x1d }, + }, + { + .msglen = 45, + .result = { 0xee, 0x85, 0x2, 0xed, 0xa1, 0x41, 0x71, 0xd4, 0x32, 0x2, 0x33, 0xec, 0x26, 0x31, 0x7b, 0xb8, 0xd0, 0xb0, 0xd6, 0xb0, 0x60, 0x52, 0xe1, 0xd9, 0xd7, 0x33, 0x72, 0x5c, 0xb9, 0xc3, 0x6c, 0x9f }, + }, + { + .msglen = 46, + .result = { 0x90, 0x3e, 0x7, 0x17, 0xa2, 0x18, 0xd, 0xa1, 0x71, 0xfe, 0x4b, 0x6d, 0x24, 0x40, 0x5e, 0xe2, 0xd1, 0x45, 0xd6, 0x18, 0xe8, 0xa3, 0x2d, 0x12, 0xe8, 0x11, 0xae, 0x1, 0xc4, 0x77, 0xa9, 0xab }, + }, + { + .msglen = 47, + .result = { 0x4a, 0x4f, 0x5a, 0xd1, 0xd0, 0xfb, 0xf7, 0x60, 0x9c, 0xbf, 0x23, 0x99, 0x95, 0xea, 0x51, 0xdb, 0x70, 0xc4, 0xa, 0xaf, 0x41, 0x13, 0x7d, 0x3d, 0xd1, 0x50, 0xa7, 0x13, 0x4f, 0xa0, 0xbf, 0xf4 }, + }, + { + .msglen = 48, + .result = { 0x63, 0x50, 0x7a, 0x54, 0xd8, 0xa5, 0xf, 0x96, 0x45, 0x3a, 0x85, 0x8e, 0x8e, 0xc6, 0x5d, 0xe0, 0xe8, 0xfd, 0xce, 0xa8, 0x3f, 0x59, 0x19, 0x81, 0x13, 0xd1, 0xf7, 0xd, 0x45, 0xe3, 0xf3, 0x31 }, + }, + { + .msglen = 49, + .result = { 0x3c, 0x7a, 0x1, 0xdd, 0x3a, 0x96, 0xae, 0x2, 0x2e, 0x6a, 0x7f, 0xd, 0x1e, 0x2f, 0x32, 0xfd, 0x5, 0x33, 0xae, 0x54, 0xa2, 0xa6, 0x89, 0x32, 0x9a, 0x7, 0xb7, 0xe9, 0x66, 0xaf, 0xf8, 0xc }, + }, + { + .msglen = 50, + .result = { 0x57, 0xd8, 0xed, 0xc4, 0xec, 0x23, 0xf, 0xf9, 0x55, 0xc1, 0x36, 0xde, 0xc3, 0xbd, 0x54, 0x53, 0x2f, 0xfa, 0xd1, 0xb3, 0xe1, 0x87, 0xc2, 0x39, 0x54, 0x59, 0xa9, 0xb9, 0xac, 0xed, 0xa0, 0x49 }, + }, + { + .msglen = 51, + .result = { 0xdf, 0xd5, 0x2e, 0xd2, 0xd2, 0xb0, 0x90, 0x12, 0x71, 0x37, 0x51, 0xba, 0x79, 0xd4, 0x43, 0xc7, 0x74, 0x12, 0xf3, 0x71, 0x74, 0x63, 0xc, 0x4d, 0x59, 0x2e, 0x5, 0xb5, 0xa2, 0x17, 0xe, 0xe9 }, + }, + { + .msglen = 52, + .result = { 0xbd, 0xa3, 0x12, 0x94, 0xea, 0xa7, 0xc4, 0xd3, 0x1f, 0x99, 0xcb, 0xbc, 0x53, 0x80, 0x45, 0xfd, 0x17, 0x13, 0xd7, 0x2b, 0x26, 0x5b, 0x23, 0x3d, 0x2d, 0xd8, 0x7f, 0x9, 0xcc, 0x9c, 0xa7, 0xfd }, + }, + { + .msglen = 53, + .result = { 0x66, 0x3a, 0xc1, 0x3b, 0x1f, 0x7d, 0x0, 0xf5, 0x9a, 0x5e, 0x92, 0x61, 0x16, 0xad, 0x2b, 0x15, 0x2f, 0x65, 0x89, 0xd2, 0xa3, 0xbd, 0x33, 0x71, 0x31, 0xe8, 0x37, 0x3c, 0xb0, 0x6d, 0x13, 0xc9 }, + }, + { + .msglen = 54, + .result = { 0xff, 0x17, 0xef, 0x42, 0x67, 0xba, 0xcf, 0xe7, 0xfe, 0xf5, 0x76, 0x96, 0x9e, 0xf0, 0x61, 0xe5, 0xd, 0xc3, 0xbb, 0x63, 0xd3, 0xcd, 0x4a, 0x10, 0x63, 0xa3, 0x3c, 0xe, 0xf2, 0xfc, 0xa, 0x33 }, + }, + { + .msglen = 55, + .result = { 0x78, 0xa8, 0xe5, 0x15, 0x18, 0x49, 0x4, 0xba, 0x34, 0xb6, 0xb3, 0x96, 0x3a, 0x6, 0xaa, 0x93, 0xad, 0x82, 0x5b, 0x87, 0x0, 0x3f, 0x5, 0x1, 0xe7, 0xe1, 0x22, 0x16, 0x3d, 0xb5, 0x5b, 0xb8 }, + }, + { + .msglen = 56, + .result = { 0x0, 0xad, 0xbf, 0x7d, 0x51, 0xc4, 0xed, 0x5, 0x6c, 0x81, 0x15, 0x5c, 0xa5, 0xe3, 0x6b, 0x39, 0x59, 0x10, 0x8e, 0xbc, 0x3f, 0xb8, 0x21, 0xbc, 0xd9, 0x9e, 0x35, 0x7d, 0x23, 0x48, 0x5, 0x8a }, + }, + { + .msglen = 57, + .result = { 0xf7, 0x5e, 0xa3, 0x88, 0x1f, 0x82, 0xf0, 0xc4, 0x39, 0x7e, 0xed, 0x22, 0x78, 0xd6, 0x65, 0x94, 0x4f, 0x8, 0x2e, 0x96, 0x7e, 0x44, 0x8f, 0x0, 0x3b, 0x92, 0xf9, 0xea, 0x83, 0x72, 0xc7, 0xe2 }, + }, + { + .msglen = 58, + .result = { 0x84, 0xa5, 0x85, 0x95, 0x0, 0x7e, 0xc4, 0x98, 0x36, 0xc9, 0xe5, 0xd4, 0xda, 0x59, 0xab, 0x22, 0x2f, 0xa8, 0xb7, 0x46, 0x55, 0x91, 0x2, 0xc, 0x5b, 0x64, 0x5c, 0x5b, 0x42, 0x8b, 0x7e, 0xa }, + }, + { + .msglen = 59, + .result = { 0x4e, 0x1c, 0x16, 0x99, 0xd8, 0x4, 0xb, 0x6, 0x91, 0x98, 0x87, 0xb0, 0xa3, 0x63, 0x9, 0xdf, 0xfb, 0xa6, 0xd6, 0xe4, 0x58, 0x27, 0xf5, 0x73, 0x9, 0x81, 0x4f, 0x5d, 0x88, 0x2c, 0xb8, 0x7 }, + }, + { + .msglen = 60, + .result = { 0x2f, 0x97, 0xbf, 0x70, 0x70, 0x4b, 0xfe, 0x5a, 0x2f, 0x91, 0x8f, 0x28, 0x8b, 0xee, 0xf6, 0xee, 0x41, 0x7d, 0x36, 0x14, 0x86, 0x69, 0x42, 0x9c, 0x4d, 0x5, 0xcc, 0x53, 0x71, 0x61, 0x78, 0xe }, + }, + { + .msglen = 61, + .result = { 0xe6, 0xba, 0x7f, 0x8, 0xb3, 0xdc, 0x7b, 0x95, 0xcb, 0xd1, 0x33, 0x64, 0x25, 0x5a, 0xa3, 0x70, 0x10, 0x4a, 0xe6, 0x2c, 0x54, 0x25, 0xfa, 0x7e, 0xd0, 0x47, 0x65, 0x8d, 0xa1, 0xa8, 0x80, 0x5 }, + }, + { + .msglen = 62, + .result = { 0x9b, 0x48, 0x8d, 0x79, 0x16, 0xe8, 0x32, 0x63, 0x89, 0xaa, 0x4b, 0x7d, 0xdb, 0x46, 0xcd, 0x80, 0x40, 0x9d, 0x8c, 0x6, 0xa5, 0xed, 0xb4, 0xe1, 0xdd, 0x87, 0x6b, 0xb3, 0x90, 0x2b, 0x77, 0xc8 }, + }, + { + .msglen = 63, + .result = { 0x72, 0xfb, 0x8c, 0xf1, 0xb9, 0xb3, 0x50, 0x55, 0x5c, 0xac, 0x93, 0x38, 0x73, 0x1c, 0xd0, 0x93, 0x6, 0x5e, 0xcd, 0x0, 0x24, 0x83, 0x4b, 0xef, 0xdc, 0xfd, 0x27, 0x58, 0xfc, 0xa1, 0x4a, 0x32 }, + }, + { + .msglen = 64, + .result = { 0x19, 0x5b, 0x88, 0x8d, 0x75, 0x97, 0x8a, 0x8c, 0x5d, 0xd4, 0xe7, 0xe4, 0xa, 0x4d, 0x5e, 0xcd, 0xe7, 0x88, 0xab, 0xb9, 0x6b, 0xd8, 0xd3, 0x80, 0x25, 0x3e, 0xa4, 0xfd, 0xc1, 0x83, 0x6e, 0x74 }, + }, + { + .msglen = 65, + .result = { 0x14, 0x3, 0xcc, 0x1f, 0xa5, 0xed, 0x5e, 0x3c, 0x45, 0x2d, 0x66, 0x9a, 0x36, 0xb7, 0x9a, 0xb, 0x1c, 0x83, 0x4d, 0xbe, 0xc9, 0x41, 0x7e, 0x7, 0x54, 0x97, 0x76, 0x25, 0x96, 0x76, 0xce, 0xd4 }, + }, + { + .msglen = 66, + .result = { 0x44, 0x62, 0x56, 0x7e, 0x68, 0x10, 0xed, 0xd9, 0x35, 0x8a, 0xe3, 0xd, 0x20, 0xf, 0xe6, 0x45, 0x89, 0x6c, 0x8c, 0x18, 0x13, 0xe5, 0xef, 0x28, 0x2d, 0xc1, 0x6a, 0x95, 0x9e, 0x3d, 0x81, 0x51 }, + }, + { + .msglen = 67, + .result = { 0x94, 0xac, 0xc2, 0xe0, 0x8, 0xb7, 0xe5, 0xe2, 0x18, 0xf0, 0x59, 0x47, 0xda, 0xf4, 0xb4, 0xb1, 0xfe, 0x11, 0xe4, 0x3c, 0x2c, 0xa8, 0x1, 0x30, 0x5e, 0x8e, 0x89, 0x4, 0xff, 0xf2, 0xc1, 0x88 }, + }, + { + .msglen = 68, + .result = { 0xa2, 0x73, 0x97, 0x2, 0xd7, 0xc4, 0x9b, 0x39, 0x20, 0xdc, 0xac, 0x6d, 0xca, 0x81, 0xdd, 0x83, 0xac, 0xd4, 0xf, 0x89, 0x94, 0x10, 0x8b, 0xf6, 0xb9, 0x10, 0xab, 0x24, 0xd3, 0xf9, 0xc8, 0x4f }, + }, + { + .msglen = 69, + .result = { 0x68, 0xa9, 0x9b, 0xc2, 0xb6, 0x1e, 0x4c, 0xe3, 0xc6, 0x89, 0xc7, 0x40, 0x2f, 0xee, 0x8f, 0x50, 0xf4, 0x9d, 0x56, 0x5, 0xba, 0x0, 0x30, 0xaa, 0xd6, 0xa6, 0x4d, 0x94, 0x46, 0xc, 0x3c, 0x3 }, + }, + { + .msglen = 70, + .result = { 0x4f, 0x71, 0x4e, 0x2f, 0x89, 0xce, 0x84, 0x3b, 0x9a, 0xab, 0x6c, 0x93, 0xac, 0xa8, 0x51, 0xf7, 0x72, 0x91, 0xd5, 0xad, 0xf7, 0x91, 0x5a, 0x3a, 0xa6, 0x16, 0x61, 0x6b, 0x9f, 0xba, 0xe3, 0x51 }, + }, + { + .msglen = 71, + .result = { 0x25, 0x50, 0x50, 0x55, 0x50, 0x6a, 0x55, 0x8d, 0x54, 0x61, 0x60, 0x44, 0x5a, 0xb0, 0x4f, 0x77, 0x7, 0xbe, 0xcf, 0x49, 0xb6, 0x68, 0x9b, 0x6d, 0x79, 0xd5, 0xb9, 0xb1, 0x45, 0x29, 0xcc, 0xc1 }, + }, + { + .msglen = 72, + .result = { 0x59, 0x47, 0xf5, 0x99, 0xad, 0xac, 0x9, 0x15, 0xdc, 0x67, 0x2f, 0x4e, 0x38, 0x83, 0xab, 0x53, 0x8d, 0xc2, 0x71, 0xf5, 0xb9, 0x4e, 0x59, 0xd5, 0x32, 0x10, 0x90, 0xd8, 0x5b, 0xb6, 0x5, 0xc0 }, + }, + { + .msglen = 73, + .result = { 0x68, 0x9, 0x2a, 0x7d, 0x49, 0x8f, 0xc1, 0xd4, 0x93, 0xc9, 0xf8, 0xe9, 0xd8, 0xc4, 0xc2, 0x34, 0xc8, 0xac, 0xc9, 0xb4, 0x9, 0x5d, 0x46, 0x51, 0xd4, 0x2e, 0x4, 0xbb, 0x8f, 0x66, 0x75, 0x15 }, + }, + { + .msglen = 74, + .result = { 0xc, 0xf, 0x3c, 0x79, 0x8b, 0x80, 0x93, 0xd9, 0x7f, 0x3, 0xb4, 0x5f, 0xfe, 0x66, 0xcf, 0xbe, 0xea, 0xe1, 0xa0, 0xfd, 0xf0, 0x49, 0x3d, 0x19, 0x54, 0xdc, 0x38, 0x73, 0x11, 0xb3, 0x8, 0xa3 }, + }, + { + .msglen = 75, + .result = { 0x33, 0xae, 0x39, 0xab, 0x8, 0x54, 0x48, 0x9e, 0x2b, 0xbe, 0x89, 0x7a, 0x32, 0xdb, 0x81, 0xc5, 0xbd, 0x39, 0x19, 0xc1, 0x87, 0x6f, 0x64, 0xb3, 0x70, 0xea, 0x9, 0xd2, 0xea, 0x72, 0x53, 0x6e }, + }, + { + .msglen = 76, + .result = { 0x37, 0xae, 0xae, 0xed, 0x35, 0xd1, 0x97, 0x88, 0x78, 0x57, 0x19, 0xdd, 0xbc, 0x3c, 0xa3, 0x10, 0x79, 0x21, 0x3a, 0xf9, 0xce, 0x34, 0xf3, 0xad, 0x85, 0x4f, 0xf2, 0xac, 0xd7, 0x24, 0x7b, 0x80 }, + }, + { + .msglen = 77, + .result = { 0xc0, 0xd0, 0xb7, 0xff, 0x19, 0x7a, 0xfe, 0x6c, 0x6, 0x4b, 0xf6, 0x12, 0x4c, 0xe6, 0xe8, 0x2, 0xf3, 0x32, 0xc3, 0x77, 0xf, 0x10, 0xab, 0x89, 0xde, 0x18, 0xc5, 0xe, 0x25, 0xab, 0x23, 0xdb }, + }, + { + .msglen = 78, + .result = { 0x5e, 0xe7, 0x3b, 0xa0, 0x6, 0x8e, 0x40, 0x26, 0xaf, 0x6f, 0xba, 0xf9, 0xa6, 0x23, 0xab, 0x49, 0x89, 0x15, 0xd4, 0x15, 0xc0, 0x6c, 0x1f, 0xfc, 0x6d, 0x3e, 0x51, 0x3a, 0x6e, 0xef, 0x3d, 0x17 }, + }, + { + .msglen = 79, + .result = { 0x2, 0xfd, 0xd7, 0x48, 0x76, 0x5b, 0x25, 0x26, 0xd4, 0x87, 0x94, 0x14, 0x9b, 0x13, 0x91, 0xa4, 0x39, 0x5, 0x4c, 0x4e, 0x6a, 0xdd, 0x60, 0x66, 0x4e, 0x23, 0xeb, 0xa5, 0xfd, 0xad, 0x5a, 0xda }, + }, + { + .msglen = 80, + .result = { 0x84, 0xf3, 0x92, 0xf1, 0xc0, 0xc0, 0x5a, 0x63, 0xec, 0x16, 0xf4, 0xfc, 0x4c, 0xc6, 0xb6, 0x62, 0x1e, 0x9f, 0xdd, 0xcb, 0xd8, 0x4a, 0x12, 0xf2, 0x9, 0x11, 0x88, 0x66, 0x4e, 0x85, 0xef, 0x9f }, + }, + { + .msglen = 81, + .result = { 0x8b, 0x28, 0x66, 0x9d, 0xe2, 0x96, 0x58, 0x21, 0x3f, 0xcd, 0xd7, 0xe0, 0xce, 0x9b, 0x51, 0x32, 0x68, 0xac, 0x1c, 0x9e, 0x38, 0x7d, 0x60, 0x5a, 0x32, 0xe1, 0x14, 0x91, 0xee, 0x36, 0x39, 0xbd }, + }, + { + .msglen = 82, + .result = { 0x5c, 0x16, 0xe3, 0xff, 0x6b, 0x51, 0xc2, 0x59, 0x8a, 0x24, 0xc2, 0xba, 0xc0, 0xd7, 0xd4, 0xac, 0xd9, 0x3e, 0x38, 0x1f, 0x7f, 0x2d, 0xb7, 0x85, 0x8b, 0xf1, 0xd2, 0x42, 0x28, 0xa9, 0xd7, 0x94 }, + }, + { + .msglen = 83, + .result = { 0xde, 0x40, 0xe0, 0xde, 0xf9, 0xe4, 0x75, 0x3d, 0x61, 0x91, 0x38, 0xac, 0x31, 0xa9, 0xba, 0x31, 0x18, 0x41, 0x57, 0x2e, 0x89, 0xdf, 0x26, 0x83, 0x40, 0x71, 0xce, 0xdc, 0x18, 0x3f, 0xe7, 0xd7 }, + }, + { + .msglen = 84, + .result = { 0x85, 0xf, 0x58, 0x5f, 0x4d, 0x81, 0x5b, 0x54, 0x6a, 0xa4, 0xd4, 0xfb, 0x3, 0x4e, 0x71, 0xa7, 0xc5, 0x11, 0xf, 0x1a, 0xa8, 0x44, 0x10, 0x15, 0x2e, 0xdf, 0x1e, 0xea, 0x4d, 0x86, 0x31, 0x33 }, + }, + { + .msglen = 85, + .result = { 0x7f, 0xe2, 0x1b, 0x95, 0x7b, 0x19, 0x2f, 0x4e, 0x72, 0x1d, 0x6c, 0x2c, 0xf3, 0x74, 0x6e, 0x99, 0x2b, 0x10, 0x76, 0x55, 0x25, 0xe4, 0x89, 0x19, 0x98, 0xb4, 0xdc, 0xea, 0xfa, 0x68, 0xec, 0x3 }, + }, + { + .msglen = 86, + .result = { 0x5c, 0x95, 0x3d, 0xcc, 0x6, 0x58, 0x9b, 0xc4, 0x71, 0x61, 0xc2, 0x5a, 0xac, 0xaf, 0x54, 0xbf, 0xcc, 0x93, 0x3d, 0x2e, 0xdf, 0x99, 0x74, 0xc8, 0xc8, 0x36, 0xe9, 0x44, 0x7e, 0x6d, 0x3d, 0xe7 }, + }, + { + .msglen = 87, + .result = { 0xf2, 0x33, 0xbc, 0x61, 0xc6, 0x2c, 0x19, 0x26, 0x80, 0x9e, 0x1e, 0x76, 0x8e, 0x9, 0x61, 0x6, 0xfb, 0xc3, 0xc8, 0xcb, 0x35, 0x9d, 0xaa, 0x73, 0xa8, 0xe6, 0xd2, 0x89, 0xc5, 0x5d, 0xee, 0xa4 }, + }, + { + .msglen = 88, + .result = { 0x3f, 0x13, 0xf7, 0x63, 0x67, 0x8d, 0x65, 0xcd, 0xa8, 0x5b, 0xcd, 0xc4, 0xb7, 0x25, 0x35, 0xbe, 0xd3, 0xc1, 0x6d, 0x36, 0xb9, 0x8c, 0x8c, 0x6a, 0x79, 0xd1, 0x12, 0xe8, 0xdc, 0x6c, 0xe3, 0x6d }, + }, + { + .msglen = 89, + .result = { 0x8f, 0x21, 0x5a, 0x7a, 0x84, 0x79, 0x7d, 0x33, 0xa, 0x7e, 0x7a, 0x7, 0x2a, 0xa9, 0xa6, 0x58, 0x33, 0xdf, 0xec, 0x40, 0x88, 0xf2, 0x9f, 0x8d, 0x12, 0xb5, 0x5e, 0xb2, 0x88, 0x2d, 0xc1, 0x7c }, + }, + { + .msglen = 90, + .result = { 0x73, 0xfc, 0xc6, 0x9, 0x5f, 0xc2, 0xab, 0x2d, 0xd5, 0x84, 0x6c, 0xdd, 0x1f, 0x70, 0x9e, 0x5c, 0x30, 0x36, 0xb4, 0xe7, 0x86, 0xab, 0x89, 0xc6, 0xc9, 0xed, 0x7d, 0x2e, 0x26, 0x13, 0x37, 0x4a }, + }, + { + .msglen = 91, + .result = { 0x3e, 0x41, 0x8a, 0x37, 0xbd, 0xec, 0x53, 0x52, 0x47, 0xd2, 0x71, 0xa4, 0x5b, 0xc7, 0x11, 0x8e, 0x8c, 0xb8, 0x2c, 0x36, 0xc9, 0xa7, 0x15, 0x21, 0x15, 0xde, 0x7f, 0x54, 0xc7, 0xb3, 0x8d, 0x34 }, + }, + { + .msglen = 92, + .result = { 0xca, 0x1a, 0xf9, 0xfd, 0xf4, 0xb9, 0xd, 0xdd, 0x91, 0xd8, 0x7b, 0x7c, 0xf4, 0x82, 0xe7, 0x57, 0xc0, 0xb9, 0xfe, 0x2f, 0x3c, 0xc7, 0x5a, 0x3d, 0xb, 0x79, 0xb3, 0x7a, 0x7e, 0xfd, 0x25, 0x20 }, + }, + { + .msglen = 93, + .result = { 0xf6, 0x54, 0xd6, 0x3a, 0x93, 0xe3, 0x7b, 0x42, 0x11, 0xa8, 0xda, 0xa4, 0x2f, 0xbf, 0xcb, 0xd0, 0x58, 0x59, 0xf8, 0xda, 0x8c, 0x5e, 0xdc, 0x1e, 0xb0, 0x64, 0x15, 0x31, 0x92, 0xe6, 0xcc, 0xc8 }, + }, + { + .msglen = 94, + .result = { 0x7b, 0x8f, 0x93, 0xa3, 0x55, 0x11, 0x1e, 0x18, 0x77, 0xd9, 0x12, 0x7c, 0x54, 0x4e, 0x3f, 0x36, 0x18, 0x2f, 0xc7, 0xba, 0xd3, 0xe7, 0xc, 0xa3, 0xb2, 0xb1, 0x66, 0x7a, 0xfe, 0x30, 0x1b, 0x4e }, + }, + { + .msglen = 95, + .result = { 0x16, 0xea, 0xe9, 0xae, 0x5d, 0x2f, 0x88, 0x87, 0x41, 0x43, 0x3d, 0xfc, 0x35, 0x7f, 0x2c, 0x4c, 0x63, 0x36, 0xf3, 0x36, 0x51, 0x84, 0xb1, 0x64, 0xc5, 0x19, 0xc0, 0xd6, 0x57, 0xef, 0x2a, 0xa4 }, + }, + { + .msglen = 96, + .result = { 0xc9, 0x79, 0x20, 0xa1, 0x14, 0xba, 0xbe, 0x88, 0x7d, 0x6f, 0x4, 0xe3, 0xfd, 0x2d, 0xfd, 0xc3, 0x8a, 0x1, 0xea, 0x12, 0x9d, 0x4c, 0x14, 0xc3, 0x82, 0x7f, 0xb6, 0x1e, 0x8d, 0xcc, 0x11, 0x84 }, + }, + { + .msglen = 97, + .result = { 0x20, 0xa9, 0xb7, 0x5a, 0x5b, 0x76, 0xaa, 0x7b, 0xed, 0x70, 0x16, 0xfb, 0xea, 0x93, 0x55, 0xd1, 0x9f, 0x95, 0xa, 0xe0, 0x79, 0x51, 0x12, 0x2c, 0xfd, 0x7d, 0x6c, 0x94, 0x4f, 0xb6, 0x5f, 0x14 }, + }, + { + .msglen = 98, + .result = { 0xfc, 0xf4, 0x1, 0xcc, 0x9f, 0xce, 0xc2, 0x50, 0x0, 0x1f, 0xf8, 0x3f, 0xe4, 0x87, 0x2e, 0x79, 0x94, 0xdb, 0x86, 0x85, 0x8a, 0x7d, 0xb4, 0x6a, 0x84, 0xb8, 0x6c, 0x32, 0xad, 0x8c, 0x20, 0x63 }, + }, + { + .msglen = 99, + .result = { 0x17, 0xa1, 0xf5, 0x6, 0xaa, 0xb0, 0xe3, 0x82, 0x2e, 0x9c, 0xf2, 0xb9, 0x75, 0x75, 0xe9, 0x36, 0x90, 0xa9, 0xb2, 0xb9, 0x97, 0xb0, 0x10, 0xbb, 0xdd, 0x65, 0xd0, 0xa8, 0xbf, 0x69, 0x1d, 0x43 }, + }, + { + .msglen = 100, + .result = { 0xb5, 0x6c, 0xca, 0xca, 0xe1, 0xc5, 0x74, 0x19, 0xb0, 0x89, 0x58, 0x5e, 0x2e, 0x61, 0xcb, 0xa1, 0x23, 0xd0, 0x25, 0x37, 0x47, 0xe3, 0xac, 0x3e, 0x9a, 0xf6, 0x5d, 0x0, 0x77, 0xc2, 0xdc, 0x47 }, + }, + { + .msglen = 101, + .result = { 0x8, 0xa4, 0x3b, 0xe7, 0x1e, 0xeb, 0x4c, 0x3a, 0x82, 0xf1, 0xe4, 0x9d, 0xb1, 0xcc, 0xbc, 0x30, 0xb7, 0xa6, 0xfe, 0x47, 0x43, 0x86, 0xb8, 0x10, 0x33, 0xef, 0x8e, 0x35, 0x34, 0xf1, 0x52, 0xae }, + }, + { + .msglen = 102, + .result = { 0x0, 0xdb, 0x9b, 0xb7, 0xfc, 0x8a, 0x55, 0x81, 0x49, 0x94, 0x5c, 0xc2, 0x63, 0xd2, 0x56, 0x85, 0xab, 0x5a, 0xa1, 0x89, 0x66, 0xa1, 0x4d, 0x39, 0x1b, 0xe2, 0x12, 0x9a, 0x51, 0x79, 0xc0, 0x1c }, + }, + { + .msglen = 103, + .result = { 0x4c, 0xeb, 0xaa, 0xec, 0xb8, 0x31, 0xef, 0xb6, 0x89, 0x8e, 0x42, 0xdf, 0x9d, 0x57, 0x42, 0xf7, 0x53, 0x5d, 0x11, 0xc0, 0x29, 0xf7, 0x64, 0x30, 0x42, 0x32, 0x23, 0xda, 0x19, 0xe, 0x8d, 0xf3 }, + }, + { + .msglen = 104, + .result = { 0x32, 0xf5, 0x6, 0x53, 0xf8, 0x18, 0x94, 0x3d, 0xaa, 0x5e, 0xb9, 0x9e, 0x95, 0x8, 0x4, 0x29, 0xea, 0x76, 0xa1, 0xe5, 0x60, 0xa, 0x29, 0xd0, 0x78, 0x7e, 0x0, 0x27, 0x4e, 0x63, 0xc3, 0x69 }, + }, + { + .msglen = 105, + .result = { 0xa9, 0xf1, 0x2b, 0xaa, 0x5e, 0xb3, 0xc9, 0xf3, 0x25, 0x6e, 0x6f, 0x8, 0xc3, 0xb4, 0xab, 0xd1, 0x20, 0x3c, 0xb1, 0x82, 0x6b, 0xfa, 0x8, 0x62, 0xaf, 0x7a, 0xa9, 0x0, 0x79, 0x9a, 0x2b, 0x12 }, + }, + { + .msglen = 106, + .result = { 0xc2, 0x5e, 0x53, 0x66, 0x14, 0x5, 0x26, 0x6a, 0xf1, 0x70, 0x50, 0xb3, 0x9b, 0x40, 0x99, 0x7a, 0x73, 0xe2, 0xed, 0x3d, 0x4c, 0xcc, 0xf9, 0xf6, 0x1b, 0x4c, 0x6, 0xdc, 0x9, 0x7a, 0xc2, 0x4a }, + }, + { + .msglen = 107, + .result = { 0x68, 0xeb, 0x96, 0xb6, 0x9, 0x7b, 0xe2, 0x4a, 0x18, 0x3a, 0xe8, 0xf8, 0xe8, 0xc7, 0x4e, 0x27, 0x8c, 0x18, 0x8a, 0xa6, 0x23, 0xfe, 0xc2, 0xb, 0xbd, 0x72, 0x1, 0x56, 0x21, 0x6b, 0x6c, 0x56 }, + }, + { + .msglen = 108, + .result = { 0xe1, 0x7, 0xeb, 0xc3, 0x3a, 0x5e, 0x28, 0x65, 0x14, 0xcb, 0x73, 0x19, 0xef, 0x32, 0x78, 0x96, 0xf3, 0xda, 0x1e, 0x5a, 0x89, 0xf4, 0x29, 0x7c, 0xa0, 0xfd, 0x3b, 0xe8, 0xb, 0xf0, 0x72, 0xf1 }, + }, + { + .msglen = 109, + .result = { 0x88, 0xac, 0xe5, 0xe7, 0xdb, 0x26, 0xa5, 0xa5, 0xef, 0x66, 0x92, 0xb4, 0xab, 0x6b, 0xed, 0x4b, 0x1a, 0x9e, 0x19, 0xb0, 0xb6, 0xd6, 0x11, 0xb1, 0x33, 0x40, 0x50, 0x69, 0x48, 0x75, 0x4, 0xe5 }, + }, + { + .msglen = 110, + .result = { 0x7d, 0x25, 0x12, 0x5, 0x37, 0x8c, 0x89, 0x8a, 0x43, 0xd9, 0x97, 0x26, 0xb8, 0xaf, 0xb3, 0x21, 0x4d, 0xde, 0x24, 0x58, 0x4f, 0xc8, 0xd, 0x31, 0x22, 0xb2, 0xdf, 0x34, 0xd5, 0xb, 0x25, 0xb9 }, + }, + { + .msglen = 111, + .result = { 0x4e, 0xfa, 0x3f, 0x64, 0x15, 0xf8, 0xe2, 0xb9, 0x10, 0x70, 0xeb, 0x6a, 0xf6, 0xf2, 0x14, 0x33, 0x0, 0xd1, 0x19, 0xf2, 0x8c, 0x50, 0x57, 0x17, 0xf0, 0xc5, 0x5d, 0xa1, 0xe, 0x22, 0xa0, 0x53 }, + }, + { + .msglen = 112, + .result = { 0x12, 0xac, 0x71, 0xa0, 0x72, 0x7a, 0x45, 0x74, 0x82, 0xf6, 0xde, 0x75, 0xe, 0xb9, 0xb2, 0x65, 0x76, 0x86, 0x13, 0x77, 0x4a, 0x30, 0xbe, 0xfa, 0x1, 0x38, 0x74, 0x49, 0xc9, 0x7f, 0x43, 0x9a }, + }, + { + .msglen = 113, + .result = { 0xfe, 0x25, 0x6b, 0xbf, 0x17, 0x61, 0x29, 0xce, 0x9e, 0xc2, 0x42, 0x9a, 0xb8, 0x29, 0xdb, 0x88, 0xef, 0x75, 0x3b, 0xad, 0xba, 0x9c, 0xd5, 0x9, 0x40, 0x2f, 0x49, 0xbd, 0x3, 0x43, 0xa7, 0x3 }, + }, + { + .msglen = 114, + .result = { 0xe5, 0x36, 0x48, 0xb5, 0x9e, 0xb3, 0x3c, 0x5f, 0x86, 0xab, 0x5, 0xe4, 0xc0, 0xe3, 0x94, 0xe4, 0x4c, 0x90, 0xcd, 0xa1, 0x97, 0x12, 0xdf, 0x33, 0x7a, 0x1a, 0x1e, 0xcd, 0xd4, 0x61, 0xa8, 0x3c }, + }, + { + .msglen = 115, + .result = { 0x52, 0xbd, 0xc6, 0x84, 0x65, 0x32, 0x88, 0x1, 0x85, 0x64, 0xfd, 0xc9, 0x98, 0x18, 0x27, 0x52, 0xe9, 0x30, 0xa2, 0x9e, 0xc2, 0xcf, 0xa9, 0x98, 0xbc, 0x47, 0x3a, 0xc7, 0xd5, 0xb1, 0x81, 0x78 }, + }, + { + .msglen = 116, + .result = { 0xab, 0xb1, 0xb3, 0xa5, 0x23, 0xea, 0x45, 0xe8, 0xe0, 0xa9, 0x3d, 0xe9, 0xe9, 0x86, 0x15, 0x10, 0x90, 0xca, 0xf7, 0xcc, 0x92, 0x64, 0x10, 0x3d, 0x63, 0x2f, 0x17, 0xec, 0x54, 0x9e, 0xbd, 0x3b }, + }, + { + .msglen = 117, + .result = { 0x82, 0xf8, 0x45, 0xcd, 0x8b, 0xfc, 0xd8, 0x81, 0x6b, 0x1f, 0x91, 0x30, 0x6d, 0xbb, 0x91, 0x70, 0x8b, 0xfe, 0x8d, 0x33, 0x35, 0x4f, 0x62, 0x7f, 0xba, 0xb6, 0x99, 0x3b, 0x79, 0xe6, 0x8f, 0x58 }, + }, + { + .msglen = 118, + .result = { 0xa6, 0x59, 0x67, 0x5e, 0x49, 0xe2, 0x95, 0x28, 0xa3, 0x4b, 0x4a, 0x10, 0x20, 0xd1, 0xd6, 0x7b, 0x86, 0x8a, 0x5c, 0x81, 0x31, 0x68, 0xea, 0xb7, 0x61, 0xbb, 0xb6, 0x3a, 0x6d, 0x78, 0xaa, 0x37 }, + }, + { + .msglen = 119, + .result = { 0x64, 0x9, 0xaf, 0x42, 0xff, 0xb1, 0xc7, 0xe6, 0xbf, 0x6f, 0xa1, 0xbb, 0x5a, 0x6, 0xea, 0xd, 0x57, 0x7d, 0x24, 0x41, 0x2b, 0xf9, 0x63, 0x82, 0x1f, 0x9, 0xa5, 0xa7, 0x58, 0xc, 0x4, 0x55 }, + }, + { + .msglen = 120, + .result = { 0x43, 0x33, 0x90, 0x81, 0xb6, 0x23, 0x50, 0xdf, 0xa2, 0x7e, 0x41, 0xa2, 0x40, 0x40, 0xa9, 0x34, 0xd6, 0x5, 0x6c, 0x44, 0x8, 0x3f, 0x2b, 0xaa, 0xff, 0x3, 0xc3, 0x49, 0x1b, 0x15, 0x5e, 0x7c }, + }, + { + .msglen = 121, + .result = { 0xe, 0xd7, 0x6d, 0x29, 0xdd, 0x8, 0xee, 0x2f, 0x1d, 0x5a, 0xb2, 0x70, 0x90, 0x8d, 0xa9, 0xf2, 0x5c, 0x5b, 0xc5, 0xe1, 0x7c, 0xec, 0x49, 0x8f, 0x46, 0x94, 0xe1, 0xc8, 0xd4, 0x68, 0xa2, 0x34 }, + }, + { + .msglen = 122, + .result = { 0x4f, 0x25, 0x61, 0xb1, 0x29, 0xb7, 0x41, 0x50, 0xc7, 0xfa, 0xab, 0x6c, 0x92, 0xff, 0x4, 0xc, 0xa3, 0xa1, 0x10, 0xf6, 0xa6, 0xa4, 0x5a, 0xbf, 0xe, 0x9a, 0x61, 0xa8, 0x24, 0xa3, 0x93, 0x1e }, + }, + { + .msglen = 123, + .result = { 0x7c, 0x8c, 0xf4, 0x5d, 0x45, 0xcf, 0x61, 0x22, 0xc9, 0x8e, 0x3a, 0xeb, 0x85, 0x55, 0x66, 0x2e, 0x1e, 0x33, 0x88, 0xab, 0x74, 0xf2, 0x66, 0x4f, 0x43, 0xfa, 0x3e, 0x25, 0xcc, 0xd2, 0x0, 0x71 }, + }, + { + .msglen = 124, + .result = { 0x8b, 0x51, 0x99, 0x90, 0x84, 0xda, 0x7a, 0xb3, 0xb1, 0x31, 0x1b, 0x1a, 0x66, 0xe2, 0x53, 0xac, 0x45, 0x94, 0x5c, 0xa6, 0x8c, 0x44, 0x45, 0x4, 0x58, 0x13, 0xcb, 0x44, 0x9e, 0x6c, 0x6a, 0x10 }, + }, + { + .msglen = 125, + .result = { 0xc5, 0xb0, 0x36, 0x55, 0x4d, 0x15, 0xf0, 0x67, 0xf8, 0x26, 0x45, 0x48, 0xa7, 0x65, 0xcc, 0xa8, 0x14, 0x1e, 0x63, 0x22, 0x36, 0xc3, 0xf3, 0x99, 0x5b, 0x77, 0xb2, 0xa8, 0xc3, 0x62, 0xb4, 0xdd }, + }, + { + .msglen = 126, + .result = { 0x38, 0xcb, 0x97, 0x81, 0x62, 0xde, 0x32, 0x5f, 0xc5, 0x27, 0x39, 0x82, 0x36, 0x77, 0x5a, 0xc4, 0xbf, 0x45, 0xf4, 0xe8, 0x17, 0xa9, 0x17, 0xfc, 0x34, 0xb, 0xa1, 0x11, 0x79, 0xf5, 0xc, 0x79 }, + }, + { + .msglen = 127, + .result = { 0x2e, 0x16, 0xab, 0xf4, 0x56, 0xea, 0x6a, 0x7e, 0x97, 0x25, 0xf9, 0x9a, 0x0, 0x5d, 0xe3, 0x70, 0x76, 0xa9, 0x2a, 0xab, 0xae, 0x32, 0xe5, 0xe8, 0xb6, 0xe1, 0x22, 0xc8, 0x74, 0xe1, 0x1f, 0x22 }, + }, + { + .msglen = 128, + .result = { 0x6e, 0x54, 0xeb, 0x50, 0x85, 0x7b, 0xd2, 0x64, 0x32, 0x2c, 0xb0, 0xd0, 0xc2, 0x3, 0x31, 0x95, 0xa8, 0x6a, 0x50, 0x49, 0xf4, 0x77, 0x27, 0x1a, 0x89, 0x10, 0x3e, 0x98, 0x45, 0x1e, 0xe7, 0xeb }, + }, + { + .msglen = 129, + .result = { 0x7, 0x2e, 0xdf, 0xe9, 0x2e, 0x73, 0xf4, 0x1e, 0x65, 0x31, 0x64, 0x25, 0xc1, 0x59, 0x46, 0xd7, 0xf9, 0x12, 0xfe, 0xc7, 0x9f, 0x24, 0xa, 0xd9, 0xfb, 0x8, 0xcb, 0x5f, 0xf2, 0x77, 0x11, 0xce }, + }, + { + .msglen = 130, + .result = { 0x6, 0x46, 0xc7, 0x42, 0xc2, 0xc3, 0xf2, 0x4c, 0x82, 0x7d, 0x1c, 0x2c, 0x68, 0xfd, 0x29, 0x6d, 0xc2, 0xac, 0x4f, 0xbc, 0x8d, 0xb2, 0xf7, 0x78, 0xb7, 0x8f, 0x4, 0x3f, 0x49, 0xb5, 0xc5, 0xd }, + }, + { + .msglen = 131, + .result = { 0x9c, 0x1f, 0xdb, 0x89, 0x3b, 0x8b, 0x5c, 0x3d, 0x1e, 0xd2, 0x9f, 0x74, 0x63, 0xb, 0x4f, 0x59, 0x72, 0x13, 0x4f, 0x40, 0x59, 0x35, 0xc6, 0x64, 0x5a, 0xb5, 0x43, 0xaf, 0x43, 0x7a, 0x13, 0xb0 }, + }, + { + .msglen = 132, + .result = { 0x25, 0xa9, 0x97, 0x9e, 0x4f, 0x52, 0xe6, 0xe7, 0xf, 0x38, 0xc6, 0xfb, 0x9e, 0x77, 0xe7, 0x1c, 0xb9, 0x8a, 0xf3, 0x4d, 0x76, 0xb3, 0x58, 0x8e, 0xab, 0x7d, 0xd6, 0xbb, 0x78, 0x26, 0xb1, 0x7f }, + }, + { + .msglen = 133, + .result = { 0x2b, 0x8, 0xfa, 0x23, 0x7d, 0xb2, 0xa1, 0x16, 0x85, 0x7b, 0x3c, 0xa4, 0xde, 0x19, 0xf7, 0x81, 0xb6, 0xaf, 0xbc, 0x11, 0x31, 0x10, 0x6f, 0x14, 0x4a, 0x62, 0x48, 0x1e, 0x43, 0x95, 0xa4, 0xb4 }, + }, + { + .msglen = 134, + .result = { 0x9c, 0x93, 0x30, 0x3f, 0x4c, 0x8f, 0xa7, 0x56, 0xd1, 0x6c, 0x9a, 0x28, 0xa1, 0x21, 0x7d, 0x5b, 0x12, 0x6b, 0x5a, 0xd4, 0xb9, 0x62, 0x5, 0xe2, 0xd5, 0xc8, 0x2a, 0xd1, 0xb0, 0x46, 0x2a, 0x2c }, + }, + { + .msglen = 135, + .result = { 0xd7, 0x17, 0xd, 0xc0, 0x46, 0x24, 0x9e, 0x14, 0x21, 0xac, 0xf3, 0xd0, 0xda, 0xf4, 0xd9, 0xf1, 0xf2, 0x96, 0xbd, 0x55, 0xff, 0x3c, 0x8d, 0x90, 0xc8, 0x2f, 0x1e, 0x87, 0xad, 0xd7, 0x8a, 0x8a }, + }, + { + .msglen = 136, + .result = { 0x90, 0xd6, 0xa4, 0x46, 0x75, 0x8c, 0xc3, 0xda, 0x26, 0x8a, 0xe1, 0xb7, 0xa4, 0xe, 0xef, 0x33, 0x65, 0x41, 0xa3, 0x60, 0x6a, 0xce, 0xfb, 0xc4, 0x1c, 0xa4, 0x95, 0x6d, 0x43, 0x49, 0x69, 0xd5 }, + }, + { + .msglen = 137, + .result = { 0xd6, 0xf5, 0xfe, 0xb0, 0x9a, 0xca, 0xec, 0xeb, 0xbe, 0x4b, 0xbd, 0x96, 0x65, 0xfe, 0x65, 0x31, 0xef, 0x36, 0x3a, 0xfc, 0x3a, 0x8, 0x3, 0xb0, 0xbf, 0xeb, 0xd, 0x2c, 0xd9, 0x27, 0x14, 0x4f }, + }, + { + .msglen = 138, + .result = { 0x97, 0x4f, 0x86, 0x11, 0xf9, 0x61, 0xad, 0xc, 0xba, 0x2d, 0xfa, 0xa4, 0x6f, 0x19, 0xb3, 0x66, 0xf8, 0xcc, 0x74, 0x2c, 0x76, 0x29, 0xdd, 0x6b, 0x5, 0xa3, 0x3a, 0x3b, 0xa6, 0xec, 0x81, 0xc0 }, + }, + { + .msglen = 139, + .result = { 0x9a, 0xe3, 0xc, 0x22, 0x5d, 0xb3, 0x71, 0x5d, 0x30, 0xcf, 0x6, 0xc1, 0x86, 0xf6, 0x84, 0xac, 0x25, 0x45, 0xb2, 0xa0, 0xd2, 0x93, 0x8b, 0x9e, 0x77, 0x55, 0x16, 0x51, 0x61, 0x4a, 0x91, 0xcd }, + }, + { + .msglen = 140, + .result = { 0xf1, 0x30, 0xf4, 0xc7, 0x6c, 0xe3, 0x8d, 0x63, 0x41, 0x62, 0x64, 0xe1, 0xc3, 0x97, 0xf0, 0xd6, 0xf3, 0xfd, 0x17, 0xe, 0xca, 0xd8, 0x9e, 0x6d, 0xa0, 0xa1, 0x27, 0x60, 0xff, 0xf, 0x7a, 0xca }, + }, + { + .msglen = 141, + .result = { 0x5, 0xab, 0x87, 0x58, 0xa8, 0x5e, 0x7d, 0xec, 0x23, 0x90, 0xd8, 0xfa, 0x87, 0x1, 0x4b, 0x32, 0xe9, 0x0, 0x7b, 0x92, 0x3b, 0x51, 0x44, 0x86, 0xa2, 0x55, 0xf0, 0xb7, 0x13, 0x3b, 0x58, 0x70 }, + }, + { + .msglen = 142, + .result = { 0xff, 0x4e, 0x8a, 0xca, 0xce, 0xe0, 0x84, 0x2a, 0x70, 0x82, 0x52, 0x1e, 0x67, 0xc, 0x67, 0x36, 0x76, 0x74, 0xed, 0x49, 0x21, 0x44, 0x0, 0x1a, 0x75, 0xcd, 0x4f, 0x17, 0xb8, 0xa9, 0xdf, 0xb9 }, + }, + { + .msglen = 143, + .result = { 0xf2, 0x36, 0x6f, 0xf3, 0x8e, 0xf3, 0xbd, 0x51, 0xec, 0xc4, 0x96, 0xc1, 0x88, 0xfe, 0x68, 0x5e, 0x1b, 0xdf, 0x71, 0x6b, 0xf3, 0x78, 0x84, 0x16, 0x11, 0xac, 0x37, 0x4d, 0x8f, 0x6e, 0x7b, 0x40 }, + }, + { + .msglen = 144, + .result = { 0x24, 0x20, 0x1d, 0x2, 0x16, 0x1, 0xc4, 0xe5, 0xdf, 0x81, 0xca, 0xa9, 0xf2, 0x4d, 0xe2, 0x77, 0x11, 0xf6, 0x43, 0xd3, 0x36, 0x36, 0x1c, 0xe6, 0x6c, 0x96, 0xc9, 0x74, 0x8e, 0x39, 0x1c, 0xb1 }, + }, + { + .msglen = 145, + .result = { 0xfc, 0x13, 0x13, 0x5c, 0x87, 0x9a, 0x95, 0xcd, 0x66, 0xac, 0x85, 0xda, 0x8c, 0x28, 0x38, 0x3f, 0x43, 0xe1, 0x40, 0x8e, 0x8f, 0x49, 0x17, 0xda, 0x75, 0xd0, 0xc4, 0xf5, 0x9e, 0x3, 0xf0, 0x62 }, + }, + { + .msglen = 146, + .result = { 0xcc, 0x3e, 0x74, 0x6a, 0x82, 0xb0, 0x67, 0x77, 0xcf, 0x6e, 0x93, 0x40, 0x84, 0xc7, 0xa1, 0x85, 0xa5, 0x38, 0x23, 0xa5, 0x4f, 0x9e, 0xee, 0x3d, 0xa7, 0xab, 0x88, 0x3b, 0x3, 0x1d, 0xdb, 0xbd }, + }, + { + .msglen = 147, + .result = { 0xaa, 0x4f, 0x52, 0xf0, 0xe8, 0x49, 0x80, 0x5e, 0xe4, 0xd4, 0x8f, 0xc1, 0x5c, 0x7d, 0x36, 0x2, 0xdb, 0xda, 0x45, 0xab, 0x6e, 0x90, 0xc1, 0x55, 0x4f, 0x8, 0xaf, 0x55, 0x4d, 0x45, 0x6b, 0x91 }, + }, + { + .msglen = 148, + .result = { 0xfb, 0x92, 0xef, 0x68, 0xc4, 0xa, 0xd9, 0xd8, 0x86, 0xb5, 0x63, 0x34, 0xa7, 0x42, 0x5a, 0xef, 0x13, 0xc0, 0xc9, 0x44, 0x8f, 0x9e, 0x40, 0x51, 0x1b, 0xcf, 0xbb, 0x8c, 0xb0, 0x2c, 0x56, 0xc }, + }, + { + .msglen = 149, + .result = { 0x88, 0xdb, 0x71, 0x51, 0x85, 0x63, 0xb6, 0xb4, 0xeb, 0x7c, 0x11, 0xaa, 0x96, 0x8, 0x9e, 0x60, 0x70, 0xa5, 0x19, 0xa4, 0x2, 0xf1, 0xa0, 0x4f, 0x16, 0xde, 0xd6, 0x8d, 0xd3, 0xc5, 0xc, 0x6c }, + }, + { + .msglen = 150, + .result = { 0x4a, 0xad, 0x96, 0xea, 0x90, 0xb7, 0x76, 0x9d, 0x92, 0x60, 0x35, 0x59, 0x1c, 0x89, 0x67, 0x54, 0xfd, 0x50, 0x20, 0x97, 0xc8, 0x16, 0xc8, 0xc2, 0x50, 0x40, 0x63, 0xba, 0xfb, 0xbc, 0x5e, 0xcd }, + }, + { + .msglen = 151, + .result = { 0xca, 0x4c, 0x3d, 0x26, 0x75, 0x82, 0x48, 0x5b, 0xa4, 0xd3, 0x28, 0x9, 0x8d, 0xe0, 0x67, 0x6d, 0xe1, 0x5, 0x8a, 0xbf, 0x17, 0xbb, 0x6e, 0x48, 0x2e, 0xd, 0xcd, 0x90, 0x7c, 0x4e, 0xa4, 0x94 }, + }, + { + .msglen = 152, + .result = { 0x6d, 0x27, 0x5e, 0x91, 0xeb, 0xc7, 0x1a, 0x31, 0x42, 0xfa, 0x2c, 0x91, 0xdc, 0x6a, 0xdc, 0x1b, 0x2b, 0x66, 0xf2, 0x9a, 0xf6, 0x11, 0x36, 0x96, 0x2a, 0xfc, 0x73, 0x89, 0x7e, 0xd4, 0x55, 0x3d }, + }, + { + .msglen = 153, + .result = { 0x76, 0xba, 0x1d, 0x4b, 0xc1, 0xa2, 0x1b, 0x56, 0xbe, 0x5, 0x38, 0x90, 0x47, 0xe9, 0x9, 0xc2, 0xd1, 0x2, 0x6d, 0x44, 0x81, 0xf7, 0x6e, 0x28, 0x88, 0x79, 0xb5, 0x10, 0x75, 0xfb, 0xc6, 0xe7 }, + }, + { + .msglen = 154, + .result = { 0x6d, 0xbc, 0x90, 0xa6, 0x2f, 0xb5, 0x45, 0x5f, 0x4a, 0xcb, 0x85, 0x32, 0x90, 0x57, 0x86, 0x75, 0x51, 0xa5, 0x7e, 0x4b, 0x6b, 0xb3, 0xeb, 0xfe, 0xba, 0x75, 0xfc, 0x55, 0x1a, 0x85, 0x3, 0x54 }, + }, + { + .msglen = 155, + .result = { 0x7d, 0x59, 0x19, 0xb6, 0xf2, 0x7f, 0x7, 0x7a, 0xaa, 0xf7, 0xdf, 0x2e, 0x2d, 0xfb, 0x57, 0x14, 0xd6, 0x9f, 0x9c, 0xcc, 0x56, 0x88, 0xe, 0x85, 0xcc, 0x30, 0x6, 0x32, 0x1f, 0x70, 0x47, 0x59 }, + }, + { + .msglen = 156, + .result = { 0xea, 0xfa, 0x44, 0x81, 0x83, 0xec, 0x2d, 0x63, 0xa6, 0xea, 0xf0, 0x6, 0x5d, 0x15, 0x32, 0x89, 0xed, 0x52, 0xf, 0x23, 0x66, 0x8b, 0x1c, 0x7c, 0x13, 0xd0, 0x35, 0xc1, 0x7d, 0x27, 0xfe, 0x80 }, + }, + { + .msglen = 157, + .result = { 0xab, 0x31, 0xe1, 0x44, 0x3d, 0x3a, 0xf5, 0x6a, 0x8b, 0x5d, 0xa6, 0xd5, 0x63, 0x23, 0x7e, 0x17, 0x24, 0xc9, 0x41, 0x53, 0x86, 0x90, 0xb7, 0x6f, 0xbc, 0x39, 0x5d, 0x1b, 0x19, 0xd9, 0xef, 0x9c }, + }, + { + .msglen = 158, + .result = { 0x3e, 0x34, 0xec, 0xd9, 0x26, 0xe7, 0x27, 0x3b, 0xc5, 0xc3, 0x8e, 0x11, 0xba, 0x58, 0xcf, 0x2b, 0x29, 0xc4, 0x49, 0xfc, 0xf6, 0x9d, 0xcc, 0x2a, 0x0, 0xff, 0xe6, 0xbc, 0x7d, 0x2a, 0x48, 0x22 }, + }, + { + .msglen = 159, + .result = { 0xc8, 0x59, 0x27, 0xa2, 0x58, 0x9e, 0xfe, 0x8c, 0x5a, 0x7f, 0x99, 0xd0, 0x58, 0xd4, 0x8c, 0xae, 0xa9, 0x4, 0x24, 0x50, 0x34, 0x23, 0x45, 0xfe, 0x87, 0xa7, 0x53, 0x5a, 0x27, 0x9d, 0x1b, 0x4f }, + }, + { + .msglen = 160, + .result = { 0xd7, 0x76, 0xaa, 0x3b, 0x97, 0x5e, 0xac, 0xbe, 0x46, 0x45, 0x80, 0x8e, 0x2c, 0xa2, 0xe1, 0xd4, 0x75, 0xb5, 0xe0, 0xd2, 0x4c, 0x59, 0xf0, 0xc3, 0xe8, 0x8c, 0x96, 0xbd, 0x85, 0x23, 0x8b, 0x40 }, + }, + { + .msglen = 161, + .result = { 0x40, 0x8e, 0xa5, 0xbd, 0x32, 0x7, 0x19, 0xc8, 0x31, 0x22, 0x32, 0xdf, 0xe0, 0xf5, 0xe2, 0x5f, 0x91, 0xf4, 0x95, 0x7a, 0xa7, 0x91, 0x9d, 0xed, 0x35, 0x2f, 0x0, 0x4, 0x62, 0x63, 0x4, 0x80 }, + }, + { + .msglen = 162, + .result = { 0xa6, 0x1b, 0x63, 0x3, 0xbf, 0x2, 0xbd, 0xbb, 0x69, 0x1b, 0xac, 0x54, 0x99, 0xee, 0x8b, 0xe, 0xb, 0x41, 0x78, 0xda, 0x8f, 0x72, 0x97, 0xdf, 0x9, 0xfa, 0x35, 0xe1, 0x8a, 0xb3, 0x80, 0xc3 }, + }, + { + .msglen = 163, + .result = { 0x7d, 0xd3, 0x5e, 0x1a, 0x9, 0x94, 0x6e, 0x30, 0xc6, 0xbb, 0xda, 0xe7, 0x92, 0x49, 0xf6, 0x37, 0xe, 0xb3, 0x30, 0x96, 0xb2, 0xaf, 0x57, 0x22, 0xe4, 0x8d, 0x9f, 0x83, 0x51, 0xbf, 0x98, 0xb0 }, + }, + { + .msglen = 164, + .result = { 0x3e, 0x10, 0xe4, 0x81, 0xa2, 0x1d, 0x92, 0x7a, 0x1a, 0x73, 0xfe, 0xd4, 0x8b, 0x28, 0x4c, 0x85, 0xcc, 0xfe, 0xe0, 0x4f, 0x55, 0xfd, 0x47, 0x95, 0x1f, 0x1b, 0x60, 0x38, 0x7, 0xe9, 0xc9, 0x4f }, + }, + { + .msglen = 165, + .result = { 0x75, 0x68, 0x14, 0xf8, 0x3c, 0x94, 0x2b, 0xe9, 0x6c, 0x49, 0xfc, 0x77, 0xa8, 0x6a, 0x5d, 0xf6, 0x4e, 0x45, 0xa0, 0x45, 0x2c, 0xfc, 0xec, 0xb1, 0xaf, 0xf5, 0x77, 0x6d, 0xbf, 0x96, 0x2b, 0x88 }, + }, + { + .msglen = 166, + .result = { 0x81, 0x1e, 0x33, 0x1c, 0xeb, 0xcf, 0x34, 0x58, 0x18, 0xa7, 0x2c, 0x60, 0x9, 0x36, 0x6e, 0xba, 0x46, 0x27, 0xee, 0x25, 0x60, 0xa9, 0x9f, 0x90, 0x4, 0x65, 0xa6, 0x92, 0x48, 0x4a, 0xf7, 0x1b }, + }, + { + .msglen = 167, + .result = { 0xdc, 0x3d, 0x6, 0x9e, 0x2c, 0x8c, 0x2d, 0x84, 0xf7, 0x97, 0xa, 0xeb, 0xe3, 0x68, 0xa7, 0x59, 0x3d, 0xa, 0xba, 0x6f, 0xfb, 0x11, 0x5a, 0xf8, 0x99, 0xae, 0x84, 0x1f, 0x43, 0xf8, 0xfd, 0xac }, + }, + { + .msglen = 168, + .result = { 0x4e, 0xd7, 0x72, 0x7d, 0xfe, 0x4d, 0x8a, 0x9a, 0xfa, 0x39, 0xb7, 0x74, 0x83, 0x61, 0xd5, 0xb6, 0xd1, 0x56, 0x88, 0xe7, 0x85, 0x15, 0xcf, 0x2d, 0x91, 0x73, 0xa4, 0xc9, 0xad, 0x76, 0x47, 0x2f }, + }, + { + .msglen = 169, + .result = { 0x33, 0x25, 0x94, 0xbc, 0xa4, 0xd, 0x39, 0x84, 0x4a, 0xe5, 0x30, 0x1f, 0x70, 0x41, 0xf0, 0xa7, 0x6d, 0x52, 0x3f, 0xa9, 0x17, 0x83, 0x46, 0xe, 0x26, 0x77, 0xe9, 0xfd, 0xe, 0x46, 0x21, 0xee }, + }, + { + .msglen = 170, + .result = { 0x84, 0xb8, 0x3c, 0x8d, 0x89, 0xd6, 0x55, 0x75, 0xbd, 0x5d, 0xcb, 0x76, 0xfe, 0x42, 0x98, 0xf9, 0xff, 0x8b, 0x4d, 0xe6, 0xe8, 0xd6, 0x1f, 0x37, 0xa6, 0xe0, 0xa8, 0x37, 0x28, 0xed, 0xf4, 0x38 }, + }, + { + .msglen = 171, + .result = { 0xf, 0x48, 0x6c, 0x1f, 0x99, 0x6d, 0x3c, 0x11, 0xd9, 0x7a, 0x33, 0xa, 0xdf, 0xb1, 0xa3, 0x59, 0x3f, 0xe3, 0xf0, 0x3, 0xab, 0x5e, 0x3f, 0x68, 0xe5, 0xa5, 0xd1, 0xbb, 0x8, 0x85, 0x50, 0x45 }, + }, + { + .msglen = 172, + .result = { 0x58, 0x25, 0xc1, 0x9e, 0x9d, 0x79, 0xa9, 0x71, 0xe7, 0xc5, 0x6, 0x8d, 0x23, 0x65, 0xf4, 0xbc, 0x9e, 0xa8, 0xab, 0xcc, 0x2f, 0x93, 0xac, 0x64, 0xb5, 0x6d, 0x28, 0x34, 0xe, 0x78, 0x9a, 0xfa }, + }, + { + .msglen = 173, + .result = { 0x10, 0xc6, 0xca, 0x3a, 0xc9, 0xe3, 0x82, 0x6e, 0x76, 0x5b, 0x8d, 0x42, 0x56, 0x4c, 0xc5, 0xf2, 0x2c, 0xaa, 0x95, 0x4, 0xc4, 0xef, 0x5f, 0xda, 0x10, 0xd3, 0x77, 0x9b, 0xc5, 0x95, 0x72, 0x14 }, + }, + { + .msglen = 174, + .result = { 0x7b, 0x64, 0xa, 0x83, 0xbf, 0x35, 0x85, 0xbf, 0xc2, 0xee, 0xdd, 0x95, 0xca, 0x5c, 0xa0, 0xee, 0xca, 0xa2, 0xb8, 0x33, 0xc1, 0x7d, 0xf3, 0x4d, 0x35, 0x2e, 0x27, 0xb8, 0x56, 0x5, 0x7a, 0x73 }, + }, + { + .msglen = 175, + .result = { 0xdb, 0x32, 0x29, 0x7c, 0xfd, 0xa5, 0x91, 0xae, 0x9b, 0xb0, 0xbd, 0xb4, 0x34, 0x4f, 0x60, 0x98, 0x65, 0x35, 0xe4, 0x60, 0xf8, 0x8b, 0x57, 0x47, 0x55, 0x14, 0xa4, 0x5e, 0xcc, 0xa6, 0xbd, 0xf4 }, + }, + { + .msglen = 176, + .result = { 0x7c, 0x6f, 0xd4, 0x3f, 0xd0, 0xa7, 0x7d, 0xd5, 0x34, 0xe0, 0x8d, 0x91, 0x5d, 0xbe, 0x92, 0xb8, 0x67, 0xbe, 0xf5, 0x80, 0xa4, 0xd5, 0x1b, 0x86, 0x12, 0xa7, 0x6, 0x43, 0x1c, 0x61, 0xa3, 0xd5 }, + }, + { + .msglen = 177, + .result = { 0x39, 0x4e, 0x86, 0xdf, 0xbd, 0x7f, 0x6a, 0x8d, 0xe7, 0x55, 0xce, 0x4b, 0x69, 0x90, 0xbc, 0x20, 0xf7, 0xd1, 0xba, 0x93, 0x2b, 0x57, 0x16, 0x5d, 0xc3, 0x16, 0xa, 0xf3, 0x62, 0x7, 0x66, 0xac }, + }, + { + .msglen = 178, + .result = { 0x5f, 0xfd, 0x40, 0x99, 0xa8, 0xdc, 0xe5, 0x2, 0x9e, 0x36, 0xf, 0x5d, 0x47, 0x53, 0xe4, 0x48, 0xcf, 0xd5, 0x5f, 0xd5, 0x29, 0x95, 0x5d, 0x92, 0x6d, 0x41, 0x22, 0x7d, 0x10, 0x8a, 0xc9, 0x88 }, + }, + { + .msglen = 179, + .result = { 0x58, 0x91, 0x6b, 0x40, 0x4d, 0x99, 0xf7, 0x78, 0xa5, 0xc7, 0x62, 0x49, 0x6c, 0x37, 0xd5, 0x90, 0x93, 0x3c, 0x59, 0x34, 0x36, 0xd1, 0x97, 0xcd, 0x85, 0x7d, 0x7a, 0x6d, 0x65, 0xce, 0x7f, 0xdb }, + }, + { + .msglen = 180, + .result = { 0x86, 0xc3, 0xa0, 0xa4, 0x46, 0x8a, 0xa8, 0x69, 0x8e, 0x6d, 0x5e, 0x79, 0x9f, 0xca, 0x9c, 0x2a, 0x94, 0xb0, 0xf8, 0x3f, 0xad, 0xa0, 0xfc, 0x50, 0x68, 0x39, 0x6c, 0xb5, 0xfc, 0x31, 0xaf, 0x74 }, + }, + { + .msglen = 181, + .result = { 0xce, 0x7, 0x9, 0x65, 0x72, 0xf3, 0x8c, 0x51, 0x6b, 0xf7, 0x2d, 0x46, 0xfc, 0xbc, 0xa6, 0xdd, 0x75, 0xe4, 0xd9, 0x54, 0x70, 0xcd, 0xa5, 0x5c, 0xa1, 0xb6, 0xd4, 0x3a, 0xe5, 0x4c, 0x18, 0x9e }, + }, + { + .msglen = 182, + .result = { 0x96, 0xbc, 0xcc, 0xbd, 0xb5, 0xf8, 0xd7, 0xef, 0xc7, 0x85, 0x44, 0x89, 0x6b, 0xd5, 0xbf, 0x78, 0xb7, 0x9d, 0xde, 0xf8, 0x72, 0xd1, 0xd9, 0xb3, 0xb0, 0xfd, 0x7f, 0x4e, 0x2a, 0xaa, 0x3d, 0x7c }, + }, + { + .msglen = 183, + .result = { 0x0, 0xdf, 0xb9, 0xd2, 0x99, 0x8e, 0x5c, 0xed, 0x85, 0x8b, 0x3d, 0x35, 0xdf, 0x35, 0x8c, 0x82, 0x3a, 0x20, 0x36, 0x60, 0x48, 0x7e, 0x9e, 0x8b, 0x60, 0xf9, 0x88, 0xb1, 0x8d, 0x5c, 0x41, 0xef }, + }, + { + .msglen = 184, + .result = { 0x99, 0xdf, 0xe5, 0xf6, 0xdf, 0xb3, 0x88, 0x88, 0x45, 0x34, 0x4a, 0x61, 0xc8, 0x87, 0x49, 0x20, 0xdf, 0xe0, 0x84, 0x5b, 0x35, 0xfe, 0x8c, 0xf8, 0x4a, 0x9c, 0xb1, 0x2d, 0x30, 0x5f, 0xfe, 0x3c }, + }, + { + .msglen = 185, + .result = { 0xfc, 0x53, 0x78, 0x1f, 0x4d, 0x43, 0xf4, 0xe9, 0xdc, 0x74, 0x8, 0xc3, 0xb5, 0xfc, 0x82, 0x88, 0x53, 0x25, 0xc, 0x81, 0x14, 0xa7, 0xff, 0xff, 0x9f, 0xda, 0xc8, 0x45, 0x38, 0x71, 0xdc, 0xd9 }, + }, + { + .msglen = 186, + .result = { 0xa5, 0x3f, 0x40, 0x24, 0x78, 0x12, 0xfc, 0xa7, 0x5b, 0x8a, 0xea, 0x5f, 0x83, 0xf9, 0x42, 0xc6, 0x21, 0xd, 0xa1, 0x46, 0x3, 0x3a, 0x62, 0xb9, 0x39, 0x39, 0xad, 0x6d, 0x70, 0x8e, 0xa2, 0x97 }, + }, + { + .msglen = 187, + .result = { 0x52, 0x23, 0x8a, 0xe, 0x32, 0xd5, 0x99, 0xd2, 0x7e, 0x77, 0x89, 0x70, 0x75, 0xdf, 0xf1, 0x90, 0x92, 0x1d, 0x14, 0xf7, 0xea, 0xa9, 0xdf, 0x5, 0x72, 0xf5, 0x8a, 0xd0, 0xdc, 0xee, 0x40, 0xd0 }, + }, + { + .msglen = 188, + .result = { 0x56, 0x86, 0xee, 0xbb, 0xde, 0xcc, 0x9d, 0xb2, 0x26, 0xa7, 0xb4, 0xef, 0x3d, 0x3f, 0x3e, 0x7d, 0xe3, 0x27, 0xea, 0x79, 0xd5, 0x82, 0x8f, 0x2f, 0x44, 0xa0, 0xe1, 0x4c, 0x67, 0xa6, 0x6b, 0x8f }, + }, + { + .msglen = 189, + .result = { 0xc0, 0x4c, 0xf2, 0x5c, 0x93, 0x4b, 0x36, 0xcb, 0xff, 0xc2, 0x15, 0x9, 0x77, 0x2f, 0xc1, 0xb0, 0x9, 0x98, 0x2b, 0x48, 0x3e, 0xcf, 0x6f, 0x4f, 0xe, 0x7d, 0xd9, 0xae, 0xdb, 0xeb, 0xd8, 0xe1 }, + }, + { + .msglen = 190, + .result = { 0x1f, 0xf1, 0x1c, 0x2c, 0x4e, 0xd0, 0x9c, 0x5e, 0x8e, 0xb4, 0x71, 0x88, 0xc8, 0xcc, 0xd8, 0x4b, 0x25, 0x6d, 0xad, 0xe7, 0x6d, 0x8d, 0x3b, 0x4d, 0x3a, 0xe9, 0xd, 0xa7, 0x69, 0xa8, 0x98, 0xde }, + }, + { + .msglen = 191, + .result = { 0x27, 0x4, 0x31, 0x8, 0x73, 0xf1, 0x5f, 0x15, 0x61, 0x2c, 0x62, 0x49, 0xa9, 0xe8, 0x11, 0xf3, 0xac, 0x54, 0x48, 0x98, 0x62, 0xf2, 0x7d, 0xd6, 0x12, 0xcf, 0x4, 0x1, 0x4e, 0xa9, 0x24, 0xc8 }, + }, + { + .msglen = 192, + .result = { 0xe4, 0x39, 0x59, 0x7e, 0x60, 0x5a, 0x45, 0x4b, 0x89, 0xa8, 0x97, 0x74, 0xfe, 0xb7, 0xeb, 0xd5, 0x6, 0xdb, 0xdc, 0x4d, 0x85, 0x3a, 0x38, 0x4c, 0x5e, 0x74, 0x86, 0xeb, 0xf0, 0xc4, 0x5, 0x32 }, + }, + { + .msglen = 193, + .result = { 0x9a, 0x14, 0xf6, 0x6f, 0xce, 0x82, 0xa0, 0xbb, 0xde, 0xb8, 0x24, 0x2b, 0xaf, 0xae, 0x18, 0xd4, 0xbb, 0x45, 0x9e, 0xe4, 0x87, 0x3b, 0x35, 0xca, 0xeb, 0x37, 0xd1, 0x52, 0x6, 0x6e, 0x84, 0x3b }, + }, + { + .msglen = 194, + .result = { 0x64, 0x9f, 0xab, 0x84, 0xaf, 0x83, 0xa6, 0xcb, 0x23, 0x0, 0xd5, 0x4c, 0xd3, 0x76, 0x4b, 0x57, 0x76, 0x70, 0xdb, 0xea, 0x3a, 0xcb, 0xb7, 0x9c, 0x16, 0x80, 0xbf, 0x66, 0x2b, 0x56, 0xc, 0x2c }, + }, + { + .msglen = 195, + .result = { 0xab, 0xa8, 0x11, 0x2b, 0x2, 0x99, 0xb0, 0x15, 0x36, 0x4d, 0x5b, 0x5d, 0x55, 0xc3, 0xa5, 0xbc, 0x70, 0x9, 0x36, 0xd9, 0x9f, 0xfe, 0x49, 0x3d, 0x5a, 0x2b, 0x8d, 0x69, 0xe2, 0x6, 0x1a, 0x6f }, + }, + { + .msglen = 196, + .result = { 0xd7, 0x6b, 0x15, 0x6c, 0xc1, 0x21, 0x84, 0x78, 0x7c, 0x5e, 0xbe, 0x16, 0x70, 0xe2, 0x83, 0x7f, 0x2c, 0x3, 0x5f, 0xb9, 0x2f, 0x17, 0x46, 0xb0, 0x5a, 0xaf, 0xac, 0x2b, 0x80, 0xcf, 0xa5, 0x9c }, + }, + { + .msglen = 197, + .result = { 0x15, 0x9c, 0x70, 0x75, 0x5a, 0x4e, 0xd2, 0x94, 0x7b, 0x6, 0xe8, 0xdd, 0x55, 0x21, 0xe9, 0x1b, 0x97, 0xe, 0x95, 0x5b, 0x18, 0xa7, 0x26, 0xc0, 0x0, 0xed, 0xe7, 0x55, 0xc8, 0x3d, 0xf3, 0xe7 }, + }, + { + .msglen = 198, + .result = { 0x2c, 0xdf, 0x2e, 0x88, 0xf, 0xee, 0xcf, 0x19, 0x1e, 0x72, 0x8b, 0x15, 0x7d, 0x18, 0xa1, 0xcf, 0x6, 0xa6, 0xc2, 0xec, 0x35, 0xe5, 0x2a, 0x0, 0x7f, 0x75, 0x9b, 0x63, 0x99, 0x9e, 0x2f, 0x66 }, + }, + { + .msglen = 199, + .result = { 0x28, 0xeb, 0xc7, 0x79, 0x5d, 0x7c, 0x29, 0xb9, 0x8a, 0xe8, 0x7b, 0xe4, 0x74, 0x3d, 0x3a, 0x74, 0xab, 0x2e, 0x67, 0xde, 0xe4, 0x28, 0x1b, 0xd0, 0xe3, 0x1b, 0xc9, 0xd0, 0xc0, 0x6c, 0xda, 0xba }, + }, + { + .msglen = 200, + .result = { 0x72, 0x17, 0x1e, 0xca, 0x67, 0xed, 0x83, 0xe9, 0x8d, 0x9b, 0x44, 0xe, 0xd4, 0x27, 0x2c, 0x6b, 0x7d, 0xe2, 0x22, 0x54, 0xf3, 0x72, 0xd1, 0x2, 0xaf, 0x47, 0x20, 0xc0, 0x47, 0x8a, 0x5, 0x9c }, + }, + { + .msglen = 201, + .result = { 0xb8, 0x2c, 0xea, 0xd9, 0xc4, 0x17, 0x66, 0xa6, 0x5a, 0xc1, 0xb8, 0x24, 0xf5, 0x5e, 0x1a, 0x2c, 0x85, 0xf0, 0xa3, 0xcd, 0xd3, 0x7e, 0xfa, 0x23, 0xd2, 0x90, 0x4f, 0xf3, 0x55, 0xfa, 0x17, 0x5c }, + }, + { + .msglen = 202, + .result = { 0x9d, 0x7f, 0x23, 0x8c, 0x92, 0xe5, 0x37, 0xb, 0xc7, 0x97, 0xa4, 0x68, 0xe5, 0xc, 0xd8, 0xfe, 0xb0, 0x4d, 0xc7, 0x79, 0x25, 0xd, 0xe6, 0xa6, 0xe6, 0x4, 0xc5, 0xfd, 0x2d, 0x25, 0x3f, 0xd2 }, + }, + { + .msglen = 203, + .result = { 0xdf, 0xdf, 0x13, 0xc0, 0x82, 0x73, 0x7b, 0xec, 0x2a, 0x4d, 0x9e, 0x62, 0xfc, 0x88, 0xa9, 0x47, 0xfd, 0x47, 0x59, 0xf2, 0x58, 0x5, 0xf9, 0x2e, 0xce, 0x5b, 0x1, 0xae, 0x37, 0x9e, 0xa8, 0x3f }, + }, + { + .msglen = 204, + .result = { 0x60, 0x10, 0x29, 0xc3, 0x82, 0x91, 0x8b, 0x74, 0xa5, 0x6a, 0x3f, 0x6a, 0x76, 0xaf, 0x50, 0x9e, 0xf1, 0x38, 0xf5, 0xd2, 0xdc, 0xe5, 0x5a, 0x3d, 0xa9, 0x8a, 0x56, 0xca, 0xeb, 0x57, 0x79, 0x5a }, + }, + { + .msglen = 205, + .result = { 0xd2, 0x71, 0x22, 0xe1, 0x91, 0x69, 0x5d, 0x9f, 0x6, 0xff, 0x51, 0xea, 0x7e, 0x8a, 0x5d, 0xb2, 0xae, 0x66, 0xf5, 0x22, 0x65, 0xa7, 0xfe, 0xf0, 0xce, 0xf5, 0x2c, 0xbf, 0x4e, 0x41, 0x19, 0x72 }, + }, + { + .msglen = 206, + .result = { 0x66, 0x41, 0x4d, 0xd9, 0xff, 0x1, 0x27, 0xda, 0xae, 0xee, 0x41, 0x34, 0x41, 0xd1, 0xb9, 0xac, 0x11, 0xf3, 0x5b, 0xc4, 0xa2, 0xd5, 0x3, 0x47, 0x87, 0xf4, 0x88, 0xee, 0x61, 0x22, 0x1, 0x6a }, + }, + { + .msglen = 207, + .result = { 0x59, 0xaf, 0xa5, 0x9a, 0xac, 0x1, 0x0, 0x73, 0x57, 0xa4, 0xdb, 0x22, 0x9, 0x3b, 0x3a, 0x66, 0x19, 0xd6, 0xe4, 0xf7, 0x1d, 0x2a, 0x37, 0x5f, 0x71, 0xc5, 0x54, 0x8e, 0xb, 0x73, 0xd5, 0x3c }, + }, + { + .msglen = 208, + .result = { 0xd1, 0xa7, 0x61, 0x34, 0xc5, 0x65, 0xb8, 0xa4, 0x8e, 0x3a, 0x9f, 0x5b, 0x11, 0x8b, 0x21, 0x5e, 0x7c, 0x9c, 0xfb, 0xd3, 0xe2, 0xe5, 0x92, 0x41, 0x6f, 0x4, 0x61, 0x30, 0x79, 0xf2, 0x8, 0xc4 }, + }, + { + .msglen = 209, + .result = { 0x84, 0x79, 0x2, 0x39, 0x2d, 0x2a, 0x11, 0xa5, 0xff, 0xa1, 0x3a, 0xfd, 0x70, 0x90, 0xb4, 0xa5, 0x85, 0xda, 0xd5, 0x4c, 0x8d, 0xaa, 0x97, 0x5e, 0x3b, 0x45, 0x89, 0xd0, 0xfd, 0x85, 0x57, 0xf3 }, + }, + { + .msglen = 210, + .result = { 0xc6, 0x3b, 0x4b, 0xbd, 0x70, 0x65, 0x2, 0x2f, 0xfc, 0xc2, 0x42, 0x4e, 0x77, 0xa0, 0xc8, 0x4d, 0x3d, 0x65, 0x4a, 0xb3, 0x47, 0xf5, 0x21, 0x39, 0xb0, 0x61, 0x8a, 0xae, 0x58, 0x18, 0x7e, 0xbe }, + }, + { + .msglen = 211, + .result = { 0x3c, 0x50, 0xdb, 0xa6, 0x45, 0x69, 0x8b, 0x58, 0x22, 0x1f, 0x3c, 0xa3, 0x1a, 0x79, 0x90, 0xef, 0xd4, 0x21, 0xf6, 0x9e, 0xfd, 0xe5, 0xb9, 0xb2, 0xbb, 0xef, 0x27, 0x36, 0x35, 0xd8, 0x6f, 0x69 }, + }, + { + .msglen = 212, + .result = { 0xd1, 0x5b, 0x4f, 0x10, 0xc6, 0x1, 0x2b, 0xe5, 0x4b, 0x8f, 0xba, 0x55, 0x36, 0x60, 0x26, 0xf3, 0x93, 0x40, 0xb7, 0xd, 0xbd, 0xf6, 0x80, 0x51, 0xbe, 0x52, 0x9, 0xdd, 0x78, 0x30, 0x47, 0xbd }, + }, + { + .msglen = 213, + .result = { 0xe6, 0x2e, 0x97, 0xbc, 0x93, 0xaf, 0x61, 0xb8, 0x40, 0x9d, 0x70, 0x90, 0xdc, 0x34, 0xb0, 0x7e, 0xad, 0x1d, 0x50, 0x55, 0x9e, 0x42, 0x92, 0x92, 0xaf, 0x54, 0x5c, 0x57, 0xa, 0x49, 0x39, 0xd }, + }, + { + .msglen = 214, + .result = { 0x6d, 0x72, 0xde, 0xd8, 0x72, 0x65, 0xc9, 0xaf, 0x36, 0x3b, 0x75, 0xf6, 0xf7, 0x71, 0x15, 0xa6, 0xad, 0x73, 0xa2, 0x9b, 0x1c, 0x86, 0xf3, 0xc1, 0xc1, 0x7a, 0x85, 0x87, 0x70, 0x44, 0x83, 0xe8 }, + }, + { + .msglen = 215, + .result = { 0x6c, 0xfb, 0xa2, 0xb9, 0xc1, 0xf0, 0xbf, 0xef, 0x33, 0x60, 0x55, 0x30, 0x5b, 0x2b, 0x4, 0x7b, 0xfb, 0x8f, 0xe0, 0x5d, 0x11, 0x90, 0x3c, 0x28, 0xcf, 0xd4, 0x5, 0x70, 0x88, 0x1a, 0x53, 0xa }, + }, + { + .msglen = 216, + .result = { 0xe6, 0x2a, 0x80, 0x77, 0xb, 0x8d, 0xc8, 0x79, 0x72, 0x32, 0xf9, 0xd, 0x41, 0xcc, 0x6e, 0x77, 0xe5, 0x5f, 0x22, 0xd2, 0xdb, 0x1, 0xf9, 0x96, 0xce, 0x13, 0x95, 0x51, 0x6, 0x95, 0x51, 0x24 }, + }, + { + .msglen = 217, + .result = { 0xf1, 0x79, 0x81, 0xb2, 0x3b, 0xb7, 0xc1, 0x12, 0x24, 0x6e, 0x97, 0xed, 0xe4, 0x87, 0xf4, 0xcf, 0x62, 0xf8, 0xb8, 0xa9, 0xb8, 0x9d, 0xf4, 0x5d, 0x17, 0xc7, 0x27, 0xe7, 0x84, 0x7, 0xb9, 0x56 }, + }, + { + .msglen = 218, + .result = { 0x6c, 0xe2, 0x55, 0x53, 0x36, 0x41, 0xe2, 0x99, 0xac, 0xb2, 0x67, 0xc1, 0xfe, 0x63, 0xb4, 0x93, 0x26, 0x50, 0x2e, 0xe, 0xac, 0xf7, 0x66, 0x20, 0x6, 0xb7, 0xb9, 0x98, 0x20, 0x17, 0xfa, 0x2d }, + }, + { + .msglen = 219, + .result = { 0xef, 0x47, 0xb1, 0x44, 0x60, 0xf2, 0x1a, 0xa5, 0x99, 0x8d, 0xd8, 0x7c, 0x80, 0x22, 0x2a, 0xac, 0x9, 0x27, 0xf, 0xc9, 0xb8, 0xa8, 0xfb, 0xec, 0x41, 0x23, 0x2b, 0x9b, 0x20, 0xed, 0xef, 0x5e }, + }, + { + .msglen = 220, + .result = { 0xea, 0x10, 0xab, 0xd, 0x8a, 0x2f, 0xff, 0xe2, 0x21, 0xb7, 0x8b, 0xff, 0x13, 0xa0, 0xa9, 0x4c, 0x78, 0x85, 0x35, 0xdf, 0x8c, 0xb8, 0x82, 0x57, 0x98, 0x5e, 0xc8, 0xe5, 0x95, 0x43, 0x14, 0x7e }, + }, + { + .msglen = 221, + .result = { 0xb6, 0x3b, 0x58, 0x81, 0xab, 0x62, 0xa9, 0xf3, 0x19, 0x1f, 0x3c, 0xe1, 0x21, 0x2f, 0x2, 0xc9, 0xdb, 0x8d, 0xd4, 0x7f, 0x38, 0x11, 0x1b, 0x18, 0x5c, 0xb, 0xa3, 0xa8, 0x38, 0xe4, 0xc4, 0x55 }, + }, + { + .msglen = 222, + .result = { 0xb, 0xc3, 0x3f, 0xaa, 0x9c, 0xff, 0x53, 0xb8, 0xe1, 0xa6, 0xd3, 0x43, 0x8e, 0xa6, 0x48, 0x7b, 0x5b, 0x4, 0x31, 0xc1, 0xad, 0x9d, 0x8, 0x39, 0xac, 0xee, 0x1, 0x87, 0xd3, 0x91, 0x7e, 0x7b }, + }, + { + .msglen = 223, + .result = { 0xb3, 0xd0, 0x23, 0x54, 0xc2, 0x1d, 0xd6, 0x23, 0x70, 0xe0, 0xc2, 0x61, 0x52, 0xa2, 0xbc, 0x3b, 0x6, 0x11, 0x80, 0xb2, 0xfa, 0x17, 0x26, 0x74, 0x90, 0x61, 0x46, 0x35, 0x66, 0x1a, 0xe9, 0x51 }, + }, + { + .msglen = 224, + .result = { 0x0, 0xab, 0x82, 0xf2, 0xaf, 0x44, 0x95, 0x58, 0x31, 0x2a, 0x20, 0x4c, 0x2c, 0xdc, 0x80, 0xfd, 0x71, 0x7a, 0xf4, 0x34, 0xe6, 0x7e, 0xe2, 0xff, 0x6e, 0xc2, 0xf, 0x82, 0x65, 0x1e, 0x6d, 0xe6 }, + }, + { + .msglen = 225, + .result = { 0x6, 0x67, 0x32, 0x34, 0x96, 0xb5, 0x7a, 0x86, 0xda, 0x89, 0xd6, 0x9b, 0x1e, 0x23, 0x40, 0xfb, 0xd, 0xdf, 0xce, 0xdf, 0x83, 0x14, 0xb3, 0xe2, 0x2c, 0xd, 0x70, 0x18, 0xde, 0x87, 0xc6, 0x65 }, + }, + { + .msglen = 226, + .result = { 0x7b, 0x2a, 0x1c, 0xc5, 0xc6, 0x2e, 0xb4, 0xed, 0x19, 0x75, 0x50, 0x8d, 0xe5, 0x74, 0xe9, 0x31, 0x32, 0x88, 0x36, 0x6a, 0x61, 0x10, 0x6c, 0xad, 0x25, 0xb5, 0x72, 0x8a, 0x4a, 0x9, 0x18, 0x7c }, + }, + { + .msglen = 227, + .result = { 0xa6, 0x34, 0x75, 0xcb, 0x1a, 0xbb, 0x6d, 0x4a, 0xfb, 0x81, 0x67, 0xd1, 0x46, 0xac, 0x59, 0xd, 0x86, 0x5b, 0xd5, 0x71, 0xb6, 0x52, 0xd2, 0xca, 0xdb, 0x31, 0x45, 0x97, 0x61, 0x5f, 0x77, 0x62 }, + }, + { + .msglen = 228, + .result = { 0x4, 0x7d, 0x3a, 0x50, 0x35, 0x1f, 0x7e, 0x94, 0x18, 0xe0, 0xeb, 0xc, 0xe7, 0x27, 0x85, 0x54, 0x4c, 0x33, 0x51, 0xf5, 0x51, 0x2e, 0x40, 0x88, 0x67, 0x36, 0x6b, 0x5d, 0x7c, 0xb1, 0x6, 0xc7 }, + }, + { + .msglen = 229, + .result = { 0x59, 0x7f, 0x6c, 0x70, 0x8c, 0x79, 0xf8, 0x9f, 0xb2, 0xb1, 0x5e, 0xc4, 0xe9, 0x26, 0x8c, 0xae, 0xc0, 0xfc, 0x48, 0x18, 0xe0, 0xa5, 0xab, 0xb4, 0x68, 0x23, 0x2c, 0x11, 0xf9, 0x1e, 0x11, 0x62 }, + }, + { + .msglen = 230, + .result = { 0x16, 0xe9, 0x5, 0x1c, 0xfd, 0x35, 0x95, 0xda, 0xad, 0xb4, 0xbd, 0xdc, 0x7b, 0xdb, 0xc3, 0x19, 0x56, 0x88, 0x42, 0x38, 0x58, 0x2f, 0x63, 0x5b, 0x73, 0x6e, 0xfd, 0x68, 0x24, 0x27, 0xce, 0xa3 }, + }, + { + .msglen = 231, + .result = { 0x7b, 0xba, 0x9e, 0x1a, 0xdb, 0xbb, 0x9b, 0x17, 0xe, 0x7, 0xbc, 0x8b, 0xbd, 0xdf, 0xab, 0x8b, 0xe7, 0xea, 0x39, 0xba, 0x20, 0xce, 0xd5, 0x83, 0x89, 0xe3, 0x27, 0xa3, 0xbe, 0x25, 0xb0, 0x4 }, + }, + { + .msglen = 232, + .result = { 0x11, 0x4a, 0xc5, 0xc9, 0x7f, 0x98, 0xeb, 0x92, 0xd3, 0x76, 0x4f, 0xc0, 0xd8, 0x8c, 0xfd, 0xe7, 0xf3, 0x1d, 0xfd, 0xbd, 0x36, 0x88, 0x48, 0xd6, 0xc7, 0x8c, 0x9f, 0x2c, 0xb2, 0x72, 0x14, 0xb9 }, + }, + { + .msglen = 233, + .result = { 0xb0, 0x67, 0xf9, 0x62, 0xb9, 0xa1, 0xc0, 0xe5, 0xb, 0x22, 0x4b, 0xe7, 0x84, 0x6b, 0x8c, 0xa9, 0xa, 0xfa, 0xd7, 0xe7, 0x5b, 0x7b, 0xc, 0xe0, 0x6e, 0x47, 0x24, 0xf8, 0xc7, 0xf5, 0x6b, 0x14 }, + }, + { + .msglen = 234, + .result = { 0x77, 0x25, 0x61, 0xfd, 0xc8, 0x39, 0x3a, 0x72, 0x74, 0x9, 0x8b, 0x49, 0x7d, 0xa3, 0x42, 0x66, 0xb, 0x5a, 0xa5, 0x53, 0x70, 0xbe, 0x69, 0x96, 0x69, 0xbb, 0x7a, 0x8a, 0x12, 0xa, 0x7, 0x14 }, + }, + { + .msglen = 235, + .result = { 0x10, 0x16, 0xbb, 0x95, 0x96, 0xb3, 0x87, 0xf6, 0x12, 0x5d, 0xcc, 0x9, 0xd3, 0xcd, 0xf8, 0x44, 0x2, 0x62, 0x96, 0xde, 0x7c, 0xa2, 0x66, 0x12, 0x4e, 0x86, 0x32, 0x11, 0xf1, 0x18, 0x38, 0x79 }, + }, + { + .msglen = 236, + .result = { 0x42, 0x91, 0x46, 0x5c, 0xa6, 0xae, 0x5c, 0x68, 0xc8, 0xb9, 0xa8, 0x38, 0xea, 0x18, 0x71, 0x63, 0xae, 0x9c, 0xc6, 0xd9, 0x22, 0xe4, 0xfa, 0x85, 0x9c, 0x94, 0xd4, 0xb8, 0xab, 0x98, 0xe, 0xf0 }, + }, + { + .msglen = 237, + .result = { 0x2b, 0x6b, 0xc, 0x10, 0x13, 0x80, 0x8e, 0xc3, 0x8a, 0xcd, 0xe7, 0xf0, 0x21, 0x1c, 0x1c, 0x7e, 0x61, 0x5e, 0x5, 0x37, 0xde, 0x5e, 0x9f, 0x2f, 0x8a, 0xe4, 0x31, 0x0, 0x63, 0x90, 0xc8, 0xa3 }, + }, + { + .msglen = 238, + .result = { 0xf5, 0x12, 0xb6, 0x60, 0xfe, 0x6c, 0xe5, 0xd2, 0x8b, 0x2e, 0xc9, 0x37, 0x66, 0xf8, 0xd5, 0x52, 0x28, 0x76, 0x35, 0xba, 0x4b, 0xf0, 0x2c, 0xbd, 0x47, 0x14, 0x3, 0x6b, 0x47, 0x58, 0xf8, 0x16 }, + }, + { + .msglen = 239, + .result = { 0xfa, 0x6c, 0x94, 0x22, 0xb, 0x98, 0x3b, 0x74, 0x18, 0xfa, 0xb8, 0xda, 0x55, 0x6c, 0xa2, 0xf5, 0x5b, 0xe4, 0x8, 0x99, 0xfa, 0xf7, 0xb4, 0x57, 0xfa, 0x7d, 0x8a, 0xc, 0x6a, 0xe1, 0xca, 0xc2 }, + }, + { + .msglen = 240, + .result = { 0x2b, 0x59, 0x71, 0x1e, 0x37, 0x8b, 0x24, 0x39, 0x98, 0x50, 0x79, 0x3b, 0xde, 0x2c, 0xce, 0xc6, 0xd, 0xf7, 0x53, 0xb6, 0x12, 0x2d, 0x70, 0x53, 0xdf, 0xbe, 0x57, 0x56, 0x87, 0xee, 0x9f, 0x12 }, + }, + { + .msglen = 241, + .result = { 0x38, 0xf6, 0x60, 0x9d, 0x7, 0x23, 0x85, 0xcc, 0x8e, 0x4a, 0xe5, 0xf1, 0xaf, 0x31, 0x9b, 0x97, 0xda, 0x34, 0x80, 0x6c, 0x23, 0x79, 0x69, 0x33, 0x87, 0xa6, 0x2d, 0x8d, 0xd4, 0x8e, 0x66, 0x2e }, + }, + { + .msglen = 242, + .result = { 0x88, 0x5d, 0xc8, 0x2, 0xf4, 0x76, 0xe4, 0x4e, 0xae, 0xcc, 0x9, 0x49, 0xc, 0x56, 0x7, 0x22, 0xd, 0x8f, 0xb0, 0xb4, 0x68, 0x1d, 0xb5, 0xaf, 0x89, 0xb0, 0xab, 0x3b, 0x37, 0x39, 0x88, 0x37 }, + }, + { + .msglen = 243, + .result = { 0x10, 0xb1, 0x44, 0x4a, 0xe2, 0xfc, 0x17, 0xc0, 0x7d, 0x39, 0x62, 0xb3, 0x45, 0x9b, 0xbe, 0xf8, 0x79, 0x2e, 0xe2, 0xfd, 0x59, 0x8e, 0xb5, 0x6c, 0x1d, 0xf5, 0x8b, 0x50, 0xad, 0x28, 0x93, 0xf }, + }, + { + .msglen = 244, + .result = { 0xf6, 0x5d, 0xce, 0x54, 0x13, 0x2, 0x3f, 0x5b, 0x4e, 0x72, 0xc8, 0xe1, 0x42, 0x83, 0xe7, 0x52, 0xde, 0x6f, 0xe6, 0x93, 0x15, 0xab, 0xe8, 0x1f, 0x53, 0x1d, 0xc5, 0xcd, 0xf3, 0x98, 0xf0, 0x9e }, + }, + { + .msglen = 245, + .result = { 0x56, 0xf1, 0x6f, 0xe1, 0xd7, 0x0, 0x33, 0x65, 0xe1, 0x61, 0x79, 0x15, 0x78, 0x5f, 0x98, 0x32, 0x4d, 0x11, 0x99, 0xf1, 0x14, 0xf2, 0xdc, 0x10, 0x7, 0x0, 0xaf, 0xea, 0x4, 0xd, 0x99, 0x33 }, + }, + { + .msglen = 246, + .result = { 0xfc, 0xcc, 0x27, 0x84, 0xc0, 0xbf, 0xf4, 0x52, 0xf2, 0x39, 0x1f, 0xb5, 0x5e, 0x8a, 0x17, 0xd2, 0x53, 0xff, 0x3c, 0x9b, 0x53, 0x25, 0x14, 0xed, 0xca, 0x1c, 0x88, 0xa9, 0x86, 0x5c, 0x50, 0xfe }, + }, + { + .msglen = 247, + .result = { 0xf3, 0x9f, 0x18, 0x4a, 0x35, 0xf4, 0xb3, 0x6, 0xac, 0xc4, 0x8c, 0x8e, 0xe7, 0x87, 0x0, 0x11, 0x63, 0xea, 0xba, 0x6a, 0x3f, 0x12, 0xa1, 0x4b, 0xf5, 0x6d, 0xbd, 0xeb, 0xcf, 0xfe, 0x6, 0x6d }, + }, + { + .msglen = 248, + .result = { 0x78, 0x69, 0xfc, 0x51, 0x5e, 0x48, 0xda, 0xb3, 0x81, 0xcb, 0x88, 0xf1, 0xc, 0x7, 0xeb, 0x16, 0x18, 0x2e, 0x6d, 0x85, 0x9d, 0xc0, 0x80, 0xea, 0xab, 0x39, 0xd3, 0x6a, 0xa8, 0x10, 0xe3, 0x26 }, + }, + { + .msglen = 249, + .result = { 0xee, 0xfb, 0xd, 0x72, 0x20, 0x48, 0x71, 0x10, 0x46, 0xc2, 0xb0, 0x5c, 0x11, 0xcf, 0x82, 0x2e, 0x6e, 0x3e, 0x3f, 0x16, 0xfa, 0x71, 0x80, 0x5f, 0x51, 0x50, 0x3e, 0xa2, 0x5d, 0xa1, 0x66, 0xbe }, + }, + { + .msglen = 250, + .result = { 0x72, 0x9c, 0x3, 0xe9, 0x25, 0xda, 0xaf, 0x7b, 0x40, 0x10, 0xe2, 0x85, 0xe0, 0x5b, 0xce, 0x55, 0x72, 0x1f, 0xfa, 0x54, 0x1c, 0x96, 0x48, 0xb, 0x55, 0x26, 0x53, 0x7d, 0xa9, 0xc5, 0x27, 0xd0 }, + }, + { + .msglen = 251, + .result = { 0x6f, 0x40, 0xd5, 0x72, 0x3b, 0x1f, 0x99, 0x9e, 0x7, 0x57, 0xbb, 0x57, 0x6c, 0x7e, 0x47, 0xb2, 0x76, 0x37, 0x5e, 0x64, 0x21, 0x51, 0x3c, 0xe8, 0x16, 0xda, 0x5f, 0x9f, 0xc9, 0x5b, 0xc3, 0x70 }, + }, + { + .msglen = 252, + .result = { 0x77, 0x3b, 0x47, 0x74, 0x0, 0xfd, 0x74, 0x95, 0xe, 0x59, 0xf6, 0xf, 0xcf, 0x9a, 0xb3, 0xbc, 0x9f, 0xd9, 0x3c, 0x3a, 0x30, 0x1c, 0x1f, 0x4d, 0x53, 0xbe, 0xce, 0x4c, 0xa1, 0x8b, 0xc1, 0x22 }, + }, + { + .msglen = 253, + .result = { 0xd0, 0xbe, 0x9, 0xb3, 0xa9, 0xa4, 0xb2, 0x46, 0x99, 0x40, 0x40, 0x6b, 0x52, 0x54, 0x3b, 0xfe, 0x94, 0x37, 0xf9, 0xc, 0xc2, 0xc2, 0x66, 0x3, 0xa5, 0x8c, 0x42, 0xae, 0x9d, 0xf8, 0x47, 0x87 }, + }, + { + .msglen = 254, + .result = { 0x85, 0x78, 0x21, 0xf4, 0xa, 0xee, 0xa3, 0x59, 0xe0, 0xb2, 0xd7, 0x7, 0x34, 0x5e, 0x57, 0xdc, 0xdd, 0x9a, 0xfa, 0x2c, 0xfd, 0xb6, 0xee, 0xa9, 0x14, 0xc0, 0x17, 0x86, 0xbf, 0x7b, 0xfe, 0x4b }, + }, + { + .msglen = 255, + .result = { 0x59, 0x52, 0x50, 0x4, 0xb6, 0x28, 0xf9, 0x28, 0x7f, 0x6c, 0x37, 0xba, 0xfb, 0xb2, 0x58, 0xe7, 0xa, 0xac, 0x6c, 0x4a, 0xef, 0x66, 0x6, 0x7b, 0x1, 0x1f, 0x4c, 0xa4, 0xe5, 0xe5, 0x29, 0x5d }, + }, + { + .msglen = 256, + .result = { 0x52, 0x1a, 0x14, 0xc3, 0xb4, 0x85, 0xf0, 0xb5, 0x82, 0xe9, 0x40, 0xc2, 0xc, 0x6d, 0x59, 0x64, 0x86, 0x7d, 0xa, 0x3b, 0x7f, 0x85, 0x78, 0xea, 0xea, 0x66, 0x48, 0xfa, 0x4a, 0xde, 0x5c, 0xd3 }, + }, +}; diff --git a/components/esp_security/test_apps/crypto_drivers/main/test_ds.c b/components/esp_security/test_apps/crypto_drivers/main/test_ds.c index 932f77f7ee..6a7629d80c 100644 --- a/components/esp_security/test_apps/crypto_drivers/main/test_ds.c +++ b/components/esp_security/test_apps/crypto_drivers/main/test_ds.c @@ -184,7 +184,7 @@ TEST_CASE("Digital Signature start HMAC key out of range", "[hw_crypto] [ds]") esp_ds_context_t *ctx; const char *message = "test"; - TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_ds_start_sign(message, &ds_data, HMAC_KEY5 + 1, &ctx)); + TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_ds_start_sign(message, &ds_data, HMAC_KEY_MAX, &ctx)); TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_ds_start_sign(message, &ds_data, HMAC_KEY0 - 1, &ctx)); } @@ -255,7 +255,7 @@ TEST_CASE("Digital Signature Blocking HMAC key out of range", "[hw_crypto] [ds]" const char *message = "test"; uint8_t signature_data [128 * 4]; - TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_ds_sign(message, &ds_data, HMAC_KEY5 + 1, signature_data)); + TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_ds_sign(message, &ds_data, HMAC_KEY_MAX, signature_data)); TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_ds_sign(message, &ds_data, HMAC_KEY0 - 1, signature_data)); } diff --git a/components/esp_security/test_apps/crypto_drivers/main/test_hmac.c b/components/esp_security/test_apps/crypto_drivers/main/test_hmac.c index 8f8ccf39ef..dc18cec22a 100644 --- a/components/esp_security/test_apps/crypto_drivers/main/test_hmac.c +++ b/components/esp_security/test_apps/crypto_drivers/main/test_hmac.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,22 +9,12 @@ #include "esp_efuse_table.h" #include "esp_log.h" #include "esp_hmac.h" +#include "hmac_test_cases.h" #if CONFIG_ESP_SECURITY_ENABLE_FPGA_TESTS -/* Allow testing varying message lengths (truncating the same message) - for various results */ -typedef struct { - int msglen; - uint8_t result[32]; -} hmac_result; - static void setup_keyblock(esp_efuse_block_t key_block, esp_efuse_purpose_t purpose) { - const uint8_t key_data[32] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32 - }; esp_err_t status = esp_efuse_write_key(key_block, purpose, key_data, sizeof(key_data)); if (status == ESP_OK) { @@ -42,16 +32,6 @@ TEST_CASE("HMAC 'downstream' JTAG Enable mode", "[hw_crypto]") setup_keyblock(EFUSE_BLK_KEY4, ESP_EFUSE_KEY_PURPOSE_HMAC_DOWN_JTAG); - // Results calculated with Python: - // - // import hmac, hashlib, binascii - // key = b"".join([chr(x).encode() for x in range(1,33)]) - // ", ".join("0x%x" % x for x in hmac.HMAC(key, b"\x00" * 32, hashlib.sha256).digest() ) - const uint8_t token_data[32] = { - 0xb2, 0xa4, 0x9b, 0x1c, 0xce, 0x1b, 0xe9, 0x22, 0xbb, 0x7e, 0x43, 0x12, 0x77, 0x41, 0x3e, 0x3e, - 0x8e, 0x6c, 0x3e, 0x8e, 0x6e, 0x17, 0x62, 0x5c, 0x50, 0xac, 0x66, 0xa9, 0xa8, 0x57, 0x94, 0x9b - }; - TEST_ASSERT_MESSAGE(ESP_OK == esp_efuse_batch_write_begin(), "Error programming security efuse.\n"); @@ -80,135 +60,6 @@ TEST_CASE("HMAC 'upstream' MAC generation with zeroes", "[hw_crypto]") setup_keyblock(EFUSE_BLK_KEY5, ESP_EFUSE_KEY_PURPOSE_HMAC_UP); const uint8_t zeroes[128] = { }; - // Produce the HMAC of various numbers of zeroes - // - // Results calculated with Python: - // - // import hmac, hashlib, binascii - // key = b"".join([chr(x).encode() for x in range(1,33)]) - // ", ".join("0x%x" % x for x in hmac.HMAC(key, b"\x00" * 128, hashlib.sha256).digest() ) - - static const hmac_result zero_results[] = { - { - .msglen = 64, - .result = { - 0x4f, 0x34, 0x31, 0x8a, 0x45, 0x74, 0x4d, 0x71, 0x53, 0xb7, 0x18, 0xf4, 0x78, 0x1c, 0xbb, 0x10, - 0x19, 0x60, 0xba, 0x9c, 0x8c, 0xe2, 0x3b, 0xc1, 0x1d, 0x79, 0xb6, 0x3c, 0xae, 0x0f, 0x30, 0xc8, - }, - }, - { - .msglen = 128, - .result = { - 0x40, 0xd5, 0xb9, 0xe6, 0x25, 0x8f, 0x3c, 0xd0, 0x3f, 0xb9, 0x6c, 0xa3, 0xa7, 0x2b, 0x84, 0xe3, - 0x1d, 0x4b, 0x4e, 0x65, 0xf8, 0x7b, 0x3e, 0x3, 0x26, 0x2, 0xcd, 0x49, 0x73, 0xf0, 0xac, 0x25 - }, - }, - { - .msglen = 48, - .result = { - 0x84, 0x4e, 0x45, 0xcd, 0xb3, 0x8f, 0xf8, 0x96, 0xe7, 0xe7, 0x80, 0x48, 0x31, 0x89, 0x79, 0xa7, - 0x5d, 0x80, 0xd1, 0xbf, 0x3, 0xca, 0x9b, 0x78, 0x4f, 0x3b, 0x42, 0x80, 0xb9, 0x6, 0x19, 0x7d - }, - }, - { - .msglen = 32, - .result = { - 0xb2, 0xa4, 0x9b, 0x1c, 0xce, 0x1b, 0xe9, 0x22, 0xbb, 0x7e, 0x43, 0x12, 0x77, 0x41, 0x3e, 0x3e, - 0x8e, 0x6c, 0x3e, 0x8e, 0x6e, 0x17, 0x62, 0x5c, 0x50, 0xac, 0x66, 0xa9, 0xa8, 0x57, 0x94, 0x9b - }, - }, - { - .msglen = 33, - .result = { - 0x98, 0xd7, 0x44, 0xab, 0xbb, 0x89, 0xca, 0x51, 0x3e, 0x2, 0x8e, 0x5c, 0xa1, 0x61, 0x25, 0xd2, - 0x93, 0x3e, 0x85, 0x4b, 0x9f, 0x73, 0x63, 0x57, 0xab, 0xbc, 0x7a, 0x66, 0x51, 0xd2, 0x39, 0xb9 - }, - }, - { - .msglen = 1, - .result = { - 0xab, 0x7d, 0x90, 0x85, 0x8, 0xb3, 0xf3, 0x7, 0x45, 0x6c, 0x85, 0x40, 0xbf, 0xcd, 0xb4, 0x52, - 0x54, 0x2c, 0x2, 0xe0, 0x53, 0xdc, 0x16, 0x12, 0x90, 0xf1, 0x5b, 0x5b, 0xf8, 0x71, 0x65, 0x44 - }, - }, - { - .msglen = 127, - .result = { - 0x19, 0x38, 0x88, 0xb, 0x30, 0xac, 0xef, 0x4e, 0xd, 0x38, 0x7d, 0x7e, 0x42, 0x5c, 0x90, 0xc4, - 0x9b, 0xc1, 0xbd, 0x9e, 0x30, 0xc6, 0x16, 0x1f, 0x36, 0x7e, 0x46, 0xcd, 0xb2, 0xd7, 0x37, 0x70 - }, - }, - { - .msglen = 126, - .result = { - 0xf, 0xa4, 0xb5, 0x16, 0x3b, 0xf5, 0xe8, 0x6e, 0xaf, 0x38, 0xc6, 0x27, 0x9a, 0xc, 0x88, 0xaf, - 0xb5, 0x10, 0x75, 0x3d, 0x4a, 0x85, 0x10, 0x4e, 0x60, 0xe4, 0x61, 0x30, 0x8, 0x46, 0x98, 0xc7 - }, - }, - { - .msglen = 125, - .result = { - 0x3f, 0x1a, 0x90, 0x47, 0xeb, 0x44, 0xcc, 0x27, 0xfa, 0x22, 0xb3, 0x5d, 0xa2, 0x22, 0x30, 0x54, - 0x61, 0x15, 0xe5, 0x54, 0x55, 0x13, 0x7c, 0xb8, 0xc7, 0xc0, 0x28, 0xa4, 0xd4, 0xbc, 0x1c, 0xad - }, - }, - { - .msglen = 124, - .result = { - 0x14, 0xdf, 0x13, 0xa2, 0xe4, 0xfd, 0xa3, 0xa8, 0x9b, 0x71, 0x78, 0x2e, 0x24, 0xb6, 0x61, 0x13, - 0xff, 0x6c, 0x6d, 0xe8, 0x95, 0xf9, 0x68, 0xb4, 0x92, 0x7c, 0xc9, 0xf7, 0x5e, 0x14, 0x44, 0x8 - }, - }, - { - .msglen = 123, - .result = { - 0x6, 0xd0, 0xe, 0xbe, 0x90, 0x3b, 0x52, 0x85, 0xd4, 0x25, 0x7e, 0xbe, 0x71, 0x92, 0xd0, 0xf0, - 0x6a, 0x99, 0x93, 0x64, 0xe6, 0x9a, 0x27, 0xfa, 0x57, 0xcb, 0x6f, 0x9f, 0x44, 0x30, 0xf5, 0xcc - }, - }, - { - .msglen = 122, - .result = { - 0x76, 0x7a, 0x86, 0x80, 0x1e, 0x54, 0x11, 0xef, 0x2f, 0x4e, 0xf9, 0x7, 0xda, 0x42, 0xd6, 0x71, - 0x3b, 0xb9, 0x92, 0xfb, 0x8, 0x1d, 0xf2, 0x41, 0x96, 0x5f, 0x28, 0x10, 0x20, 0x1a, 0x7b, 0xef - }, - }, - { - .msglen = 121, - .result = { - 0x59, 0xb0, 0xdb, 0x73, 0xee, 0x43, 0xb9, 0x63, 0x82, 0x36, 0x11, 0x5a, 0x6b, 0x46, 0x8, 0xbb, - 0x18, 0xdd, 0x74, 0x82, 0x8f, 0xf3, 0xb3, 0x5d, 0xd1, 0xad, 0xe, 0x8e, 0x77, 0x90, 0xde, 0x70 - }, - }, - { - .msglen = 120, - .result = { - 0xe0, 0x24, 0xc5, 0x2, 0x6b, 0xe, 0xe3, 0x9b, 0x1, 0x95, 0x6, 0x21, 0xc6, 0xad, 0x0, 0x72, - 0x36, 0x9, 0x75, 0xcd, 0x10, 0xa3, 0xf, 0xa2, 0xe5, 0xcd, 0x27, 0x6b, 0x95, 0x23, 0x6, 0x72 - }, - }, - { - .msglen = 119, - .result = { - 0x70, 0x4, 0x2c, 0x78, 0xc5, 0x40, 0x3f, 0xfb, 0x71, 0xfb, 0x3e, 0xbd, 0x9f, 0x4e, 0x2f, 0xf8, - 0x3c, 0x9b, 0xd1, 0xad, 0xee, 0xc8, 0x4f, 0x40, 0xec, 0x29, 0x5a, 0xb9, 0x9a, 0xa7, 0xe9, 0x51 - }, - }, - { - .msglen = 118, - .result = { - 0x1a, 0x4b, 0x49, 0xd3, 0x6, 0x1, 0x75, 0xca, 0x3, 0x12, 0x2e, 0x9a, 0xd4, 0xda, 0xb8, 0x23, - 0xf9, 0xa0, 0xa6, 0xbc, 0xbc, 0xcc, 0xa1, 0x6f, 0xd8, 0x3b, 0x2a, 0x37, 0xd3, 0xc3, 0xca, 0x5f - }, - }, - { - .msglen = 0, - .result = { - 0x46, 0x24, 0x76, 0xa8, 0x97, 0xdd, 0xfd, 0xbd, 0x40, 0xd1, 0x42, 0xe, 0x8, 0xa5, 0xbc, 0xfe, - 0xeb, 0x25, 0xc3, 0xe2, 0xad, 0xe6, 0xa0, 0xa9, 0x8, 0x3b, 0x32, 0x7b, 0x9e, 0xf9, 0xfc, 0xa1 - }, - }, - }; const size_t num_zero_results = sizeof(zero_results) / sizeof(hmac_result); @@ -224,1047 +75,6 @@ TEST_CASE("HMAC 'upstream' MAC generation from data", "[hw_crypto]") setup_keyblock(EFUSE_BLK_KEY5, ESP_EFUSE_KEY_PURPOSE_HMAC_UP); - // 257 characters of pseudo-Latin from lipsum.com (not Copyright) - const char *message = "Deleniti voluptas explicabo et assumenda. Sed et aliquid minus quis. Praesentium cupiditate quia nemo est. Laboriosam pariatur ut distinctio tenetur. Sunt architecto iure aspernatur soluta ut recusandae. Ut quibusdam occaecati ut qui sit dignissimos eaque.."; - - // 256 different HMAC results for different length portions of the above. Generated as follows: - // - // import hmac, hashlib, binascii - // key = b"".join([chr(x).encode() for x in range(1,33)]) - // assert len(message) == 257 - // for l in range(1, len(message)): - // print(" // %d" % l) - // mac = hmac.HMAC(key, message[:l], hashlib.sha256).digest() - // print("{ " + ", ".join("0x%x" % ord(x) for x in mac) + " }, ") - // - // (Note: the zero length case is handled in the other unit test.) - static const hmac_result results[] = { - { - .msglen = 1, - .result = { 0xf2, 0x1a, 0x8e, 0x60, 0xea, 0xd9, 0x36, 0xd1, 0xc2, 0x74, 0x24, 0xae, 0x6, 0x2d, 0x81, 0x28, 0x16, 0xa6, 0x33, 0xca, 0x9d, 0x55, 0xc0, 0x82, 0x28, 0xd9, 0x79, 0x8f, 0x5a, 0xaa, 0xfd, 0x25 }, - }, - { - .msglen = 2, - .result = { 0x1f, 0x6, 0xfc, 0x68, 0x5c, 0xa8, 0xbf, 0x3e, 0x57, 0x6d, 0x2, 0x56, 0x4a, 0x35, 0x31, 0xbd, 0xeb, 0xf4, 0x5d, 0xd5, 0x71, 0xf9, 0x65, 0x7d, 0xa9, 0x32, 0x1d, 0x68, 0x21, 0xd2, 0x9b, 0xaf }, - }, - { - .msglen = 3, - .result = { 0x2b, 0xb4, 0x4e, 0x80, 0x6e, 0xd2, 0xcb, 0xee, 0x4b, 0x40, 0xfb, 0xf9, 0x61, 0x76, 0x78, 0x2a, 0xb1, 0xc8, 0xea, 0xa3, 0x3e, 0xf7, 0x24, 0x86, 0xa0, 0x73, 0xda, 0xe, 0xaf, 0x98, 0xb, 0xf0 }, - }, - { - .msglen = 4, - .result = { 0xf, 0x39, 0xd1, 0x1a, 0x3a, 0xe9, 0xa9, 0xf8, 0xe9, 0x39, 0xed, 0x1b, 0x32, 0x3, 0xbc, 0x24, 0x32, 0xe8, 0x12, 0xd7, 0xc4, 0xed, 0x2a, 0x8a, 0xed, 0x46, 0xbf, 0xa7, 0x21, 0x31, 0x37, 0xb5 }, - }, - { - .msglen = 5, - .result = { 0x6c, 0xfc, 0xf8, 0x9a, 0x56, 0xce, 0xe6, 0x1, 0x36, 0xca, 0x36, 0x37, 0xa8, 0xb9, 0xca, 0x99, 0x3b, 0xb1, 0xf8, 0x24, 0xa5, 0xf6, 0x20, 0x4d, 0xff, 0x8c, 0x60, 0xd3, 0x9, 0x92, 0xef, 0xb3 }, - }, - { - .msglen = 6, - .result = { 0x86, 0x99, 0x7, 0xd7, 0x5b, 0xb3, 0x93, 0x95, 0x3a, 0x9e, 0xf5, 0x95, 0x9d, 0x5e, 0x7b, 0xaf, 0x9b, 0x4b, 0x19, 0x35, 0x31, 0x34, 0xba, 0x29, 0xa, 0x56, 0xb, 0xe4, 0xa4, 0xbf, 0xb8, 0x9f }, - }, - { - .msglen = 7, - .result = { 0xa9, 0x9, 0x85, 0x26, 0x7b, 0x92, 0x23, 0xe7, 0x3d, 0x44, 0xa1, 0xcc, 0xba, 0x5c, 0xda, 0xdb, 0x5a, 0xe2, 0x76, 0x78, 0xd7, 0x42, 0x77, 0x4a, 0x8e, 0x2b, 0x79, 0x73, 0x4c, 0x29, 0x6, 0x1c }, - }, - { - .msglen = 8, - .result = { 0x26, 0x15, 0x1f, 0xe3, 0x53, 0xd9, 0x8, 0xc5, 0xf0, 0x11, 0x7, 0x7, 0x5f, 0x8c, 0xf6, 0x61, 0xd2, 0x21, 0x16, 0xe4, 0xb9, 0x61, 0x29, 0x1c, 0x4d, 0x2b, 0x6d, 0x9a, 0x88, 0x8c, 0xdc, 0xa9 }, - }, - { - .msglen = 9, - .result = { 0x2, 0xf2, 0xe6, 0xc8, 0x9c, 0xdc, 0x1b, 0x64, 0xd6, 0x32, 0xc2, 0x48, 0x62, 0x51, 0x9c, 0x0, 0x90, 0xf4, 0xf1, 0x2a, 0x0, 0x2, 0xce, 0x32, 0xbb, 0x8f, 0x38, 0x9c, 0x8b, 0xaa, 0xdd, 0x5d }, - }, - { - .msglen = 10, - .result = { 0x44, 0x76, 0x8a, 0x53, 0xcf, 0xbb, 0xc1, 0xd0, 0x36, 0x96, 0xb5, 0xe9, 0xe, 0xfb, 0xce, 0xb3, 0x47, 0x21, 0xaa, 0xea, 0xac, 0x76, 0x54, 0x91, 0xc1, 0xcb, 0x88, 0x32, 0xb1, 0xea, 0xd5, 0x4c }, - }, - { - .msglen = 11, - .result = { 0x95, 0xf9, 0x78, 0x12, 0xe5, 0x7a, 0xf4, 0xc5, 0xee, 0x5e, 0x27, 0xe7, 0x5e, 0x8, 0x56, 0x60, 0x97, 0xc1, 0xee, 0xf, 0xf5, 0x24, 0x5c, 0x20, 0xbe, 0x95, 0x3c, 0xa2, 0xf5, 0x68, 0x69, 0x6f }, - }, - { - .msglen = 12, - .result = { 0x8e, 0x71, 0xa8, 0x23, 0x7a, 0x8, 0x6a, 0xf4, 0x2e, 0xab, 0x58, 0x56, 0x37, 0x55, 0x26, 0x57, 0x13, 0xc, 0x6b, 0x6b, 0x65, 0xb6, 0x4f, 0xec, 0xde, 0xc2, 0xe6, 0xb0, 0x34, 0xc0, 0x4a, 0xba }, - }, - { - .msglen = 13, - .result = { 0x75, 0xc8, 0x29, 0x60, 0x89, 0xb7, 0xba, 0xc7, 0x40, 0x18, 0x73, 0x8a, 0xa3, 0x92, 0xb2, 0x2c, 0x79, 0x74, 0x1c, 0xdc, 0xc0, 0x97, 0x14, 0xdb, 0x26, 0xcc, 0xad, 0x7f, 0x9d, 0x2f, 0xd, 0x5 }, - }, - { - .msglen = 14, - .result = { 0xe9, 0xf2, 0x97, 0x12, 0x4d, 0xc3, 0x22, 0xca, 0x7, 0xc, 0xac, 0xae, 0xcb, 0x63, 0xe2, 0x88, 0xa2, 0xf8, 0xb0, 0x94, 0xfc, 0x21, 0xf4, 0x69, 0x8e, 0xa0, 0x95, 0x3, 0x54, 0xa1, 0x61, 0xed }, - }, - { - .msglen = 15, - .result = { 0x34, 0xd4, 0x3e, 0xcd, 0xcc, 0xa, 0x5f, 0xaf, 0xf5, 0x3d, 0xb8, 0xaa, 0x18, 0x4a, 0x18, 0xef, 0x22, 0x75, 0x29, 0x17, 0x1b, 0x33, 0xf2, 0x50, 0x4e, 0x90, 0xd5, 0xa3, 0x10, 0xff, 0x79, 0xbc }, - }, - { - .msglen = 16, - .result = { 0xcf, 0x6, 0x59, 0x8d, 0x2d, 0x7b, 0xb, 0x3d, 0x1a, 0xa3, 0x9c, 0xfa, 0xa2, 0xf1, 0x88, 0x6, 0xd2, 0xb4, 0xb5, 0x2d, 0x4c, 0x56, 0x7, 0xf5, 0x20, 0xce, 0x9a, 0x79, 0x3a, 0x2e, 0x11, 0xfa }, - }, - { - .msglen = 17, - .result = { 0x55, 0x5f, 0x37, 0xd9, 0x7, 0x3a, 0x3a, 0x6b, 0x22, 0xf8, 0x1c, 0x8f, 0xd8, 0xf6, 0xf7, 0x18, 0x77, 0xf3, 0x52, 0x32, 0xc6, 0x9b, 0xe0, 0xc7, 0xa6, 0xf0, 0x6b, 0xb0, 0x6a, 0xad, 0xb2, 0x7e }, - }, - { - .msglen = 18, - .result = { 0xa0, 0x60, 0x25, 0x34, 0xd7, 0xe1, 0x66, 0x7e, 0xdd, 0xec, 0x8, 0x95, 0xb5, 0xd9, 0x2d, 0x4e, 0x29, 0x89, 0x39, 0xb9, 0xc1, 0xe4, 0xc1, 0x86, 0x10, 0x16, 0x5, 0x17, 0xd0, 0x6, 0x91, 0x2d }, - }, - { - .msglen = 19, - .result = { 0xb4, 0x45, 0xbc, 0xae, 0xb3, 0x5b, 0x61, 0xd3, 0x50, 0x8c, 0x38, 0x7a, 0x4c, 0x4c, 0xbc, 0x38, 0x89, 0x98, 0x75, 0x23, 0xa9, 0x92, 0xa4, 0xea, 0xfe, 0xe6, 0x88, 0x61, 0xb0, 0xf0, 0x8, 0x7b }, - }, - { - .msglen = 20, - .result = { 0x1d, 0x2e, 0x5c, 0x69, 0x7b, 0x2a, 0xa0, 0x9d, 0xe6, 0x5b, 0xc, 0x3, 0x53, 0x9, 0x66, 0x74, 0xd8, 0xf6, 0xe8, 0x87, 0x5d, 0xc7, 0x1, 0xf0, 0xce, 0xaf, 0xb1, 0x15, 0x34, 0x22, 0x8e, 0x83 }, - }, - { - .msglen = 21, - .result = { 0x8e, 0xd9, 0xb1, 0xc7, 0x99, 0x91, 0x1, 0x9a, 0xe, 0xfa, 0xd2, 0xed, 0xc4, 0xae, 0x47, 0xf2, 0xa2, 0x48, 0x53, 0xa8, 0x92, 0xff, 0xe4, 0xcc, 0x95, 0x5e, 0x25, 0x1a, 0x2a, 0x49, 0x6c, 0xfd }, - }, - { - .msglen = 22, - .result = { 0x14, 0xba, 0x32, 0xbe, 0x21, 0x6, 0x6e, 0x6a, 0x28, 0x2b, 0x4e, 0xfc, 0x97, 0xa5, 0x6, 0x32, 0x62, 0x7, 0xf3, 0x61, 0x41, 0x43, 0x5e, 0x34, 0x93, 0x0, 0xa8, 0xb3, 0x9, 0x55, 0x37, 0x3f }, - }, - { - .msglen = 23, - .result = { 0xa1, 0xf0, 0xe6, 0xf1, 0x9d, 0x5d, 0x30, 0x10, 0x17, 0xce, 0x39, 0x5e, 0x93, 0x2b, 0xe6, 0xeb, 0x6b, 0x5b, 0x64, 0x47, 0x65, 0xe8, 0x93, 0x2e, 0x39, 0x74, 0x6a, 0x71, 0xf3, 0xdb, 0xb6, 0x8d }, - }, - { - .msglen = 24, - .result = { 0xab, 0xf4, 0xe1, 0x78, 0xc1, 0x63, 0x95, 0xf2, 0x6c, 0x54, 0xc, 0xac, 0xce, 0x88, 0x17, 0xf6, 0x1c, 0x84, 0x5b, 0x26, 0xa3, 0x5c, 0xea, 0xf7, 0x66, 0xcb, 0x84, 0xed, 0xbe, 0x52, 0xd, 0x25 }, - }, - { - .msglen = 25, - .result = { 0xd8, 0x94, 0x77, 0xa7, 0x6c, 0x51, 0x30, 0x3c, 0xd7, 0x4f, 0xc4, 0x6e, 0x1a, 0x25, 0xf8, 0x87, 0x93, 0x49, 0x28, 0x6b, 0x1b, 0x3, 0x79, 0x5, 0x14, 0x15, 0xd1, 0xee, 0x51, 0x7b, 0x9f, 0x94 }, - }, - { - .msglen = 26, - .result = { 0xbb, 0x8a, 0x5f, 0x73, 0x8d, 0x4e, 0x8a, 0x11, 0x95, 0x5d, 0xf5, 0xcf, 0x25, 0xea, 0x79, 0x38, 0xc4, 0x4b, 0xb4, 0x6f, 0xa3, 0x1f, 0x18, 0x23, 0x73, 0x1e, 0x46, 0xcb, 0x5d, 0x97, 0xcf, 0x6c }, - }, - { - .msglen = 27, - .result = { 0xe2, 0xad, 0x4b, 0x4e, 0x43, 0xf1, 0x6d, 0x62, 0x1a, 0xb4, 0x65, 0xbb, 0xb3, 0x34, 0x8, 0xf7, 0x14, 0x14, 0xd2, 0x6f, 0x41, 0x8f, 0xa7, 0x6f, 0xab, 0x6e, 0x61, 0xe2, 0x5, 0x5b, 0x2a, 0xe6 }, - }, - { - .msglen = 28, - .result = { 0xd9, 0xea, 0x5, 0x72, 0x59, 0x12, 0xff, 0xb, 0x33, 0x87, 0x17, 0x9d, 0xb2, 0x9, 0x4f, 0xfc, 0xba, 0xd7, 0xc, 0x45, 0x3b, 0xbe, 0x6a, 0x12, 0x59, 0x38, 0x40, 0x30, 0x8c, 0xa4, 0xf, 0x7d }, - }, - { - .msglen = 29, - .result = { 0x29, 0xe, 0x6d, 0x59, 0x2a, 0xaf, 0x5f, 0x93, 0xc7, 0x97, 0xbb, 0x29, 0x92, 0x2c, 0xba, 0x6b, 0xa5, 0xcb, 0x7e, 0x88, 0x5b, 0xcd, 0xd4, 0xfe, 0xb4, 0xc7, 0x65, 0xae, 0x6b, 0x7f, 0x78, 0xb6 }, - }, - { - .msglen = 30, - .result = { 0x5e, 0xea, 0x58, 0xb5, 0x93, 0x4b, 0xb7, 0x32, 0x50, 0xcb, 0xc6, 0x6c, 0x63, 0x9d, 0x5d, 0xa9, 0x3f, 0x80, 0xc4, 0x91, 0xbc, 0xe3, 0x2a, 0xd6, 0x20, 0xfb, 0xf9, 0x43, 0x59, 0xcf, 0x86, 0x1d }, - }, - { - .msglen = 31, - .result = { 0x46, 0xee, 0x3a, 0x2a, 0x1, 0xf6, 0x43, 0xe, 0xbb, 0xc6, 0x90, 0x4f, 0x66, 0xa5, 0xe9, 0xd7, 0xa8, 0x29, 0x7e, 0x16, 0x4, 0x57, 0xee, 0x5c, 0xf4, 0x6c, 0xc8, 0x4a, 0x92, 0x27, 0x83, 0x42 }, - }, - { - .msglen = 32, - .result = { 0x82, 0x36, 0xe6, 0xf, 0xa, 0x37, 0x2d, 0x7b, 0x2, 0x75, 0xc4, 0x48, 0x36, 0xbf, 0xdf, 0x79, 0x35, 0xdf, 0xcb, 0x65, 0x25, 0xae, 0x11, 0x2c, 0xfa, 0x54, 0x4a, 0x99, 0xfe, 0x2a, 0x63, 0xbd }, - }, - { - .msglen = 33, - .result = { 0x9e, 0x35, 0xc8, 0x6c, 0xa7, 0xe8, 0x8b, 0xb2, 0x0, 0x4c, 0x41, 0x51, 0x5b, 0xd2, 0x4b, 0x9f, 0x10, 0xea, 0xfe, 0xd7, 0xc1, 0xd1, 0x36, 0xfb, 0x52, 0xd6, 0xe3, 0xe2, 0x23, 0xc9, 0x53, 0x33 }, - }, - { - .msglen = 34, - .result = { 0x52, 0xe9, 0x15, 0x90, 0x65, 0xb, 0x75, 0x89, 0xb3, 0xed, 0x7a, 0xb6, 0x12, 0xe6, 0xe, 0xeb, 0x7c, 0x25, 0xb4, 0xf3, 0x2a, 0xf6, 0xfe, 0x6a, 0x3c, 0xd9, 0xf0, 0x2a, 0xaf, 0xc7, 0x1b, 0xbc }, - }, - { - .msglen = 35, - .result = { 0xfc, 0xa5, 0xf1, 0x9a, 0xa0, 0xfa, 0x42, 0x7b, 0x49, 0xf, 0xd7, 0x76, 0xe0, 0xf9, 0x31, 0x17, 0x87, 0x70, 0x19, 0x90, 0x26, 0x96, 0xcd, 0xd6, 0xf, 0xa8, 0xb, 0x1f, 0x31, 0x45, 0x9c, 0xd0 }, - }, - { - .msglen = 36, - .result = { 0x85, 0x76, 0xf4, 0xfc, 0x96, 0xfb, 0x69, 0x31, 0x6, 0x5c, 0x6e, 0xd9, 0x75, 0xda, 0xf0, 0x14, 0xba, 0x4b, 0x74, 0x96, 0xf7, 0xe6, 0xd0, 0x3d, 0x36, 0x9b, 0x94, 0x8c, 0x1a, 0xb9, 0x7a, 0x88 }, - }, - { - .msglen = 37, - .result = { 0x8b, 0xc7, 0xad, 0xb8, 0xce, 0xc6, 0xd7, 0x8e, 0xd6, 0xfa, 0xa5, 0xd3, 0x59, 0x3d, 0x39, 0xdc, 0x74, 0x56, 0x3c, 0xd9, 0xc8, 0x0, 0xd2, 0xb0, 0x21, 0x7b, 0x93, 0xcb, 0x18, 0xec, 0x5f, 0xdd }, - }, - { - .msglen = 38, - .result = { 0x95, 0x7a, 0xf3, 0x9c, 0x5b, 0x40, 0x86, 0xdf, 0xa6, 0xf7, 0x34, 0x40, 0xb0, 0x7a, 0x34, 0x6c, 0xd5, 0x3d, 0x6, 0x9d, 0xc7, 0x9f, 0x11, 0x32, 0x98, 0x78, 0xee, 0xed, 0xb6, 0xb4, 0x1f, 0x34 }, - }, - { - .msglen = 39, - .result = { 0xf3, 0x50, 0x40, 0xd2, 0xbb, 0x54, 0xb3, 0xcf, 0x37, 0x55, 0xff, 0xc8, 0x41, 0x30, 0xde, 0x33, 0x2f, 0x4, 0xe3, 0xe7, 0x42, 0x31, 0x68, 0xe6, 0x6d, 0x5d, 0xdc, 0x14, 0x5a, 0x58, 0xf4, 0x46 }, - }, - { - .msglen = 40, - .result = { 0xda, 0x9d, 0xeb, 0xf7, 0xa7, 0xa1, 0x4, 0xd1, 0xfb, 0xe3, 0xd8, 0x11, 0x8d, 0x54, 0x88, 0x65, 0x42, 0x6e, 0x78, 0x7a, 0x8f, 0x1b, 0xc5, 0x13, 0x98, 0x53, 0x38, 0x26, 0xf3, 0x3d, 0xd2, 0xff }, - }, - { - .msglen = 41, - .result = { 0x9c, 0x23, 0x67, 0xa3, 0xeb, 0xed, 0xca, 0x21, 0x4b, 0x4c, 0x68, 0x95, 0xaf, 0xfb, 0x9b, 0x17, 0xf0, 0x2a, 0x5c, 0x78, 0x58, 0x65, 0xf1, 0x20, 0xfd, 0x3c, 0xd9, 0x66, 0x94, 0x66, 0x4d, 0xcc }, - }, - { - .msglen = 42, - .result = { 0xfa, 0x61, 0xf5, 0xd7, 0x58, 0xd2, 0x32, 0xb0, 0xb, 0x95, 0x88, 0xfc, 0x8a, 0x79, 0x15, 0x61, 0x1e, 0xa7, 0xf7, 0xf2, 0xf1, 0x91, 0xe7, 0xb3, 0x55, 0xa0, 0x65, 0x3c, 0xca, 0xf6, 0xac, 0x19 }, - }, - { - .msglen = 43, - .result = { 0xae, 0xc1, 0xb4, 0xa9, 0x88, 0xf3, 0x6d, 0xfe, 0xc2, 0x48, 0x19, 0x2a, 0x68, 0x41, 0x5e, 0x3f, 0xbe, 0x32, 0x20, 0xc7, 0x90, 0x6f, 0x23, 0x6d, 0x42, 0xaa, 0x38, 0xbb, 0xd5, 0x34, 0x7e, 0x21 }, - }, - { - .msglen = 44, - .result = { 0x12, 0xb0, 0xb, 0x1, 0xcf, 0xc9, 0x20, 0x8d, 0x59, 0xc1, 0xb7, 0xe9, 0x23, 0x53, 0x12, 0xd4, 0x41, 0x99, 0x7f, 0xb9, 0x57, 0x11, 0x5d, 0x9c, 0x60, 0xa8, 0x0, 0x3, 0x68, 0x9, 0x4d, 0x1d }, - }, - { - .msglen = 45, - .result = { 0xee, 0x85, 0x2, 0xed, 0xa1, 0x41, 0x71, 0xd4, 0x32, 0x2, 0x33, 0xec, 0x26, 0x31, 0x7b, 0xb8, 0xd0, 0xb0, 0xd6, 0xb0, 0x60, 0x52, 0xe1, 0xd9, 0xd7, 0x33, 0x72, 0x5c, 0xb9, 0xc3, 0x6c, 0x9f }, - }, - { - .msglen = 46, - .result = { 0x90, 0x3e, 0x7, 0x17, 0xa2, 0x18, 0xd, 0xa1, 0x71, 0xfe, 0x4b, 0x6d, 0x24, 0x40, 0x5e, 0xe2, 0xd1, 0x45, 0xd6, 0x18, 0xe8, 0xa3, 0x2d, 0x12, 0xe8, 0x11, 0xae, 0x1, 0xc4, 0x77, 0xa9, 0xab }, - }, - { - .msglen = 47, - .result = { 0x4a, 0x4f, 0x5a, 0xd1, 0xd0, 0xfb, 0xf7, 0x60, 0x9c, 0xbf, 0x23, 0x99, 0x95, 0xea, 0x51, 0xdb, 0x70, 0xc4, 0xa, 0xaf, 0x41, 0x13, 0x7d, 0x3d, 0xd1, 0x50, 0xa7, 0x13, 0x4f, 0xa0, 0xbf, 0xf4 }, - }, - { - .msglen = 48, - .result = { 0x63, 0x50, 0x7a, 0x54, 0xd8, 0xa5, 0xf, 0x96, 0x45, 0x3a, 0x85, 0x8e, 0x8e, 0xc6, 0x5d, 0xe0, 0xe8, 0xfd, 0xce, 0xa8, 0x3f, 0x59, 0x19, 0x81, 0x13, 0xd1, 0xf7, 0xd, 0x45, 0xe3, 0xf3, 0x31 }, - }, - { - .msglen = 49, - .result = { 0x3c, 0x7a, 0x1, 0xdd, 0x3a, 0x96, 0xae, 0x2, 0x2e, 0x6a, 0x7f, 0xd, 0x1e, 0x2f, 0x32, 0xfd, 0x5, 0x33, 0xae, 0x54, 0xa2, 0xa6, 0x89, 0x32, 0x9a, 0x7, 0xb7, 0xe9, 0x66, 0xaf, 0xf8, 0xc }, - }, - { - .msglen = 50, - .result = { 0x57, 0xd8, 0xed, 0xc4, 0xec, 0x23, 0xf, 0xf9, 0x55, 0xc1, 0x36, 0xde, 0xc3, 0xbd, 0x54, 0x53, 0x2f, 0xfa, 0xd1, 0xb3, 0xe1, 0x87, 0xc2, 0x39, 0x54, 0x59, 0xa9, 0xb9, 0xac, 0xed, 0xa0, 0x49 }, - }, - { - .msglen = 51, - .result = { 0xdf, 0xd5, 0x2e, 0xd2, 0xd2, 0xb0, 0x90, 0x12, 0x71, 0x37, 0x51, 0xba, 0x79, 0xd4, 0x43, 0xc7, 0x74, 0x12, 0xf3, 0x71, 0x74, 0x63, 0xc, 0x4d, 0x59, 0x2e, 0x5, 0xb5, 0xa2, 0x17, 0xe, 0xe9 }, - }, - { - .msglen = 52, - .result = { 0xbd, 0xa3, 0x12, 0x94, 0xea, 0xa7, 0xc4, 0xd3, 0x1f, 0x99, 0xcb, 0xbc, 0x53, 0x80, 0x45, 0xfd, 0x17, 0x13, 0xd7, 0x2b, 0x26, 0x5b, 0x23, 0x3d, 0x2d, 0xd8, 0x7f, 0x9, 0xcc, 0x9c, 0xa7, 0xfd }, - }, - { - .msglen = 53, - .result = { 0x66, 0x3a, 0xc1, 0x3b, 0x1f, 0x7d, 0x0, 0xf5, 0x9a, 0x5e, 0x92, 0x61, 0x16, 0xad, 0x2b, 0x15, 0x2f, 0x65, 0x89, 0xd2, 0xa3, 0xbd, 0x33, 0x71, 0x31, 0xe8, 0x37, 0x3c, 0xb0, 0x6d, 0x13, 0xc9 }, - }, - { - .msglen = 54, - .result = { 0xff, 0x17, 0xef, 0x42, 0x67, 0xba, 0xcf, 0xe7, 0xfe, 0xf5, 0x76, 0x96, 0x9e, 0xf0, 0x61, 0xe5, 0xd, 0xc3, 0xbb, 0x63, 0xd3, 0xcd, 0x4a, 0x10, 0x63, 0xa3, 0x3c, 0xe, 0xf2, 0xfc, 0xa, 0x33 }, - }, - { - .msglen = 55, - .result = { 0x78, 0xa8, 0xe5, 0x15, 0x18, 0x49, 0x4, 0xba, 0x34, 0xb6, 0xb3, 0x96, 0x3a, 0x6, 0xaa, 0x93, 0xad, 0x82, 0x5b, 0x87, 0x0, 0x3f, 0x5, 0x1, 0xe7, 0xe1, 0x22, 0x16, 0x3d, 0xb5, 0x5b, 0xb8 }, - }, - { - .msglen = 56, - .result = { 0x0, 0xad, 0xbf, 0x7d, 0x51, 0xc4, 0xed, 0x5, 0x6c, 0x81, 0x15, 0x5c, 0xa5, 0xe3, 0x6b, 0x39, 0x59, 0x10, 0x8e, 0xbc, 0x3f, 0xb8, 0x21, 0xbc, 0xd9, 0x9e, 0x35, 0x7d, 0x23, 0x48, 0x5, 0x8a }, - }, - { - .msglen = 57, - .result = { 0xf7, 0x5e, 0xa3, 0x88, 0x1f, 0x82, 0xf0, 0xc4, 0x39, 0x7e, 0xed, 0x22, 0x78, 0xd6, 0x65, 0x94, 0x4f, 0x8, 0x2e, 0x96, 0x7e, 0x44, 0x8f, 0x0, 0x3b, 0x92, 0xf9, 0xea, 0x83, 0x72, 0xc7, 0xe2 }, - }, - { - .msglen = 58, - .result = { 0x84, 0xa5, 0x85, 0x95, 0x0, 0x7e, 0xc4, 0x98, 0x36, 0xc9, 0xe5, 0xd4, 0xda, 0x59, 0xab, 0x22, 0x2f, 0xa8, 0xb7, 0x46, 0x55, 0x91, 0x2, 0xc, 0x5b, 0x64, 0x5c, 0x5b, 0x42, 0x8b, 0x7e, 0xa }, - }, - { - .msglen = 59, - .result = { 0x4e, 0x1c, 0x16, 0x99, 0xd8, 0x4, 0xb, 0x6, 0x91, 0x98, 0x87, 0xb0, 0xa3, 0x63, 0x9, 0xdf, 0xfb, 0xa6, 0xd6, 0xe4, 0x58, 0x27, 0xf5, 0x73, 0x9, 0x81, 0x4f, 0x5d, 0x88, 0x2c, 0xb8, 0x7 }, - }, - { - .msglen = 60, - .result = { 0x2f, 0x97, 0xbf, 0x70, 0x70, 0x4b, 0xfe, 0x5a, 0x2f, 0x91, 0x8f, 0x28, 0x8b, 0xee, 0xf6, 0xee, 0x41, 0x7d, 0x36, 0x14, 0x86, 0x69, 0x42, 0x9c, 0x4d, 0x5, 0xcc, 0x53, 0x71, 0x61, 0x78, 0xe }, - }, - { - .msglen = 61, - .result = { 0xe6, 0xba, 0x7f, 0x8, 0xb3, 0xdc, 0x7b, 0x95, 0xcb, 0xd1, 0x33, 0x64, 0x25, 0x5a, 0xa3, 0x70, 0x10, 0x4a, 0xe6, 0x2c, 0x54, 0x25, 0xfa, 0x7e, 0xd0, 0x47, 0x65, 0x8d, 0xa1, 0xa8, 0x80, 0x5 }, - }, - { - .msglen = 62, - .result = { 0x9b, 0x48, 0x8d, 0x79, 0x16, 0xe8, 0x32, 0x63, 0x89, 0xaa, 0x4b, 0x7d, 0xdb, 0x46, 0xcd, 0x80, 0x40, 0x9d, 0x8c, 0x6, 0xa5, 0xed, 0xb4, 0xe1, 0xdd, 0x87, 0x6b, 0xb3, 0x90, 0x2b, 0x77, 0xc8 }, - }, - { - .msglen = 63, - .result = { 0x72, 0xfb, 0x8c, 0xf1, 0xb9, 0xb3, 0x50, 0x55, 0x5c, 0xac, 0x93, 0x38, 0x73, 0x1c, 0xd0, 0x93, 0x6, 0x5e, 0xcd, 0x0, 0x24, 0x83, 0x4b, 0xef, 0xdc, 0xfd, 0x27, 0x58, 0xfc, 0xa1, 0x4a, 0x32 }, - }, - { - .msglen = 64, - .result = { 0x19, 0x5b, 0x88, 0x8d, 0x75, 0x97, 0x8a, 0x8c, 0x5d, 0xd4, 0xe7, 0xe4, 0xa, 0x4d, 0x5e, 0xcd, 0xe7, 0x88, 0xab, 0xb9, 0x6b, 0xd8, 0xd3, 0x80, 0x25, 0x3e, 0xa4, 0xfd, 0xc1, 0x83, 0x6e, 0x74 }, - }, - { - .msglen = 65, - .result = { 0x14, 0x3, 0xcc, 0x1f, 0xa5, 0xed, 0x5e, 0x3c, 0x45, 0x2d, 0x66, 0x9a, 0x36, 0xb7, 0x9a, 0xb, 0x1c, 0x83, 0x4d, 0xbe, 0xc9, 0x41, 0x7e, 0x7, 0x54, 0x97, 0x76, 0x25, 0x96, 0x76, 0xce, 0xd4 }, - }, - { - .msglen = 66, - .result = { 0x44, 0x62, 0x56, 0x7e, 0x68, 0x10, 0xed, 0xd9, 0x35, 0x8a, 0xe3, 0xd, 0x20, 0xf, 0xe6, 0x45, 0x89, 0x6c, 0x8c, 0x18, 0x13, 0xe5, 0xef, 0x28, 0x2d, 0xc1, 0x6a, 0x95, 0x9e, 0x3d, 0x81, 0x51 }, - }, - { - .msglen = 67, - .result = { 0x94, 0xac, 0xc2, 0xe0, 0x8, 0xb7, 0xe5, 0xe2, 0x18, 0xf0, 0x59, 0x47, 0xda, 0xf4, 0xb4, 0xb1, 0xfe, 0x11, 0xe4, 0x3c, 0x2c, 0xa8, 0x1, 0x30, 0x5e, 0x8e, 0x89, 0x4, 0xff, 0xf2, 0xc1, 0x88 }, - }, - { - .msglen = 68, - .result = { 0xa2, 0x73, 0x97, 0x2, 0xd7, 0xc4, 0x9b, 0x39, 0x20, 0xdc, 0xac, 0x6d, 0xca, 0x81, 0xdd, 0x83, 0xac, 0xd4, 0xf, 0x89, 0x94, 0x10, 0x8b, 0xf6, 0xb9, 0x10, 0xab, 0x24, 0xd3, 0xf9, 0xc8, 0x4f }, - }, - { - .msglen = 69, - .result = { 0x68, 0xa9, 0x9b, 0xc2, 0xb6, 0x1e, 0x4c, 0xe3, 0xc6, 0x89, 0xc7, 0x40, 0x2f, 0xee, 0x8f, 0x50, 0xf4, 0x9d, 0x56, 0x5, 0xba, 0x0, 0x30, 0xaa, 0xd6, 0xa6, 0x4d, 0x94, 0x46, 0xc, 0x3c, 0x3 }, - }, - { - .msglen = 70, - .result = { 0x4f, 0x71, 0x4e, 0x2f, 0x89, 0xce, 0x84, 0x3b, 0x9a, 0xab, 0x6c, 0x93, 0xac, 0xa8, 0x51, 0xf7, 0x72, 0x91, 0xd5, 0xad, 0xf7, 0x91, 0x5a, 0x3a, 0xa6, 0x16, 0x61, 0x6b, 0x9f, 0xba, 0xe3, 0x51 }, - }, - { - .msglen = 71, - .result = { 0x25, 0x50, 0x50, 0x55, 0x50, 0x6a, 0x55, 0x8d, 0x54, 0x61, 0x60, 0x44, 0x5a, 0xb0, 0x4f, 0x77, 0x7, 0xbe, 0xcf, 0x49, 0xb6, 0x68, 0x9b, 0x6d, 0x79, 0xd5, 0xb9, 0xb1, 0x45, 0x29, 0xcc, 0xc1 }, - }, - { - .msglen = 72, - .result = { 0x59, 0x47, 0xf5, 0x99, 0xad, 0xac, 0x9, 0x15, 0xdc, 0x67, 0x2f, 0x4e, 0x38, 0x83, 0xab, 0x53, 0x8d, 0xc2, 0x71, 0xf5, 0xb9, 0x4e, 0x59, 0xd5, 0x32, 0x10, 0x90, 0xd8, 0x5b, 0xb6, 0x5, 0xc0 }, - }, - { - .msglen = 73, - .result = { 0x68, 0x9, 0x2a, 0x7d, 0x49, 0x8f, 0xc1, 0xd4, 0x93, 0xc9, 0xf8, 0xe9, 0xd8, 0xc4, 0xc2, 0x34, 0xc8, 0xac, 0xc9, 0xb4, 0x9, 0x5d, 0x46, 0x51, 0xd4, 0x2e, 0x4, 0xbb, 0x8f, 0x66, 0x75, 0x15 }, - }, - { - .msglen = 74, - .result = { 0xc, 0xf, 0x3c, 0x79, 0x8b, 0x80, 0x93, 0xd9, 0x7f, 0x3, 0xb4, 0x5f, 0xfe, 0x66, 0xcf, 0xbe, 0xea, 0xe1, 0xa0, 0xfd, 0xf0, 0x49, 0x3d, 0x19, 0x54, 0xdc, 0x38, 0x73, 0x11, 0xb3, 0x8, 0xa3 }, - }, - { - .msglen = 75, - .result = { 0x33, 0xae, 0x39, 0xab, 0x8, 0x54, 0x48, 0x9e, 0x2b, 0xbe, 0x89, 0x7a, 0x32, 0xdb, 0x81, 0xc5, 0xbd, 0x39, 0x19, 0xc1, 0x87, 0x6f, 0x64, 0xb3, 0x70, 0xea, 0x9, 0xd2, 0xea, 0x72, 0x53, 0x6e }, - }, - { - .msglen = 76, - .result = { 0x37, 0xae, 0xae, 0xed, 0x35, 0xd1, 0x97, 0x88, 0x78, 0x57, 0x19, 0xdd, 0xbc, 0x3c, 0xa3, 0x10, 0x79, 0x21, 0x3a, 0xf9, 0xce, 0x34, 0xf3, 0xad, 0x85, 0x4f, 0xf2, 0xac, 0xd7, 0x24, 0x7b, 0x80 }, - }, - { - .msglen = 77, - .result = { 0xc0, 0xd0, 0xb7, 0xff, 0x19, 0x7a, 0xfe, 0x6c, 0x6, 0x4b, 0xf6, 0x12, 0x4c, 0xe6, 0xe8, 0x2, 0xf3, 0x32, 0xc3, 0x77, 0xf, 0x10, 0xab, 0x89, 0xde, 0x18, 0xc5, 0xe, 0x25, 0xab, 0x23, 0xdb }, - }, - { - .msglen = 78, - .result = { 0x5e, 0xe7, 0x3b, 0xa0, 0x6, 0x8e, 0x40, 0x26, 0xaf, 0x6f, 0xba, 0xf9, 0xa6, 0x23, 0xab, 0x49, 0x89, 0x15, 0xd4, 0x15, 0xc0, 0x6c, 0x1f, 0xfc, 0x6d, 0x3e, 0x51, 0x3a, 0x6e, 0xef, 0x3d, 0x17 }, - }, - { - .msglen = 79, - .result = { 0x2, 0xfd, 0xd7, 0x48, 0x76, 0x5b, 0x25, 0x26, 0xd4, 0x87, 0x94, 0x14, 0x9b, 0x13, 0x91, 0xa4, 0x39, 0x5, 0x4c, 0x4e, 0x6a, 0xdd, 0x60, 0x66, 0x4e, 0x23, 0xeb, 0xa5, 0xfd, 0xad, 0x5a, 0xda }, - }, - { - .msglen = 80, - .result = { 0x84, 0xf3, 0x92, 0xf1, 0xc0, 0xc0, 0x5a, 0x63, 0xec, 0x16, 0xf4, 0xfc, 0x4c, 0xc6, 0xb6, 0x62, 0x1e, 0x9f, 0xdd, 0xcb, 0xd8, 0x4a, 0x12, 0xf2, 0x9, 0x11, 0x88, 0x66, 0x4e, 0x85, 0xef, 0x9f }, - }, - { - .msglen = 81, - .result = { 0x8b, 0x28, 0x66, 0x9d, 0xe2, 0x96, 0x58, 0x21, 0x3f, 0xcd, 0xd7, 0xe0, 0xce, 0x9b, 0x51, 0x32, 0x68, 0xac, 0x1c, 0x9e, 0x38, 0x7d, 0x60, 0x5a, 0x32, 0xe1, 0x14, 0x91, 0xee, 0x36, 0x39, 0xbd }, - }, - { - .msglen = 82, - .result = { 0x5c, 0x16, 0xe3, 0xff, 0x6b, 0x51, 0xc2, 0x59, 0x8a, 0x24, 0xc2, 0xba, 0xc0, 0xd7, 0xd4, 0xac, 0xd9, 0x3e, 0x38, 0x1f, 0x7f, 0x2d, 0xb7, 0x85, 0x8b, 0xf1, 0xd2, 0x42, 0x28, 0xa9, 0xd7, 0x94 }, - }, - { - .msglen = 83, - .result = { 0xde, 0x40, 0xe0, 0xde, 0xf9, 0xe4, 0x75, 0x3d, 0x61, 0x91, 0x38, 0xac, 0x31, 0xa9, 0xba, 0x31, 0x18, 0x41, 0x57, 0x2e, 0x89, 0xdf, 0x26, 0x83, 0x40, 0x71, 0xce, 0xdc, 0x18, 0x3f, 0xe7, 0xd7 }, - }, - { - .msglen = 84, - .result = { 0x85, 0xf, 0x58, 0x5f, 0x4d, 0x81, 0x5b, 0x54, 0x6a, 0xa4, 0xd4, 0xfb, 0x3, 0x4e, 0x71, 0xa7, 0xc5, 0x11, 0xf, 0x1a, 0xa8, 0x44, 0x10, 0x15, 0x2e, 0xdf, 0x1e, 0xea, 0x4d, 0x86, 0x31, 0x33 }, - }, - { - .msglen = 85, - .result = { 0x7f, 0xe2, 0x1b, 0x95, 0x7b, 0x19, 0x2f, 0x4e, 0x72, 0x1d, 0x6c, 0x2c, 0xf3, 0x74, 0x6e, 0x99, 0x2b, 0x10, 0x76, 0x55, 0x25, 0xe4, 0x89, 0x19, 0x98, 0xb4, 0xdc, 0xea, 0xfa, 0x68, 0xec, 0x3 }, - }, - { - .msglen = 86, - .result = { 0x5c, 0x95, 0x3d, 0xcc, 0x6, 0x58, 0x9b, 0xc4, 0x71, 0x61, 0xc2, 0x5a, 0xac, 0xaf, 0x54, 0xbf, 0xcc, 0x93, 0x3d, 0x2e, 0xdf, 0x99, 0x74, 0xc8, 0xc8, 0x36, 0xe9, 0x44, 0x7e, 0x6d, 0x3d, 0xe7 }, - }, - { - .msglen = 87, - .result = { 0xf2, 0x33, 0xbc, 0x61, 0xc6, 0x2c, 0x19, 0x26, 0x80, 0x9e, 0x1e, 0x76, 0x8e, 0x9, 0x61, 0x6, 0xfb, 0xc3, 0xc8, 0xcb, 0x35, 0x9d, 0xaa, 0x73, 0xa8, 0xe6, 0xd2, 0x89, 0xc5, 0x5d, 0xee, 0xa4 }, - }, - { - .msglen = 88, - .result = { 0x3f, 0x13, 0xf7, 0x63, 0x67, 0x8d, 0x65, 0xcd, 0xa8, 0x5b, 0xcd, 0xc4, 0xb7, 0x25, 0x35, 0xbe, 0xd3, 0xc1, 0x6d, 0x36, 0xb9, 0x8c, 0x8c, 0x6a, 0x79, 0xd1, 0x12, 0xe8, 0xdc, 0x6c, 0xe3, 0x6d }, - }, - { - .msglen = 89, - .result = { 0x8f, 0x21, 0x5a, 0x7a, 0x84, 0x79, 0x7d, 0x33, 0xa, 0x7e, 0x7a, 0x7, 0x2a, 0xa9, 0xa6, 0x58, 0x33, 0xdf, 0xec, 0x40, 0x88, 0xf2, 0x9f, 0x8d, 0x12, 0xb5, 0x5e, 0xb2, 0x88, 0x2d, 0xc1, 0x7c }, - }, - { - .msglen = 90, - .result = { 0x73, 0xfc, 0xc6, 0x9, 0x5f, 0xc2, 0xab, 0x2d, 0xd5, 0x84, 0x6c, 0xdd, 0x1f, 0x70, 0x9e, 0x5c, 0x30, 0x36, 0xb4, 0xe7, 0x86, 0xab, 0x89, 0xc6, 0xc9, 0xed, 0x7d, 0x2e, 0x26, 0x13, 0x37, 0x4a }, - }, - { - .msglen = 91, - .result = { 0x3e, 0x41, 0x8a, 0x37, 0xbd, 0xec, 0x53, 0x52, 0x47, 0xd2, 0x71, 0xa4, 0x5b, 0xc7, 0x11, 0x8e, 0x8c, 0xb8, 0x2c, 0x36, 0xc9, 0xa7, 0x15, 0x21, 0x15, 0xde, 0x7f, 0x54, 0xc7, 0xb3, 0x8d, 0x34 }, - }, - { - .msglen = 92, - .result = { 0xca, 0x1a, 0xf9, 0xfd, 0xf4, 0xb9, 0xd, 0xdd, 0x91, 0xd8, 0x7b, 0x7c, 0xf4, 0x82, 0xe7, 0x57, 0xc0, 0xb9, 0xfe, 0x2f, 0x3c, 0xc7, 0x5a, 0x3d, 0xb, 0x79, 0xb3, 0x7a, 0x7e, 0xfd, 0x25, 0x20 }, - }, - { - .msglen = 93, - .result = { 0xf6, 0x54, 0xd6, 0x3a, 0x93, 0xe3, 0x7b, 0x42, 0x11, 0xa8, 0xda, 0xa4, 0x2f, 0xbf, 0xcb, 0xd0, 0x58, 0x59, 0xf8, 0xda, 0x8c, 0x5e, 0xdc, 0x1e, 0xb0, 0x64, 0x15, 0x31, 0x92, 0xe6, 0xcc, 0xc8 }, - }, - { - .msglen = 94, - .result = { 0x7b, 0x8f, 0x93, 0xa3, 0x55, 0x11, 0x1e, 0x18, 0x77, 0xd9, 0x12, 0x7c, 0x54, 0x4e, 0x3f, 0x36, 0x18, 0x2f, 0xc7, 0xba, 0xd3, 0xe7, 0xc, 0xa3, 0xb2, 0xb1, 0x66, 0x7a, 0xfe, 0x30, 0x1b, 0x4e }, - }, - { - .msglen = 95, - .result = { 0x16, 0xea, 0xe9, 0xae, 0x5d, 0x2f, 0x88, 0x87, 0x41, 0x43, 0x3d, 0xfc, 0x35, 0x7f, 0x2c, 0x4c, 0x63, 0x36, 0xf3, 0x36, 0x51, 0x84, 0xb1, 0x64, 0xc5, 0x19, 0xc0, 0xd6, 0x57, 0xef, 0x2a, 0xa4 }, - }, - { - .msglen = 96, - .result = { 0xc9, 0x79, 0x20, 0xa1, 0x14, 0xba, 0xbe, 0x88, 0x7d, 0x6f, 0x4, 0xe3, 0xfd, 0x2d, 0xfd, 0xc3, 0x8a, 0x1, 0xea, 0x12, 0x9d, 0x4c, 0x14, 0xc3, 0x82, 0x7f, 0xb6, 0x1e, 0x8d, 0xcc, 0x11, 0x84 }, - }, - { - .msglen = 97, - .result = { 0x20, 0xa9, 0xb7, 0x5a, 0x5b, 0x76, 0xaa, 0x7b, 0xed, 0x70, 0x16, 0xfb, 0xea, 0x93, 0x55, 0xd1, 0x9f, 0x95, 0xa, 0xe0, 0x79, 0x51, 0x12, 0x2c, 0xfd, 0x7d, 0x6c, 0x94, 0x4f, 0xb6, 0x5f, 0x14 }, - }, - { - .msglen = 98, - .result = { 0xfc, 0xf4, 0x1, 0xcc, 0x9f, 0xce, 0xc2, 0x50, 0x0, 0x1f, 0xf8, 0x3f, 0xe4, 0x87, 0x2e, 0x79, 0x94, 0xdb, 0x86, 0x85, 0x8a, 0x7d, 0xb4, 0x6a, 0x84, 0xb8, 0x6c, 0x32, 0xad, 0x8c, 0x20, 0x63 }, - }, - { - .msglen = 99, - .result = { 0x17, 0xa1, 0xf5, 0x6, 0xaa, 0xb0, 0xe3, 0x82, 0x2e, 0x9c, 0xf2, 0xb9, 0x75, 0x75, 0xe9, 0x36, 0x90, 0xa9, 0xb2, 0xb9, 0x97, 0xb0, 0x10, 0xbb, 0xdd, 0x65, 0xd0, 0xa8, 0xbf, 0x69, 0x1d, 0x43 }, - }, - { - .msglen = 100, - .result = { 0xb5, 0x6c, 0xca, 0xca, 0xe1, 0xc5, 0x74, 0x19, 0xb0, 0x89, 0x58, 0x5e, 0x2e, 0x61, 0xcb, 0xa1, 0x23, 0xd0, 0x25, 0x37, 0x47, 0xe3, 0xac, 0x3e, 0x9a, 0xf6, 0x5d, 0x0, 0x77, 0xc2, 0xdc, 0x47 }, - }, - { - .msglen = 101, - .result = { 0x8, 0xa4, 0x3b, 0xe7, 0x1e, 0xeb, 0x4c, 0x3a, 0x82, 0xf1, 0xe4, 0x9d, 0xb1, 0xcc, 0xbc, 0x30, 0xb7, 0xa6, 0xfe, 0x47, 0x43, 0x86, 0xb8, 0x10, 0x33, 0xef, 0x8e, 0x35, 0x34, 0xf1, 0x52, 0xae }, - }, - { - .msglen = 102, - .result = { 0x0, 0xdb, 0x9b, 0xb7, 0xfc, 0x8a, 0x55, 0x81, 0x49, 0x94, 0x5c, 0xc2, 0x63, 0xd2, 0x56, 0x85, 0xab, 0x5a, 0xa1, 0x89, 0x66, 0xa1, 0x4d, 0x39, 0x1b, 0xe2, 0x12, 0x9a, 0x51, 0x79, 0xc0, 0x1c }, - }, - { - .msglen = 103, - .result = { 0x4c, 0xeb, 0xaa, 0xec, 0xb8, 0x31, 0xef, 0xb6, 0x89, 0x8e, 0x42, 0xdf, 0x9d, 0x57, 0x42, 0xf7, 0x53, 0x5d, 0x11, 0xc0, 0x29, 0xf7, 0x64, 0x30, 0x42, 0x32, 0x23, 0xda, 0x19, 0xe, 0x8d, 0xf3 }, - }, - { - .msglen = 104, - .result = { 0x32, 0xf5, 0x6, 0x53, 0xf8, 0x18, 0x94, 0x3d, 0xaa, 0x5e, 0xb9, 0x9e, 0x95, 0x8, 0x4, 0x29, 0xea, 0x76, 0xa1, 0xe5, 0x60, 0xa, 0x29, 0xd0, 0x78, 0x7e, 0x0, 0x27, 0x4e, 0x63, 0xc3, 0x69 }, - }, - { - .msglen = 105, - .result = { 0xa9, 0xf1, 0x2b, 0xaa, 0x5e, 0xb3, 0xc9, 0xf3, 0x25, 0x6e, 0x6f, 0x8, 0xc3, 0xb4, 0xab, 0xd1, 0x20, 0x3c, 0xb1, 0x82, 0x6b, 0xfa, 0x8, 0x62, 0xaf, 0x7a, 0xa9, 0x0, 0x79, 0x9a, 0x2b, 0x12 }, - }, - { - .msglen = 106, - .result = { 0xc2, 0x5e, 0x53, 0x66, 0x14, 0x5, 0x26, 0x6a, 0xf1, 0x70, 0x50, 0xb3, 0x9b, 0x40, 0x99, 0x7a, 0x73, 0xe2, 0xed, 0x3d, 0x4c, 0xcc, 0xf9, 0xf6, 0x1b, 0x4c, 0x6, 0xdc, 0x9, 0x7a, 0xc2, 0x4a }, - }, - { - .msglen = 107, - .result = { 0x68, 0xeb, 0x96, 0xb6, 0x9, 0x7b, 0xe2, 0x4a, 0x18, 0x3a, 0xe8, 0xf8, 0xe8, 0xc7, 0x4e, 0x27, 0x8c, 0x18, 0x8a, 0xa6, 0x23, 0xfe, 0xc2, 0xb, 0xbd, 0x72, 0x1, 0x56, 0x21, 0x6b, 0x6c, 0x56 }, - }, - { - .msglen = 108, - .result = { 0xe1, 0x7, 0xeb, 0xc3, 0x3a, 0x5e, 0x28, 0x65, 0x14, 0xcb, 0x73, 0x19, 0xef, 0x32, 0x78, 0x96, 0xf3, 0xda, 0x1e, 0x5a, 0x89, 0xf4, 0x29, 0x7c, 0xa0, 0xfd, 0x3b, 0xe8, 0xb, 0xf0, 0x72, 0xf1 }, - }, - { - .msglen = 109, - .result = { 0x88, 0xac, 0xe5, 0xe7, 0xdb, 0x26, 0xa5, 0xa5, 0xef, 0x66, 0x92, 0xb4, 0xab, 0x6b, 0xed, 0x4b, 0x1a, 0x9e, 0x19, 0xb0, 0xb6, 0xd6, 0x11, 0xb1, 0x33, 0x40, 0x50, 0x69, 0x48, 0x75, 0x4, 0xe5 }, - }, - { - .msglen = 110, - .result = { 0x7d, 0x25, 0x12, 0x5, 0x37, 0x8c, 0x89, 0x8a, 0x43, 0xd9, 0x97, 0x26, 0xb8, 0xaf, 0xb3, 0x21, 0x4d, 0xde, 0x24, 0x58, 0x4f, 0xc8, 0xd, 0x31, 0x22, 0xb2, 0xdf, 0x34, 0xd5, 0xb, 0x25, 0xb9 }, - }, - { - .msglen = 111, - .result = { 0x4e, 0xfa, 0x3f, 0x64, 0x15, 0xf8, 0xe2, 0xb9, 0x10, 0x70, 0xeb, 0x6a, 0xf6, 0xf2, 0x14, 0x33, 0x0, 0xd1, 0x19, 0xf2, 0x8c, 0x50, 0x57, 0x17, 0xf0, 0xc5, 0x5d, 0xa1, 0xe, 0x22, 0xa0, 0x53 }, - }, - { - .msglen = 112, - .result = { 0x12, 0xac, 0x71, 0xa0, 0x72, 0x7a, 0x45, 0x74, 0x82, 0xf6, 0xde, 0x75, 0xe, 0xb9, 0xb2, 0x65, 0x76, 0x86, 0x13, 0x77, 0x4a, 0x30, 0xbe, 0xfa, 0x1, 0x38, 0x74, 0x49, 0xc9, 0x7f, 0x43, 0x9a }, - }, - { - .msglen = 113, - .result = { 0xfe, 0x25, 0x6b, 0xbf, 0x17, 0x61, 0x29, 0xce, 0x9e, 0xc2, 0x42, 0x9a, 0xb8, 0x29, 0xdb, 0x88, 0xef, 0x75, 0x3b, 0xad, 0xba, 0x9c, 0xd5, 0x9, 0x40, 0x2f, 0x49, 0xbd, 0x3, 0x43, 0xa7, 0x3 }, - }, - { - .msglen = 114, - .result = { 0xe5, 0x36, 0x48, 0xb5, 0x9e, 0xb3, 0x3c, 0x5f, 0x86, 0xab, 0x5, 0xe4, 0xc0, 0xe3, 0x94, 0xe4, 0x4c, 0x90, 0xcd, 0xa1, 0x97, 0x12, 0xdf, 0x33, 0x7a, 0x1a, 0x1e, 0xcd, 0xd4, 0x61, 0xa8, 0x3c }, - }, - { - .msglen = 115, - .result = { 0x52, 0xbd, 0xc6, 0x84, 0x65, 0x32, 0x88, 0x1, 0x85, 0x64, 0xfd, 0xc9, 0x98, 0x18, 0x27, 0x52, 0xe9, 0x30, 0xa2, 0x9e, 0xc2, 0xcf, 0xa9, 0x98, 0xbc, 0x47, 0x3a, 0xc7, 0xd5, 0xb1, 0x81, 0x78 }, - }, - { - .msglen = 116, - .result = { 0xab, 0xb1, 0xb3, 0xa5, 0x23, 0xea, 0x45, 0xe8, 0xe0, 0xa9, 0x3d, 0xe9, 0xe9, 0x86, 0x15, 0x10, 0x90, 0xca, 0xf7, 0xcc, 0x92, 0x64, 0x10, 0x3d, 0x63, 0x2f, 0x17, 0xec, 0x54, 0x9e, 0xbd, 0x3b }, - }, - { - .msglen = 117, - .result = { 0x82, 0xf8, 0x45, 0xcd, 0x8b, 0xfc, 0xd8, 0x81, 0x6b, 0x1f, 0x91, 0x30, 0x6d, 0xbb, 0x91, 0x70, 0x8b, 0xfe, 0x8d, 0x33, 0x35, 0x4f, 0x62, 0x7f, 0xba, 0xb6, 0x99, 0x3b, 0x79, 0xe6, 0x8f, 0x58 }, - }, - { - .msglen = 118, - .result = { 0xa6, 0x59, 0x67, 0x5e, 0x49, 0xe2, 0x95, 0x28, 0xa3, 0x4b, 0x4a, 0x10, 0x20, 0xd1, 0xd6, 0x7b, 0x86, 0x8a, 0x5c, 0x81, 0x31, 0x68, 0xea, 0xb7, 0x61, 0xbb, 0xb6, 0x3a, 0x6d, 0x78, 0xaa, 0x37 }, - }, - { - .msglen = 119, - .result = { 0x64, 0x9, 0xaf, 0x42, 0xff, 0xb1, 0xc7, 0xe6, 0xbf, 0x6f, 0xa1, 0xbb, 0x5a, 0x6, 0xea, 0xd, 0x57, 0x7d, 0x24, 0x41, 0x2b, 0xf9, 0x63, 0x82, 0x1f, 0x9, 0xa5, 0xa7, 0x58, 0xc, 0x4, 0x55 }, - }, - { - .msglen = 120, - .result = { 0x43, 0x33, 0x90, 0x81, 0xb6, 0x23, 0x50, 0xdf, 0xa2, 0x7e, 0x41, 0xa2, 0x40, 0x40, 0xa9, 0x34, 0xd6, 0x5, 0x6c, 0x44, 0x8, 0x3f, 0x2b, 0xaa, 0xff, 0x3, 0xc3, 0x49, 0x1b, 0x15, 0x5e, 0x7c }, - }, - { - .msglen = 121, - .result = { 0xe, 0xd7, 0x6d, 0x29, 0xdd, 0x8, 0xee, 0x2f, 0x1d, 0x5a, 0xb2, 0x70, 0x90, 0x8d, 0xa9, 0xf2, 0x5c, 0x5b, 0xc5, 0xe1, 0x7c, 0xec, 0x49, 0x8f, 0x46, 0x94, 0xe1, 0xc8, 0xd4, 0x68, 0xa2, 0x34 }, - }, - { - .msglen = 122, - .result = { 0x4f, 0x25, 0x61, 0xb1, 0x29, 0xb7, 0x41, 0x50, 0xc7, 0xfa, 0xab, 0x6c, 0x92, 0xff, 0x4, 0xc, 0xa3, 0xa1, 0x10, 0xf6, 0xa6, 0xa4, 0x5a, 0xbf, 0xe, 0x9a, 0x61, 0xa8, 0x24, 0xa3, 0x93, 0x1e }, - }, - { - .msglen = 123, - .result = { 0x7c, 0x8c, 0xf4, 0x5d, 0x45, 0xcf, 0x61, 0x22, 0xc9, 0x8e, 0x3a, 0xeb, 0x85, 0x55, 0x66, 0x2e, 0x1e, 0x33, 0x88, 0xab, 0x74, 0xf2, 0x66, 0x4f, 0x43, 0xfa, 0x3e, 0x25, 0xcc, 0xd2, 0x0, 0x71 }, - }, - { - .msglen = 124, - .result = { 0x8b, 0x51, 0x99, 0x90, 0x84, 0xda, 0x7a, 0xb3, 0xb1, 0x31, 0x1b, 0x1a, 0x66, 0xe2, 0x53, 0xac, 0x45, 0x94, 0x5c, 0xa6, 0x8c, 0x44, 0x45, 0x4, 0x58, 0x13, 0xcb, 0x44, 0x9e, 0x6c, 0x6a, 0x10 }, - }, - { - .msglen = 125, - .result = { 0xc5, 0xb0, 0x36, 0x55, 0x4d, 0x15, 0xf0, 0x67, 0xf8, 0x26, 0x45, 0x48, 0xa7, 0x65, 0xcc, 0xa8, 0x14, 0x1e, 0x63, 0x22, 0x36, 0xc3, 0xf3, 0x99, 0x5b, 0x77, 0xb2, 0xa8, 0xc3, 0x62, 0xb4, 0xdd }, - }, - { - .msglen = 126, - .result = { 0x38, 0xcb, 0x97, 0x81, 0x62, 0xde, 0x32, 0x5f, 0xc5, 0x27, 0x39, 0x82, 0x36, 0x77, 0x5a, 0xc4, 0xbf, 0x45, 0xf4, 0xe8, 0x17, 0xa9, 0x17, 0xfc, 0x34, 0xb, 0xa1, 0x11, 0x79, 0xf5, 0xc, 0x79 }, - }, - { - .msglen = 127, - .result = { 0x2e, 0x16, 0xab, 0xf4, 0x56, 0xea, 0x6a, 0x7e, 0x97, 0x25, 0xf9, 0x9a, 0x0, 0x5d, 0xe3, 0x70, 0x76, 0xa9, 0x2a, 0xab, 0xae, 0x32, 0xe5, 0xe8, 0xb6, 0xe1, 0x22, 0xc8, 0x74, 0xe1, 0x1f, 0x22 }, - }, - { - .msglen = 128, - .result = { 0x6e, 0x54, 0xeb, 0x50, 0x85, 0x7b, 0xd2, 0x64, 0x32, 0x2c, 0xb0, 0xd0, 0xc2, 0x3, 0x31, 0x95, 0xa8, 0x6a, 0x50, 0x49, 0xf4, 0x77, 0x27, 0x1a, 0x89, 0x10, 0x3e, 0x98, 0x45, 0x1e, 0xe7, 0xeb }, - }, - { - .msglen = 129, - .result = { 0x7, 0x2e, 0xdf, 0xe9, 0x2e, 0x73, 0xf4, 0x1e, 0x65, 0x31, 0x64, 0x25, 0xc1, 0x59, 0x46, 0xd7, 0xf9, 0x12, 0xfe, 0xc7, 0x9f, 0x24, 0xa, 0xd9, 0xfb, 0x8, 0xcb, 0x5f, 0xf2, 0x77, 0x11, 0xce }, - }, - { - .msglen = 130, - .result = { 0x6, 0x46, 0xc7, 0x42, 0xc2, 0xc3, 0xf2, 0x4c, 0x82, 0x7d, 0x1c, 0x2c, 0x68, 0xfd, 0x29, 0x6d, 0xc2, 0xac, 0x4f, 0xbc, 0x8d, 0xb2, 0xf7, 0x78, 0xb7, 0x8f, 0x4, 0x3f, 0x49, 0xb5, 0xc5, 0xd }, - }, - { - .msglen = 131, - .result = { 0x9c, 0x1f, 0xdb, 0x89, 0x3b, 0x8b, 0x5c, 0x3d, 0x1e, 0xd2, 0x9f, 0x74, 0x63, 0xb, 0x4f, 0x59, 0x72, 0x13, 0x4f, 0x40, 0x59, 0x35, 0xc6, 0x64, 0x5a, 0xb5, 0x43, 0xaf, 0x43, 0x7a, 0x13, 0xb0 }, - }, - { - .msglen = 132, - .result = { 0x25, 0xa9, 0x97, 0x9e, 0x4f, 0x52, 0xe6, 0xe7, 0xf, 0x38, 0xc6, 0xfb, 0x9e, 0x77, 0xe7, 0x1c, 0xb9, 0x8a, 0xf3, 0x4d, 0x76, 0xb3, 0x58, 0x8e, 0xab, 0x7d, 0xd6, 0xbb, 0x78, 0x26, 0xb1, 0x7f }, - }, - { - .msglen = 133, - .result = { 0x2b, 0x8, 0xfa, 0x23, 0x7d, 0xb2, 0xa1, 0x16, 0x85, 0x7b, 0x3c, 0xa4, 0xde, 0x19, 0xf7, 0x81, 0xb6, 0xaf, 0xbc, 0x11, 0x31, 0x10, 0x6f, 0x14, 0x4a, 0x62, 0x48, 0x1e, 0x43, 0x95, 0xa4, 0xb4 }, - }, - { - .msglen = 134, - .result = { 0x9c, 0x93, 0x30, 0x3f, 0x4c, 0x8f, 0xa7, 0x56, 0xd1, 0x6c, 0x9a, 0x28, 0xa1, 0x21, 0x7d, 0x5b, 0x12, 0x6b, 0x5a, 0xd4, 0xb9, 0x62, 0x5, 0xe2, 0xd5, 0xc8, 0x2a, 0xd1, 0xb0, 0x46, 0x2a, 0x2c }, - }, - { - .msglen = 135, - .result = { 0xd7, 0x17, 0xd, 0xc0, 0x46, 0x24, 0x9e, 0x14, 0x21, 0xac, 0xf3, 0xd0, 0xda, 0xf4, 0xd9, 0xf1, 0xf2, 0x96, 0xbd, 0x55, 0xff, 0x3c, 0x8d, 0x90, 0xc8, 0x2f, 0x1e, 0x87, 0xad, 0xd7, 0x8a, 0x8a }, - }, - { - .msglen = 136, - .result = { 0x90, 0xd6, 0xa4, 0x46, 0x75, 0x8c, 0xc3, 0xda, 0x26, 0x8a, 0xe1, 0xb7, 0xa4, 0xe, 0xef, 0x33, 0x65, 0x41, 0xa3, 0x60, 0x6a, 0xce, 0xfb, 0xc4, 0x1c, 0xa4, 0x95, 0x6d, 0x43, 0x49, 0x69, 0xd5 }, - }, - { - .msglen = 137, - .result = { 0xd6, 0xf5, 0xfe, 0xb0, 0x9a, 0xca, 0xec, 0xeb, 0xbe, 0x4b, 0xbd, 0x96, 0x65, 0xfe, 0x65, 0x31, 0xef, 0x36, 0x3a, 0xfc, 0x3a, 0x8, 0x3, 0xb0, 0xbf, 0xeb, 0xd, 0x2c, 0xd9, 0x27, 0x14, 0x4f }, - }, - { - .msglen = 138, - .result = { 0x97, 0x4f, 0x86, 0x11, 0xf9, 0x61, 0xad, 0xc, 0xba, 0x2d, 0xfa, 0xa4, 0x6f, 0x19, 0xb3, 0x66, 0xf8, 0xcc, 0x74, 0x2c, 0x76, 0x29, 0xdd, 0x6b, 0x5, 0xa3, 0x3a, 0x3b, 0xa6, 0xec, 0x81, 0xc0 }, - }, - { - .msglen = 139, - .result = { 0x9a, 0xe3, 0xc, 0x22, 0x5d, 0xb3, 0x71, 0x5d, 0x30, 0xcf, 0x6, 0xc1, 0x86, 0xf6, 0x84, 0xac, 0x25, 0x45, 0xb2, 0xa0, 0xd2, 0x93, 0x8b, 0x9e, 0x77, 0x55, 0x16, 0x51, 0x61, 0x4a, 0x91, 0xcd }, - }, - { - .msglen = 140, - .result = { 0xf1, 0x30, 0xf4, 0xc7, 0x6c, 0xe3, 0x8d, 0x63, 0x41, 0x62, 0x64, 0xe1, 0xc3, 0x97, 0xf0, 0xd6, 0xf3, 0xfd, 0x17, 0xe, 0xca, 0xd8, 0x9e, 0x6d, 0xa0, 0xa1, 0x27, 0x60, 0xff, 0xf, 0x7a, 0xca }, - }, - { - .msglen = 141, - .result = { 0x5, 0xab, 0x87, 0x58, 0xa8, 0x5e, 0x7d, 0xec, 0x23, 0x90, 0xd8, 0xfa, 0x87, 0x1, 0x4b, 0x32, 0xe9, 0x0, 0x7b, 0x92, 0x3b, 0x51, 0x44, 0x86, 0xa2, 0x55, 0xf0, 0xb7, 0x13, 0x3b, 0x58, 0x70 }, - }, - { - .msglen = 142, - .result = { 0xff, 0x4e, 0x8a, 0xca, 0xce, 0xe0, 0x84, 0x2a, 0x70, 0x82, 0x52, 0x1e, 0x67, 0xc, 0x67, 0x36, 0x76, 0x74, 0xed, 0x49, 0x21, 0x44, 0x0, 0x1a, 0x75, 0xcd, 0x4f, 0x17, 0xb8, 0xa9, 0xdf, 0xb9 }, - }, - { - .msglen = 143, - .result = { 0xf2, 0x36, 0x6f, 0xf3, 0x8e, 0xf3, 0xbd, 0x51, 0xec, 0xc4, 0x96, 0xc1, 0x88, 0xfe, 0x68, 0x5e, 0x1b, 0xdf, 0x71, 0x6b, 0xf3, 0x78, 0x84, 0x16, 0x11, 0xac, 0x37, 0x4d, 0x8f, 0x6e, 0x7b, 0x40 }, - }, - { - .msglen = 144, - .result = { 0x24, 0x20, 0x1d, 0x2, 0x16, 0x1, 0xc4, 0xe5, 0xdf, 0x81, 0xca, 0xa9, 0xf2, 0x4d, 0xe2, 0x77, 0x11, 0xf6, 0x43, 0xd3, 0x36, 0x36, 0x1c, 0xe6, 0x6c, 0x96, 0xc9, 0x74, 0x8e, 0x39, 0x1c, 0xb1 }, - }, - { - .msglen = 145, - .result = { 0xfc, 0x13, 0x13, 0x5c, 0x87, 0x9a, 0x95, 0xcd, 0x66, 0xac, 0x85, 0xda, 0x8c, 0x28, 0x38, 0x3f, 0x43, 0xe1, 0x40, 0x8e, 0x8f, 0x49, 0x17, 0xda, 0x75, 0xd0, 0xc4, 0xf5, 0x9e, 0x3, 0xf0, 0x62 }, - }, - { - .msglen = 146, - .result = { 0xcc, 0x3e, 0x74, 0x6a, 0x82, 0xb0, 0x67, 0x77, 0xcf, 0x6e, 0x93, 0x40, 0x84, 0xc7, 0xa1, 0x85, 0xa5, 0x38, 0x23, 0xa5, 0x4f, 0x9e, 0xee, 0x3d, 0xa7, 0xab, 0x88, 0x3b, 0x3, 0x1d, 0xdb, 0xbd }, - }, - { - .msglen = 147, - .result = { 0xaa, 0x4f, 0x52, 0xf0, 0xe8, 0x49, 0x80, 0x5e, 0xe4, 0xd4, 0x8f, 0xc1, 0x5c, 0x7d, 0x36, 0x2, 0xdb, 0xda, 0x45, 0xab, 0x6e, 0x90, 0xc1, 0x55, 0x4f, 0x8, 0xaf, 0x55, 0x4d, 0x45, 0x6b, 0x91 }, - }, - { - .msglen = 148, - .result = { 0xfb, 0x92, 0xef, 0x68, 0xc4, 0xa, 0xd9, 0xd8, 0x86, 0xb5, 0x63, 0x34, 0xa7, 0x42, 0x5a, 0xef, 0x13, 0xc0, 0xc9, 0x44, 0x8f, 0x9e, 0x40, 0x51, 0x1b, 0xcf, 0xbb, 0x8c, 0xb0, 0x2c, 0x56, 0xc }, - }, - { - .msglen = 149, - .result = { 0x88, 0xdb, 0x71, 0x51, 0x85, 0x63, 0xb6, 0xb4, 0xeb, 0x7c, 0x11, 0xaa, 0x96, 0x8, 0x9e, 0x60, 0x70, 0xa5, 0x19, 0xa4, 0x2, 0xf1, 0xa0, 0x4f, 0x16, 0xde, 0xd6, 0x8d, 0xd3, 0xc5, 0xc, 0x6c }, - }, - { - .msglen = 150, - .result = { 0x4a, 0xad, 0x96, 0xea, 0x90, 0xb7, 0x76, 0x9d, 0x92, 0x60, 0x35, 0x59, 0x1c, 0x89, 0x67, 0x54, 0xfd, 0x50, 0x20, 0x97, 0xc8, 0x16, 0xc8, 0xc2, 0x50, 0x40, 0x63, 0xba, 0xfb, 0xbc, 0x5e, 0xcd }, - }, - { - .msglen = 151, - .result = { 0xca, 0x4c, 0x3d, 0x26, 0x75, 0x82, 0x48, 0x5b, 0xa4, 0xd3, 0x28, 0x9, 0x8d, 0xe0, 0x67, 0x6d, 0xe1, 0x5, 0x8a, 0xbf, 0x17, 0xbb, 0x6e, 0x48, 0x2e, 0xd, 0xcd, 0x90, 0x7c, 0x4e, 0xa4, 0x94 }, - }, - { - .msglen = 152, - .result = { 0x6d, 0x27, 0x5e, 0x91, 0xeb, 0xc7, 0x1a, 0x31, 0x42, 0xfa, 0x2c, 0x91, 0xdc, 0x6a, 0xdc, 0x1b, 0x2b, 0x66, 0xf2, 0x9a, 0xf6, 0x11, 0x36, 0x96, 0x2a, 0xfc, 0x73, 0x89, 0x7e, 0xd4, 0x55, 0x3d }, - }, - { - .msglen = 153, - .result = { 0x76, 0xba, 0x1d, 0x4b, 0xc1, 0xa2, 0x1b, 0x56, 0xbe, 0x5, 0x38, 0x90, 0x47, 0xe9, 0x9, 0xc2, 0xd1, 0x2, 0x6d, 0x44, 0x81, 0xf7, 0x6e, 0x28, 0x88, 0x79, 0xb5, 0x10, 0x75, 0xfb, 0xc6, 0xe7 }, - }, - { - .msglen = 154, - .result = { 0x6d, 0xbc, 0x90, 0xa6, 0x2f, 0xb5, 0x45, 0x5f, 0x4a, 0xcb, 0x85, 0x32, 0x90, 0x57, 0x86, 0x75, 0x51, 0xa5, 0x7e, 0x4b, 0x6b, 0xb3, 0xeb, 0xfe, 0xba, 0x75, 0xfc, 0x55, 0x1a, 0x85, 0x3, 0x54 }, - }, - { - .msglen = 155, - .result = { 0x7d, 0x59, 0x19, 0xb6, 0xf2, 0x7f, 0x7, 0x7a, 0xaa, 0xf7, 0xdf, 0x2e, 0x2d, 0xfb, 0x57, 0x14, 0xd6, 0x9f, 0x9c, 0xcc, 0x56, 0x88, 0xe, 0x85, 0xcc, 0x30, 0x6, 0x32, 0x1f, 0x70, 0x47, 0x59 }, - }, - { - .msglen = 156, - .result = { 0xea, 0xfa, 0x44, 0x81, 0x83, 0xec, 0x2d, 0x63, 0xa6, 0xea, 0xf0, 0x6, 0x5d, 0x15, 0x32, 0x89, 0xed, 0x52, 0xf, 0x23, 0x66, 0x8b, 0x1c, 0x7c, 0x13, 0xd0, 0x35, 0xc1, 0x7d, 0x27, 0xfe, 0x80 }, - }, - { - .msglen = 157, - .result = { 0xab, 0x31, 0xe1, 0x44, 0x3d, 0x3a, 0xf5, 0x6a, 0x8b, 0x5d, 0xa6, 0xd5, 0x63, 0x23, 0x7e, 0x17, 0x24, 0xc9, 0x41, 0x53, 0x86, 0x90, 0xb7, 0x6f, 0xbc, 0x39, 0x5d, 0x1b, 0x19, 0xd9, 0xef, 0x9c }, - }, - { - .msglen = 158, - .result = { 0x3e, 0x34, 0xec, 0xd9, 0x26, 0xe7, 0x27, 0x3b, 0xc5, 0xc3, 0x8e, 0x11, 0xba, 0x58, 0xcf, 0x2b, 0x29, 0xc4, 0x49, 0xfc, 0xf6, 0x9d, 0xcc, 0x2a, 0x0, 0xff, 0xe6, 0xbc, 0x7d, 0x2a, 0x48, 0x22 }, - }, - { - .msglen = 159, - .result = { 0xc8, 0x59, 0x27, 0xa2, 0x58, 0x9e, 0xfe, 0x8c, 0x5a, 0x7f, 0x99, 0xd0, 0x58, 0xd4, 0x8c, 0xae, 0xa9, 0x4, 0x24, 0x50, 0x34, 0x23, 0x45, 0xfe, 0x87, 0xa7, 0x53, 0x5a, 0x27, 0x9d, 0x1b, 0x4f }, - }, - { - .msglen = 160, - .result = { 0xd7, 0x76, 0xaa, 0x3b, 0x97, 0x5e, 0xac, 0xbe, 0x46, 0x45, 0x80, 0x8e, 0x2c, 0xa2, 0xe1, 0xd4, 0x75, 0xb5, 0xe0, 0xd2, 0x4c, 0x59, 0xf0, 0xc3, 0xe8, 0x8c, 0x96, 0xbd, 0x85, 0x23, 0x8b, 0x40 }, - }, - { - .msglen = 161, - .result = { 0x40, 0x8e, 0xa5, 0xbd, 0x32, 0x7, 0x19, 0xc8, 0x31, 0x22, 0x32, 0xdf, 0xe0, 0xf5, 0xe2, 0x5f, 0x91, 0xf4, 0x95, 0x7a, 0xa7, 0x91, 0x9d, 0xed, 0x35, 0x2f, 0x0, 0x4, 0x62, 0x63, 0x4, 0x80 }, - }, - { - .msglen = 162, - .result = { 0xa6, 0x1b, 0x63, 0x3, 0xbf, 0x2, 0xbd, 0xbb, 0x69, 0x1b, 0xac, 0x54, 0x99, 0xee, 0x8b, 0xe, 0xb, 0x41, 0x78, 0xda, 0x8f, 0x72, 0x97, 0xdf, 0x9, 0xfa, 0x35, 0xe1, 0x8a, 0xb3, 0x80, 0xc3 }, - }, - { - .msglen = 163, - .result = { 0x7d, 0xd3, 0x5e, 0x1a, 0x9, 0x94, 0x6e, 0x30, 0xc6, 0xbb, 0xda, 0xe7, 0x92, 0x49, 0xf6, 0x37, 0xe, 0xb3, 0x30, 0x96, 0xb2, 0xaf, 0x57, 0x22, 0xe4, 0x8d, 0x9f, 0x83, 0x51, 0xbf, 0x98, 0xb0 }, - }, - { - .msglen = 164, - .result = { 0x3e, 0x10, 0xe4, 0x81, 0xa2, 0x1d, 0x92, 0x7a, 0x1a, 0x73, 0xfe, 0xd4, 0x8b, 0x28, 0x4c, 0x85, 0xcc, 0xfe, 0xe0, 0x4f, 0x55, 0xfd, 0x47, 0x95, 0x1f, 0x1b, 0x60, 0x38, 0x7, 0xe9, 0xc9, 0x4f }, - }, - { - .msglen = 165, - .result = { 0x75, 0x68, 0x14, 0xf8, 0x3c, 0x94, 0x2b, 0xe9, 0x6c, 0x49, 0xfc, 0x77, 0xa8, 0x6a, 0x5d, 0xf6, 0x4e, 0x45, 0xa0, 0x45, 0x2c, 0xfc, 0xec, 0xb1, 0xaf, 0xf5, 0x77, 0x6d, 0xbf, 0x96, 0x2b, 0x88 }, - }, - { - .msglen = 166, - .result = { 0x81, 0x1e, 0x33, 0x1c, 0xeb, 0xcf, 0x34, 0x58, 0x18, 0xa7, 0x2c, 0x60, 0x9, 0x36, 0x6e, 0xba, 0x46, 0x27, 0xee, 0x25, 0x60, 0xa9, 0x9f, 0x90, 0x4, 0x65, 0xa6, 0x92, 0x48, 0x4a, 0xf7, 0x1b }, - }, - { - .msglen = 167, - .result = { 0xdc, 0x3d, 0x6, 0x9e, 0x2c, 0x8c, 0x2d, 0x84, 0xf7, 0x97, 0xa, 0xeb, 0xe3, 0x68, 0xa7, 0x59, 0x3d, 0xa, 0xba, 0x6f, 0xfb, 0x11, 0x5a, 0xf8, 0x99, 0xae, 0x84, 0x1f, 0x43, 0xf8, 0xfd, 0xac }, - }, - { - .msglen = 168, - .result = { 0x4e, 0xd7, 0x72, 0x7d, 0xfe, 0x4d, 0x8a, 0x9a, 0xfa, 0x39, 0xb7, 0x74, 0x83, 0x61, 0xd5, 0xb6, 0xd1, 0x56, 0x88, 0xe7, 0x85, 0x15, 0xcf, 0x2d, 0x91, 0x73, 0xa4, 0xc9, 0xad, 0x76, 0x47, 0x2f }, - }, - { - .msglen = 169, - .result = { 0x33, 0x25, 0x94, 0xbc, 0xa4, 0xd, 0x39, 0x84, 0x4a, 0xe5, 0x30, 0x1f, 0x70, 0x41, 0xf0, 0xa7, 0x6d, 0x52, 0x3f, 0xa9, 0x17, 0x83, 0x46, 0xe, 0x26, 0x77, 0xe9, 0xfd, 0xe, 0x46, 0x21, 0xee }, - }, - { - .msglen = 170, - .result = { 0x84, 0xb8, 0x3c, 0x8d, 0x89, 0xd6, 0x55, 0x75, 0xbd, 0x5d, 0xcb, 0x76, 0xfe, 0x42, 0x98, 0xf9, 0xff, 0x8b, 0x4d, 0xe6, 0xe8, 0xd6, 0x1f, 0x37, 0xa6, 0xe0, 0xa8, 0x37, 0x28, 0xed, 0xf4, 0x38 }, - }, - { - .msglen = 171, - .result = { 0xf, 0x48, 0x6c, 0x1f, 0x99, 0x6d, 0x3c, 0x11, 0xd9, 0x7a, 0x33, 0xa, 0xdf, 0xb1, 0xa3, 0x59, 0x3f, 0xe3, 0xf0, 0x3, 0xab, 0x5e, 0x3f, 0x68, 0xe5, 0xa5, 0xd1, 0xbb, 0x8, 0x85, 0x50, 0x45 }, - }, - { - .msglen = 172, - .result = { 0x58, 0x25, 0xc1, 0x9e, 0x9d, 0x79, 0xa9, 0x71, 0xe7, 0xc5, 0x6, 0x8d, 0x23, 0x65, 0xf4, 0xbc, 0x9e, 0xa8, 0xab, 0xcc, 0x2f, 0x93, 0xac, 0x64, 0xb5, 0x6d, 0x28, 0x34, 0xe, 0x78, 0x9a, 0xfa }, - }, - { - .msglen = 173, - .result = { 0x10, 0xc6, 0xca, 0x3a, 0xc9, 0xe3, 0x82, 0x6e, 0x76, 0x5b, 0x8d, 0x42, 0x56, 0x4c, 0xc5, 0xf2, 0x2c, 0xaa, 0x95, 0x4, 0xc4, 0xef, 0x5f, 0xda, 0x10, 0xd3, 0x77, 0x9b, 0xc5, 0x95, 0x72, 0x14 }, - }, - { - .msglen = 174, - .result = { 0x7b, 0x64, 0xa, 0x83, 0xbf, 0x35, 0x85, 0xbf, 0xc2, 0xee, 0xdd, 0x95, 0xca, 0x5c, 0xa0, 0xee, 0xca, 0xa2, 0xb8, 0x33, 0xc1, 0x7d, 0xf3, 0x4d, 0x35, 0x2e, 0x27, 0xb8, 0x56, 0x5, 0x7a, 0x73 }, - }, - { - .msglen = 175, - .result = { 0xdb, 0x32, 0x29, 0x7c, 0xfd, 0xa5, 0x91, 0xae, 0x9b, 0xb0, 0xbd, 0xb4, 0x34, 0x4f, 0x60, 0x98, 0x65, 0x35, 0xe4, 0x60, 0xf8, 0x8b, 0x57, 0x47, 0x55, 0x14, 0xa4, 0x5e, 0xcc, 0xa6, 0xbd, 0xf4 }, - }, - { - .msglen = 176, - .result = { 0x7c, 0x6f, 0xd4, 0x3f, 0xd0, 0xa7, 0x7d, 0xd5, 0x34, 0xe0, 0x8d, 0x91, 0x5d, 0xbe, 0x92, 0xb8, 0x67, 0xbe, 0xf5, 0x80, 0xa4, 0xd5, 0x1b, 0x86, 0x12, 0xa7, 0x6, 0x43, 0x1c, 0x61, 0xa3, 0xd5 }, - }, - { - .msglen = 177, - .result = { 0x39, 0x4e, 0x86, 0xdf, 0xbd, 0x7f, 0x6a, 0x8d, 0xe7, 0x55, 0xce, 0x4b, 0x69, 0x90, 0xbc, 0x20, 0xf7, 0xd1, 0xba, 0x93, 0x2b, 0x57, 0x16, 0x5d, 0xc3, 0x16, 0xa, 0xf3, 0x62, 0x7, 0x66, 0xac }, - }, - { - .msglen = 178, - .result = { 0x5f, 0xfd, 0x40, 0x99, 0xa8, 0xdc, 0xe5, 0x2, 0x9e, 0x36, 0xf, 0x5d, 0x47, 0x53, 0xe4, 0x48, 0xcf, 0xd5, 0x5f, 0xd5, 0x29, 0x95, 0x5d, 0x92, 0x6d, 0x41, 0x22, 0x7d, 0x10, 0x8a, 0xc9, 0x88 }, - }, - { - .msglen = 179, - .result = { 0x58, 0x91, 0x6b, 0x40, 0x4d, 0x99, 0xf7, 0x78, 0xa5, 0xc7, 0x62, 0x49, 0x6c, 0x37, 0xd5, 0x90, 0x93, 0x3c, 0x59, 0x34, 0x36, 0xd1, 0x97, 0xcd, 0x85, 0x7d, 0x7a, 0x6d, 0x65, 0xce, 0x7f, 0xdb }, - }, - { - .msglen = 180, - .result = { 0x86, 0xc3, 0xa0, 0xa4, 0x46, 0x8a, 0xa8, 0x69, 0x8e, 0x6d, 0x5e, 0x79, 0x9f, 0xca, 0x9c, 0x2a, 0x94, 0xb0, 0xf8, 0x3f, 0xad, 0xa0, 0xfc, 0x50, 0x68, 0x39, 0x6c, 0xb5, 0xfc, 0x31, 0xaf, 0x74 }, - }, - { - .msglen = 181, - .result = { 0xce, 0x7, 0x9, 0x65, 0x72, 0xf3, 0x8c, 0x51, 0x6b, 0xf7, 0x2d, 0x46, 0xfc, 0xbc, 0xa6, 0xdd, 0x75, 0xe4, 0xd9, 0x54, 0x70, 0xcd, 0xa5, 0x5c, 0xa1, 0xb6, 0xd4, 0x3a, 0xe5, 0x4c, 0x18, 0x9e }, - }, - { - .msglen = 182, - .result = { 0x96, 0xbc, 0xcc, 0xbd, 0xb5, 0xf8, 0xd7, 0xef, 0xc7, 0x85, 0x44, 0x89, 0x6b, 0xd5, 0xbf, 0x78, 0xb7, 0x9d, 0xde, 0xf8, 0x72, 0xd1, 0xd9, 0xb3, 0xb0, 0xfd, 0x7f, 0x4e, 0x2a, 0xaa, 0x3d, 0x7c }, - }, - { - .msglen = 183, - .result = { 0x0, 0xdf, 0xb9, 0xd2, 0x99, 0x8e, 0x5c, 0xed, 0x85, 0x8b, 0x3d, 0x35, 0xdf, 0x35, 0x8c, 0x82, 0x3a, 0x20, 0x36, 0x60, 0x48, 0x7e, 0x9e, 0x8b, 0x60, 0xf9, 0x88, 0xb1, 0x8d, 0x5c, 0x41, 0xef }, - }, - { - .msglen = 184, - .result = { 0x99, 0xdf, 0xe5, 0xf6, 0xdf, 0xb3, 0x88, 0x88, 0x45, 0x34, 0x4a, 0x61, 0xc8, 0x87, 0x49, 0x20, 0xdf, 0xe0, 0x84, 0x5b, 0x35, 0xfe, 0x8c, 0xf8, 0x4a, 0x9c, 0xb1, 0x2d, 0x30, 0x5f, 0xfe, 0x3c }, - }, - { - .msglen = 185, - .result = { 0xfc, 0x53, 0x78, 0x1f, 0x4d, 0x43, 0xf4, 0xe9, 0xdc, 0x74, 0x8, 0xc3, 0xb5, 0xfc, 0x82, 0x88, 0x53, 0x25, 0xc, 0x81, 0x14, 0xa7, 0xff, 0xff, 0x9f, 0xda, 0xc8, 0x45, 0x38, 0x71, 0xdc, 0xd9 }, - }, - { - .msglen = 186, - .result = { 0xa5, 0x3f, 0x40, 0x24, 0x78, 0x12, 0xfc, 0xa7, 0x5b, 0x8a, 0xea, 0x5f, 0x83, 0xf9, 0x42, 0xc6, 0x21, 0xd, 0xa1, 0x46, 0x3, 0x3a, 0x62, 0xb9, 0x39, 0x39, 0xad, 0x6d, 0x70, 0x8e, 0xa2, 0x97 }, - }, - { - .msglen = 187, - .result = { 0x52, 0x23, 0x8a, 0xe, 0x32, 0xd5, 0x99, 0xd2, 0x7e, 0x77, 0x89, 0x70, 0x75, 0xdf, 0xf1, 0x90, 0x92, 0x1d, 0x14, 0xf7, 0xea, 0xa9, 0xdf, 0x5, 0x72, 0xf5, 0x8a, 0xd0, 0xdc, 0xee, 0x40, 0xd0 }, - }, - { - .msglen = 188, - .result = { 0x56, 0x86, 0xee, 0xbb, 0xde, 0xcc, 0x9d, 0xb2, 0x26, 0xa7, 0xb4, 0xef, 0x3d, 0x3f, 0x3e, 0x7d, 0xe3, 0x27, 0xea, 0x79, 0xd5, 0x82, 0x8f, 0x2f, 0x44, 0xa0, 0xe1, 0x4c, 0x67, 0xa6, 0x6b, 0x8f }, - }, - { - .msglen = 189, - .result = { 0xc0, 0x4c, 0xf2, 0x5c, 0x93, 0x4b, 0x36, 0xcb, 0xff, 0xc2, 0x15, 0x9, 0x77, 0x2f, 0xc1, 0xb0, 0x9, 0x98, 0x2b, 0x48, 0x3e, 0xcf, 0x6f, 0x4f, 0xe, 0x7d, 0xd9, 0xae, 0xdb, 0xeb, 0xd8, 0xe1 }, - }, - { - .msglen = 190, - .result = { 0x1f, 0xf1, 0x1c, 0x2c, 0x4e, 0xd0, 0x9c, 0x5e, 0x8e, 0xb4, 0x71, 0x88, 0xc8, 0xcc, 0xd8, 0x4b, 0x25, 0x6d, 0xad, 0xe7, 0x6d, 0x8d, 0x3b, 0x4d, 0x3a, 0xe9, 0xd, 0xa7, 0x69, 0xa8, 0x98, 0xde }, - }, - { - .msglen = 191, - .result = { 0x27, 0x4, 0x31, 0x8, 0x73, 0xf1, 0x5f, 0x15, 0x61, 0x2c, 0x62, 0x49, 0xa9, 0xe8, 0x11, 0xf3, 0xac, 0x54, 0x48, 0x98, 0x62, 0xf2, 0x7d, 0xd6, 0x12, 0xcf, 0x4, 0x1, 0x4e, 0xa9, 0x24, 0xc8 }, - }, - { - .msglen = 192, - .result = { 0xe4, 0x39, 0x59, 0x7e, 0x60, 0x5a, 0x45, 0x4b, 0x89, 0xa8, 0x97, 0x74, 0xfe, 0xb7, 0xeb, 0xd5, 0x6, 0xdb, 0xdc, 0x4d, 0x85, 0x3a, 0x38, 0x4c, 0x5e, 0x74, 0x86, 0xeb, 0xf0, 0xc4, 0x5, 0x32 }, - }, - { - .msglen = 193, - .result = { 0x9a, 0x14, 0xf6, 0x6f, 0xce, 0x82, 0xa0, 0xbb, 0xde, 0xb8, 0x24, 0x2b, 0xaf, 0xae, 0x18, 0xd4, 0xbb, 0x45, 0x9e, 0xe4, 0x87, 0x3b, 0x35, 0xca, 0xeb, 0x37, 0xd1, 0x52, 0x6, 0x6e, 0x84, 0x3b }, - }, - { - .msglen = 194, - .result = { 0x64, 0x9f, 0xab, 0x84, 0xaf, 0x83, 0xa6, 0xcb, 0x23, 0x0, 0xd5, 0x4c, 0xd3, 0x76, 0x4b, 0x57, 0x76, 0x70, 0xdb, 0xea, 0x3a, 0xcb, 0xb7, 0x9c, 0x16, 0x80, 0xbf, 0x66, 0x2b, 0x56, 0xc, 0x2c }, - }, - { - .msglen = 195, - .result = { 0xab, 0xa8, 0x11, 0x2b, 0x2, 0x99, 0xb0, 0x15, 0x36, 0x4d, 0x5b, 0x5d, 0x55, 0xc3, 0xa5, 0xbc, 0x70, 0x9, 0x36, 0xd9, 0x9f, 0xfe, 0x49, 0x3d, 0x5a, 0x2b, 0x8d, 0x69, 0xe2, 0x6, 0x1a, 0x6f }, - }, - { - .msglen = 196, - .result = { 0xd7, 0x6b, 0x15, 0x6c, 0xc1, 0x21, 0x84, 0x78, 0x7c, 0x5e, 0xbe, 0x16, 0x70, 0xe2, 0x83, 0x7f, 0x2c, 0x3, 0x5f, 0xb9, 0x2f, 0x17, 0x46, 0xb0, 0x5a, 0xaf, 0xac, 0x2b, 0x80, 0xcf, 0xa5, 0x9c }, - }, - { - .msglen = 197, - .result = { 0x15, 0x9c, 0x70, 0x75, 0x5a, 0x4e, 0xd2, 0x94, 0x7b, 0x6, 0xe8, 0xdd, 0x55, 0x21, 0xe9, 0x1b, 0x97, 0xe, 0x95, 0x5b, 0x18, 0xa7, 0x26, 0xc0, 0x0, 0xed, 0xe7, 0x55, 0xc8, 0x3d, 0xf3, 0xe7 }, - }, - { - .msglen = 198, - .result = { 0x2c, 0xdf, 0x2e, 0x88, 0xf, 0xee, 0xcf, 0x19, 0x1e, 0x72, 0x8b, 0x15, 0x7d, 0x18, 0xa1, 0xcf, 0x6, 0xa6, 0xc2, 0xec, 0x35, 0xe5, 0x2a, 0x0, 0x7f, 0x75, 0x9b, 0x63, 0x99, 0x9e, 0x2f, 0x66 }, - }, - { - .msglen = 199, - .result = { 0x28, 0xeb, 0xc7, 0x79, 0x5d, 0x7c, 0x29, 0xb9, 0x8a, 0xe8, 0x7b, 0xe4, 0x74, 0x3d, 0x3a, 0x74, 0xab, 0x2e, 0x67, 0xde, 0xe4, 0x28, 0x1b, 0xd0, 0xe3, 0x1b, 0xc9, 0xd0, 0xc0, 0x6c, 0xda, 0xba }, - }, - { - .msglen = 200, - .result = { 0x72, 0x17, 0x1e, 0xca, 0x67, 0xed, 0x83, 0xe9, 0x8d, 0x9b, 0x44, 0xe, 0xd4, 0x27, 0x2c, 0x6b, 0x7d, 0xe2, 0x22, 0x54, 0xf3, 0x72, 0xd1, 0x2, 0xaf, 0x47, 0x20, 0xc0, 0x47, 0x8a, 0x5, 0x9c }, - }, - { - .msglen = 201, - .result = { 0xb8, 0x2c, 0xea, 0xd9, 0xc4, 0x17, 0x66, 0xa6, 0x5a, 0xc1, 0xb8, 0x24, 0xf5, 0x5e, 0x1a, 0x2c, 0x85, 0xf0, 0xa3, 0xcd, 0xd3, 0x7e, 0xfa, 0x23, 0xd2, 0x90, 0x4f, 0xf3, 0x55, 0xfa, 0x17, 0x5c }, - }, - { - .msglen = 202, - .result = { 0x9d, 0x7f, 0x23, 0x8c, 0x92, 0xe5, 0x37, 0xb, 0xc7, 0x97, 0xa4, 0x68, 0xe5, 0xc, 0xd8, 0xfe, 0xb0, 0x4d, 0xc7, 0x79, 0x25, 0xd, 0xe6, 0xa6, 0xe6, 0x4, 0xc5, 0xfd, 0x2d, 0x25, 0x3f, 0xd2 }, - }, - { - .msglen = 203, - .result = { 0xdf, 0xdf, 0x13, 0xc0, 0x82, 0x73, 0x7b, 0xec, 0x2a, 0x4d, 0x9e, 0x62, 0xfc, 0x88, 0xa9, 0x47, 0xfd, 0x47, 0x59, 0xf2, 0x58, 0x5, 0xf9, 0x2e, 0xce, 0x5b, 0x1, 0xae, 0x37, 0x9e, 0xa8, 0x3f }, - }, - { - .msglen = 204, - .result = { 0x60, 0x10, 0x29, 0xc3, 0x82, 0x91, 0x8b, 0x74, 0xa5, 0x6a, 0x3f, 0x6a, 0x76, 0xaf, 0x50, 0x9e, 0xf1, 0x38, 0xf5, 0xd2, 0xdc, 0xe5, 0x5a, 0x3d, 0xa9, 0x8a, 0x56, 0xca, 0xeb, 0x57, 0x79, 0x5a }, - }, - { - .msglen = 205, - .result = { 0xd2, 0x71, 0x22, 0xe1, 0x91, 0x69, 0x5d, 0x9f, 0x6, 0xff, 0x51, 0xea, 0x7e, 0x8a, 0x5d, 0xb2, 0xae, 0x66, 0xf5, 0x22, 0x65, 0xa7, 0xfe, 0xf0, 0xce, 0xf5, 0x2c, 0xbf, 0x4e, 0x41, 0x19, 0x72 }, - }, - { - .msglen = 206, - .result = { 0x66, 0x41, 0x4d, 0xd9, 0xff, 0x1, 0x27, 0xda, 0xae, 0xee, 0x41, 0x34, 0x41, 0xd1, 0xb9, 0xac, 0x11, 0xf3, 0x5b, 0xc4, 0xa2, 0xd5, 0x3, 0x47, 0x87, 0xf4, 0x88, 0xee, 0x61, 0x22, 0x1, 0x6a }, - }, - { - .msglen = 207, - .result = { 0x59, 0xaf, 0xa5, 0x9a, 0xac, 0x1, 0x0, 0x73, 0x57, 0xa4, 0xdb, 0x22, 0x9, 0x3b, 0x3a, 0x66, 0x19, 0xd6, 0xe4, 0xf7, 0x1d, 0x2a, 0x37, 0x5f, 0x71, 0xc5, 0x54, 0x8e, 0xb, 0x73, 0xd5, 0x3c }, - }, - { - .msglen = 208, - .result = { 0xd1, 0xa7, 0x61, 0x34, 0xc5, 0x65, 0xb8, 0xa4, 0x8e, 0x3a, 0x9f, 0x5b, 0x11, 0x8b, 0x21, 0x5e, 0x7c, 0x9c, 0xfb, 0xd3, 0xe2, 0xe5, 0x92, 0x41, 0x6f, 0x4, 0x61, 0x30, 0x79, 0xf2, 0x8, 0xc4 }, - }, - { - .msglen = 209, - .result = { 0x84, 0x79, 0x2, 0x39, 0x2d, 0x2a, 0x11, 0xa5, 0xff, 0xa1, 0x3a, 0xfd, 0x70, 0x90, 0xb4, 0xa5, 0x85, 0xda, 0xd5, 0x4c, 0x8d, 0xaa, 0x97, 0x5e, 0x3b, 0x45, 0x89, 0xd0, 0xfd, 0x85, 0x57, 0xf3 }, - }, - { - .msglen = 210, - .result = { 0xc6, 0x3b, 0x4b, 0xbd, 0x70, 0x65, 0x2, 0x2f, 0xfc, 0xc2, 0x42, 0x4e, 0x77, 0xa0, 0xc8, 0x4d, 0x3d, 0x65, 0x4a, 0xb3, 0x47, 0xf5, 0x21, 0x39, 0xb0, 0x61, 0x8a, 0xae, 0x58, 0x18, 0x7e, 0xbe }, - }, - { - .msglen = 211, - .result = { 0x3c, 0x50, 0xdb, 0xa6, 0x45, 0x69, 0x8b, 0x58, 0x22, 0x1f, 0x3c, 0xa3, 0x1a, 0x79, 0x90, 0xef, 0xd4, 0x21, 0xf6, 0x9e, 0xfd, 0xe5, 0xb9, 0xb2, 0xbb, 0xef, 0x27, 0x36, 0x35, 0xd8, 0x6f, 0x69 }, - }, - { - .msglen = 212, - .result = { 0xd1, 0x5b, 0x4f, 0x10, 0xc6, 0x1, 0x2b, 0xe5, 0x4b, 0x8f, 0xba, 0x55, 0x36, 0x60, 0x26, 0xf3, 0x93, 0x40, 0xb7, 0xd, 0xbd, 0xf6, 0x80, 0x51, 0xbe, 0x52, 0x9, 0xdd, 0x78, 0x30, 0x47, 0xbd }, - }, - { - .msglen = 213, - .result = { 0xe6, 0x2e, 0x97, 0xbc, 0x93, 0xaf, 0x61, 0xb8, 0x40, 0x9d, 0x70, 0x90, 0xdc, 0x34, 0xb0, 0x7e, 0xad, 0x1d, 0x50, 0x55, 0x9e, 0x42, 0x92, 0x92, 0xaf, 0x54, 0x5c, 0x57, 0xa, 0x49, 0x39, 0xd }, - }, - { - .msglen = 214, - .result = { 0x6d, 0x72, 0xde, 0xd8, 0x72, 0x65, 0xc9, 0xaf, 0x36, 0x3b, 0x75, 0xf6, 0xf7, 0x71, 0x15, 0xa6, 0xad, 0x73, 0xa2, 0x9b, 0x1c, 0x86, 0xf3, 0xc1, 0xc1, 0x7a, 0x85, 0x87, 0x70, 0x44, 0x83, 0xe8 }, - }, - { - .msglen = 215, - .result = { 0x6c, 0xfb, 0xa2, 0xb9, 0xc1, 0xf0, 0xbf, 0xef, 0x33, 0x60, 0x55, 0x30, 0x5b, 0x2b, 0x4, 0x7b, 0xfb, 0x8f, 0xe0, 0x5d, 0x11, 0x90, 0x3c, 0x28, 0xcf, 0xd4, 0x5, 0x70, 0x88, 0x1a, 0x53, 0xa }, - }, - { - .msglen = 216, - .result = { 0xe6, 0x2a, 0x80, 0x77, 0xb, 0x8d, 0xc8, 0x79, 0x72, 0x32, 0xf9, 0xd, 0x41, 0xcc, 0x6e, 0x77, 0xe5, 0x5f, 0x22, 0xd2, 0xdb, 0x1, 0xf9, 0x96, 0xce, 0x13, 0x95, 0x51, 0x6, 0x95, 0x51, 0x24 }, - }, - { - .msglen = 217, - .result = { 0xf1, 0x79, 0x81, 0xb2, 0x3b, 0xb7, 0xc1, 0x12, 0x24, 0x6e, 0x97, 0xed, 0xe4, 0x87, 0xf4, 0xcf, 0x62, 0xf8, 0xb8, 0xa9, 0xb8, 0x9d, 0xf4, 0x5d, 0x17, 0xc7, 0x27, 0xe7, 0x84, 0x7, 0xb9, 0x56 }, - }, - { - .msglen = 218, - .result = { 0x6c, 0xe2, 0x55, 0x53, 0x36, 0x41, 0xe2, 0x99, 0xac, 0xb2, 0x67, 0xc1, 0xfe, 0x63, 0xb4, 0x93, 0x26, 0x50, 0x2e, 0xe, 0xac, 0xf7, 0x66, 0x20, 0x6, 0xb7, 0xb9, 0x98, 0x20, 0x17, 0xfa, 0x2d }, - }, - { - .msglen = 219, - .result = { 0xef, 0x47, 0xb1, 0x44, 0x60, 0xf2, 0x1a, 0xa5, 0x99, 0x8d, 0xd8, 0x7c, 0x80, 0x22, 0x2a, 0xac, 0x9, 0x27, 0xf, 0xc9, 0xb8, 0xa8, 0xfb, 0xec, 0x41, 0x23, 0x2b, 0x9b, 0x20, 0xed, 0xef, 0x5e }, - }, - { - .msglen = 220, - .result = { 0xea, 0x10, 0xab, 0xd, 0x8a, 0x2f, 0xff, 0xe2, 0x21, 0xb7, 0x8b, 0xff, 0x13, 0xa0, 0xa9, 0x4c, 0x78, 0x85, 0x35, 0xdf, 0x8c, 0xb8, 0x82, 0x57, 0x98, 0x5e, 0xc8, 0xe5, 0x95, 0x43, 0x14, 0x7e }, - }, - { - .msglen = 221, - .result = { 0xb6, 0x3b, 0x58, 0x81, 0xab, 0x62, 0xa9, 0xf3, 0x19, 0x1f, 0x3c, 0xe1, 0x21, 0x2f, 0x2, 0xc9, 0xdb, 0x8d, 0xd4, 0x7f, 0x38, 0x11, 0x1b, 0x18, 0x5c, 0xb, 0xa3, 0xa8, 0x38, 0xe4, 0xc4, 0x55 }, - }, - { - .msglen = 222, - .result = { 0xb, 0xc3, 0x3f, 0xaa, 0x9c, 0xff, 0x53, 0xb8, 0xe1, 0xa6, 0xd3, 0x43, 0x8e, 0xa6, 0x48, 0x7b, 0x5b, 0x4, 0x31, 0xc1, 0xad, 0x9d, 0x8, 0x39, 0xac, 0xee, 0x1, 0x87, 0xd3, 0x91, 0x7e, 0x7b }, - }, - { - .msglen = 223, - .result = { 0xb3, 0xd0, 0x23, 0x54, 0xc2, 0x1d, 0xd6, 0x23, 0x70, 0xe0, 0xc2, 0x61, 0x52, 0xa2, 0xbc, 0x3b, 0x6, 0x11, 0x80, 0xb2, 0xfa, 0x17, 0x26, 0x74, 0x90, 0x61, 0x46, 0x35, 0x66, 0x1a, 0xe9, 0x51 }, - }, - { - .msglen = 224, - .result = { 0x0, 0xab, 0x82, 0xf2, 0xaf, 0x44, 0x95, 0x58, 0x31, 0x2a, 0x20, 0x4c, 0x2c, 0xdc, 0x80, 0xfd, 0x71, 0x7a, 0xf4, 0x34, 0xe6, 0x7e, 0xe2, 0xff, 0x6e, 0xc2, 0xf, 0x82, 0x65, 0x1e, 0x6d, 0xe6 }, - }, - { - .msglen = 225, - .result = { 0x6, 0x67, 0x32, 0x34, 0x96, 0xb5, 0x7a, 0x86, 0xda, 0x89, 0xd6, 0x9b, 0x1e, 0x23, 0x40, 0xfb, 0xd, 0xdf, 0xce, 0xdf, 0x83, 0x14, 0xb3, 0xe2, 0x2c, 0xd, 0x70, 0x18, 0xde, 0x87, 0xc6, 0x65 }, - }, - { - .msglen = 226, - .result = { 0x7b, 0x2a, 0x1c, 0xc5, 0xc6, 0x2e, 0xb4, 0xed, 0x19, 0x75, 0x50, 0x8d, 0xe5, 0x74, 0xe9, 0x31, 0x32, 0x88, 0x36, 0x6a, 0x61, 0x10, 0x6c, 0xad, 0x25, 0xb5, 0x72, 0x8a, 0x4a, 0x9, 0x18, 0x7c }, - }, - { - .msglen = 227, - .result = { 0xa6, 0x34, 0x75, 0xcb, 0x1a, 0xbb, 0x6d, 0x4a, 0xfb, 0x81, 0x67, 0xd1, 0x46, 0xac, 0x59, 0xd, 0x86, 0x5b, 0xd5, 0x71, 0xb6, 0x52, 0xd2, 0xca, 0xdb, 0x31, 0x45, 0x97, 0x61, 0x5f, 0x77, 0x62 }, - }, - { - .msglen = 228, - .result = { 0x4, 0x7d, 0x3a, 0x50, 0x35, 0x1f, 0x7e, 0x94, 0x18, 0xe0, 0xeb, 0xc, 0xe7, 0x27, 0x85, 0x54, 0x4c, 0x33, 0x51, 0xf5, 0x51, 0x2e, 0x40, 0x88, 0x67, 0x36, 0x6b, 0x5d, 0x7c, 0xb1, 0x6, 0xc7 }, - }, - { - .msglen = 229, - .result = { 0x59, 0x7f, 0x6c, 0x70, 0x8c, 0x79, 0xf8, 0x9f, 0xb2, 0xb1, 0x5e, 0xc4, 0xe9, 0x26, 0x8c, 0xae, 0xc0, 0xfc, 0x48, 0x18, 0xe0, 0xa5, 0xab, 0xb4, 0x68, 0x23, 0x2c, 0x11, 0xf9, 0x1e, 0x11, 0x62 }, - }, - { - .msglen = 230, - .result = { 0x16, 0xe9, 0x5, 0x1c, 0xfd, 0x35, 0x95, 0xda, 0xad, 0xb4, 0xbd, 0xdc, 0x7b, 0xdb, 0xc3, 0x19, 0x56, 0x88, 0x42, 0x38, 0x58, 0x2f, 0x63, 0x5b, 0x73, 0x6e, 0xfd, 0x68, 0x24, 0x27, 0xce, 0xa3 }, - }, - { - .msglen = 231, - .result = { 0x7b, 0xba, 0x9e, 0x1a, 0xdb, 0xbb, 0x9b, 0x17, 0xe, 0x7, 0xbc, 0x8b, 0xbd, 0xdf, 0xab, 0x8b, 0xe7, 0xea, 0x39, 0xba, 0x20, 0xce, 0xd5, 0x83, 0x89, 0xe3, 0x27, 0xa3, 0xbe, 0x25, 0xb0, 0x4 }, - }, - { - .msglen = 232, - .result = { 0x11, 0x4a, 0xc5, 0xc9, 0x7f, 0x98, 0xeb, 0x92, 0xd3, 0x76, 0x4f, 0xc0, 0xd8, 0x8c, 0xfd, 0xe7, 0xf3, 0x1d, 0xfd, 0xbd, 0x36, 0x88, 0x48, 0xd6, 0xc7, 0x8c, 0x9f, 0x2c, 0xb2, 0x72, 0x14, 0xb9 }, - }, - { - .msglen = 233, - .result = { 0xb0, 0x67, 0xf9, 0x62, 0xb9, 0xa1, 0xc0, 0xe5, 0xb, 0x22, 0x4b, 0xe7, 0x84, 0x6b, 0x8c, 0xa9, 0xa, 0xfa, 0xd7, 0xe7, 0x5b, 0x7b, 0xc, 0xe0, 0x6e, 0x47, 0x24, 0xf8, 0xc7, 0xf5, 0x6b, 0x14 }, - }, - { - .msglen = 234, - .result = { 0x77, 0x25, 0x61, 0xfd, 0xc8, 0x39, 0x3a, 0x72, 0x74, 0x9, 0x8b, 0x49, 0x7d, 0xa3, 0x42, 0x66, 0xb, 0x5a, 0xa5, 0x53, 0x70, 0xbe, 0x69, 0x96, 0x69, 0xbb, 0x7a, 0x8a, 0x12, 0xa, 0x7, 0x14 }, - }, - { - .msglen = 235, - .result = { 0x10, 0x16, 0xbb, 0x95, 0x96, 0xb3, 0x87, 0xf6, 0x12, 0x5d, 0xcc, 0x9, 0xd3, 0xcd, 0xf8, 0x44, 0x2, 0x62, 0x96, 0xde, 0x7c, 0xa2, 0x66, 0x12, 0x4e, 0x86, 0x32, 0x11, 0xf1, 0x18, 0x38, 0x79 }, - }, - { - .msglen = 236, - .result = { 0x42, 0x91, 0x46, 0x5c, 0xa6, 0xae, 0x5c, 0x68, 0xc8, 0xb9, 0xa8, 0x38, 0xea, 0x18, 0x71, 0x63, 0xae, 0x9c, 0xc6, 0xd9, 0x22, 0xe4, 0xfa, 0x85, 0x9c, 0x94, 0xd4, 0xb8, 0xab, 0x98, 0xe, 0xf0 }, - }, - { - .msglen = 237, - .result = { 0x2b, 0x6b, 0xc, 0x10, 0x13, 0x80, 0x8e, 0xc3, 0x8a, 0xcd, 0xe7, 0xf0, 0x21, 0x1c, 0x1c, 0x7e, 0x61, 0x5e, 0x5, 0x37, 0xde, 0x5e, 0x9f, 0x2f, 0x8a, 0xe4, 0x31, 0x0, 0x63, 0x90, 0xc8, 0xa3 }, - }, - { - .msglen = 238, - .result = { 0xf5, 0x12, 0xb6, 0x60, 0xfe, 0x6c, 0xe5, 0xd2, 0x8b, 0x2e, 0xc9, 0x37, 0x66, 0xf8, 0xd5, 0x52, 0x28, 0x76, 0x35, 0xba, 0x4b, 0xf0, 0x2c, 0xbd, 0x47, 0x14, 0x3, 0x6b, 0x47, 0x58, 0xf8, 0x16 }, - }, - { - .msglen = 239, - .result = { 0xfa, 0x6c, 0x94, 0x22, 0xb, 0x98, 0x3b, 0x74, 0x18, 0xfa, 0xb8, 0xda, 0x55, 0x6c, 0xa2, 0xf5, 0x5b, 0xe4, 0x8, 0x99, 0xfa, 0xf7, 0xb4, 0x57, 0xfa, 0x7d, 0x8a, 0xc, 0x6a, 0xe1, 0xca, 0xc2 }, - }, - { - .msglen = 240, - .result = { 0x2b, 0x59, 0x71, 0x1e, 0x37, 0x8b, 0x24, 0x39, 0x98, 0x50, 0x79, 0x3b, 0xde, 0x2c, 0xce, 0xc6, 0xd, 0xf7, 0x53, 0xb6, 0x12, 0x2d, 0x70, 0x53, 0xdf, 0xbe, 0x57, 0x56, 0x87, 0xee, 0x9f, 0x12 }, - }, - { - .msglen = 241, - .result = { 0x38, 0xf6, 0x60, 0x9d, 0x7, 0x23, 0x85, 0xcc, 0x8e, 0x4a, 0xe5, 0xf1, 0xaf, 0x31, 0x9b, 0x97, 0xda, 0x34, 0x80, 0x6c, 0x23, 0x79, 0x69, 0x33, 0x87, 0xa6, 0x2d, 0x8d, 0xd4, 0x8e, 0x66, 0x2e }, - }, - { - .msglen = 242, - .result = { 0x88, 0x5d, 0xc8, 0x2, 0xf4, 0x76, 0xe4, 0x4e, 0xae, 0xcc, 0x9, 0x49, 0xc, 0x56, 0x7, 0x22, 0xd, 0x8f, 0xb0, 0xb4, 0x68, 0x1d, 0xb5, 0xaf, 0x89, 0xb0, 0xab, 0x3b, 0x37, 0x39, 0x88, 0x37 }, - }, - { - .msglen = 243, - .result = { 0x10, 0xb1, 0x44, 0x4a, 0xe2, 0xfc, 0x17, 0xc0, 0x7d, 0x39, 0x62, 0xb3, 0x45, 0x9b, 0xbe, 0xf8, 0x79, 0x2e, 0xe2, 0xfd, 0x59, 0x8e, 0xb5, 0x6c, 0x1d, 0xf5, 0x8b, 0x50, 0xad, 0x28, 0x93, 0xf }, - }, - { - .msglen = 244, - .result = { 0xf6, 0x5d, 0xce, 0x54, 0x13, 0x2, 0x3f, 0x5b, 0x4e, 0x72, 0xc8, 0xe1, 0x42, 0x83, 0xe7, 0x52, 0xde, 0x6f, 0xe6, 0x93, 0x15, 0xab, 0xe8, 0x1f, 0x53, 0x1d, 0xc5, 0xcd, 0xf3, 0x98, 0xf0, 0x9e }, - }, - { - .msglen = 245, - .result = { 0x56, 0xf1, 0x6f, 0xe1, 0xd7, 0x0, 0x33, 0x65, 0xe1, 0x61, 0x79, 0x15, 0x78, 0x5f, 0x98, 0x32, 0x4d, 0x11, 0x99, 0xf1, 0x14, 0xf2, 0xdc, 0x10, 0x7, 0x0, 0xaf, 0xea, 0x4, 0xd, 0x99, 0x33 }, - }, - { - .msglen = 246, - .result = { 0xfc, 0xcc, 0x27, 0x84, 0xc0, 0xbf, 0xf4, 0x52, 0xf2, 0x39, 0x1f, 0xb5, 0x5e, 0x8a, 0x17, 0xd2, 0x53, 0xff, 0x3c, 0x9b, 0x53, 0x25, 0x14, 0xed, 0xca, 0x1c, 0x88, 0xa9, 0x86, 0x5c, 0x50, 0xfe }, - }, - { - .msglen = 247, - .result = { 0xf3, 0x9f, 0x18, 0x4a, 0x35, 0xf4, 0xb3, 0x6, 0xac, 0xc4, 0x8c, 0x8e, 0xe7, 0x87, 0x0, 0x11, 0x63, 0xea, 0xba, 0x6a, 0x3f, 0x12, 0xa1, 0x4b, 0xf5, 0x6d, 0xbd, 0xeb, 0xcf, 0xfe, 0x6, 0x6d }, - }, - { - .msglen = 248, - .result = { 0x78, 0x69, 0xfc, 0x51, 0x5e, 0x48, 0xda, 0xb3, 0x81, 0xcb, 0x88, 0xf1, 0xc, 0x7, 0xeb, 0x16, 0x18, 0x2e, 0x6d, 0x85, 0x9d, 0xc0, 0x80, 0xea, 0xab, 0x39, 0xd3, 0x6a, 0xa8, 0x10, 0xe3, 0x26 }, - }, - { - .msglen = 249, - .result = { 0xee, 0xfb, 0xd, 0x72, 0x20, 0x48, 0x71, 0x10, 0x46, 0xc2, 0xb0, 0x5c, 0x11, 0xcf, 0x82, 0x2e, 0x6e, 0x3e, 0x3f, 0x16, 0xfa, 0x71, 0x80, 0x5f, 0x51, 0x50, 0x3e, 0xa2, 0x5d, 0xa1, 0x66, 0xbe }, - }, - { - .msglen = 250, - .result = { 0x72, 0x9c, 0x3, 0xe9, 0x25, 0xda, 0xaf, 0x7b, 0x40, 0x10, 0xe2, 0x85, 0xe0, 0x5b, 0xce, 0x55, 0x72, 0x1f, 0xfa, 0x54, 0x1c, 0x96, 0x48, 0xb, 0x55, 0x26, 0x53, 0x7d, 0xa9, 0xc5, 0x27, 0xd0 }, - }, - { - .msglen = 251, - .result = { 0x6f, 0x40, 0xd5, 0x72, 0x3b, 0x1f, 0x99, 0x9e, 0x7, 0x57, 0xbb, 0x57, 0x6c, 0x7e, 0x47, 0xb2, 0x76, 0x37, 0x5e, 0x64, 0x21, 0x51, 0x3c, 0xe8, 0x16, 0xda, 0x5f, 0x9f, 0xc9, 0x5b, 0xc3, 0x70 }, - }, - { - .msglen = 252, - .result = { 0x77, 0x3b, 0x47, 0x74, 0x0, 0xfd, 0x74, 0x95, 0xe, 0x59, 0xf6, 0xf, 0xcf, 0x9a, 0xb3, 0xbc, 0x9f, 0xd9, 0x3c, 0x3a, 0x30, 0x1c, 0x1f, 0x4d, 0x53, 0xbe, 0xce, 0x4c, 0xa1, 0x8b, 0xc1, 0x22 }, - }, - { - .msglen = 253, - .result = { 0xd0, 0xbe, 0x9, 0xb3, 0xa9, 0xa4, 0xb2, 0x46, 0x99, 0x40, 0x40, 0x6b, 0x52, 0x54, 0x3b, 0xfe, 0x94, 0x37, 0xf9, 0xc, 0xc2, 0xc2, 0x66, 0x3, 0xa5, 0x8c, 0x42, 0xae, 0x9d, 0xf8, 0x47, 0x87 }, - }, - { - .msglen = 254, - .result = { 0x85, 0x78, 0x21, 0xf4, 0xa, 0xee, 0xa3, 0x59, 0xe0, 0xb2, 0xd7, 0x7, 0x34, 0x5e, 0x57, 0xdc, 0xdd, 0x9a, 0xfa, 0x2c, 0xfd, 0xb6, 0xee, 0xa9, 0x14, 0xc0, 0x17, 0x86, 0xbf, 0x7b, 0xfe, 0x4b }, - }, - { - .msglen = 255, - .result = { 0x59, 0x52, 0x50, 0x4, 0xb6, 0x28, 0xf9, 0x28, 0x7f, 0x6c, 0x37, 0xba, 0xfb, 0xb2, 0x58, 0xe7, 0xa, 0xac, 0x6c, 0x4a, 0xef, 0x66, 0x6, 0x7b, 0x1, 0x1f, 0x4c, 0xa4, 0xe5, 0xe5, 0x29, 0x5d }, - }, - { - .msglen = 256, - .result = { 0x52, 0x1a, 0x14, 0xc3, 0xb4, 0x85, 0xf0, 0xb5, 0x82, 0xe9, 0x40, 0xc2, 0xc, 0x6d, 0x59, 0x64, 0x86, 0x7d, 0xa, 0x3b, 0x7f, 0x85, 0x78, 0xea, 0xea, 0x66, 0x48, 0xfa, 0x4a, 0xde, 0x5c, 0xd3 }, - }, - }; - for (int i = 0; i < sizeof(results) / sizeof(hmac_result); i++) { TEST_ESP_OK(esp_hmac_calculate(HMAC_KEY5, message, results[i].msglen, hmac)); TEST_ASSERT_EQUAL_HEX8_ARRAY(results[i].result, hmac, sizeof(hmac)); @@ -1275,22 +85,8 @@ TEST_CASE("HMAC 'upstream' wait lock", "[hw_crypto]") { uint8_t hmac[32]; - // 257 characters of pseudo-Latin from lipsum.com (not Copyright) - const char *message = "Deleniti voluptas explicabo et assumenda. Sed et aliquid minus quis. Praesentium cupiditate quia nemo est. Laboriosam pariatur ut distinctio tenetur. Sunt architecto iure aspernatur soluta ut recusandae. Ut quibusdam occaecati ut qui sit dignissimos eaque.."; - setup_keyblock(EFUSE_BLK_KEY5, ESP_EFUSE_KEY_PURPOSE_HMAC_UP); - static const hmac_result results[] = { - { - .msglen = 255, - .result = { 0x59, 0x52, 0x50, 0x4, 0xb6, 0x28, 0xf9, 0x28, 0x7f, 0x6c, 0x37, 0xba, 0xfb, 0xb2, 0x58, 0xe7, 0xa, 0xac, 0x6c, 0x4a, 0xef, 0x66, 0x6, 0x7b, 0x1, 0x1f, 0x4c, 0xa4, 0xe5, 0xe5, 0x29, 0x5d }, - }, - { - .msglen = 256, - .result = { 0x52, 0x1a, 0x14, 0xc3, 0xb4, 0x85, 0xf0, 0xb5, 0x82, 0xe9, 0x40, 0xc2, 0xc, 0x6d, 0x59, 0x64, 0x86, 0x7d, 0xa, 0x3b, 0x7f, 0x85, 0x78, 0xea, 0xea, 0x66, 0x48, 0xfa, 0x4a, 0xde, 0x5c, 0xd3 }, - }, - }; - for (int i = 0; i < sizeof(results) / sizeof(hmac_result); i++) { TEST_ESP_OK(esp_hmac_calculate(HMAC_KEY5, message, results[i].msglen, hmac)); TEST_ASSERT_EQUAL_HEX8_ARRAY(results[i].result, hmac, sizeof(hmac)); @@ -1307,9 +103,6 @@ TEST_CASE("HMAC key out of range", "[hw_crypto]") { uint8_t hmac[32]; - // 257 characters of pseudo-Latin from lipsum.com (not Copyright) - const char *message = "Deleniti voluptas explicabo et assumenda. Sed et aliquid minus quis."; - TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_hmac_calculate(HMAC_KEY0 - 1, message, 47, hmac)); - TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_hmac_calculate(HMAC_KEY5 + 1, message, 47, hmac)); + TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_hmac_calculate(HMAC_KEY_MAX, message, 47, hmac)); } diff --git a/components/esp_security/test_apps/crypto_drivers/main/test_key_mgr.c b/components/esp_security/test_apps/crypto_drivers/main/test_key_mgr.c index 1fdb5b28f1..1b2a25a4b6 100644 --- a/components/esp_security/test_apps/crypto_drivers/main/test_key_mgr.c +++ b/components/esp_security/test_apps/crypto_drivers/main/test_key_mgr.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -18,6 +18,31 @@ #include "esp_key_mgr.h" #include "esp_system.h" #include "unity_test_utils_memory.h" + +#if SOC_KEY_MANAGER_HMAC_KEY_DEPLOY +#include "esp_hmac.h" +#include "hmac_test_cases.h" +#endif /* SOC_KEY_MANAGER_HMAC_KEY_DEPLOY */ + +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY +#include "esp_ds.h" + +#define NUM_RESULTS 10 +typedef struct { + uint8_t iv[ESP_DS_IV_LEN]; + esp_ds_p_data_t p_data; + uint8_t expected_c[ESP_DS_C_LEN]; + uint8_t hmac_key_idx; + uint32_t expected_results[NUM_RESULTS][SOC_RSA_MAX_BIT_LEN / 32]; +} encrypt_testcase_t; + +#if SOC_RSA_MAX_BIT_LEN == 4096 +#include "digital_signature_test_cases_4096.h" +#elif SOC_RSA_MAX_BIT_LEN == 3072 +#include "digital_signature_test_cases_3072.h" +#endif +#endif /* SOC_KEY_MANAGER_DS_KEY_DEPLOY */ + static const char *TAG = "key_mgr_test"; #define ENCRYPTED_DATA_SIZE 128 @@ -33,41 +58,55 @@ static const uint8_t plaintext_data[ENCRYPTED_DATA_SIZE] = { }; static const uint8_t expected_ciphertext[ENCRYPTED_DATA_SIZE] = { - 0x1f, 0x41, 0xa4, 0xec, 0x0f, 0xd3, 0xaf, 0xe1, 0xb5, 0xc0, 0x56, 0x41, 0xcb, 0x28, 0x97, 0x1c, - 0x45, 0x02, 0x23, 0xcd, 0x45, 0x06, 0x19, 0xd8, 0xf9, 0x40, 0x8d, 0xdf, 0xb8, 0x71, 0xa7, 0x79, - 0xdf, 0xbb, 0x2d, 0x6a, 0xdd, 0x16, 0x18, 0x32, 0xe4, 0xa6, 0xfe, 0x23, 0xc9, 0x70, 0xa0, 0xfa, - 0xec, 0x74, 0xf4, 0x62, 0xea, 0x31, 0xc7, 0x1e, 0xfe, 0x94, 0xda, 0xe1, 0x70, 0xf8, 0x9f, 0xa3, - 0x03, 0xdf, 0x89, 0x77, 0x0a, 0x41, 0x7d, 0xc5, 0xe6, 0xc8, 0xb1, 0x10, 0xc8, 0x12, 0xa6, 0x3f, - 0xea, 0xf0, 0xfa, 0x7a, 0x5d, 0x33, 0xb3, 0xe6, 0xc2, 0x27, 0x07, 0x1e, 0x71, 0x22, 0x87, 0x73, - 0xc4, 0x2a, 0xbd, 0x59, 0x8f, 0xc6, 0xfb, 0x28, 0x2e, 0xec, 0xa2, 0x1f, 0x42, 0x7c, 0x54, 0xec, - 0x1e, 0x0f, 0x9f, 0xf2, 0x6e, 0x3f, 0xb8, 0x7d, 0xbf, 0xee, 0xf9, 0x7c, 0x93, 0xb2, 0x79, 0x98 + 0xf9, 0xb6, 0x08, 0x0f, 0xfb, 0x37, 0x46, 0xe4, 0x99, 0x3c, 0xf9, 0x29, 0xab, 0x90, 0xd5, 0x3f, + 0xc8, 0x70, 0x45, 0xae, 0x28, 0x16, 0xbd, 0x83, 0x66, 0x16, 0x83, 0x86, 0x01, 0xc9, 0xa2, 0x97, + 0xa4, 0xf6, 0xf0, 0x40, 0xb5, 0xfd, 0xb7, 0x13, 0x60, 0xc3, 0x39, 0xf2, 0x32, 0x5a, 0xa3, 0x89, + 0xfd, 0x77, 0x9c, 0x6b, 0x0e, 0x98, 0xdf, 0x8f, 0xf7, 0xcc, 0x2a, 0x1e, 0xce, 0xdc, 0xef, 0x41, + 0xac, 0x0f, 0x48, 0x97, 0xa1, 0x1a, 0xc0, 0x82, 0x42, 0x7e, 0x1a, 0x35, 0xcd, 0xcb, 0x2b, 0x1d, + 0x72, 0xc6, 0x78, 0xab, 0x35, 0x58, 0xd1, 0xe3, 0xb1, 0x61, 0x8d, 0x11, 0x70, 0x91, 0x62, 0xb4, + 0x5f, 0xdd, 0x75, 0x2f, 0x78, 0xc4, 0x95, 0x67, 0x3a, 0xd3, 0x87, 0x02, 0x35, 0x78, 0x48, 0xef, + 0xf2, 0xde, 0xdb, 0x59, 0xda, 0x33, 0xa6, 0x27, 0xdd, 0x33, 0x18, 0x0c, 0x57, 0x24, 0x95, 0x38, }; /* Big endian */ -uint8_t init_key[] = { - 0x4d, 0x21, 0x64, 0x21, 0x8f, 0xa2, 0xe3, 0xa0, 0xab, 0x74, 0xb5, 0xab, 0x17, 0x9a, 0x5d, 0x08, - 0x58, 0xf4, 0x22, 0x03, 0xbd, 0x52, 0xe7, 0x88, 0x3c, 0x22, 0x0f, 0x95, 0x89, 0x70, 0xe1, 0x93 +static const uint8_t init_key[] = { + 0xee, 0x89, 0x95, 0xda, 0x3c, 0x8a, 0x43, 0x83, 0xa9, 0x4b, 0x25, 0x5b, 0x04, 0x7e, 0xf1, 0x57, + 0xb8, 0xe8, 0x06, 0x45, 0x87, 0x76, 0xee, 0x1b, 0x4e, 0x2e, 0x55, 0xa7, 0x1f, 0x25, 0xe1, 0x94, }; /* Big endian */ -uint8_t k2_info[] = { - 0xd8, 0xcd, 0x04, 0x45, 0xb4, 0x45, 0xc4, 0x15, 0xf6, 0x40, 0x1c, 0x7d, 0x90, 0x1b, 0x99, 0xa4, - 0x79, 0x6b, 0xfb, 0x5b, 0x2a, 0x40, 0x60, 0xe1, 0xc1, 0xe1, 0x48, 0xcd, 0x46, 0x6b, 0x9b, 0x48, - 0xda, 0x7a, 0x70, 0x0a, 0x78, 0x0b, 0x9d, 0xf9, 0x0e, 0xed, 0x91, 0xfc, 0xa5, 0xc2, 0x96, 0x05, - 0x91, 0x76, 0xdb, 0x68, 0x84, 0x5d, 0x5e, 0x5b, 0xa6, 0xe9, 0x6b, 0x3b, 0x12, 0x50, 0x05, 0xc3 +static const uint8_t k2_info[] = { + 0x8f, 0x96, 0x33, 0x47, 0xe1, 0xa5, 0x57, 0xe9, 0x2a, 0x51, 0xa9, 0xbe, 0x48, 0x84, 0x25, 0x4e, + 0x6f, 0x50, 0x1c, 0x45, 0xdb, 0xb6, 0xfa, 0xeb, 0x35, 0xd2, 0x27, 0x91, 0x3f, 0x67, 0x57, 0xd9, + 0xcb, 0x55, 0xe4, 0x2b, 0x18, 0x16, 0xe7, 0xce, 0x6c, 0xf2, 0x58, 0x71, 0x17, 0x76, 0x2a, 0x86, + 0x05, 0xe7, 0x37, 0x45, 0x71, 0x34, 0xca, 0xaf, 0x60, 0x07, 0xdf, 0xf4, 0xd2, 0xee, 0x3d, 0x4b, }; /* Big endian */ -uint8_t k1_ecdsa_encrypt[] = { - 0xeb, 0x83, 0x24, 0x7d, 0xf8, 0x40, 0xc9, 0x88, 0x5f, 0x5e, 0x58, 0x57, 0x25, 0xa9, 0x23, 0x4a, - 0xa4, 0xc4, 0x12, 0x17, 0xf3, 0x9e, 0x1f, 0xa0, 0xa0, 0xfa, 0xd5, 0xbf, 0xb6, 0x6c, 0xb5, 0x48 +static const uint8_t k1_encrypt[] = { + 0xe0, 0xe8, 0x41, 0xe3, 0xd0, 0x92, 0x71, 0x84, 0x4b, 0x02, 0x1e, 0xec, 0x14, 0xdd, 0xaf, 0xf8, + 0x39, 0xf9, 0x6a, 0x8d, 0x1b, 0xd7, 0x64, 0x3b, 0x7b, 0xa6, 0x05, 0x42, 0x01, 0xfb, 0xab, 0xe1, }; -uint8_t k1_xts_encrypt[] = { - 0xeb, 0x83, 0x24, 0x7d, 0xf8, 0x40, 0xc9, 0x88, 0x5f, 0x5e, 0x58, 0x57, 0x25, 0xa9, 0x23, 0x4a, - 0xa4, 0xc4, 0x12, 0x17, 0xf3, 0x9e, 0x1f, 0xa0, 0xa0, 0xfa, 0xd5, 0xbf, 0xb6, 0x6c, 0xb5, 0x48 +static const uint8_t k1_hmac_encrypt[] = { + 0x9e, 0xd8, 0x62, 0x4f, 0x27, 0xe1, 0x13, 0xfc, 0x50, 0x4b, 0x7f, 0x68, 0x70, 0x7b, 0xa1, 0xb2, + 0xb1, 0x75, 0x21, 0x43, 0x88, 0x7d, 0xed, 0x4b, 0x58, 0x27, 0xb4, 0x15, 0x57, 0xc2, 0x46, 0x78, }; +// Note: generated using the hmac_key_idx = 0 of digital_signature_test_cases_3072 +static const uint8_t k1_ds_encrypt[] = { + 0xa9, 0xf7, 0xd1, 0xd9, 0xaa, 0x80, 0xfa, 0x6f, 0xfa, 0x34, 0xf6, 0x66, 0xbf, 0xba, 0x7b, 0xc9, + 0xa9, 0xf4, 0xeb, 0xba, 0x43, 0x61, 0x59, 0x32, 0x5d, 0xa0, 0xda, 0xd9, 0x0d, 0xc7, 0xde, 0xb2, +}; + +static const uint8_t k1_G[] = { + 0x25, 0x8c, 0x48, 0x4d, 0x0b, 0x4d, 0x3f, 0xbf, 0xde, 0xcf, 0x00, 0xc9, 0x4b, 0x0b, 0xf1, 0x14, + 0xb4, 0x31, 0x97, 0x79, 0x5a, 0xd3, 0x48, 0x72, 0x44, 0x2d, 0xab, 0x76, 0x29, 0xb9, 0x8b, 0x05, + 0xf5, 0x6b, 0xfb, 0xb4, 0xe4, 0xde, 0x81, 0x83, 0xa7, 0x0a, 0x90, 0xe4, 0x33, 0x41, 0x92, 0xaa, + 0xc5, 0xed, 0x93, 0xe0, 0x76, 0x2b, 0xe2, 0x4b, 0xdd, 0xa2, 0x8e, 0xe1, 0xc9, 0xe2, 0x94, 0x50, +}; + +#if SOC_KEY_MANAGER_FE_KEY_DEPLOY const esp_partition_t *get_test_storage_partition(void) { /* This finds "storage" partition defined partition table */ @@ -81,7 +120,7 @@ const esp_partition_t *get_test_storage_partition(void) return result; } -static esp_err_t test_xts_aes_key(void) +static esp_err_t test_xts_aes_key(bool verify) { const esp_partition_t *partition = get_test_storage_partition(); ESP_ERROR_CHECK(esp_partition_erase_range(partition, 0, partition->size)); @@ -90,55 +129,268 @@ static esp_err_t test_xts_aes_key(void) ESP_ERROR_CHECK(esp_flash_write_encrypted(NULL, address, plaintext_data, sizeof(plaintext_data))); uint8_t read_data[ENCRYPTED_DATA_SIZE]; ESP_ERROR_CHECK(esp_flash_read(NULL, read_data, address, sizeof(read_data))); - if (memcmp(read_data, expected_ciphertext, sizeof(expected_ciphertext)) != 0) { - ESP_LOGE(TAG, "Encrypted data does not match expected data"); - return ESP_FAIL; + if (verify) { + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_ciphertext, read_data, sizeof(expected_ciphertext)); } return ESP_OK; } -extern void set_leak_threshold(int threshold); -TEST_CASE("Key Manager AES mode: XTS-AES key deployment", "[hw_crypto] [key_mgr]") +TEST_CASE("Key Manager AES mode: XTS-AES-128 key deployment", "[hw_crypto] [key_mgr]") { - static esp_key_mgr_aes_key_config_t key_config; - memcpy(key_config.k2_info, (uint8_t*) k2_info, KEY_MGR_K2_INFO_SIZE); - memcpy(key_config.k1_encrypted, (uint8_t*) k1_xts_encrypt, KEY_MGR_K1_ENCRYPTED_SIZE); - memcpy(key_config.sw_init_key, (uint8_t*) 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; + esp_key_mgr_aes_key_config_t *key_config = calloc(1, sizeof(esp_key_mgr_aes_key_config_t)); + TEST_ASSERT_NOT_NULL(key_config); - static esp_key_mgr_key_recovery_info_t key_info; - esp_err_t esp_ret = ESP_FAIL; - esp_ret = esp_key_mgr_deploy_key_in_aes_mode(&key_config, &key_info); - TEST_ASSERT_EQUAL(ESP_OK, esp_ret); - esp_ret = esp_key_mgr_activate_key(&key_info); - TEST_ASSERT_EQUAL(ESP_OK, esp_ret); - esp_ret = test_xts_aes_key(); - TEST_ASSERT_EQUAL(ESP_OK, esp_ret); - esp_ret = esp_key_mgr_deactivate_key(key_info.key_type); - TEST_ASSERT_EQUAL(ESP_OK, esp_ret); + memcpy(key_config->k2_info, (uint8_t*) k2_info, KEY_MGR_K2_INFO_SIZE); + memcpy(key_config->k1_encrypted, (uint8_t*) k1_encrypt, KEY_MGR_K1_ENCRYPTED_SIZE); + memcpy(key_config->sw_init_key, (uint8_t*) 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; + + esp_key_mgr_key_recovery_info_t *key_recovery_info = calloc(1, sizeof(esp_key_mgr_key_recovery_info_t)); + TEST_ASSERT_NOT_NULL(key_recovery_info); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_aes_mode(key_config, key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, test_xts_aes_key(true)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info->key_type)); + + free(key_config); + free(key_recovery_info); } -TEST_CASE("Key Manager random mode: XTS_AES_128 key deployment", "[hw_crypto] [key_mgr]") +TEST_CASE("Key Manager ECDH0 mode: XTS-AES-128 key deployment", "[hw_crypto] [key_mgr]") { - ESP_LOGI(TAG, "Key Manager Example Start"); - static esp_key_mgr_random_key_config_t key_config; + esp_key_mgr_ecdh0_key_config_t *key_config = calloc(1, sizeof(esp_key_mgr_ecdh0_key_config_t)); + TEST_ASSERT_NOT_NULL(key_config); - key_config.key_type = ESP_KEY_MGR_XTS_AES_128_KEY; + memcpy(key_config->k1_G, (uint8_t*) k1_G, KEY_MGR_ECDH0_INFO_SIZE); + key_config->key_type = ESP_KEY_MGR_XTS_AES_128_KEY; - static esp_key_mgr_key_recovery_info_t key_info; - esp_err_t esp_ret = ESP_FAIL; - esp_ret = esp_key_mgr_deploy_key_in_random_mode(&key_config, &key_info); - TEST_ASSERT_EQUAL(ESP_OK, esp_ret); + esp_key_mgr_key_recovery_info_t *key_recovery_info = calloc(1, sizeof(esp_key_mgr_key_recovery_info_t)); + TEST_ASSERT_NOT_NULL(key_recovery_info); + esp_key_mgr_ecdh0_info_t *ecdh0_info = calloc(1, sizeof(esp_key_mgr_ecdh0_info_t)); + TEST_ASSERT_NOT_NULL(ecdh0_info); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_ecdh0_mode(key_config, key_recovery_info, ecdh0_info)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, test_xts_aes_key(false)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info->key_type)); + + free(key_config); + free(key_recovery_info); + free(ecdh0_info); } +TEST_CASE("Key Manager Random mode: XTS-AES-128 key deployment", "[hw_crypto] [key_mgr]") +{ + esp_key_mgr_random_key_config_t *key_config = calloc(1, sizeof(esp_key_mgr_random_key_config_t)); + TEST_ASSERT_NOT_NULL(key_config); + + key_config->key_type = ESP_KEY_MGR_XTS_AES_128_KEY; + + esp_key_mgr_key_recovery_info_t *key_recovery_info = calloc(1, sizeof(esp_key_mgr_key_recovery_info_t)); + TEST_ASSERT_NOT_NULL(key_recovery_info); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_random_mode(key_config, key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, test_xts_aes_key(false)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info->key_type)); + + free(key_config); + free(key_recovery_info); +} +#endif /* SOC_KEY_MANAGER_FE_KEY_DEPLOY */ + +#if SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY TEST_CASE("Key Manager random mode: ECDSA key deployment", "[hw_crypto] [key_mgr]") { - static esp_key_mgr_random_key_config_t key_config; - static esp_key_mgr_key_recovery_info_t key_info; - esp_err_t esp_ret = ESP_FAIL; - key_config.key_type = ESP_KEY_MGR_ECDSA_KEY; - esp_ret = esp_key_mgr_deploy_key_in_random_mode(&key_config, &key_info); - TEST_ASSERT_EQUAL(ESP_OK, esp_ret); + esp_key_mgr_random_key_config_t *key_config = calloc(1, sizeof(esp_key_mgr_random_key_config_t)); + TEST_ASSERT_NOT_NULL(key_config); + + key_config->key_type = ESP_KEY_MGR_ECDSA_256_KEY; + + esp_key_mgr_key_recovery_info_t *key_recovery_info = calloc(1, sizeof(esp_key_mgr_key_recovery_info_t)); + TEST_ASSERT_NOT_NULL(key_recovery_info); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_random_mode(key_config, key_recovery_info)); + + free(key_config); + free(key_recovery_info); } +#endif /* SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY */ + +#if SOC_KEY_MANAGER_HMAC_KEY_DEPLOY +static esp_err_t test_hmac_key(bool verify) +{ + uint8_t hmac[32]; + for (int i = 0; i < sizeof(results) / sizeof(hmac_result); i++) { + TEST_ESP_OK(esp_hmac_calculate(HMAC_KEY_KM, message, results[i].msglen, hmac)); + if (verify) { + TEST_ASSERT_EQUAL_HEX8_ARRAY(results[i].result, hmac, sizeof(hmac)); + } + } + return ESP_OK; +} + +TEST_CASE("Key Manager AES mode: HMAC key deployment", "[hw_crypto] [key_mgr]") +{ + esp_key_mgr_aes_key_config_t *key_config = calloc(1, sizeof(esp_key_mgr_aes_key_config_t)); + TEST_ASSERT_NOT_NULL(key_config); + + memcpy(key_config->k2_info, (uint8_t*) k2_info, KEY_MGR_K2_INFO_SIZE); + memcpy(key_config->k1_encrypted, (uint8_t*) k1_hmac_encrypt, KEY_MGR_K1_ENCRYPTED_SIZE); + memcpy(key_config->sw_init_key, (uint8_t*) init_key, KEY_MGR_SW_INIT_KEY_SIZE); + key_config->use_pre_generated_sw_init_key = 1; + key_config->key_type = ESP_KEY_MGR_HMAC_KEY; + + esp_key_mgr_key_recovery_info_t *key_recovery_info = calloc(1, sizeof(esp_key_mgr_key_recovery_info_t)); + TEST_ASSERT_NOT_NULL(key_recovery_info); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_aes_mode(key_config, key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, test_hmac_key(true)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info->key_type)); + + free(key_config); + free(key_recovery_info); +} + +TEST_CASE("Key Manager ECDH0 mode: HMAC key deployment", "[hw_crypto] [key_mgr]") +{ + esp_key_mgr_ecdh0_key_config_t *key_config = calloc(1, sizeof(esp_key_mgr_ecdh0_key_config_t)); + TEST_ASSERT_NOT_NULL(key_config); + + memcpy(key_config->k1_G, (uint8_t*) k1_G, KEY_MGR_ECDH0_INFO_SIZE); + key_config->key_type = ESP_KEY_MGR_HMAC_KEY; + + esp_key_mgr_key_recovery_info_t *key_recovery_info = calloc(1, sizeof(esp_key_mgr_key_recovery_info_t)); + TEST_ASSERT_NOT_NULL(key_recovery_info); + + esp_key_mgr_ecdh0_info_t *ecdh0_info = calloc(1, sizeof(esp_key_mgr_ecdh0_info_t)); + TEST_ASSERT_NOT_NULL(ecdh0_info); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_ecdh0_mode(key_config, key_recovery_info, ecdh0_info)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, test_hmac_key(false)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info->key_type)); + + free(key_config); + free(key_recovery_info); + free(ecdh0_info); +} + +TEST_CASE("Key Manager random mode: HMAC key deployment", "[hw_crypto] [key_mgr]") +{ + esp_key_mgr_random_key_config_t *key_config = calloc(1, sizeof(esp_key_mgr_random_key_config_t)); + TEST_ASSERT_NOT_NULL(key_config); + + key_config->key_type = ESP_KEY_MGR_HMAC_KEY; + + esp_key_mgr_key_recovery_info_t *key_recovery_info = calloc(1, sizeof(esp_key_mgr_key_recovery_info_t)); + TEST_ASSERT_NOT_NULL(key_recovery_info); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_random_mode(key_config, key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, test_hmac_key(false)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info->key_type)); + + free(key_config); + free(key_recovery_info); +} +#endif /* SOC_KEY_MANAGER_HMAC_KEY_DEPLOY */ + +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY +static esp_err_t test_ds_key(void) +{ + esp_ds_data_t ds_data = { }; + uint8_t signature[ESP_DS_SIGNATURE_MAX_BIT_LEN / 8] = { 0 }; + esp_err_t ds_r = ESP_FAIL; + + for (int i = 0; i < NUM_MESSAGES; i++) { + printf("Running test case %d...\n", i); + const encrypt_testcase_t *t = &test_cases[0]; + assert(t->hmac_key_idx == 0); // as the key deployed using Key Manager is the HMAC key ID 0 + + // copy encrypt parameter test case into ds_data structure + memcpy(ds_data.iv, t->iv, ESP_DS_IV_LEN); + memcpy(ds_data.c, t->expected_c, ESP_DS_C_LEN); + ds_data.rsa_length = t->p_data.length; + + ds_r = esp_ds_sign(test_messages[i], + &ds_data, + HMAC_KEY_KM, + signature); + + TEST_ASSERT_EQUAL(ESP_OK, ds_r); + TEST_ASSERT_EQUAL_HEX8_ARRAY(t->expected_results[i], signature, sizeof(signature)); + } + return ESP_OK; +} + +TEST_CASE("Key Manager AES mode: DS key deployment", "[hw_crypto] [key_mgr]") +{ + esp_key_mgr_aes_key_config_t *key_config = calloc(1, sizeof(esp_key_mgr_aes_key_config_t)); + TEST_ASSERT_NOT_NULL(key_config); + + memcpy(key_config->k2_info, (uint8_t*) k2_info, KEY_MGR_K2_INFO_SIZE); + memcpy(key_config->k1_encrypted, (uint8_t*) k1_ds_encrypt, KEY_MGR_K1_ENCRYPTED_SIZE); + memcpy(key_config->sw_init_key, (uint8_t*) init_key, KEY_MGR_SW_INIT_KEY_SIZE); + key_config->use_pre_generated_sw_init_key = 1; + key_config->key_type = ESP_KEY_MGR_DS_KEY; + + esp_key_mgr_key_recovery_info_t *key_recovery_info = calloc(1, sizeof(esp_key_mgr_key_recovery_info_t)); + TEST_ASSERT_NOT_NULL(key_recovery_info); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_aes_mode(key_config, key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, test_ds_key()); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info->key_type)); + + free(key_config); + free(key_recovery_info); +} + +TEST_CASE("Key Manager ECDH0 mode: DS key deployment", "[hw_crypto] [key_mgr]") +{ + esp_key_mgr_ecdh0_key_config_t *key_config = calloc(1, sizeof(esp_key_mgr_ecdh0_key_config_t)); + TEST_ASSERT_NOT_NULL(key_config); + + memcpy(key_config->k1_G, (uint8_t*) k1_G, KEY_MGR_ECDH0_INFO_SIZE); + key_config->key_type = ESP_KEY_MGR_DS_KEY; + + esp_key_mgr_key_recovery_info_t *key_recovery_info = calloc(1, sizeof(esp_key_mgr_key_recovery_info_t)); + TEST_ASSERT_NOT_NULL(key_recovery_info); + + esp_key_mgr_ecdh0_info_t *ecdh0_info = calloc(1, sizeof(esp_key_mgr_ecdh0_info_t)); + TEST_ASSERT_NOT_NULL(ecdh0_info); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_ecdh0_mode(key_config, key_recovery_info, ecdh0_info)); + // Generate the deployed DS key and use ds_encrypt_params to generate encrypted input params + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info->key_type)); + + free(key_config); + free(key_recovery_info); + free(ecdh0_info); +} + +TEST_CASE("Key Manager random mode: DS key deployment", "[hw_crypto] [key_mgr]") +{ + esp_key_mgr_random_key_config_t *key_config = calloc(1, sizeof(esp_key_mgr_random_key_config_t)); + TEST_ASSERT_NOT_NULL(key_config); + + key_config->key_type = ESP_KEY_MGR_DS_KEY; + + esp_key_mgr_key_recovery_info_t *key_recovery_info = calloc(1, sizeof(esp_key_mgr_key_recovery_info_t)); + TEST_ASSERT_NOT_NULL(key_recovery_info); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_random_mode(key_config, key_recovery_info)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(key_recovery_info)); + // No way to generate encrypted input params when DS key deployed in random mode + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info->key_type)); + + free(key_config); + free(key_recovery_info); +} +#endif /* SOC_KEY_MANAGER_DS_KEY_DEPLOY */ diff --git a/components/esp_security/test_apps/crypto_drivers/sdkconfig.defaults.esp32c5 b/components/esp_security/test_apps/crypto_drivers/sdkconfig.defaults.esp32c5 new file mode 100644 index 0000000000..8ff365b198 --- /dev/null +++ b/components/esp_security/test_apps/crypto_drivers/sdkconfig.defaults.esp32c5 @@ -0,0 +1,3 @@ +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" diff --git a/components/hal/ds_hal.c b/components/hal/ds_hal.c index 53f9279456..7591eff3a8 100644 --- a/components/hal/ds_hal.c +++ b/components/hal/ds_hal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include "hal/systimer_hal.h" #include "hal/ds_hal.h" #include "hal/ds_ll.h" +#include "soc/soc_caps.h" void ds_hal_start(void) { @@ -23,6 +24,13 @@ void ds_hal_configure_iv(const uint32_t *iv) ds_ll_configure_iv(iv); } +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY +void ds_hal_set_key_source(ds_key_source_t key_source) +{ + ds_ll_set_key_source(key_source); +} +#endif + void ds_hal_write_message(const uint8_t *msg, size_t size) { ds_ll_write_message(msg, size); diff --git a/components/hal/ecdsa_hal.c b/components/hal/ecdsa_hal.c index 98e227cb59..097ac9e53b 100644 --- a/components/hal/ecdsa_hal.c +++ b/components/hal/ecdsa_hal.c @@ -16,7 +16,7 @@ #endif #ifdef SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY -#include "hal/key_mgr_ll.h" +#include "hal/key_mgr_hal.h" #endif #define ECDSA_HAL_P192_COMPONENT_LEN 24 @@ -30,12 +30,20 @@ static void configure_ecdsa_periph(ecdsa_hal_config_t *conf) #if SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY // Force Key Manager to use eFuse key for XTS-AES operation - key_mgr_ll_set_key_usage(ESP_KEY_MGR_ECDSA_KEY, ESP_KEY_MGR_USE_EFUSE_KEY); + if (conf->curve == ECDSA_CURVE_SECP192R1) { + key_mgr_hal_set_key_usage(ESP_KEY_MGR_ECDSA_192_KEY, ESP_KEY_MGR_USE_EFUSE_KEY); + } else { + key_mgr_hal_set_key_usage(ESP_KEY_MGR_ECDSA_256_KEY, ESP_KEY_MGR_USE_EFUSE_KEY); + } #endif } #if SOC_KEY_MANAGER_SUPPORTED else { - key_mgr_ll_set_key_usage(ESP_KEY_MGR_ECDSA_KEY, ESP_KEY_MGR_USE_OWN_KEY); + if (conf->curve == ECDSA_CURVE_SECP192R1) { + key_mgr_hal_set_key_usage(ESP_KEY_MGR_ECDSA_192_KEY, ESP_KEY_MGR_USE_OWN_KEY); + } else { + key_mgr_hal_set_key_usage(ESP_KEY_MGR_ECDSA_256_KEY, ESP_KEY_MGR_USE_OWN_KEY); + } } #endif diff --git a/components/hal/esp32c5/include/hal/ds_ll.h b/components/hal/esp32c5/include/hal/ds_ll.h index 02b4e41c35..61ebbc4870 100644 --- a/components/hal/esp32c5/include/hal/ds_ll.h +++ b/components/hal/esp32c5/include/hal/ds_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -78,6 +78,14 @@ static inline ds_key_check_t ds_ll_key_error_source(void) } } +/** + * @brief Set the DS key source. + */ +static inline void ds_ll_set_key_source(ds_key_source_t key_source) +{ + REG_WRITE(DS_KEY_SOURCE_REG, key_source); +} + /** * @brief Write the initialization vector to the corresponding register field. */ diff --git a/components/hal/esp32c5/include/hal/huk_ll.h b/components/hal/esp32c5/include/hal/huk_ll.h index 37215ae35e..fb6e4e69f4 100644 --- a/components/hal/esp32c5/include/hal/huk_ll.h +++ b/components/hal/esp32c5/include/hal/huk_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -22,6 +22,8 @@ #include "hal/huk_types.h" #include "soc/huk_reg.h" #include "soc/soc_caps.h" +#include "soc/lp_aon_reg.h" +#include "esp_rom_sys.h" // HUK memory recharge workaround #ifdef __cplusplus extern "C" { @@ -103,6 +105,20 @@ static inline esp_huk_gen_status_t huk_ll_get_gen_status(void) return (esp_huk_gen_status_t) REG_GET_FIELD(HUK_STATUS_REG, HUK_STATUS); } + +static inline void __attribute__((always_inline)) huk_ll_recharge_huk_memory(void) +{ + REG_CLR_BIT(LP_AON_MEM_CTRL_REG, LP_AON_HUK_MEM_FORCE_PD); + + REG_CLR_BIT(LP_AON_PUF_MEM_SW_REG, LP_AON_PUF_MEM_SW); + REG_SET_BIT(LP_AON_PUF_MEM_DISCHARGE_REG, LP_AON_PUF_MEM_DISCHARGE); + esp_rom_delay_us(100000); + + REG_CLR_BIT(LP_AON_PUF_MEM_DISCHARGE_REG, LP_AON_PUF_MEM_DISCHARGE); + REG_SET_BIT(LP_AON_PUF_MEM_SW_REG, LP_AON_PUF_MEM_SW); + esp_rom_delay_us(100000); +} + /** * @brief Read the HUK date information */ diff --git a/components/hal/esp32c5/include/hal/key_mgr_ll.h b/components/hal/esp32c5/include/hal/key_mgr_ll.h index 581af34e18..455979d4cf 100644 --- a/components/hal/esp32c5/include/hal/key_mgr_ll.h +++ b/components/hal/esp32c5/include/hal/key_mgr_ll.h @@ -19,6 +19,7 @@ #include "hal/key_mgr_types.h" #include "soc/keymng_reg.h" #include "soc/pcr_struct.h" +#include "soc/pcr_reg.h" #ifdef __cplusplus extern "C" { @@ -34,32 +35,38 @@ static inline esp_key_mgr_state_t key_mgr_ll_get_state(void) return (esp_key_mgr_state_t) REG_GET_FIELD(KEYMNG_STATE_REG, KEYMNG_STATE); } +static inline void key_mgr_ll_power_up(void) +{ + /* Power up the Key Manager peripheral (default state is power-down) */ + REG_CLR_BIT(PCR_KM_PD_CTRL_REG, PCR_KM_MEM_FORCE_PD); + REG_SET_BIT(PCR_KM_PD_CTRL_REG, PCR_KM_MEM_FORCE_PU); +} + +#define key_mgr_ll_enable_bus_clock(...) do { \ + _key_mgr_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) + +static inline void key_mgr_ll_power_down(void) +{ + /* Power down the Key Manager peripheral */ + REG_CLR_BIT(PCR_KM_PD_CTRL_REG, PCR_KM_MEM_FORCE_PU); + REG_SET_BIT(PCR_KM_PD_CTRL_REG, PCR_KM_MEM_FORCE_PD); +} + /** * @brief Enable the bus clock for Key Manager peripheral - * Note: Please use key_mgr_ll_enable_bus_clock which requires the critical section - * and do not use _key_mgr_ll_enable_bus_clock + * * @param true to enable, false to disable */ static inline void _key_mgr_ll_enable_bus_clock(bool enable) { - // Set the force power down bit to 0 to enable key manager - PCR.km_pd_ctrl.km_mem_force_pd = 0; // Enable key manager clock - PCR.km_conf.km_clk_en = 1; + PCR.km_conf.km_clk_en = enable; } -/// use a macro to wrap the function, force the caller to use it in a critical section -/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance -#define key_mgr_ll_enable_bus_clock(...) do { \ - (void)__DECLARE_RCC_ATOMIC_ENV; \ - _key_mgr_ll_enable_bus_clock(__VA_ARGS__); \ - } while(0) - /** * @brief Enable the peripheral clock for Key Manager * - * Note: Please use key_mgr_ll_enable_peripheral_clock which requires the critical section - * and do not use _key_mgr_ll_enable_peripheral_clock * @param true to enable, false to disable */ static inline void _key_mgr_ll_enable_peripheral_clock(bool enable) @@ -68,14 +75,12 @@ static inline void _key_mgr_ll_enable_peripheral_clock(bool enable) } #define key_mgr_ll_enable_peripheral_clock(...) do { \ - (void)__DECLARE_RCC_ATOMIC_ENV; \ _key_mgr_ll_enable_peripheral_clock(__VA_ARGS__); \ } while(0) /** * @brief Reset the Key Manager peripheral - * Note: Please use key_mgr_ll_reset_register which requires the critical section - * and do not use _key_mgr_ll_reset_register + * */ static inline void _key_mgr_ll_reset_register(void) { @@ -90,10 +95,7 @@ static inline void _key_mgr_ll_reset_register(void) } -/// use a macro to wrap the function, force the caller to use it in a critical section -/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance #define key_mgr_ll_reset_register(...) do { \ - (void)__DECLARE_RCC_ATOMIC_ENV; \ _key_mgr_ll_reset_register(__VA_ARGS__); \ } while(0) @@ -160,13 +162,16 @@ static inline void key_mgr_ll_use_sw_init_key(void) static inline void key_mgr_ll_set_key_usage(const esp_key_mgr_key_type_t key_type, const esp_key_mgr_key_usage_t key_usage) { switch (key_type) { - case ESP_KEY_MGR_ECDSA_KEY: + case ESP_KEY_MGR_ECDSA_192_KEY: + case ESP_KEY_MGR_ECDSA_256_KEY: + case ESP_KEY_MGR_ECDSA_384_KEY: if (key_usage == ESP_KEY_MGR_USE_EFUSE_KEY) { REG_SET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_ECDSA); } else { REG_CLR_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_ECDSA); } break; + case ESP_KEY_MGR_XTS_AES_128_KEY: case ESP_KEY_MGR_XTS_AES_256_KEY: if (key_usage == ESP_KEY_MGR_USE_EFUSE_KEY) { @@ -176,6 +181,30 @@ static inline void key_mgr_ll_set_key_usage(const esp_key_mgr_key_type_t key_typ } break; + case ESP_KEY_MGR_HMAC_KEY: + if (key_usage == ESP_KEY_MGR_USE_EFUSE_KEY) { + REG_SET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_HMAC); + } else { + REG_CLR_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_HMAC); + } + break; + + case ESP_KEY_MGR_DS_KEY: + if (key_usage == ESP_KEY_MGR_USE_EFUSE_KEY) { + REG_SET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_DS); + } else { + REG_CLR_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_DS); + } + break; + + case ESP_KEY_MGR_PSRAM_128_KEY: + case ESP_KEY_MGR_PSRAM_256_KEY: + if (key_usage == ESP_KEY_MGR_USE_EFUSE_KEY) { + REG_SET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_PSRAM); + } else { + REG_CLR_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_PSRAM); + } + break; default: HAL_ASSERT(false && "Unsupported mode"); return; @@ -185,7 +214,9 @@ static inline void key_mgr_ll_set_key_usage(const esp_key_mgr_key_type_t key_typ static inline esp_key_mgr_key_usage_t key_mgr_ll_get_key_usage(esp_key_mgr_key_type_t key_type) { switch (key_type) { - case ESP_KEY_MGR_ECDSA_KEY: + case ESP_KEY_MGR_ECDSA_192_KEY: + case ESP_KEY_MGR_ECDSA_256_KEY: + case ESP_KEY_MGR_ECDSA_384_KEY: return (esp_key_mgr_key_usage_t) (REG_GET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_ECDSA)); break; @@ -194,6 +225,19 @@ static inline esp_key_mgr_key_usage_t key_mgr_ll_get_key_usage(esp_key_mgr_key_t return (esp_key_mgr_key_usage_t) (REG_GET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_FLASH)); break; + case ESP_KEY_MGR_HMAC_KEY: + return (esp_key_mgr_key_usage_t) (REG_GET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_HMAC)); + break; + + case ESP_KEY_MGR_DS_KEY: + return (esp_key_mgr_key_usage_t) (REG_GET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_DS)); + break; + + case ESP_KEY_MGR_PSRAM_128_KEY: + case ESP_KEY_MGR_PSRAM_256_KEY: + return (esp_key_mgr_key_usage_t) (REG_GET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_PSRAM)); + break; + default: HAL_ASSERT(false && "Unsupported mode"); return ESP_KEY_MGR_USAGE_INVALID; @@ -219,13 +263,30 @@ static inline void key_mgr_ll_lock_use_sw_init_key_reg(void) static inline void key_mgr_ll_lock_use_efuse_key_reg(esp_key_mgr_key_type_t key_type) { switch(key_type) { - case ESP_KEY_MGR_ECDSA_KEY: + case ESP_KEY_MGR_ECDSA_192_KEY: + case ESP_KEY_MGR_ECDSA_256_KEY: + case ESP_KEY_MGR_ECDSA_384_KEY: REG_SET_BIT(KEYMNG_LOCK_REG, KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA); break; + case ESP_KEY_MGR_XTS_AES_128_KEY: case ESP_KEY_MGR_XTS_AES_256_KEY: REG_SET_BIT(KEYMNG_LOCK_REG, KEYMNG_USE_EFUSE_KEY_LOCK_FLASH); break; + + case ESP_KEY_MGR_HMAC_KEY: + REG_SET_BIT(KEYMNG_LOCK_REG, KEYMNG_USE_EFUSE_KEY_LOCK_HMAC); + break; + + case ESP_KEY_MGR_DS_KEY: + REG_SET_BIT(KEYMNG_LOCK_REG, KEYMNG_USE_EFUSE_KEY_LOCK_DS); + break; + + case ESP_KEY_MGR_PSRAM_128_KEY: + case ESP_KEY_MGR_PSRAM_256_KEY: + REG_SET_BIT(KEYMNG_LOCK_REG, KEYMNG_USE_EFUSE_KEY_LOCK_PSRAM); + break; + default: HAL_ASSERT(false && "Unsupported mode"); return; @@ -264,9 +325,12 @@ static inline bool key_mgr_ll_is_result_success(void) static inline bool key_mgr_ll_is_key_deployment_valid(const esp_key_mgr_key_type_t key_type) { switch (key_type) { - - case ESP_KEY_MGR_ECDSA_KEY: - return REG_GET_FIELD(KEYMNG_KEY_VLD_REG, KEYMNG_KEY_ECDSA_VLD); + case ESP_KEY_MGR_ECDSA_192_KEY: + return REG_GET_FIELD(KEYMNG_KEY_VLD_REG, KEYMNG_KEY_ECDSA_192_VLD); + case ESP_KEY_MGR_ECDSA_256_KEY: + return REG_GET_FIELD(KEYMNG_KEY_VLD_REG, KEYMNG_KEY_ECDSA_256_VLD); + case ESP_KEY_MGR_ECDSA_384_KEY: + return REG_GET_FIELD(KEYMNG_KEY_VLD_REG, KEYMNG_KEY_ECDSA_384_VLD); break; case ESP_KEY_MGR_XTS_AES_128_KEY: @@ -274,6 +338,19 @@ static inline bool key_mgr_ll_is_key_deployment_valid(const esp_key_mgr_key_type return REG_GET_FIELD(KEYMNG_KEY_VLD_REG, KEYMNG_KEY_FLASH_VLD); break; + case ESP_KEY_MGR_HMAC_KEY: + return REG_GET_FIELD(KEYMNG_KEY_VLD_REG, KEYMNG_KEY_HMAC_VLD); + break; + + case ESP_KEY_MGR_DS_KEY: + return REG_GET_FIELD(KEYMNG_KEY_VLD_REG, KEYMNG_KEY_DS_VLD); + break; + + case ESP_KEY_MGR_PSRAM_128_KEY: + case ESP_KEY_MGR_PSRAM_256_KEY: + return REG_GET_FIELD(KEYMNG_KEY_VLD_REG, KEYMNG_KEY_PSRAM_VLD); + break; + default: HAL_ASSERT(false && "Unsupported mode"); return 0; @@ -343,15 +420,23 @@ static inline bool key_mgr_ll_is_huk_valid(void) } /* @brief Set the XTS-AES (Flash Encryption) key length for the Key Manager */ -static inline void key_mgr_ll_set_xts_aes_key_len(const esp_key_mgr_xts_aes_key_len_t key_len) +static inline void key_mgr_ll_set_xts_aes_key_len(const esp_key_mgr_key_type_t key_type, const esp_key_mgr_xts_aes_key_len_t key_len) { - REG_SET_FIELD(KEYMNG_STATIC_REG, KEYMNG_FLASH_KEY_LEN, key_len); + if (key_type == ESP_KEY_MGR_XTS_AES_128_KEY || key_type == ESP_KEY_MGR_XTS_AES_256_KEY) { + REG_SET_FIELD(KEYMNG_STATIC_REG, KEYMNG_FLASH_KEY_LEN, key_len); + } else if (key_type == ESP_KEY_MGR_PSRAM_128_KEY || key_type == ESP_KEY_MGR_PSRAM_256_KEY) { + REG_SET_FIELD(KEYMNG_STATIC_REG, KEYMNG_PSRAM_KEY_LEN, key_len); + } } /* @brief Get the XTS-AES (Flash Encryption) key length for the Key Manager */ -static inline esp_key_mgr_xts_aes_key_len_t key_mgr_ll_get_xts_aes_key_len(void) +static inline esp_key_mgr_xts_aes_key_len_t key_mgr_ll_get_xts_aes_key_len(const esp_key_mgr_key_type_t key_type) { - return (esp_key_mgr_xts_aes_key_len_t) REG_GET_FIELD(KEYMNG_STATIC_REG, KEYMNG_FLASH_KEY_LEN); + if (key_type == ESP_KEY_MGR_PSRAM_128_KEY || key_type == ESP_KEY_MGR_PSRAM_256_KEY) { + return (esp_key_mgr_xts_aes_key_len_t) REG_GET_FIELD(KEYMNG_STATIC_REG, KEYMNG_PSRAM_KEY_LEN); + } else { + return (esp_key_mgr_xts_aes_key_len_t) REG_GET_FIELD(KEYMNG_STATIC_REG, KEYMNG_FLASH_KEY_LEN); + } } /** diff --git a/components/hal/esp32p4/include/hal/key_mgr_ll.h b/components/hal/esp32p4/include/hal/key_mgr_ll.h index e098b9c368..7e7be21d50 100644 --- a/components/hal/esp32p4/include/hal/key_mgr_ll.h +++ b/components/hal/esp32p4/include/hal/key_mgr_ll.h @@ -19,6 +19,7 @@ #include "hal/key_mgr_types.h" #include "soc/keymng_reg.h" #include "soc/hp_sys_clkrst_struct.h" +#include "esp_private/esp_crypto_lock_internal.h" #ifdef __cplusplus extern "C" { @@ -158,7 +159,8 @@ static inline void key_mgr_ll_use_sw_init_key(void) static inline void key_mgr_ll_set_key_usage(const esp_key_mgr_key_type_t key_type, const esp_key_mgr_key_usage_t key_usage) { switch (key_type) { - case ESP_KEY_MGR_ECDSA_KEY: + case ESP_KEY_MGR_ECDSA_192_KEY: + case ESP_KEY_MGR_ECDSA_256_KEY: if (key_usage == ESP_KEY_MGR_USE_EFUSE_KEY) { REG_SET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_ECDSA); } else { @@ -182,7 +184,8 @@ static inline void key_mgr_ll_set_key_usage(const esp_key_mgr_key_type_t key_typ static inline esp_key_mgr_key_usage_t key_mgr_ll_get_key_usage(esp_key_mgr_key_type_t key_type) { switch (key_type) { - case ESP_KEY_MGR_ECDSA_KEY: + case ESP_KEY_MGR_ECDSA_192_KEY: + case ESP_KEY_MGR_ECDSA_256_KEY: return (esp_key_mgr_key_usage_t) (REG_GET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_ECDSA)); break; @@ -216,20 +219,38 @@ static inline void key_mgr_ll_lock_use_sw_init_key_reg(void) static inline void key_mgr_ll_lock_use_efuse_key_reg(esp_key_mgr_key_type_t key_type) { switch(key_type) { - case ESP_KEY_MGR_ECDSA_KEY: + case ESP_KEY_MGR_ECDSA_192_KEY: + case ESP_KEY_MGR_ECDSA_256_KEY: REG_SET_BIT(KEYMNG_LOCK_REG, KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA); break; case ESP_KEY_MGR_XTS_AES_128_KEY: case ESP_KEY_MGR_XTS_AES_256_KEY: REG_SET_BIT(KEYMNG_LOCK_REG, KEYMNG_USE_EFUSE_KEY_LOCK_XTS); break; + default: + HAL_ASSERT(false && "Unsupported key type"); + return; } } /* @brief Configure the key purpose to be used by the Key Manager for key generator operation */ static inline void key_mgr_ll_set_key_purpose(const esp_key_mgr_key_purpose_t key_purpose) { - REG_SET_FIELD(KEYMNG_CONF_REG, KEYMNG_KEY_PURPOSE, key_purpose); + switch(key_purpose) { + case ESP_KEY_MGR_KEY_PURPOSE_ECDSA_192: + case ESP_KEY_MGR_KEY_PURPOSE_ECDSA_256: + REG_SET_FIELD(KEYMNG_CONF_REG, KEYMNG_KEY_PURPOSE, KEYMNG_KEY_PURPOSE_ECDSA); + break; + case ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1: + REG_SET_FIELD(KEYMNG_CONF_REG, KEYMNG_KEY_PURPOSE, KEYMNG_KEY_PURPOSE_XTS_AES_256_1); + break; + case ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2: + REG_SET_FIELD(KEYMNG_CONF_REG, KEYMNG_KEY_PURPOSE, KEYMNG_KEY_PURPOSE_XTS_AES_256_2); + break; + default: + HAL_ASSERT(false && "Unsupported mode"); + return; + } } /** @@ -259,7 +280,8 @@ static inline bool key_mgr_ll_is_key_deployment_valid(const esp_key_mgr_key_type { switch (key_type) { - case ESP_KEY_MGR_ECDSA_KEY: + case ESP_KEY_MGR_ECDSA_192_KEY: + case ESP_KEY_MGR_ECDSA_256_KEY: return REG_GET_FIELD(KEYMNG_KEY_VLD_REG, KEYMNG_KEY_ECDSA_VLD); break; diff --git a/components/hal/hmac_hal.c b/components/hal/hmac_hal.c index 59dcc1f945..99bb565863 100644 --- a/components/hal/hmac_hal.c +++ b/components/hal/hmac_hal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,11 @@ #include "stdio.h" #include "hal/hmac_hal.h" #include "hal/hmac_ll.h" +#include "soc/soc_caps.h" + +#if SOC_KEY_MANAGER_HMAC_KEY_DEPLOY +#include "hal/key_mgr_hal.h" +#endif void hmac_hal_start(void) { @@ -18,6 +23,20 @@ uint32_t hmac_hal_configure(hmac_hal_output_t config, uint32_t key_id) { hmac_ll_wait_idle(); hmac_ll_config_output(config); + +#if SOC_KEY_MANAGER_HMAC_KEY_DEPLOY + if (key_id == HMAC_KEY_KM) { + if (config == HMAC_OUTPUT_USER) { + key_mgr_hal_set_key_usage(ESP_KEY_MGR_HMAC_KEY, ESP_KEY_MGR_USE_OWN_KEY); + } else { + // No other HMAC output type is allowed when using key manager + return 1; + } + } else { + key_mgr_hal_set_key_usage(ESP_KEY_MGR_HMAC_KEY, ESP_KEY_MGR_USE_EFUSE_KEY); + } +#endif + hmac_ll_config_hw_key_id(key_id); hmac_ll_config_finish(); hmac_ll_wait_idle(); diff --git a/components/hal/huk_hal.c b/components/hal/huk_hal.c index 70aa576459..c9f9e51399 100644 --- a/components/hal/huk_hal.c +++ b/components/hal/huk_hal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -13,6 +13,7 @@ #include "hal/log.h" #include "rom/km.h" #include "esp_err.h" +#include "soc/soc_caps.h" esp_huk_state_t huk_hal_get_state(void) { @@ -28,11 +29,11 @@ static void inline huk_hal_wait_for_state(esp_huk_state_t state) esp_err_t huk_hal_configure(const esp_huk_mode_t huk_mode, uint8_t *huk_info_buf) { - if (esp_rom_km_huk_conf(huk_mode, huk_info_buf) == ETS_OK) { - return ESP_OK; - } else { + if (esp_rom_km_huk_conf(huk_mode, huk_info_buf) != ETS_OK) { return ESP_FAIL; } + + return ESP_OK; } uint8_t huk_hal_get_risk_level(void) @@ -44,3 +45,10 @@ uint32_t huk_hal_get_date_info(void) { return huk_ll_get_date_info(); } + +#if SOC_HUK_MEM_NEEDS_RECHARGE +void huk_hal_recharge_huk_memory(void) +{ + huk_ll_recharge_huk_memory(); +} +#endif diff --git a/components/hal/include/hal/ds_hal.h b/components/hal/include/hal/ds_hal.h index bf9a18df5d..766854d8b9 100644 --- a/components/hal/include/hal/ds_hal.h +++ b/components/hal/include/hal/ds_hal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -15,6 +15,7 @@ #include #include #include +#include "soc/soc_caps.h" #include "hal/ds_types.h" #ifdef __cplusplus @@ -38,6 +39,13 @@ void ds_hal_finish(void); */ void ds_hal_configure_iv(const uint32_t *iv); +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY +/** + * @brief Set the DS key source. + */ +void ds_hal_set_key_source(ds_key_source_t key_source); +#endif + /** * @brief Write the message which should be signed. * diff --git a/components/hal/include/hal/ds_types.h b/components/hal/include/hal/ds_types.h index f739a11b66..7734a6fae1 100644 --- a/components/hal/include/hal/ds_types.h +++ b/components/hal/include/hal/ds_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,6 +9,8 @@ extern "C" { #endif +#include "soc/soc_caps.h" + /** * The result when checking whether the key to decrypt the RSA parameters is ready. */ @@ -25,6 +27,13 @@ typedef enum { DS_SIGNATURE_PADDING_AND_MD_FAIL = 3, /**< Both padding and MD check failed. */ } ds_signature_check_t; +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY +typedef enum { + DS_KEY_SOURCE_EFUSE = 0, + DS_KEY_SOURCE_KEY_MGR = 1, +} ds_key_source_t; +#endif + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/hmac_types.h b/components/hal/include/hal/hmac_types.h index af309b3fe5..5be28942d6 100644 --- a/components/hal/include/hal/hmac_types.h +++ b/components/hal/include/hal/hmac_types.h @@ -1,14 +1,31 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once +#include "soc/soc_caps.h" #ifdef __cplusplus extern "C" { #endif +/** + * The possible efuse keys for the HMAC peripheral + */ +typedef enum { + HMAC_KEY0 = 0, + HMAC_KEY1, + HMAC_KEY2, + HMAC_KEY3, + HMAC_KEY4, + HMAC_KEY5, +#if SOC_KEY_MANAGER_HMAC_KEY_DEPLOY + HMAC_KEY_KM = 7, +#endif + HMAC_KEY_MAX = 8, +} hmac_key_id_t; + /** * The HMAC peripheral can be configured to deliver its output to the user directly, or to deliver * the output directly to another peripheral instead, e.g. the Digital Signature peripheral. diff --git a/components/hal/include/hal/huk_hal.h b/components/hal/include/hal/huk_hal.h index e158f1fc66..3bdd04c896 100644 --- a/components/hal/include/hal/huk_hal.h +++ b/components/hal/include/hal/huk_hal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,7 +9,7 @@ #include "soc/soc_caps.h" -#if SOC_KEY_MANAGER_SUPPORTED +#if SOC_HUK_SUPPORTED #include "hal/huk_types.h" #include #include "esp_err.h" @@ -51,6 +51,13 @@ uint8_t huk_hal_get_risk_level(void); */ uint32_t huk_hal_get_date_info(void); +#if SOC_HUK_MEM_NEEDS_RECHARGE +/** + * @brief Recharge HUK memory + */ +void huk_hal_recharge_huk_memory(void); +#endif + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/huk_types.h b/components/hal/include/hal/huk_types.h index 8812fe6f2f..a0f6319313 100644 --- a/components/hal/include/hal/huk_types.h +++ b/components/hal/include/hal/huk_types.h @@ -11,12 +11,12 @@ #include "esp_assert.h" #include "rom/km.h" +#include "rom/key_mgr.h" #ifdef __cplusplus extern "C" { #endif -#define HUK_INFO_SIZE 384 #define HUK_RISK_ALERT_LEVEL 4 /** @@ -35,7 +35,7 @@ ESP_STATIC_ASSERT(sizeof(esp_huk_mode_t) == sizeof(huk_mode_t), "Size of esp_huk */ typedef enum { ESP_HUK_STATE_IDLE = 0, /* Key Manager is idle */ - ESP_HUK_STATE_LOAD, /* Key Manager is read to recieve input */ + ESP_HUK_STATE_LOAD, /* Key Manager is read to receive input */ ESP_HUK_STATE_GAIN, /* Key Manager is ready to provide output */ ESP_HUK_STATE_BUSY /* Key Manager is busy */ } esp_huk_state_t; diff --git a/components/hal/include/hal/key_mgr_hal.h b/components/hal/include/hal/key_mgr_hal.h index 8a3ca092dc..8434601a5d 100644 --- a/components/hal/include/hal/key_mgr_hal.h +++ b/components/hal/include/hal/key_mgr_hal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -111,11 +111,11 @@ void key_mgr_hal_write_public_info(const uint8_t *public_info_buf, const size_t */ void key_mgr_hal_read_public_info(uint8_t *public_info_buf, const size_t read_len); -/* @brief Set the AES-XTS key length for the Key Manager */ -void key_mgr_hal_set_xts_aes_key_len(const esp_key_mgr_xts_aes_key_len_t key_len); +/* @brief Set the XTS-AES key length for the Key Manager */ +void key_mgr_hal_set_xts_aes_key_len(const esp_key_mgr_key_type_t key_type, const esp_key_mgr_xts_aes_key_len_t key_len); -/* @brief Get the AES-XTS key length for the Key Manager */ -esp_key_mgr_xts_aes_key_len_t key_mgr_hal_get_aes_xts_key_len(void); +/* @brief Get the XTS-AES key length for the Key Manager */ +esp_key_mgr_xts_aes_key_len_t key_mgr_hal_get_xts_aes_key_len(const esp_key_mgr_key_type_t key_type); /** * @brief Read state of Key Manager diff --git a/components/hal/include/hal/key_mgr_types.h b/components/hal/include/hal/key_mgr_types.h index 31ea39aeb4..550b333621 100644 --- a/components/hal/include/hal/key_mgr_types.h +++ b/components/hal/include/hal/key_mgr_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -30,17 +30,31 @@ typedef enum { * @brief Length of the XTS AES key */ typedef enum { - ESP_KEY_MGR_XTS_AES_LEN_256 = 0, /* xts-aes key is 256 bit, please note that xts-aes algorithm is XTS_AES_128*/ - ESP_KEY_MGR_XTS_AES_LEN_512, /* xts-aes key is 512 bit, please note that xts-aes algorithm is XTS_AES_256 */ + ESP_KEY_MGR_XTS_AES_LEN_256 = 0, /* xts-aes key is 256 bit, please note that xts-aes algorithm is XTS_AES_128 */ + ESP_KEY_MGR_XTS_AES_LEN_512, /* xts-aes key is 512 bit, please note that xts-aes algorithm is XTS_AES_256 */ } esp_key_mgr_xts_aes_key_len_t; +/** + * @brief Length of the PSRAM key + */ +typedef enum { + ESP_KEY_MGR_PSRAM_LEN_256 = 0, /* psram key is 256 bit, please note that xts-aes algorithm is XTS_AES_128 */ + ESP_KEY_MGR_PSRAM_LEN_512, /* psram key is 512 bit, please note that xts-aes algorithm is XTS_AES_256 */ +} esp_key_mgr_psram_key_len_t; + /** * @brief Type of the key: ECDSA, XTS */ typedef enum { - ESP_KEY_MGR_ECDSA_KEY = 0, /* ECDSA key */ - ESP_KEY_MGR_XTS_AES_128_KEY, /* XTS-AES 128 key */ - ESP_KEY_MGR_XTS_AES_256_KEY, /* XTS-AES 256 key */ + ESP_KEY_MGR_XTS_AES_128_KEY, /* XTS-AES 128-bit key */ + ESP_KEY_MGR_XTS_AES_256_KEY, /* XTS-AES 256-bit key */ + ESP_KEY_MGR_ECDSA_192_KEY, /* ECDSA 192-bit key */ + ESP_KEY_MGR_ECDSA_256_KEY, /* ECDSA 256-bit key */ + ESP_KEY_MGR_ECDSA_384_KEY, /* ECDSA 384-bit key */ + ESP_KEY_MGR_HMAC_KEY, /* HMAC key */ + ESP_KEY_MGR_DS_KEY, /* Digital signature key */ + ESP_KEY_MGR_PSRAM_128_KEY, /* PSRAM 128-bit key */ + ESP_KEY_MGR_PSRAM_256_KEY, /* PSRAM 256-bit key */ } esp_key_mgr_key_type_t; /* @@ -48,7 +62,7 @@ typedef enum { */ typedef enum { ESP_KEY_MGR_USE_OWN_KEY = 0, /* Use key from the key manager */ - ESP_KEY_MGR_USE_EFUSE_KEY, /* Use key from the eFuse */ + ESP_KEY_MGR_USE_EFUSE_KEY, /* Use key from the eFuse */ ESP_KEY_MGR_USAGE_INVALID, } esp_key_mgr_key_usage_t; @@ -56,10 +70,21 @@ typedef enum { * @brief Key Purpose to be set for a particular key in the Key Manager */ typedef enum { - ESP_KEY_MGR_KEY_PURPOSE_ECDSA = 1, - ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1 = 2, /* First half of the XTS AES 256 bit key */ - ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 = 3, /* Second half of the XTS AES 256 bit key */ - ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_128 = 4, /* XTS AES 128 bit key */ + ESP_KEY_MGR_KEY_PURPOSE_ECDSA_192 = 1, /* ECDSA 192-bit key */ + ESP_KEY_MGR_KEY_PURPOSE_ECDSA_256 = 2, /* ECDSA 256-bit key */ + ESP_KEY_MGR_KEY_PURPOSE_FLASH_256_1 = 3, /* First half of flash 256-bit key */ + ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_1 = ESP_KEY_MGR_KEY_PURPOSE_FLASH_256_1, + ESP_KEY_MGR_KEY_PURPOSE_FLASH_256_2 = 4, /* Second half of flash 256-bit key */ + ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_256_2 = ESP_KEY_MGR_KEY_PURPOSE_FLASH_256_2, + ESP_KEY_MGR_KEY_PURPOSE_FLASH_128 = 5, /* Flash 128-bit key */ + ESP_KEY_MGR_KEY_PURPOSE_XTS_AES_128 = ESP_KEY_MGR_KEY_PURPOSE_FLASH_128, + ESP_KEY_MGR_KEY_PURPOSE_HMAC = 6, /* HMAC key */ + ESP_KEY_MGR_KEY_PURPOSE_DS = 7, /* Digital signature key */ + ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_1 = 8, /* First half of PSRAM 256-bit key */ + ESP_KEY_MGR_KEY_PURPOSE_PSRAM_256_2 = 9, /* Second half of PSRAM 256-bit key */ + ESP_KEY_MGR_KEY_PURPOSE_PSRAM_128 = 10, /* PSRAM 128-bit key */ + ESP_KEY_MGR_KEY_PURPOSE_ECDSA_384_L = 11, /* Lower half of ECDSA 384-bit key */ + ESP_KEY_MGR_KEY_PURPOSE_ECDSA_384_H = 12, /* Higher half of ECDSA 384-bit key */ } esp_key_mgr_key_purpose_t; /** @@ -86,7 +111,7 @@ typedef enum { // store huk info, occupy 96 words typedef struct PACKED_ATTR { -#define HUK_INFO_LEN 384 +#define HUK_INFO_LEN 660 uint8_t info[HUK_INFO_LEN]; uint32_t crc; } esp_key_mgr_huk_info_t; diff --git a/components/hal/key_mgr_hal.c b/components/hal/key_mgr_hal.c index 3658371fd5..5dcb67f5b2 100644 --- a/components/hal/key_mgr_hal.c +++ b/components/hal/key_mgr_hal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -79,14 +79,14 @@ bool key_mgr_hal_is_huk_valid(void) return key_mgr_ll_is_huk_valid(); } -void key_mgr_hal_set_xts_aes_key_len(const esp_key_mgr_xts_aes_key_len_t key_len) +void key_mgr_hal_set_xts_aes_key_len(const esp_key_mgr_key_type_t key_type, const esp_key_mgr_xts_aes_key_len_t key_len) { - key_mgr_ll_set_xts_aes_key_len(key_len); + key_mgr_ll_set_xts_aes_key_len(key_type, key_len); } -esp_key_mgr_xts_aes_key_len_t key_mgr_hal_get_xts_aes_key_len(void) +esp_key_mgr_xts_aes_key_len_t key_mgr_hal_get_xts_aes_key_len(const esp_key_mgr_key_type_t key_type) { - return key_mgr_ll_get_xts_aes_key_len(); + return key_mgr_ll_get_xts_aes_key_len(key_type); } void key_mgr_hal_continue(void) diff --git a/components/hal/mpi_hal.c b/components/hal/mpi_hal.c index 8302ae847a..014ab14655 100644 --- a/components/hal/mpi_hal.c +++ b/components/hal/mpi_hal.c @@ -15,7 +15,6 @@ size_t mpi_hal_calc_hardware_words(size_t words) void mpi_hal_enable_hardware_hw_op(void) { - mpi_ll_power_up(); while (mpi_ll_check_memory_init_complete()) { } // Note: from enabling RSA clock to here takes about 1.3us @@ -27,7 +26,7 @@ void mpi_hal_enable_hardware_hw_op(void) void mpi_hal_disable_hardware_hw_op(void) { - mpi_ll_power_down(); + } void mpi_hal_interrupt_enable(bool enable) diff --git a/components/hal/test_apps/crypto/main/aes/aes_block.c b/components/hal/test_apps/crypto/main/aes/aes_block.c index d64beb007d..15de815e8c 100644 --- a/components/hal/test_apps/crypto/main/aes/aes_block.c +++ b/components/hal/test_apps/crypto/main/aes/aes_block.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: CC0-1.0 */ @@ -8,7 +8,7 @@ #include #include -#include "esp_private/esp_crypto_lock_internal.h" +#include "esp_crypto_periph_clk.h" #include "hal/aes_types.h" #include "hal/aes_hal.h" #include "hal/aes_ll.h" @@ -30,10 +30,7 @@ void aes_crypt_cbc_block(int mode, uint32_t *iv_words = (uint32_t *)iv; unsigned char temp[16]; - AES_RCC_ATOMIC() { - aes_ll_enable_bus_clock(true); - aes_ll_reset_register(); - } + esp_crypto_aes_enable_periph_clk(true); /* Sets the key used for AES encryption/decryption */ aes_hal_setkey(key, key_bytes, mode); @@ -71,9 +68,7 @@ void aes_crypt_cbc_block(int mode, } } - AES_RCC_ATOMIC() { - aes_ll_enable_bus_clock(false); - } + esp_crypto_aes_enable_periph_clk(false); } @@ -89,10 +84,7 @@ void aes_crypt_ctr_block(uint8_t key_bytes, int c, i; size_t n = *nc_off; - AES_RCC_ATOMIC() { - aes_ll_enable_bus_clock(true); - aes_ll_reset_register(); - } + esp_crypto_aes_enable_periph_clk(true); /* Sets the key used for AES encryption/decryption */ aes_hal_setkey(key, key_bytes, ESP_AES_ENCRYPT); @@ -113,9 +105,7 @@ void aes_crypt_ctr_block(uint8_t key_bytes, *nc_off = n; - AES_RCC_ATOMIC() { - aes_ll_enable_bus_clock(false); - } + esp_crypto_aes_enable_periph_clk(false); } #endif diff --git a/components/hal/test_apps/crypto/main/ds/ds_types.h b/components/hal/test_apps/crypto/main/ds/ds_types.h new file mode 100644 index 0000000000..6b82bf20fe --- /dev/null +++ b/components/hal/test_apps/crypto/main/ds/ds_types.h @@ -0,0 +1,47 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ +#include +#include "soc/soc_caps.h" + +#define ESP_ERR_HW_CRYPTO_DS_HMAC_FAIL (0x1) /*!< HMAC peripheral problem */ +#define ESP_ERR_HW_CRYPTO_DS_INVALID_KEY (0x2) /*!< given HMAC key isn't correct, HMAC peripheral problem */ +#define ESP_ERR_HW_CRYPTO_DS_INVALID_DIGEST (0x4) /*!< message digest check failed, result is invalid */ +#define ESP_ERR_HW_CRYPTO_DS_INVALID_PADDING (0x5) /*!< padding check failed, but result is produced anyway and can be read*/ + +#define ESP_DS_IV_BIT_LEN 128 +#define ESP_DS_IV_LEN (ESP_DS_IV_BIT_LEN / 8) +#define ESP_DS_SIGNATURE_MAX_BIT_LEN SOC_RSA_MAX_BIT_LEN +#define ESP_DS_SIGNATURE_MD_BIT_LEN 256 +#define ESP_DS_SIGNATURE_M_PRIME_BIT_LEN 32 +#define ESP_DS_SIGNATURE_L_BIT_LEN 32 +#define ESP_DS_SIGNATURE_PADDING_BIT_LEN 64 + +#define ESP_DS_C_LEN (((ESP_DS_SIGNATURE_MAX_BIT_LEN * 3 \ + + ESP_DS_SIGNATURE_MD_BIT_LEN \ + + ESP_DS_SIGNATURE_M_PRIME_BIT_LEN \ + + ESP_DS_SIGNATURE_L_BIT_LEN \ + + ESP_DS_SIGNATURE_PADDING_BIT_LEN) / 8)) + +typedef enum { + ESP_DS_RSA_1024 = (1024 / 32) - 1, + ESP_DS_RSA_2048 = (2048 / 32) - 1, + ESP_DS_RSA_3072 = (3072 / 32) - 1, + ESP_DS_RSA_4096 = (4096 / 32) - 1 +} esp_digital_signature_length_t; + +typedef struct esp_digital_signature_data { + esp_digital_signature_length_t rsa_length; + uint32_t iv[ESP_DS_IV_BIT_LEN / 32]; + uint8_t c[ESP_DS_C_LEN]; +} esp_ds_data_t; + +typedef struct { + uint32_t Y[ESP_DS_SIGNATURE_MAX_BIT_LEN / 32]; + uint32_t M[ESP_DS_SIGNATURE_MAX_BIT_LEN / 32]; + uint32_t Rb[ESP_DS_SIGNATURE_MAX_BIT_LEN / 32]; + uint32_t M_prime; + uint32_t length; +} esp_ds_p_data_t; diff --git a/components/hal/test_apps/crypto/main/ds/test_ds.c b/components/hal/test_apps/crypto/main/ds/test_ds.c index ab8654623b..e56d2f3c57 100644 --- a/components/hal/test_apps/crypto/main/ds/test_ds.c +++ b/components/hal/test_apps/crypto/main/ds/test_ds.c @@ -13,84 +13,23 @@ #include "soc/soc_caps.h" #include "esp_log.h" +#include "ds_types.h" const static char *TAG = "test_ds"; #include "rom/efuse.h" -#if CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/rom/digital_signature.h" -#include "esp32s2/rom/aes.h" -#include "esp32s2/rom/sha.h" -#include "esp32s2/rom/hmac.h" -#include "soc/soc_memory_layout.h" -#elif CONFIG_IDF_TARGET_ESP32C3 -#include "esp32c3/rom/digital_signature.h" -#include "esp32c3/rom/hmac.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/rom/digital_signature.h" -#include "esp32s3/rom/aes.h" -#include "esp32s3/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32C6 -#include "esp32c6/rom/digital_signature.h" -#include "esp32c6/rom/aes.h" -#include "esp32c6/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32H2 -#include "esp32h2/rom/digital_signature.h" -#include "esp32h2/rom/aes.h" -#include "esp32h2/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32P4 -#include "esp32p4/rom/digital_signature.h" -#include "esp32p4/rom/aes.h" -#include "esp32p4/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32C5 -#include "esp32c5/rom/digital_signature.h" -#include "esp32c5/rom/aes.h" -#include "esp32c5/rom/sha.h" -#elif CONFIG_IDF_TARGET_ESP32H21 -#include "esp32h21/rom/digital_signature.h" -#include "esp32h21/rom/aes.h" -#include "esp32h21/rom/sha.h" +#include "rom/sha.h" +#include "rom/digital_signature.h" +#include "rom/aes.h" +#include "rom/hmac.h" + +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY +#include "hal/key_mgr_ll.h" #endif -#define ESP_ERR_HW_CRYPTO_DS_HMAC_FAIL (0x1) /*!< HMAC peripheral problem */ -#define ESP_ERR_HW_CRYPTO_DS_INVALID_KEY (0x2) /*!< given HMAC key isn't correct, HMAC peripheral problem */ -#define ESP_ERR_HW_CRYPTO_DS_INVALID_DIGEST (0x4) /*!< message digest check failed, result is invalid */ -#define ESP_ERR_HW_CRYPTO_DS_INVALID_PADDING (0x5) /*!< padding check failed, but result is produced anyway and can be read*/ - -#define ESP_DS_IV_BIT_LEN 128 -#define ESP_DS_IV_LEN (ESP_DS_IV_BIT_LEN / 8) -#define ESP_DS_SIGNATURE_MAX_BIT_LEN SOC_RSA_MAX_BIT_LEN -#define ESP_DS_SIGNATURE_MD_BIT_LEN 256 -#define ESP_DS_SIGNATURE_M_PRIME_BIT_LEN 32 -#define ESP_DS_SIGNATURE_L_BIT_LEN 32 -#define ESP_DS_SIGNATURE_PADDING_BIT_LEN 64 - -#define ESP_DS_C_LEN (((ESP_DS_SIGNATURE_MAX_BIT_LEN * 3 \ - + ESP_DS_SIGNATURE_MD_BIT_LEN \ - + ESP_DS_SIGNATURE_M_PRIME_BIT_LEN \ - + ESP_DS_SIGNATURE_L_BIT_LEN \ - + ESP_DS_SIGNATURE_PADDING_BIT_LEN) / 8)) - -typedef enum { - ESP_DS_RSA_1024 = (1024 / 32) - 1, - ESP_DS_RSA_2048 = (2048 / 32) - 1, - ESP_DS_RSA_3072 = (3072 / 32) - 1, - ESP_DS_RSA_4096 = (4096 / 32) - 1 -} esp_digital_signature_length_t; - -typedef struct esp_digital_signature_data { - esp_digital_signature_length_t rsa_length; - uint32_t iv[ESP_DS_IV_BIT_LEN / 32]; - uint8_t c[ESP_DS_C_LEN]; -} esp_ds_data_t; - -typedef struct { - uint32_t Y[ESP_DS_SIGNATURE_MAX_BIT_LEN / 32]; - uint32_t M[ESP_DS_SIGNATURE_MAX_BIT_LEN / 32]; - uint32_t Rb[ESP_DS_SIGNATURE_MAX_BIT_LEN / 32]; - uint32_t M_prime; - uint32_t length; -} esp_ds_p_data_t; +#if CONFIG_IDF_TARGET_ESP32S2 +#include "soc/soc_memory_layout.h" +#endif #define NUM_RESULTS 10 @@ -128,43 +67,23 @@ _Static_assert(NUM_RESULTS == NUM_MESSAGES, "expected_results size should be the #include "hal/hmac_hal.h" #include "hal/hmac_ll.h" #include "hal/sha_ll.h" - +#include "esp_crypto_periph_clk.h" static void ds_acquire_enable(void) { - HMAC_RCC_ATOMIC() { - hmac_ll_enable_bus_clock(true); - hmac_ll_reset_register(); - } - - SHA_RCC_ATOMIC() { - sha_ll_enable_bus_clock(true); - sha_ll_reset_register(); - } - - DS_RCC_ATOMIC() { - ds_ll_enable_bus_clock(true); - ds_ll_reset_register(); - } - - hmac_hal_start(); + // We also enable SHA and HMAC here. SHA is used by HMAC, HMAC is used by DS. + esp_crypto_hmac_enable_periph_clk(true); + esp_crypto_sha_enable_periph_clk(true); + esp_crypto_mpi_enable_periph_clk(true); + esp_crypto_ds_enable_periph_clk(true); } static void ds_disable_release(void) { - ds_hal_finish(); - - DS_RCC_ATOMIC() { - ds_ll_enable_bus_clock(false); - } - - SHA_RCC_ATOMIC() { - sha_ll_enable_bus_clock(false); - } - - HMAC_RCC_ATOMIC() { - hmac_ll_enable_bus_clock(false); - } + esp_crypto_mpi_enable_periph_clk(false); + esp_crypto_sha_enable_periph_clk(false); + esp_crypto_hmac_enable_periph_clk(false); + esp_crypto_ds_enable_periph_clk(false); } @@ -172,11 +91,22 @@ static esp_err_t esp_ds_start_sign(const void *message, const esp_ds_data_t *dat { ds_acquire_enable(); - uint32_t conf_error = hmac_hal_configure(HMAC_OUTPUT_DS, key_id); - if (conf_error) { - ds_disable_release(); - return ESP_ERR_HW_CRYPTO_DS_HMAC_FAIL; +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY + if (key_id == HMAC_KEY_KM) { + ds_hal_set_key_source(DS_KEY_SOURCE_KEY_MGR); + } else { + ds_hal_set_key_source(DS_KEY_SOURCE_EFUSE); +#endif + hmac_hal_start(); + uint32_t conf_error = hmac_hal_configure(HMAC_OUTPUT_DS, key_id); + if (conf_error) { + ds_disable_release(); + ESP_LOGE(TAG, "HMAC configure failed"); + return ESP_ERR_HW_CRYPTO_DS_HMAC_FAIL; + } +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY } +#endif ds_hal_start(); @@ -211,13 +141,13 @@ static esp_err_t esp_ds_finish_sign(void *signature, const esp_ds_data_t *data) } hmac_hal_clean(); - + ds_hal_finish(); ds_disable_release(); return return_value; } -static esp_err_t esp_ds_sign(const void *message, +esp_err_t esp_ds_sign(const void *message, const esp_ds_data_t *data, uint32_t key_id, void *signature) @@ -287,8 +217,8 @@ static void ds_disable_release(void) } static esp_err_t esp_ds_start_sign(const void *message, - const esp_ds_data_t *data, - uint32_t key_id) + const esp_ds_data_t *data, + uint32_t key_id) { ds_acquire_enable(); diff --git a/components/hal/test_apps/crypto/main/ecc/test_ecc.c b/components/hal/test_apps/crypto/main/ecc/test_ecc.c index 433915e575..603771d081 100644 --- a/components/hal/test_apps/crypto/main/ecc/test_ecc.c +++ b/components/hal/test_apps/crypto/main/ecc/test_ecc.c @@ -9,7 +9,7 @@ #include #include #include "sdkconfig.h" -#include "esp_private/esp_crypto_lock_internal.h" +#include "esp_crypto_periph_clk.h" #include "esp_log.h" #include "ecc_params.h" #include "soc/soc_caps.h" @@ -43,24 +43,6 @@ static void ecc_be_to_le(const uint8_t* be_point, uint8_t *le_point, uint8_t len } } -static void ecc_enable_and_reset(void) -{ - ECC_RCC_ATOMIC() { - ecc_ll_enable_bus_clock(true); - ecc_ll_power_up(); - ecc_ll_reset_register(); - } -} - -static void ecc_disable(void) -{ - ECC_RCC_ATOMIC() { - ecc_ll_enable_bus_clock(false); - ecc_ll_power_down(); - } -} - - TEST_GROUP(ecc); TEST_SETUP(ecc) @@ -79,7 +61,7 @@ TEST_TEAR_DOWN(ecc) static void ecc_point_mul(const uint8_t *k_le, const uint8_t *x_le, const uint8_t *y_le, uint8_t len, bool verify_first, uint8_t *res_x_le, uint8_t *res_y_le) { - ecc_enable_and_reset(); + esp_crypto_ecc_enable_periph_clk(true); ecc_hal_write_mul_param(k_le, x_le, y_le, len); if (verify_first) { @@ -95,7 +77,7 @@ static void ecc_point_mul(const uint8_t *k_le, const uint8_t *x_le, const uint8_ } ecc_hal_read_mul_result(res_x_le, res_y_le, len); - ecc_disable(); + esp_crypto_ecc_enable_periph_clk(false); } static void test_ecc_point_mul_inner(bool verify_first) @@ -161,7 +143,7 @@ TEST(ecc, ecc_point_multiplication_on_SECP192R1_and_SECP256R1) #if SOC_ECC_CONSTANT_TIME_POINT_MUL -#define CONST_TIME_DEVIATION_PERCENT 0.002 +#define CONST_TIME_DEVIATION_PERCENT 0.0025 static void test_ecc_point_mul_inner_constant_time(void) { @@ -237,7 +219,7 @@ TEST(ecc, ecc_point_multiplication_const_time_check_on_SECP192R1_and_SECP256R1) #if SOC_ECC_SUPPORT_POINT_VERIFY && !defined(SOC_ECC_SUPPORT_POINT_VERIFY_QUIRK) static int ecc_point_verify(const uint8_t *x_le, const uint8_t *y_le, uint8_t len) { - ecc_enable_and_reset(); + esp_crypto_ecc_enable_periph_clk(true); ecc_hal_write_verify_param(x_le, y_le, len); ecc_hal_set_mode(ECC_MODE_VERIFY); @@ -248,7 +230,7 @@ static int ecc_point_verify(const uint8_t *x_le, const uint8_t *y_le, uint8_t le } int ret = ecc_hal_read_verify_result(); - ecc_disable(); + esp_crypto_ecc_enable_periph_clk(false); return ret; } @@ -297,7 +279,7 @@ TEST(ecc, ecc_point_verification_and_multiplication_on_SECP192R1_and_SECP256R1) #if SOC_ECC_SUPPORT_POINT_DIVISION static void ecc_point_inv_mul(const uint8_t *num_le, const uint8_t *deno_le, uint8_t len, uint8_t *res_le) { - ecc_enable_and_reset(); + esp_crypto_ecc_enable_periph_clk(true); uint8_t zero[32] = {0}; ecc_hal_write_mul_param(zero, num_le, deno_le, len); @@ -311,7 +293,7 @@ static void ecc_point_inv_mul(const uint8_t *num_le, const uint8_t *deno_le, uin } ecc_hal_read_mul_result(zero, res_le, len); - ecc_disable(); + esp_crypto_ecc_enable_periph_clk(false); } TEST(ecc, ecc_inverse_multiplication_or_mod_division_using_SECP192R1_and_SECP256R1_order_of_curve) @@ -329,7 +311,7 @@ TEST(ecc, ecc_inverse_multiplication_or_mod_division_using_SECP192R1_and_SECP256 static void ecc_jacob_mul(uint8_t *k_le, uint8_t *x_le, uint8_t *y_le, uint8_t len, bool verify_first, uint8_t *res_x_le, uint8_t *res_y_le, uint8_t *res_z_le) { - ecc_enable_and_reset(); + esp_crypto_ecc_enable_periph_clk(true); ecc_hal_write_mul_param(k_le, x_le, y_le, len); if (verify_first) { @@ -344,7 +326,7 @@ static void ecc_jacob_mul(uint8_t *k_le, uint8_t *x_le, uint8_t *y_le, uint8_t l } ecc_hal_read_jacob_mul_result(res_x_le, res_y_le, res_z_le, len); - ecc_disable(); + esp_crypto_ecc_enable_periph_clk(false); } static void test_ecc_jacob_mul_inner(bool verify_first) @@ -393,7 +375,7 @@ TEST(ecc, ecc_jacobian_point_multiplication_on_SECP192R1_and_SECP256R1) #if SOC_ECC_SUPPORT_JACOB_POINT_VERIFY static int ecc_jacob_verify(const uint8_t *x_le, const uint8_t *y_le, const uint8_t *z_le, uint8_t len) { - ecc_enable_and_reset(); + esp_crypto_ecc_enable_periph_clk(true); ecc_hal_write_jacob_verify_param(x_le, y_le, z_le, len); @@ -406,7 +388,7 @@ static int ecc_jacob_verify(const uint8_t *x_le, const uint8_t *y_le, const uint } int ret = ecc_hal_read_verify_result(); - ecc_disable(); + esp_crypto_ecc_enable_periph_clk(false); return ret; } @@ -436,7 +418,7 @@ static void ecc_point_addition(uint8_t *px_le, uint8_t *py_le, uint8_t *qx_le, u uint8_t len, bool jacob_output, uint8_t *x_res_le, uint8_t *y_res_le, uint8_t *z_res_le) { - ecc_enable_and_reset(); + esp_crypto_ecc_enable_periph_clk(true); ecc_hal_write_point_add_param(px_le, py_le, qx_le, qy_le, qz_le, len); @@ -449,7 +431,7 @@ static void ecc_point_addition(uint8_t *px_le, uint8_t *py_le, uint8_t *qx_le, u } ecc_hal_read_point_add_result(x_res_le, y_res_le, z_res_le, len, jacob_output); - ecc_disable(); + esp_crypto_ecc_enable_periph_clk(false); } TEST(ecc, ecc_point_addition_on_SECP192R1_and_SECP256R1) @@ -508,7 +490,7 @@ TEST(ecc, ecc_point_addition_on_SECP192R1_and_SECP256R1) #if SOC_ECC_SUPPORT_MOD_ADD || SOC_ECC_SUPPORT_MOD_SUB || SOC_ECC_SUPPORT_MOD_MUL static void ecc_mod_op(ecc_mode_t mode, const uint8_t *a, const uint8_t *b, uint8_t len, uint8_t *res_le) { - ecc_enable_and_reset(); + esp_crypto_ecc_enable_periph_clk(true); ecc_hal_write_mod_op_param(a, b, len); @@ -521,7 +503,7 @@ static void ecc_mod_op(ecc_mode_t mode, const uint8_t *a, const uint8_t *b, uint } ecc_hal_read_mod_op_result(res_le, len); - ecc_disable(); + esp_crypto_ecc_enable_periph_clk(false); } #endif diff --git a/components/hal/test_apps/crypto/main/ecdsa/test_ecdsa.c b/components/hal/test_apps/crypto/main/ecdsa/test_ecdsa.c index f8bec33c46..6438ede5a5 100644 --- a/components/hal/test_apps/crypto/main/ecdsa/test_ecdsa.c +++ b/components/hal/test_apps/crypto/main/ecdsa/test_ecdsa.c @@ -10,7 +10,7 @@ #include "esp_crypto_lock.h" #include "esp_efuse_chip.h" -#include "esp_private/esp_crypto_lock_internal.h" +#include "esp_crypto_periph_clk.h" #include "esp_random.h" #include "esp_err.h" #include "esp_efuse.h" @@ -35,41 +35,20 @@ __attribute__((unused)) static const char * TAG = "crypto_test"; static void ecdsa_enable_and_reset(void) { - ECDSA_RCC_ATOMIC() { - ecdsa_ll_enable_bus_clock(true); - ecdsa_ll_reset_register(); - } - - ECC_RCC_ATOMIC() { - ecc_ll_enable_bus_clock(true); - ecc_ll_power_up(); - ecc_ll_reset_register(); - } - + esp_crypto_ecdsa_enable_periph_clk(true); + esp_crypto_ecc_enable_periph_clk(true); #ifdef SOC_ECDSA_USES_MPI - MPI_RCC_ATOMIC() { - mpi_ll_enable_bus_clock(true); - mpi_ll_reset_register(); - } + esp_crypto_mpi_enable_periph_clk(true); #endif } static void ecdsa_disable(void) { #ifdef SOC_ECDSA_USES_MPI - MPI_RCC_ATOMIC() { - mpi_ll_enable_bus_clock(false); - } + esp_crypto_mpi_enable_periph_clk(false); #endif - - ECC_RCC_ATOMIC() { - ecc_ll_enable_bus_clock(false); - ecc_ll_power_down(); - } - - ECDSA_RCC_ATOMIC() { - ecdsa_ll_enable_bus_clock(false); - } + esp_crypto_ecc_enable_periph_clk(false); + esp_crypto_ecdsa_enable_periph_clk(false); } static void ecc_be_to_le(const uint8_t* be_point, uint8_t *le_point, uint8_t len) diff --git a/components/hal/test_apps/crypto/main/hmac/test_hmac.c b/components/hal/test_apps/crypto/main/hmac/test_hmac.c index 3cffb6b8af..930d2a6566 100644 --- a/components/hal/test_apps/crypto/main/hmac/test_hmac.c +++ b/components/hal/test_apps/crypto/main/hmac/test_hmac.c @@ -1,11 +1,11 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include -#include "esp_private/esp_crypto_lock_internal.h" +#include "esp_crypto_periph_clk.h" #include "esp_log.h" #include "memory_checks.h" #include "unity_fixture.h" @@ -61,24 +61,13 @@ static void write_and_padd(uint8_t *block, const uint8_t *data, uint16_t data_le bzero(block + data_len + 1, SHA256_BLOCK_SZ - data_len - 1); } -static esp_err_t hmac_calculate(uint32_t key_id, const void *message, size_t message_len, uint8_t *hmac) +esp_err_t hmac_calculate(uint32_t key_id, const void *message, size_t message_len, uint8_t *hmac) { const uint8_t *message_bytes = (const uint8_t *)message; - HMAC_RCC_ATOMIC() { - hmac_ll_enable_bus_clock(true); - hmac_ll_reset_register(); - } - - SHA_RCC_ATOMIC() { - sha_ll_enable_bus_clock(true); - sha_ll_reset_register(); - } - - DS_RCC_ATOMIC() { - ds_ll_enable_bus_clock(true); - ds_ll_reset_register(); - } + esp_crypto_hmac_enable_periph_clk(true); + esp_crypto_sha_enable_periph_clk(true); + esp_crypto_ds_enable_periph_clk(true); hmac_hal_start(); @@ -130,17 +119,9 @@ static esp_err_t hmac_calculate(uint32_t key_id, const void *message, size_t mes hmac_hal_read_result_256(hmac); - DS_RCC_ATOMIC() { - ds_ll_enable_bus_clock(false); - } - - SHA_RCC_ATOMIC() { - sha_ll_enable_bus_clock(false); - } - - HMAC_RCC_ATOMIC() { - hmac_ll_enable_bus_clock(false); - } + esp_crypto_hmac_enable_periph_clk(false); + esp_crypto_sha_enable_periph_clk(false); + esp_crypto_ds_enable_periph_clk(false); return ESP_OK; } diff --git a/components/hal/test_apps/crypto/main/key_manager/ecdsa_256_key.pem b/components/hal/test_apps/crypto/main/key_manager/ecdsa_256_key.pem new file mode 100644 index 0000000000..5e4dc4d806 --- /dev/null +++ b/components/hal/test_apps/crypto/main/key_manager/ecdsa_256_key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEICySt/VCEPFi962COuQDE+cXD3Bz8XjZy2O5SM1LsHsGoAoGCCqGSM49 +AwEHoUQDQgAEBYu5KXarLURySNNaeZcxtBTxC0vJAM/evz9NC01IjCVQlOLJ4Y6i +3UviK3bgk+3FqpJBM+SQCqeDgd7ktPtr9Q== +-----END EC PRIVATE KEY----- diff --git a/components/hal/test_apps/crypto/main/key_manager/gen_key_manager_test_cases.py b/components/hal/test_apps/crypto/main/key_manager/gen_key_manager_test_cases.py index 053c2e41a2..3853455e1e 100644 --- a/components/hal/test_apps/crypto/main/key_manager/gen_key_manager_test_cases.py +++ b/components/hal/test_apps/crypto/main/key_manager/gen_key_manager_test_cases.py @@ -1,19 +1,29 @@ -# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Unlicense OR CC0-1.0 +import argparse +import hashlib +import hmac import os +import random import struct from typing import Any from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import ec -from cryptography.hazmat.primitives.ciphers import algorithms +from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.ciphers import Cipher +from cryptography.hazmat.primitives.ciphers import algorithms from cryptography.hazmat.primitives.ciphers import modes +from cryptography.utils import int_to_bytes from ecdsa.curves import NIST256p +supported_targets = {'esp32p4', 'esp32c5'} +supported_ds_key_size = {'esp32p4': [4096, 3072, 2048, 1024], 'esp32c5': [3072, 2048, 1024]} + # Constants TEST_COUNT = 5 +STORAGE_PARTITION_OFFSET = 0x160000 # Helper functions @@ -45,7 +55,9 @@ def calculate_aes_cipher(data: bytes, key: bytes) -> Any: return encryptor.update(data) + encryptor.finalize() -def _flash_encryption_operation_aes_xts(input_data: bytes, flash_address: int, key: bytes, do_decrypt: bool = False) -> bytes: +def _flash_encryption_operation_aes_xts( + input_data: bytes, flash_address: int, key: bytes, do_decrypt: bool = False +) -> bytes: backend = default_backend() indata = input_data @@ -54,9 +66,9 @@ def _flash_encryption_operation_aes_xts(input_data: bytes, flash_address: int, k indata = (b'\x00' * pad_left) + indata pad_right = (0x80 - (len(indata) % 0x80)) % 0x80 - indata += (b'\x00' * pad_right) + indata += b'\x00' * pad_right - inblocks = [indata[i:i + 0x80] for i in range(0, len(indata), 0x80)] + inblocks = [indata[i : i + 0x80] for i in range(0, len(indata), 0x80)] output = b'' for inblock in inblocks: @@ -68,17 +80,17 @@ def _flash_encryption_operation_aes_xts(input_data: bytes, flash_address: int, k outblock = encryptor.update(inblock[::-1]) output += outblock[::-1] - return output[pad_left:len(output) - pad_right] + return output[pad_left : len(output) - pad_right] -def generate_xts_test_data(key: bytes, base_flash_address: int = 0x120000) -> list: +def generate_xts_test_data(key: bytes, base_flash_address: int = STORAGE_PARTITION_OFFSET) -> list: xts_test_data = [] plaintext_data = bytes(range(1, 129)) data_size = 16 flash_address = base_flash_address for i in range(TEST_COUNT): data_size = (data_size * 2) % 256 - if (data_size < 16): + if data_size < 16: data_size = 16 input_data = plaintext_data[:data_size] flash_address = base_flash_address + (i * 0x100) @@ -96,7 +108,7 @@ def generate_ecdsa_256_key_and_pub_key(filename: str) -> tuple: pem = private_key.private_bytes( encoding=serialization.Encoding.PEM, format=serialization.PrivateFormat.TraditionalOpenSSL, - encryption_algorithm=serialization.NoEncryption() + encryption_algorithm=serialization.NoEncryption(), ) with open('ecdsa_256_key.pem', 'wb') as pem_file: @@ -134,10 +146,120 @@ def generate_k1_G(key_file_path: str) -> tuple: return k1_G, k1_G -def write_to_c_header(init_key: bytes, k1: bytes, k2_info: bytes, k1_encrypted_32: list, - test_data_xts_aes_128: list, k1_encrypted_64: list, - xts_test_data_xts_aes_256: list, pubx: bytes, - puby: bytes, k1_G_0: bytes, k1_G_1: bytes) -> None: +def generate_hmac_test_data(key: bytes) -> tuple: + hmac_message = ( + 'Deleniti voluptas explicabo et assumenda. Sed et aliquid minus quis. ' + 'Praesentium cupiditate quia nemo est. Laboriosam pariatur ut distinctio tenetur. ' + 'Sunt architecto iure aspernatur soluta ut recusandae. ' + 'Ut quibusdam occaecati ut qui sit dignissimos eaque..' + ).encode('utf-8') + hmac_result = hmac.HMAC(key, hmac_message, hashlib.sha256).digest() + return hmac_message, hmac_result + + +def number_as_bytes(number, pad_bits=0): # type: (int, int) -> bytes + """ + Given a number, format as a little endian array of bytes + """ + result = int_to_bytes(number)[::-1] # type: bytes + while pad_bits != 0 and len(result) < (pad_bits // 8): + result += b'\x00' + return result + + +def number_as_bignum_words(number): # type: (int) -> str + """ + Given a number, format result as a C array of words + (little-endian, same as ESP32 RSA peripheral or mbedTLS) + """ + result = [] + while number != 0: + result.append('0x%08x' % (number & 0xFFFFFFFF)) + number >>= 32 + return '{ ' + ', '.join(result) + ' }' + + +def generate_ds_encrypted_input_params(aes_key: bytes, target: str) -> tuple: + iv = os.urandom(16) + max_key_size = max(supported_ds_key_size[target]) + key_size = max_key_size + private_key = rsa.generate_private_key(public_exponent=65537, key_size=key_size, backend=default_backend()) + + priv_numbers = private_key.private_numbers() + pub_numbers = private_key.public_key().public_numbers() + Y = priv_numbers.d + M = pub_numbers.n + + rr = 1 << (key_size * 2) + rinv = rr % pub_numbers.n + mprime = -rsa._modinv(M, 1 << 32) + mprime &= 0xFFFFFFFF + length = key_size // 32 - 1 + + # calculate MD from preceding values and IV + # Y_max_key_size || M_max_key_size || Rb_max_key_size || M_prime32 || LENGTH32 || IV128 + md_in = ( + number_as_bytes(Y, max_key_size) + + number_as_bytes(M, max_key_size) + + number_as_bytes(rinv, max_key_size) + + struct.pack(' None: with open('key_manager_test_cases.h', 'w', encoding='utf-8') as file: header_content = """#include @@ -154,13 +276,30 @@ typedef struct test_ecdsa_data { uint8_t puby[32]; } test_ecdsa_data_t; +typedef struct test_hmac_data { + uint8_t message[%d]; + uint8_t hmac_result[32]; +} test_hmac_data_t; + +typedef struct test_ds_data { + uint8_t ds_message[%d / 8]; + uint8_t ds_encrypted_input_params[%d]; + uint8_t ds_encrypted_input_params_iv[16]; + size_t ds_key_size; + uint8_t ds_result[%d]; +} test_ds_data_t; + typedef struct test_data { uint8_t init_key[32]; uint8_t k2_info[64]; uint8_t k1_encrypted[2][32]; // For both 256-bit and 512-bit keys uint8_t plaintext_data[128]; - test_xts_data_t xts_test_data[TEST_COUNT]; - test_ecdsa_data_t ecdsa_test_data; + union { + test_xts_data_t xts_test_data[TEST_COUNT]; + test_ecdsa_data_t ecdsa_test_data; + test_hmac_data_t hmac_test_data; + test_ds_data_t ds_test_data; + }; } test_data_aes_mode_t; typedef struct test_data_ecdh0 { @@ -176,10 +315,23 @@ test_data_aes_mode_t test_data_xts_aes_128 = { .k1_encrypted = { { %s }, { } }, .plaintext_data = { %s }, .xts_test_data = { -""" % (key_to_c_format(init_key), key_to_c_format(k2_info), key_to_c_format(k1_encrypted_32[0]), key_to_c_format(bytes(range(1, 129)))) +""" % ( + len(hmac_message), + ds_key_size, + len(ds_encrypted_input_params), + len(ds_result), + key_to_c_format(init_key), + key_to_c_format(k2_info), + key_to_c_format(k1_encrypted_32_reversed[0]), + key_to_c_format(bytes(range(1, 129))), + ) for data_size, flash_address, ciphertext in test_data_xts_aes_128: - header_content += f'\t\t{{.data_size = {data_size}, .data_offset = 0x{flash_address:x}, .ciphertext = {{{key_to_c_format(ciphertext)}}}}},\n' + header_content += ( + f'\t\t{{.data_size = {data_size}, ' + f'.data_offset = 0x{flash_address:x}, ' + f'.ciphertext = {{{key_to_c_format(ciphertext)}}}}},\n' + ) header_content += '\t}\n};\n\n' # For 64-byte k1 key @@ -187,14 +339,22 @@ test_data_aes_mode_t test_data_xts_aes_128 = { header_content += 'test_data_aes_mode_t test_data_xts_aes_256 = {\n' header_content += f'\t.init_key = {{{key_to_c_format(init_key)}}},\n' header_content += f'\t.k2_info = {{{key_to_c_format(k2_info)}}},\n' - header_content += f'\t.k1_encrypted = {{{{{key_to_c_format(k1_encrypted_64[0])}}}, {{{key_to_c_format(k1_encrypted_64[1])}}}}},\n' + header_content += ( + f'\t.k1_encrypted = {{{{{key_to_c_format(k1_encrypted_64_reversed[0])}}}, ' + f'{{{key_to_c_format(k1_encrypted_64_reversed[1])}}}}},\n' + ) header_content += f'\t.plaintext_data = {{{key_to_c_format(bytes(range(1, 129)))}}},\n' header_content += ' .xts_test_data = {\n' for data_size, flash_address, ciphertext in xts_test_data_xts_aes_256: - header_content += f' {{.data_size = {data_size}, .data_offset = 0x{flash_address:x}, .ciphertext = {{{key_to_c_format(ciphertext)}}}}},\n' - header_content += ' }\n};\n' - header_content += ''' + header_content += ( + f'\t\t{{.data_size = {data_size}, ' + f'.data_offset = 0x{flash_address:x}, ' + f'.ciphertext = {{{key_to_c_format(ciphertext)}}}}},\n' + ) + header_content += '\t}\n};\n' + + header_content += """ test_data_aes_mode_t test_data_ecdsa = { .init_key = { %s }, .k2_info = { %s }, @@ -204,8 +364,15 @@ test_data_aes_mode_t test_data_ecdsa = { .puby = { %s } } };\n -''' % (key_to_c_format(init_key), key_to_c_format(k2_info), key_to_c_format(k1_encrypted_32[0]), key_to_c_format(pubx),key_to_c_format(puby)) - header_content += ''' +""" % ( + key_to_c_format(init_key), + key_to_c_format(k2_info), + key_to_c_format(k1_encrypted_32_reversed[0]), + key_to_c_format(pubx), + key_to_c_format(puby), + ) + + header_content += """ test_data_ecdh0_mode_t test_data_ecdh0 = { .plaintext_data = { %s }, .k1 = { @@ -217,41 +384,132 @@ test_data_ecdh0_mode_t test_data_ecdh0 = { { %s }, } };\n +""" % ( + key_to_c_format(bytes(range(1, 129))), + key_to_c_format(k1), + key_to_c_format(k1), + key_to_c_format(k1_G_0), + key_to_c_format(k1_G_1), + ) -''' % (key_to_c_format(bytes(range(1, 129))), key_to_c_format(k1), key_to_c_format(k1), key_to_c_format(k1_G_0), key_to_c_format(k1_G_1)) + header_content += """ +test_data_aes_mode_t test_data_hmac = { + .init_key = { %s }, + .k2_info = { %s }, + .k1_encrypted = { { %s }, { } }, + .hmac_test_data = { + .message = { %s }, + .hmac_result = { %s } + } +};\n +""" % ( + key_to_c_format(init_key), + key_to_c_format(k2_info), + key_to_c_format(k1_encrypted_32[0]), + key_to_c_format(hmac_message), + key_to_c_format(hmac_result), + ) + + header_content += """ +test_data_aes_mode_t test_data_ds = { + .init_key = { %s }, + .k2_info = { %s }, + .k1_encrypted = { { %s }, { } }, + .ds_test_data = { + .ds_message = { %s }, + .ds_encrypted_input_params = { %s }, + .ds_encrypted_input_params_iv = { %s }, + .ds_key_size = %d, + .ds_result = { %s } + } +};\n +""" % ( + key_to_c_format(init_key), + key_to_c_format(k2_info), + key_to_c_format(k1_encrypted_32_reversed[0]), + key_to_c_format(ds_message), + key_to_c_format(ds_encrypted_input_params), + key_to_c_format(ds_encrypted_input_params_iv), + ds_key_size, + key_to_c_format(ds_result), + ) file.write(header_content) -# Main script logic follows as per your provided structure -init_key = key_from_file_or_generate('init_key.bin', 32) -k2 = key_from_file_or_generate('k2.bin', 32) -rand_num = key_from_file_or_generate('rand_num.bin', 32) +def generate_tests_cases(target: str) -> None: + # Main script logic follows as per your provided structure + init_key = key_from_file_or_generate('init_key.bin', 32) + k2 = key_from_file_or_generate('k2.bin', 32) + rand_num = key_from_file_or_generate('rand_num.bin', 32) -temp_result_inner = calculate_aes_cipher(k2, rand_num) -temp_result_outer = calculate_aes_cipher(temp_result_inner + rand_num, init_key) -k2_info = temp_result_outer + temp_result_inner = calculate_aes_cipher(k2, rand_num) + temp_result_outer = calculate_aes_cipher(temp_result_inner + rand_num, init_key) + k2_info = temp_result_outer -k1_32 = key_from_file_or_generate('k1.bin', 32) -k1_64 = key_from_file_or_generate('k1_64.bin', 64) + k1_32 = key_from_file_or_generate('k1.bin', 32) + k1_64 = key_from_file_or_generate('k1_64.bin', 64) -k1_32_reversed = k1_32[::-1] + k1_32_reversed = k1_32[::-1] -k1_64_reversed = k1_64[::-1] + k1_64_1 = k1_64[:32] + k1_64_1_reversed = k1_64_1[::-1] + k1_64_2 = k1_64[32:] + k1_64_2_reversed = k1_64_2[::-1] -k1_64_1 = k1_64[:32] -k1_64_1_reversed = k1_64_1[::-1] -k1_64_2 = k1_64[32:] -k1_64_2_reversed = k1_64_2[::-1] + k1_encrypted_32 = [calculate_aes_cipher(k1_32, k2)] + k1_encrypted_64 = [calculate_aes_cipher(k1_64_1, k2), calculate_aes_cipher(k1_64_2, k2)] -k1_encrypted_32 = [calculate_aes_cipher(k1_32_reversed, k2)] -k1_encrypted_64 = [calculate_aes_cipher(k1_64_1_reversed, k2), calculate_aes_cipher(k1_64_2_reversed, k2)] + k1_encrypted_32_reversed = [calculate_aes_cipher(k1_32_reversed, k2)] + k1_encrypted_64_reversed = [calculate_aes_cipher(k1_64_1_reversed, k2), calculate_aes_cipher(k1_64_2_reversed, k2)] -test_data_xts_aes_128 = generate_xts_test_data(k1_32) -xts_test_data_xts_aes_256 = generate_xts_test_data(k1_64) + test_data_xts_aes_128 = generate_xts_test_data(k1_32) + xts_test_data_xts_aes_256 = generate_xts_test_data(k1_64) -pubx, puby = generate_ecdsa_256_key_and_pub_key('k1.bin') + pubx, puby = generate_ecdsa_256_key_and_pub_key('k1.bin') -k1_G_0, k1_G_1 = generate_k1_G('k1.bin') + k1_G_0, k1_G_1 = generate_k1_G('k1.bin') -write_to_c_header(init_key, k1_32, k2_info, k1_encrypted_32, test_data_xts_aes_128, k1_encrypted_64, xts_test_data_xts_aes_256, pubx, puby, k1_G_0, k1_G_1) + hmac_message, hmac_result = generate_hmac_test_data(k1_32) + + ds_message, ds_encrypted_input_params, ds_encrypted_input_params_iv, ds_key_size, ds_result = ( + generate_ds_encrypted_input_params(k1_32, target) + ) + + write_to_c_header( + init_key, + k1_32, + k2_info, + k1_encrypted_32, + k1_encrypted_32_reversed, + test_data_xts_aes_128, + k1_encrypted_64, + k1_encrypted_64_reversed, + xts_test_data_xts_aes_256, + pubx, + puby, + k1_G_0, + k1_G_1, + hmac_message, + hmac_result, + ds_message, + ds_encrypted_input_params, + ds_encrypted_input_params_iv, + ds_key_size, + ds_result, + ) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description="""Generates Digital Signature Test Cases""") + + parser.add_argument( + '--target', + required=True, + choices=supported_targets, + help='Target to generate test cases for, different targets support different max key length', + ) + + args = parser.parse_args() + + generate_tests_cases(args.target) diff --git a/components/hal/test_apps/crypto/main/key_manager/init_key.bin b/components/hal/test_apps/crypto/main/key_manager/init_key.bin new file mode 100644 index 0000000000..726a088171 --- /dev/null +++ b/components/hal/test_apps/crypto/main/key_manager/init_key.bin @@ -0,0 +1 @@ +Ú<ŠCƒ©K%[~ñW¸èE‡vîN.U§%á” \ No newline at end of file diff --git a/components/hal/test_apps/crypto/main/key_manager/k1.bin b/components/hal/test_apps/crypto/main/key_manager/k1.bin new file mode 100644 index 0000000000..33b9a09e2b --- /dev/null +++ b/components/hal/test_apps/crypto/main/key_manager/k1.bin @@ -0,0 +1 @@ +,’·õBñb÷­‚:äçpsñxÙËc¹HÍK°{ \ No newline at end of file diff --git a/components/hal/test_apps/crypto/main/key_manager/k1_64.bin b/components/hal/test_apps/crypto/main/key_manager/k1_64.bin new file mode 100644 index 0000000000..ed2a746277 Binary files /dev/null and b/components/hal/test_apps/crypto/main/key_manager/k1_64.bin differ diff --git a/components/hal/test_apps/crypto/main/key_manager/k2.bin b/components/hal/test_apps/crypto/main/key_manager/k2.bin new file mode 100644 index 0000000000..6aaa516228 --- /dev/null +++ b/components/hal/test_apps/crypto/main/key_manager/k2.bin @@ -0,0 +1 @@ +!ÙV1,Jˆ8~fÈ*µDö_à*·B+É(7ާX(Ô \ No newline at end of file diff --git a/components/hal/test_apps/crypto/main/key_manager/key_manager_test_cases.h b/components/hal/test_apps/crypto/main/key_manager/key_manager_test_cases.h index 6a7a2abf7a..18ec4fd461 100644 --- a/components/hal/test_apps/crypto/main/key_manager/key_manager_test_cases.h +++ b/components/hal/test_apps/crypto/main/key_manager/key_manager_test_cases.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -18,13 +18,30 @@ typedef struct test_ecdsa_data { uint8_t puby[32]; } test_ecdsa_data_t; +typedef struct test_hmac_data { + uint8_t message[257]; + uint8_t hmac_result[32]; +} test_hmac_data_t; + +typedef struct test_ds_data { + uint8_t ds_message[3072 / 8]; + uint8_t ds_encrypted_input_params[1200]; + uint8_t ds_encrypted_input_params_iv[16]; + size_t ds_key_size; + uint8_t ds_result[384]; +} test_ds_data_t; + typedef struct test_data { uint8_t init_key[32]; uint8_t k2_info[64]; uint8_t k1_encrypted[2][32]; // For both 256-bit and 512-bit keys uint8_t plaintext_data[128]; - test_xts_data_t xts_test_data[TEST_COUNT]; - test_ecdsa_data_t ecdsa_test_data; + union { + test_xts_data_t xts_test_data[TEST_COUNT]; + test_ecdsa_data_t ecdsa_test_data; + test_hmac_data_t hmac_test_data; + test_ds_data_t ds_test_data; + }; } test_data_aes_mode_t; typedef struct test_data_ecdh0 { @@ -35,41 +52,41 @@ typedef struct test_data_ecdh0 { // For 32-byte k1 key test_data_aes_mode_t test_data_xts_aes_128 = { - .init_key = { 0x4d, 0x21, 0x64, 0x21, 0x8f, 0xa2, 0xe3, 0xa0, 0xab, 0x74, 0xb5, 0xab, 0x17, 0x9a, 0x5d, 0x08, 0x58, 0xf4, 0x22, 0x03, 0xbd, 0x52, 0xe7, 0x88, 0x3c, 0x22, 0x0f, 0x95, 0x89, 0x70, 0xe1, 0x93 }, - .k2_info = { 0xd8, 0xcd, 0x04, 0x45, 0xb4, 0x45, 0xc4, 0x15, 0xf6, 0x40, 0x1c, 0x7d, 0x90, 0x1b, 0x99, 0xa4, 0x79, 0x6b, 0xfb, 0x5b, 0x2a, 0x40, 0x60, 0xe1, 0xc1, 0xe1, 0x48, 0xcd, 0x46, 0x6b, 0x9b, 0x48, 0xda, 0x7a, 0x70, 0x0a, 0x78, 0x0b, 0x9d, 0xf9, 0x0e, 0xed, 0x91, 0xfc, 0xa5, 0xc2, 0x96, 0x05, 0x91, 0x76, 0xdb, 0x68, 0x84, 0x5d, 0x5e, 0x5b, 0xa6, 0xe9, 0x6b, 0x3b, 0x12, 0x50, 0x05, 0xc3 }, - .k1_encrypted = { { 0xeb, 0x83, 0x24, 0x7d, 0xf8, 0x40, 0xc9, 0x88, 0x5f, 0x5e, 0x58, 0x57, 0x25, 0xa9, 0x23, 0x4a, 0xa4, 0xc4, 0x12, 0x17, 0xf3, 0x9e, 0x1f, 0xa0, 0xa0, 0xfa, 0xd5, 0xbf, 0xb6, 0x6c, 0xb5, 0x48 }, { } }, + .init_key = { 0xee, 0x89, 0x95, 0xda, 0x3c, 0x8a, 0x43, 0x83, 0xa9, 0x4b, 0x25, 0x5b, 0x04, 0x7e, 0xf1, 0x57, 0xb8, 0xe8, 0x06, 0x45, 0x87, 0x76, 0xee, 0x1b, 0x4e, 0x2e, 0x55, 0xa7, 0x1f, 0x25, 0xe1, 0x94 }, + .k2_info = { 0x8f, 0x96, 0x33, 0x47, 0xe1, 0xa5, 0x57, 0xe9, 0x2a, 0x51, 0xa9, 0xbe, 0x48, 0x84, 0x25, 0x4e, 0x6f, 0x50, 0x1c, 0x45, 0xdb, 0xb6, 0xfa, 0xeb, 0x35, 0xd2, 0x27, 0x91, 0x3f, 0x67, 0x57, 0xd9, 0xcb, 0x55, 0xe4, 0x2b, 0x18, 0x16, 0xe7, 0xce, 0x6c, 0xf2, 0x58, 0x71, 0x17, 0x76, 0x2a, 0x86, 0x05, 0xe7, 0x37, 0x45, 0x71, 0x34, 0xca, 0xaf, 0x60, 0x07, 0xdf, 0xf4, 0xd2, 0xee, 0x3d, 0x4b }, + .k1_encrypted = { { 0xe0, 0xe8, 0x41, 0xe3, 0xd0, 0x92, 0x71, 0x84, 0x4b, 0x02, 0x1e, 0xec, 0x14, 0xdd, 0xaf, 0xf8, 0x39, 0xf9, 0x6a, 0x8d, 0x1b, 0xd7, 0x64, 0x3b, 0x7b, 0xa6, 0x05, 0x42, 0x01, 0xfb, 0xab, 0xe1 }, { } }, .plaintext_data = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80 }, .xts_test_data = { - {.data_size = 32, .data_offset = 0x120000, .ciphertext = {0xe7, 0xf3, 0xb4, 0x51, 0xc6, 0x62, 0x8e, 0x25, 0x10, 0x12, 0xc2, 0x09, 0x82, 0x7b, 0x3e, 0x9a, 0x78, 0xe2, 0x00, 0x9a, 0x96, 0x02, 0x50, 0xeb, 0xff, 0xf1, 0xf8, 0x0d, 0xf6, 0xa6, 0xb8, 0xa1}}, - {.data_size = 64, .data_offset = 0x120100, .ciphertext = {0x3b, 0x54, 0xa8, 0x58, 0xe2, 0x63, 0x7a, 0xb0, 0x7c, 0xc7, 0x37, 0xd8, 0x1e, 0x89, 0x1e, 0x25, 0x39, 0x3d, 0x0d, 0x18, 0x14, 0xb3, 0x2e, 0x18, 0x15, 0xf6, 0xbd, 0xf8, 0xb6, 0x5f, 0x6b, 0x89, 0x1a, 0x0a, 0x53, 0x36, 0xf1, 0x5b, 0x1b, 0x18, 0xd3, 0xf4, 0x7b, 0xd5, 0xcd, 0x4f, 0x48, 0x7b, 0x11, 0xcf, 0xad, 0x6b, 0x79, 0x36, 0x1b, 0xda, 0x5a, 0xd3, 0x18, 0x44, 0xa0, 0xf3, 0xf2, 0xad}}, - {.data_size = 128, .data_offset = 0x120200, .ciphertext = {0x6b, 0x42, 0x10, 0x9f, 0x67, 0x72, 0x31, 0xc7, 0x8f, 0x63, 0xde, 0xc1, 0xf9, 0x84, 0x37, 0x74, 0xe5, 0x5a, 0xe4, 0x31, 0x1a, 0x2e, 0x45, 0x6b, 0xb5, 0xd4, 0xd0, 0x41, 0xe1, 0x2c, 0x0a, 0x43, 0xd9, 0x4c, 0xd5, 0x1c, 0x34, 0xc9, 0x29, 0x39, 0xc8, 0x09, 0xc3, 0xcd, 0x99, 0xaf, 0x3a, 0xe6, 0x4d, 0xae, 0xce, 0xfd, 0x0a, 0xd4, 0x8f, 0x81, 0x4c, 0x25, 0xc5, 0x5e, 0x3d, 0x82, 0x3d, 0x58, 0x55, 0xe5, 0xa4, 0xe4, 0x13, 0x2b, 0xa0, 0x04, 0x3a, 0x7a, 0x65, 0xfa, 0x7a, 0xfb, 0x28, 0x36, 0x1e, 0xfa, 0x71, 0x50, 0x80, 0xa5, 0x0c, 0xa6, 0x4e, 0x45, 0xf9, 0xd9, 0x05, 0xc1, 0x63, 0xa1, 0xf2, 0x7f, 0x54, 0x62, 0xf1, 0x5a, 0xe2, 0x5a, 0x5c, 0x06, 0x16, 0x71, 0xa9, 0x5f, 0xab, 0x7d, 0xc9, 0x85, 0x68, 0xc5, 0x3a, 0xfe, 0xc1, 0xe0, 0xc9, 0xc3, 0xd4, 0x33, 0x10, 0x89, 0x5e, 0x43}}, - {.data_size = 16, .data_offset = 0x120300, .ciphertext = {0xbe, 0xd7, 0x01, 0x8a, 0x60, 0xab, 0x0c, 0xb7, 0xb6, 0x14, 0x9e, 0x64, 0xbc, 0xca, 0xda, 0xaa}}, - {.data_size = 32, .data_offset = 0x120400, .ciphertext = {0xda, 0x84, 0x17, 0x3d, 0x4c, 0x85, 0x07, 0xe2, 0x56, 0x98, 0x69, 0x33, 0x1b, 0x9a, 0x01, 0x9e, 0x6c, 0x81, 0xd8, 0x90, 0x9e, 0x59, 0x92, 0x12, 0x6d, 0xba, 0x58, 0x09, 0x90, 0xe6, 0x50, 0x33}}, + {.data_size = 32, .data_offset = 0x160000, .ciphertext = {0x0d, 0x02, 0x33, 0x69, 0x2f, 0x0f, 0x6f, 0x3e, 0xd1, 0xf0, 0x3d, 0x38, 0x63, 0xe3, 0x45, 0xe1, 0x01, 0xe2, 0xde, 0x88, 0xf2, 0x4e, 0x94, 0xa2, 0x22, 0xfe, 0x01, 0x6e, 0xe0, 0xf5, 0x16, 0x7c}}, + {.data_size = 64, .data_offset = 0x160100, .ciphertext = {0xc0, 0xc8, 0x19, 0x93, 0x12, 0xa2, 0xa6, 0x9c, 0xeb, 0x2b, 0x15, 0x84, 0x06, 0x71, 0x34, 0xfc, 0xef, 0xba, 0x53, 0xef, 0x66, 0xd8, 0xfd, 0x7f, 0x47, 0x88, 0x03, 0xe7, 0x44, 0xc4, 0x83, 0x30, 0x11, 0x2d, 0xd8, 0x87, 0xcd, 0xf9, 0x0c, 0x74, 0xa4, 0x14, 0x2d, 0xa5, 0xab, 0xf6, 0xd7, 0xdc, 0x4f, 0x8d, 0x22, 0x1a, 0x2e, 0x3d, 0x6d, 0x0f, 0xb3, 0xed, 0xf0, 0x7b, 0x01, 0x18, 0xf0, 0xd3}}, + {.data_size = 128, .data_offset = 0x160200, .ciphertext = {0xba, 0xe8, 0x7d, 0xfe, 0x1d, 0x7c, 0x95, 0x41, 0x5b, 0x59, 0x84, 0x4b, 0x37, 0x8e, 0x29, 0x53, 0xf5, 0x9d, 0x90, 0x07, 0xec, 0xc9, 0xdf, 0x52, 0xd5, 0xab, 0x7c, 0x73, 0x21, 0x52, 0x8d, 0xdc, 0x6f, 0xe1, 0xaa, 0x16, 0x4d, 0x86, 0x8a, 0x12, 0x29, 0x49, 0x9f, 0x96, 0x23, 0xd2, 0x4c, 0xa8, 0xcf, 0xe7, 0xa8, 0x83, 0x69, 0x57, 0x41, 0x92, 0x0a, 0x06, 0xf8, 0x7a, 0x30, 0xc6, 0xd6, 0x51, 0xb0, 0x34, 0x46, 0x08, 0x77, 0xc9, 0x49, 0x9d, 0x63, 0xee, 0x9f, 0x66, 0x08, 0xc1, 0x01, 0x0c, 0x07, 0x24, 0xc2, 0x76, 0x86, 0x14, 0xcb, 0xa1, 0x27, 0xc0, 0xe9, 0xcd, 0x1d, 0x60, 0x70, 0xa0, 0x0a, 0x21, 0x9e, 0x91, 0xfa, 0x1a, 0x8c, 0x10, 0x87, 0x17, 0x36, 0xf6, 0x20, 0xc2, 0x7e, 0x96, 0x0f, 0xde, 0x30, 0x28, 0x5a, 0x3a, 0x9e, 0x08, 0xe1, 0x35, 0xb3, 0x36, 0x2f, 0xc7, 0x0d, 0x28}}, + {.data_size = 16, .data_offset = 0x160300, .ciphertext = {0x0a, 0x2c, 0xcf, 0x75, 0x73, 0xa0, 0x5f, 0x80, 0xbb, 0xfb, 0xed, 0x9b, 0xc2, 0xd6, 0x05, 0x92}}, + {.data_size = 32, .data_offset = 0x160400, .ciphertext = {0x1e, 0x45, 0xab, 0xea, 0x70, 0x46, 0xb9, 0x08, 0x6d, 0x2f, 0xd1, 0xe4, 0x7f, 0xf3, 0x5d, 0xf9, 0x2e, 0xf9, 0x3d, 0x1f, 0x23, 0xe8, 0xa2, 0xd8, 0x5a, 0x53, 0xe7, 0xd7, 0xd7, 0x51, 0xe6, 0x92}}, } }; // For 64-byte k1 key test_data_aes_mode_t test_data_xts_aes_256 = { - .init_key = {0x4d, 0x21, 0x64, 0x21, 0x8f, 0xa2, 0xe3, 0xa0, 0xab, 0x74, 0xb5, 0xab, 0x17, 0x9a, 0x5d, 0x08, 0x58, 0xf4, 0x22, 0x03, 0xbd, 0x52, 0xe7, 0x88, 0x3c, 0x22, 0x0f, 0x95, 0x89, 0x70, 0xe1, 0x93}, - .k2_info = {0xd8, 0xcd, 0x04, 0x45, 0xb4, 0x45, 0xc4, 0x15, 0xf6, 0x40, 0x1c, 0x7d, 0x90, 0x1b, 0x99, 0xa4, 0x79, 0x6b, 0xfb, 0x5b, 0x2a, 0x40, 0x60, 0xe1, 0xc1, 0xe1, 0x48, 0xcd, 0x46, 0x6b, 0x9b, 0x48, 0xda, 0x7a, 0x70, 0x0a, 0x78, 0x0b, 0x9d, 0xf9, 0x0e, 0xed, 0x91, 0xfc, 0xa5, 0xc2, 0x96, 0x05, 0x91, 0x76, 0xdb, 0x68, 0x84, 0x5d, 0x5e, 0x5b, 0xa6, 0xe9, 0x6b, 0x3b, 0x12, 0x50, 0x05, 0xc3}, - .k1_encrypted = {{0xeb, 0x83, 0x24, 0x7d, 0xf8, 0x40, 0xc9, 0x88, 0x5f, 0x5e, 0x58, 0x57, 0x25, 0xa9, 0x23, 0x4a, 0xa4, 0xc4, 0x12, 0x17, 0xf3, 0x9e, 0x1f, 0xa0, 0xa0, 0xfa, 0xd5, 0xbf, 0xb6, 0x6c, 0xb5, 0x48}, {0x65, 0x9e, 0x12, 0x7f, 0xc0, 0x4a, 0xb6, 0x04, 0xa1, 0xd0, 0x38, 0x04, 0x6c, 0x8e, 0x1f, 0xc7, 0x03, 0x24, 0x3e, 0x75, 0x3c, 0x9d, 0x7a, 0xc2, 0xef, 0xd6, 0xf2, 0x60, 0x46, 0xfc, 0x07, 0x3f}}, + .init_key = {0xee, 0x89, 0x95, 0xda, 0x3c, 0x8a, 0x43, 0x83, 0xa9, 0x4b, 0x25, 0x5b, 0x04, 0x7e, 0xf1, 0x57, 0xb8, 0xe8, 0x06, 0x45, 0x87, 0x76, 0xee, 0x1b, 0x4e, 0x2e, 0x55, 0xa7, 0x1f, 0x25, 0xe1, 0x94}, + .k2_info = {0x8f, 0x96, 0x33, 0x47, 0xe1, 0xa5, 0x57, 0xe9, 0x2a, 0x51, 0xa9, 0xbe, 0x48, 0x84, 0x25, 0x4e, 0x6f, 0x50, 0x1c, 0x45, 0xdb, 0xb6, 0xfa, 0xeb, 0x35, 0xd2, 0x27, 0x91, 0x3f, 0x67, 0x57, 0xd9, 0xcb, 0x55, 0xe4, 0x2b, 0x18, 0x16, 0xe7, 0xce, 0x6c, 0xf2, 0x58, 0x71, 0x17, 0x76, 0x2a, 0x86, 0x05, 0xe7, 0x37, 0x45, 0x71, 0x34, 0xca, 0xaf, 0x60, 0x07, 0xdf, 0xf4, 0xd2, 0xee, 0x3d, 0x4b}, + .k1_encrypted = {{0x37, 0xcf, 0x5b, 0x9e, 0x08, 0x26, 0x36, 0x31, 0xd7, 0x51, 0x3c, 0x33, 0x0d, 0x5d, 0x03, 0xad, 0x48, 0x6e, 0xbe, 0x82, 0xce, 0xa9, 0xc8, 0xd5, 0x98, 0x11, 0x24, 0xcc, 0x83, 0xf8, 0xf9, 0x53}, {0x84, 0xf7, 0x09, 0x06, 0xa3, 0xf2, 0xc7, 0x5f, 0x08, 0x43, 0xfd, 0xe9, 0x2e, 0xab, 0x32, 0xf3, 0x31, 0xd4, 0x4f, 0xf4, 0xf6, 0x1d, 0xa1, 0xc7, 0x1f, 0x2c, 0x11, 0xca, 0x9f, 0x21, 0x26, 0xaa}}, .plaintext_data = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80}, .xts_test_data = { - {.data_size = 32, .data_offset = 0x120000, .ciphertext = {0x9b, 0xd8, 0x2b, 0xc6, 0xae, 0xcc, 0x9d, 0x0c, 0x38, 0x30, 0x85, 0x6a, 0x2b, 0x22, 0x2e, 0x34, 0x9f, 0xa2, 0xcd, 0xe8, 0xec, 0xe3, 0xc4, 0x21, 0xfe, 0xbb, 0x4a, 0x55, 0xf2, 0x4a, 0xe2, 0x14}}, - {.data_size = 64, .data_offset = 0x120100, .ciphertext = {0x1e, 0x36, 0x3f, 0xf6, 0xd6, 0x52, 0x34, 0xce, 0xc3, 0x58, 0x15, 0xa1, 0x15, 0x6f, 0x3d, 0x66, 0xa7, 0x90, 0x14, 0x71, 0xbb, 0x6d, 0x7e, 0x93, 0xf2, 0x4d, 0x5d, 0x74, 0xb2, 0xd7, 0x77, 0x32, 0x2e, 0x31, 0x16, 0x28, 0xd2, 0x10, 0x65, 0x81, 0x49, 0xc0, 0x56, 0xf0, 0x6d, 0x71, 0x5b, 0xc2, 0xf2, 0x01, 0x04, 0xbf, 0x97, 0x77, 0xe6, 0x57, 0xe5, 0xb5, 0xad, 0x73, 0xc0, 0x76, 0x91, 0xb6}}, - {.data_size = 128, .data_offset = 0x120200, .ciphertext = {0xcf, 0x7d, 0xdd, 0x69, 0x69, 0xf4, 0x3b, 0xcd, 0x65, 0x5d, 0xcf, 0xfc, 0xff, 0xd3, 0x45, 0x1c, 0x51, 0xab, 0x2e, 0x26, 0x5c, 0xdc, 0x5b, 0x5a, 0x6e, 0xbb, 0x18, 0x36, 0x55, 0xbe, 0xe7, 0x30, 0x7a, 0x07, 0x48, 0xd8, 0x1a, 0x34, 0xdc, 0xa6, 0x1e, 0xd6, 0x67, 0xa8, 0x90, 0xc3, 0xac, 0x26, 0x7a, 0x52, 0x67, 0x82, 0x71, 0xc9, 0x80, 0x8d, 0xed, 0x20, 0x83, 0x34, 0x10, 0x8e, 0xe5, 0x84, 0x81, 0xa5, 0xe2, 0x42, 0xf0, 0x53, 0xef, 0x93, 0x00, 0xfe, 0xbd, 0x74, 0x14, 0xac, 0x92, 0x37, 0x00, 0x45, 0xd5, 0x71, 0x29, 0xaf, 0x8b, 0x83, 0xe2, 0x20, 0x2e, 0xd0, 0xf6, 0xaa, 0x45, 0x9a, 0x6f, 0x59, 0xb9, 0x8d, 0xef, 0xcd, 0xb6, 0xf6, 0x25, 0x99, 0xd2, 0x32, 0x2e, 0x90, 0x8a, 0x3a, 0x5d, 0xd8, 0x3f, 0xbf, 0x84, 0x80, 0x89, 0xaa, 0x9c, 0xa8, 0x57, 0xc9, 0x1c, 0xc4, 0xaa, 0x64}}, - {.data_size = 16, .data_offset = 0x120300, .ciphertext = {0x1b, 0x7a, 0xf1, 0x35, 0x33, 0x22, 0x64, 0x74, 0x06, 0x6a, 0xc1, 0x0c, 0x39, 0xee, 0x1f, 0x9f}}, - {.data_size = 32, .data_offset = 0x120400, .ciphertext = {0x94, 0xd9, 0x01, 0x0f, 0xec, 0xcc, 0xb5, 0x22, 0x50, 0x8b, 0x8a, 0x3d, 0x01, 0x18, 0x29, 0xda, 0x53, 0x9b, 0xcf, 0x64, 0xac, 0x4f, 0x7b, 0x97, 0xf3, 0xff, 0xfd, 0x33, 0x96, 0x8a, 0xde, 0x27}}, - } + {.data_size = 32, .data_offset = 0x160000, .ciphertext = {0x3d, 0xab, 0x5b, 0x96, 0x8f, 0xa5, 0x5b, 0x6f, 0xcb, 0x82, 0xcb, 0x3a, 0x94, 0xa0, 0xa6, 0x3e, 0xc6, 0x59, 0xde, 0x61, 0x0e, 0xb4, 0x8f, 0x99, 0x03, 0xff, 0xaf, 0x24, 0x11, 0x6e, 0x3b, 0x3b}}, + {.data_size = 64, .data_offset = 0x160100, .ciphertext = {0x75, 0xaa, 0x68, 0xcd, 0x98, 0x29, 0x70, 0xe2, 0xaf, 0xb2, 0x7c, 0x39, 0x0a, 0x50, 0xac, 0x08, 0x01, 0x71, 0x7a, 0xdb, 0x1f, 0x04, 0xb8, 0x5e, 0x4d, 0x8d, 0x4c, 0xc4, 0x0d, 0xde, 0xcf, 0x5e, 0x1f, 0xa0, 0xfb, 0x74, 0xf6, 0xb2, 0x51, 0xe0, 0x69, 0x84, 0x47, 0x61, 0x71, 0xc5, 0x92, 0x8c, 0x12, 0x69, 0x77, 0xfb, 0xdf, 0xe8, 0xd2, 0x86, 0xc3, 0xbc, 0xd2, 0x2d, 0x8c, 0xbc, 0x4b, 0x59}}, + {.data_size = 128, .data_offset = 0x160200, .ciphertext = {0xb9, 0x2b, 0xf5, 0x02, 0x84, 0xba, 0x1b, 0xda, 0xf8, 0x85, 0x2c, 0xba, 0x36, 0x42, 0x16, 0xa7, 0x83, 0x22, 0x37, 0xab, 0x41, 0x9d, 0x84, 0xde, 0x81, 0x4c, 0xa5, 0x2e, 0x40, 0x65, 0xd2, 0xc9, 0x30, 0x81, 0x5c, 0x61, 0x86, 0x22, 0xc3, 0xec, 0xf7, 0x7f, 0x66, 0x02, 0x73, 0x7b, 0xf2, 0x22, 0x17, 0x6d, 0x41, 0x90, 0xda, 0xb1, 0x4e, 0x2f, 0xbe, 0xe2, 0x0b, 0x22, 0x4e, 0xb4, 0x6a, 0x90, 0x13, 0x1f, 0x9b, 0xf2, 0x78, 0x03, 0x4f, 0xb5, 0x37, 0x62, 0x6d, 0x01, 0x56, 0xfc, 0xe3, 0xfa, 0xe7, 0x19, 0xbf, 0x81, 0x05, 0x9d, 0x7f, 0xef, 0xbe, 0xe4, 0x3a, 0xa8, 0xa0, 0x98, 0x74, 0x68, 0x10, 0xe4, 0x95, 0x7a, 0x93, 0xf0, 0x75, 0x68, 0x09, 0xf3, 0x63, 0xe9, 0x1a, 0xbb, 0x2a, 0xf4, 0x1e, 0xa0, 0x45, 0x61, 0x5b, 0x1f, 0x2d, 0x08, 0xfd, 0xed, 0x79, 0x61, 0x11, 0xad, 0x57, 0xb6}}, + {.data_size = 16, .data_offset = 0x160300, .ciphertext = {0x0f, 0x8f, 0xff, 0x33, 0x23, 0x1c, 0x63, 0x5f, 0xae, 0x91, 0x87, 0x13, 0x5d, 0x27, 0xd0, 0xef}}, + {.data_size = 32, .data_offset = 0x160400, .ciphertext = {0x29, 0x23, 0x17, 0x47, 0xb3, 0xd3, 0x19, 0xf4, 0x9d, 0x6b, 0x3c, 0x82, 0x49, 0x83, 0x25, 0x7a, 0x3d, 0xfc, 0x51, 0xca, 0x7c, 0x96, 0x5e, 0x1e, 0xcf, 0x7a, 0x85, 0x99, 0x0c, 0x33, 0x17, 0xe4}}, + } }; test_data_aes_mode_t test_data_ecdsa = { - .init_key = { 0x4d, 0x21, 0x64, 0x21, 0x8f, 0xa2, 0xe3, 0xa0, 0xab, 0x74, 0xb5, 0xab, 0x17, 0x9a, 0x5d, 0x08, 0x58, 0xf4, 0x22, 0x03, 0xbd, 0x52, 0xe7, 0x88, 0x3c, 0x22, 0x0f, 0x95, 0x89, 0x70, 0xe1, 0x93 }, - .k2_info = { 0xd8, 0xcd, 0x04, 0x45, 0xb4, 0x45, 0xc4, 0x15, 0xf6, 0x40, 0x1c, 0x7d, 0x90, 0x1b, 0x99, 0xa4, 0x79, 0x6b, 0xfb, 0x5b, 0x2a, 0x40, 0x60, 0xe1, 0xc1, 0xe1, 0x48, 0xcd, 0x46, 0x6b, 0x9b, 0x48, 0xda, 0x7a, 0x70, 0x0a, 0x78, 0x0b, 0x9d, 0xf9, 0x0e, 0xed, 0x91, 0xfc, 0xa5, 0xc2, 0x96, 0x05, 0x91, 0x76, 0xdb, 0x68, 0x84, 0x5d, 0x5e, 0x5b, 0xa6, 0xe9, 0x6b, 0x3b, 0x12, 0x50, 0x05, 0xc3 }, - .k1_encrypted = { { 0xeb, 0x83, 0x24, 0x7d, 0xf8, 0x40, 0xc9, 0x88, 0x5f, 0x5e, 0x58, 0x57, 0x25, 0xa9, 0x23, 0x4a, 0xa4, 0xc4, 0x12, 0x17, 0xf3, 0x9e, 0x1f, 0xa0, 0xa0, 0xfa, 0xd5, 0xbf, 0xb6, 0x6c, 0xb5, 0x48 }, { } }, + .init_key = { 0xee, 0x89, 0x95, 0xda, 0x3c, 0x8a, 0x43, 0x83, 0xa9, 0x4b, 0x25, 0x5b, 0x04, 0x7e, 0xf1, 0x57, 0xb8, 0xe8, 0x06, 0x45, 0x87, 0x76, 0xee, 0x1b, 0x4e, 0x2e, 0x55, 0xa7, 0x1f, 0x25, 0xe1, 0x94 }, + .k2_info = { 0x8f, 0x96, 0x33, 0x47, 0xe1, 0xa5, 0x57, 0xe9, 0x2a, 0x51, 0xa9, 0xbe, 0x48, 0x84, 0x25, 0x4e, 0x6f, 0x50, 0x1c, 0x45, 0xdb, 0xb6, 0xfa, 0xeb, 0x35, 0xd2, 0x27, 0x91, 0x3f, 0x67, 0x57, 0xd9, 0xcb, 0x55, 0xe4, 0x2b, 0x18, 0x16, 0xe7, 0xce, 0x6c, 0xf2, 0x58, 0x71, 0x17, 0x76, 0x2a, 0x86, 0x05, 0xe7, 0x37, 0x45, 0x71, 0x34, 0xca, 0xaf, 0x60, 0x07, 0xdf, 0xf4, 0xd2, 0xee, 0x3d, 0x4b }, + .k1_encrypted = { { 0xe0, 0xe8, 0x41, 0xe3, 0xd0, 0x92, 0x71, 0x84, 0x4b, 0x02, 0x1e, 0xec, 0x14, 0xdd, 0xaf, 0xf8, 0x39, 0xf9, 0x6a, 0x8d, 0x1b, 0xd7, 0x64, 0x3b, 0x7b, 0xa6, 0x05, 0x42, 0x01, 0xfb, 0xab, 0xe1 }, { } }, .ecdsa_test_data = { - .pubx = { 0x8f, 0xc2, 0x37, 0x2e, 0x36, 0x77, 0x8f, 0xc7, 0x59, 0x18, 0xec, 0x39, 0x23, 0x16, 0x6b, 0x0b, 0x4f, 0xf8, 0x19, 0xa8, 0x9f, 0xd9, 0xf7, 0x59, 0x4d, 0x8a, 0x2d, 0x16, 0xd5, 0x84, 0xe1, 0x21 }, - .puby = { 0xf1, 0x8b, 0x1e, 0x2d, 0x7e, 0xc4, 0x8b, 0xf8, 0xe3, 0xc9, 0xb1, 0x54, 0xa4, 0x65, 0xed, 0x7d, 0xbc, 0x56, 0x1a, 0x66, 0xcd, 0x43, 0x10, 0x2e, 0x46, 0x2a, 0x3f, 0xfe, 0xdb, 0x9a, 0x28, 0xf9 } + .pubx = { 0x25, 0x8c, 0x48, 0x4d, 0x0b, 0x4d, 0x3f, 0xbf, 0xde, 0xcf, 0x00, 0xc9, 0x4b, 0x0b, 0xf1, 0x14, 0xb4, 0x31, 0x97, 0x79, 0x5a, 0xd3, 0x48, 0x72, 0x44, 0x2d, 0xab, 0x76, 0x29, 0xb9, 0x8b, 0x05 }, + .puby = { 0xf5, 0x6b, 0xfb, 0xb4, 0xe4, 0xde, 0x81, 0x83, 0xa7, 0x0a, 0x90, 0xe4, 0x33, 0x41, 0x92, 0xaa, 0xc5, 0xed, 0x93, 0xe0, 0x76, 0x2b, 0xe2, 0x4b, 0xdd, 0xa2, 0x8e, 0xe1, 0xc9, 0xe2, 0x94, 0x50 } } }; @@ -77,11 +94,36 @@ test_data_aes_mode_t test_data_ecdsa = { test_data_ecdh0_mode_t test_data_ecdh0 = { .plaintext_data = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80 }, .k1 = { - { 0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 }, - { 0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 }, + { 0x2c, 0x92, 0xb7, 0xf5, 0x42, 0x10, 0xf1, 0x62, 0xf7, 0xad, 0x82, 0x3a, 0xe4, 0x03, 0x13, 0xe7, 0x17, 0x0f, 0x70, 0x73, 0xf1, 0x78, 0xd9, 0xcb, 0x63, 0xb9, 0x48, 0xcd, 0x4b, 0xb0, 0x7b, 0x06 }, + { 0x2c, 0x92, 0xb7, 0xf5, 0x42, 0x10, 0xf1, 0x62, 0xf7, 0xad, 0x82, 0x3a, 0xe4, 0x03, 0x13, 0xe7, 0x17, 0x0f, 0x70, 0x73, 0xf1, 0x78, 0xd9, 0xcb, 0x63, 0xb9, 0x48, 0xcd, 0x4b, 0xb0, 0x7b, 0x06 }, }, .k1_G = { - { 0x8f, 0xc2, 0x37, 0x2e, 0x36, 0x77, 0x8f, 0xc7, 0x59, 0x18, 0xec, 0x39, 0x23, 0x16, 0x6b, 0x0b, 0x4f, 0xf8, 0x19, 0xa8, 0x9f, 0xd9, 0xf7, 0x59, 0x4d, 0x8a, 0x2d, 0x16, 0xd5, 0x84, 0xe1, 0x21, 0xf1, 0x8b, 0x1e, 0x2d, 0x7e, 0xc4, 0x8b, 0xf8, 0xe3, 0xc9, 0xb1, 0x54, 0xa4, 0x65, 0xed, 0x7d, 0xbc, 0x56, 0x1a, 0x66, 0xcd, 0x43, 0x10, 0x2e, 0x46, 0x2a, 0x3f, 0xfe, 0xdb, 0x9a, 0x28, 0xf9 }, - { 0x8f, 0xc2, 0x37, 0x2e, 0x36, 0x77, 0x8f, 0xc7, 0x59, 0x18, 0xec, 0x39, 0x23, 0x16, 0x6b, 0x0b, 0x4f, 0xf8, 0x19, 0xa8, 0x9f, 0xd9, 0xf7, 0x59, 0x4d, 0x8a, 0x2d, 0x16, 0xd5, 0x84, 0xe1, 0x21, 0xf1, 0x8b, 0x1e, 0x2d, 0x7e, 0xc4, 0x8b, 0xf8, 0xe3, 0xc9, 0xb1, 0x54, 0xa4, 0x65, 0xed, 0x7d, 0xbc, 0x56, 0x1a, 0x66, 0xcd, 0x43, 0x10, 0x2e, 0x46, 0x2a, 0x3f, 0xfe, 0xdb, 0x9a, 0x28, 0xf9 }, + { 0x25, 0x8c, 0x48, 0x4d, 0x0b, 0x4d, 0x3f, 0xbf, 0xde, 0xcf, 0x00, 0xc9, 0x4b, 0x0b, 0xf1, 0x14, 0xb4, 0x31, 0x97, 0x79, 0x5a, 0xd3, 0x48, 0x72, 0x44, 0x2d, 0xab, 0x76, 0x29, 0xb9, 0x8b, 0x05, 0xf5, 0x6b, 0xfb, 0xb4, 0xe4, 0xde, 0x81, 0x83, 0xa7, 0x0a, 0x90, 0xe4, 0x33, 0x41, 0x92, 0xaa, 0xc5, 0xed, 0x93, 0xe0, 0x76, 0x2b, 0xe2, 0x4b, 0xdd, 0xa2, 0x8e, 0xe1, 0xc9, 0xe2, 0x94, 0x50 }, + { 0x25, 0x8c, 0x48, 0x4d, 0x0b, 0x4d, 0x3f, 0xbf, 0xde, 0xcf, 0x00, 0xc9, 0x4b, 0x0b, 0xf1, 0x14, 0xb4, 0x31, 0x97, 0x79, 0x5a, 0xd3, 0x48, 0x72, 0x44, 0x2d, 0xab, 0x76, 0x29, 0xb9, 0x8b, 0x05, 0xf5, 0x6b, 0xfb, 0xb4, 0xe4, 0xde, 0x81, 0x83, 0xa7, 0x0a, 0x90, 0xe4, 0x33, 0x41, 0x92, 0xaa, 0xc5, 0xed, 0x93, 0xe0, 0x76, 0x2b, 0xe2, 0x4b, 0xdd, 0xa2, 0x8e, 0xe1, 0xc9, 0xe2, 0x94, 0x50 }, + } +}; + + +test_data_aes_mode_t test_data_hmac = { + .init_key = { 0xee, 0x89, 0x95, 0xda, 0x3c, 0x8a, 0x43, 0x83, 0xa9, 0x4b, 0x25, 0x5b, 0x04, 0x7e, 0xf1, 0x57, 0xb8, 0xe8, 0x06, 0x45, 0x87, 0x76, 0xee, 0x1b, 0x4e, 0x2e, 0x55, 0xa7, 0x1f, 0x25, 0xe1, 0x94 }, + .k2_info = { 0x8f, 0x96, 0x33, 0x47, 0xe1, 0xa5, 0x57, 0xe9, 0x2a, 0x51, 0xa9, 0xbe, 0x48, 0x84, 0x25, 0x4e, 0x6f, 0x50, 0x1c, 0x45, 0xdb, 0xb6, 0xfa, 0xeb, 0x35, 0xd2, 0x27, 0x91, 0x3f, 0x67, 0x57, 0xd9, 0xcb, 0x55, 0xe4, 0x2b, 0x18, 0x16, 0xe7, 0xce, 0x6c, 0xf2, 0x58, 0x71, 0x17, 0x76, 0x2a, 0x86, 0x05, 0xe7, 0x37, 0x45, 0x71, 0x34, 0xca, 0xaf, 0x60, 0x07, 0xdf, 0xf4, 0xd2, 0xee, 0x3d, 0x4b }, + .k1_encrypted = { { 0xd8, 0xf5, 0xe3, 0x3e, 0x9e, 0x79, 0xb7, 0x94, 0x3c, 0x84, 0xb0, 0xd4, 0x73, 0x21, 0x55, 0x39, 0x3f, 0xa4, 0x5f, 0x27, 0x5d, 0x4a, 0x2d, 0x2a, 0x30, 0xe5, 0xa2, 0xae, 0x78, 0xde, 0x34, 0x50 }, { } }, + .hmac_test_data = { + .message = { 0x44, 0x65, 0x6c, 0x65, 0x6e, 0x69, 0x74, 0x69, 0x20, 0x76, 0x6f, 0x6c, 0x75, 0x70, 0x74, 0x61, 0x73, 0x20, 0x65, 0x78, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x62, 0x6f, 0x20, 0x65, 0x74, 0x20, 0x61, 0x73, 0x73, 0x75, 0x6d, 0x65, 0x6e, 0x64, 0x61, 0x2e, 0x20, 0x53, 0x65, 0x64, 0x20, 0x65, 0x74, 0x20, 0x61, 0x6c, 0x69, 0x71, 0x75, 0x69, 0x64, 0x20, 0x6d, 0x69, 0x6e, 0x75, 0x73, 0x20, 0x71, 0x75, 0x69, 0x73, 0x2e, 0x20, 0x50, 0x72, 0x61, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x69, 0x75, 0x6d, 0x20, 0x63, 0x75, 0x70, 0x69, 0x64, 0x69, 0x74, 0x61, 0x74, 0x65, 0x20, 0x71, 0x75, 0x69, 0x61, 0x20, 0x6e, 0x65, 0x6d, 0x6f, 0x20, 0x65, 0x73, 0x74, 0x2e, 0x20, 0x4c, 0x61, 0x62, 0x6f, 0x72, 0x69, 0x6f, 0x73, 0x61, 0x6d, 0x20, 0x70, 0x61, 0x72, 0x69, 0x61, 0x74, 0x75, 0x72, 0x20, 0x75, 0x74, 0x20, 0x64, 0x69, 0x73, 0x74, 0x69, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x20, 0x74, 0x65, 0x6e, 0x65, 0x74, 0x75, 0x72, 0x2e, 0x20, 0x53, 0x75, 0x6e, 0x74, 0x20, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x6f, 0x20, 0x69, 0x75, 0x72, 0x65, 0x20, 0x61, 0x73, 0x70, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x20, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x61, 0x20, 0x75, 0x74, 0x20, 0x72, 0x65, 0x63, 0x75, 0x73, 0x61, 0x6e, 0x64, 0x61, 0x65, 0x2e, 0x20, 0x55, 0x74, 0x20, 0x71, 0x75, 0x69, 0x62, 0x75, 0x73, 0x64, 0x61, 0x6d, 0x20, 0x6f, 0x63, 0x63, 0x61, 0x65, 0x63, 0x61, 0x74, 0x69, 0x20, 0x75, 0x74, 0x20, 0x71, 0x75, 0x69, 0x20, 0x73, 0x69, 0x74, 0x20, 0x64, 0x69, 0x67, 0x6e, 0x69, 0x73, 0x73, 0x69, 0x6d, 0x6f, 0x73, 0x20, 0x65, 0x61, 0x71, 0x75, 0x65, 0x2e, 0x2e }, + .hmac_result = { 0xa8, 0xc0, 0x4e, 0x46, 0x70, 0x24, 0x52, 0x24, 0x47, 0x05, 0x8a, 0xa0, 0x99, 0x2b, 0xf8, 0x67, 0xf6, 0x72, 0x6f, 0x51, 0xe0, 0x94, 0x97, 0xe5, 0x88, 0x71, 0x2d, 0x42, 0x63, 0xa9, 0x2c, 0xb7 } + } +}; + + +test_data_aes_mode_t test_data_ds = { + .init_key = { 0xee, 0x89, 0x95, 0xda, 0x3c, 0x8a, 0x43, 0x83, 0xa9, 0x4b, 0x25, 0x5b, 0x04, 0x7e, 0xf1, 0x57, 0xb8, 0xe8, 0x06, 0x45, 0x87, 0x76, 0xee, 0x1b, 0x4e, 0x2e, 0x55, 0xa7, 0x1f, 0x25, 0xe1, 0x94 }, + .k2_info = { 0x8f, 0x96, 0x33, 0x47, 0xe1, 0xa5, 0x57, 0xe9, 0x2a, 0x51, 0xa9, 0xbe, 0x48, 0x84, 0x25, 0x4e, 0x6f, 0x50, 0x1c, 0x45, 0xdb, 0xb6, 0xfa, 0xeb, 0x35, 0xd2, 0x27, 0x91, 0x3f, 0x67, 0x57, 0xd9, 0xcb, 0x55, 0xe4, 0x2b, 0x18, 0x16, 0xe7, 0xce, 0x6c, 0xf2, 0x58, 0x71, 0x17, 0x76, 0x2a, 0x86, 0x05, 0xe7, 0x37, 0x45, 0x71, 0x34, 0xca, 0xaf, 0x60, 0x07, 0xdf, 0xf4, 0xd2, 0xee, 0x3d, 0x4b }, + .k1_encrypted = { { 0xe0, 0xe8, 0x41, 0xe3, 0xd0, 0x92, 0x71, 0x84, 0x4b, 0x02, 0x1e, 0xec, 0x14, 0xdd, 0xaf, 0xf8, 0x39, 0xf9, 0x6a, 0x8d, 0x1b, 0xd7, 0x64, 0x3b, 0x7b, 0xa6, 0x05, 0x42, 0x01, 0xfb, 0xab, 0xe1 }, { } }, + .ds_test_data = { + .ds_message = { 0x61, 0xaf, 0x8a, 0x89, 0xd9, 0x0c, 0x47, 0x6f, 0x08, 0xf8, 0x39, 0x77, 0x6c, 0xf1, 0x24, 0x23, 0xaa, 0xe3, 0xa2, 0x68, 0x62, 0xa5, 0x45, 0x3b, 0x01, 0x1a, 0xc4, 0xf6, 0x0d, 0x20, 0x9d, 0x7e, 0xa9, 0xcd, 0x0a, 0x73, 0xc7, 0x27, 0xf6, 0xff, 0xf7, 0x97, 0x8d, 0xd3, 0x99, 0xbd, 0xcc, 0xdf, 0xa2, 0xc8, 0xf5, 0x84, 0x58, 0xce, 0xaf, 0xef, 0x62, 0x52, 0xfb, 0x0b, 0x3b, 0xd0, 0x55, 0xb4, 0x69, 0x2d, 0x33, 0xf4, 0xd9, 0x6f, 0x84, 0xba, 0x35, 0x98, 0x07, 0x13, 0x41, 0x2f, 0xab, 0xec, 0x9d, 0xf0, 0x69, 0xc5, 0x72, 0xde, 0x19, 0x0f, 0xac, 0xda, 0x9c, 0x89, 0x97, 0xfa, 0x6f, 0x88, 0xff, 0xc5, 0x14, 0x36, 0x7f, 0x53, 0x85, 0xcd, 0x07, 0x73, 0x52, 0xcc, 0xe2, 0x5a, 0xc3, 0x09, 0xc3, 0x4c, 0x3b, 0x9d, 0x9e, 0xaa, 0xe1, 0x69, 0x4a, 0xea, 0x38, 0xac, 0x38, 0x13, 0x50, 0x25, 0x4f, 0xe2, 0x01, 0x27, 0x82, 0xaa, 0x5e, 0x9c, 0xeb, 0x0b, 0xe1, 0x2b, 0x9a, 0x05, 0x71, 0xdd, 0xf5, 0x6b, 0xaa, 0x63, 0xdb, 0xa3, 0xbc, 0xff, 0x31, 0xf9, 0xdb, 0x1d, 0xe5, 0x5f, 0x82, 0xc3, 0x67, 0x9a, 0xee, 0x2b, 0xc6, 0xc6, 0xbb, 0x10, 0x2d, 0xa7, 0xa5, 0x16, 0x7b, 0x7a, 0x80, 0x81, 0xd2, 0xf3, 0xfd, 0x00, 0xd4, 0x8f, 0x7e, 0x5d, 0xba, 0xd5, 0xbd, 0x73, 0x51, 0x4a, 0x25, 0x13, 0x18, 0x3f, 0xbf, 0xd1, 0x4d, 0xc1, 0x23, 0x94, 0xc7, 0xb6, 0xd4, 0xa8, 0xd3, 0xa2, 0xcf, 0x7f, 0x0e, 0x1e, 0xa7, 0xd9, 0xce, 0x36, 0x3b, 0x04, 0x5f, 0xf8, 0x83, 0xc4, 0x21, 0xa0, 0x48, 0x3d, 0xe3, 0xc7, 0xf8, 0x41, 0x4e, 0x69, 0x18, 0x30, 0x4b, 0x36, 0x88, 0x9d, 0x33, 0x29, 0x7e, 0xe0, 0x6f, 0x93, 0x59, 0xa2, 0x0e, 0x50, 0xc9, 0x1d, 0x38, 0xe2, 0x1b, 0x68, 0xfa, 0xc1, 0x2f, 0x29, 0x35, 0x02, 0x65, 0x1a, 0x2b, 0x36, 0x98, 0x00, 0x3f, 0xf3, 0x6d, 0xa3, 0xbf, 0xe3, 0xd8, 0x39, 0x6e, 0x30, 0x1e, 0xd2, 0xe9, 0x58, 0xb0, 0xb0, 0x60, 0xc0, 0x85, 0x0b, 0x8d, 0x47, 0xa2, 0xcb, 0x67, 0x8a, 0xe3, 0x13, 0xec, 0x2d, 0x6d, 0x01, 0xf6, 0x6c, 0x07, 0xab, 0xfe, 0xe5, 0x29, 0xe9, 0x65, 0x3e, 0x55, 0x7a, 0x76, 0xcb, 0x45, 0xa1, 0x42, 0xa8, 0xa3, 0x34, 0x67, 0xb8, 0xec, 0x61, 0x00, 0xa7, 0xfc, 0xd0, 0xc3, 0xdb, 0xc9, 0xf9, 0xa1, 0x46, 0xf5, 0x8a, 0xc2, 0x96, 0xf4, 0xae, 0x34, 0xf9, 0xd8, 0x86, 0x9f, 0x67, 0x57, 0x58, 0xba, 0x46, 0x1b, 0x2f, 0xdf, 0x0f, 0x9c, 0x49, 0x21, 0x16, 0x2f, 0xb2, 0xc1, 0xa6, 0xe4, 0x8e, 0x4f, 0x87, 0x3d, 0x8c, 0x29, 0x03, 0x0a, 0x81, 0xbf, 0x3f, 0xa4, 0xee, 0x99, 0xd1, 0xbc, 0x01, 0x40, 0xfb, 0xdf, 0x1e, 0xe3, 0x71, 0x58, 0x5a }, + .ds_encrypted_input_params = { 0x1c, 0x8e, 0xa5, 0x03, 0xc3, 0x5e, 0xc3, 0xcc, 0xf6, 0x52, 0xda, 0x20, 0x95, 0xff, 0xf7, 0xe5, 0x36, 0x45, 0x4e, 0xae, 0xf6, 0x41, 0xcc, 0xda, 0x73, 0xa5, 0xfd, 0xa4, 0x56, 0x61, 0xaa, 0x5d, 0xf7, 0x55, 0xed, 0x01, 0x03, 0xd0, 0x15, 0x65, 0x32, 0x76, 0x38, 0xc4, 0x84, 0x25, 0x4f, 0x48, 0xe2, 0xe3, 0x1f, 0xf9, 0x16, 0xe2, 0xf2, 0x58, 0xde, 0x46, 0x2a, 0x92, 0x68, 0xb6, 0x1c, 0xe0, 0xde, 0x17, 0x77, 0x25, 0x06, 0xa2, 0x93, 0x02, 0xfe, 0x84, 0x72, 0xae, 0xba, 0x09, 0x45, 0xdc, 0x1e, 0x69, 0xa8, 0xbd, 0xfa, 0x34, 0xce, 0x58, 0x8c, 0x3a, 0x46, 0xab, 0xdc, 0x42, 0xa1, 0x54, 0x0d, 0x36, 0x91, 0x99, 0xe5, 0x27, 0x3c, 0x2b, 0x09, 0x7a, 0xc7, 0x79, 0xc0, 0x0f, 0x54, 0x02, 0xfa, 0x93, 0x95, 0xb0, 0xdd, 0xca, 0x26, 0xdc, 0x91, 0x65, 0x29, 0xf7, 0x19, 0xb0, 0xa8, 0xb3, 0xf8, 0xa4, 0xf8, 0xbc, 0x02, 0x84, 0x3d, 0xda, 0xef, 0x44, 0x48, 0xef, 0x06, 0xd8, 0x41, 0x44, 0x0d, 0x5c, 0xfa, 0x4c, 0xe2, 0x1a, 0x6e, 0x15, 0xf0, 0x74, 0xce, 0xfd, 0x61, 0xda, 0x83, 0xe4, 0x3a, 0xfc, 0xd3, 0xc4, 0xc2, 0x94, 0xb0, 0xf6, 0x80, 0x10, 0xf3, 0x6c, 0xa1, 0x3f, 0xe0, 0x55, 0x8e, 0x6d, 0x0c, 0x21, 0x3f, 0xfb, 0xe8, 0x61, 0x63, 0x01, 0x3f, 0x64, 0x93, 0xfc, 0x67, 0x0e, 0x0f, 0x85, 0x18, 0xe9, 0x34, 0x0b, 0x89, 0xa9, 0x87, 0x6f, 0xfe, 0x39, 0x91, 0x31, 0x42, 0xcd, 0x3c, 0xe0, 0x7b, 0x22, 0x46, 0xf2, 0xee, 0xb3, 0x4b, 0x5c, 0xd0, 0x6f, 0xb8, 0x0d, 0x24, 0x3d, 0x06, 0xf5, 0x13, 0x7c, 0x21, 0xb5, 0xc7, 0xd3, 0x0e, 0x9e, 0x53, 0x29, 0x19, 0x96, 0x76, 0xf3, 0x44, 0x69, 0x67, 0x3e, 0xb3, 0x3c, 0x89, 0x92, 0x6c, 0x86, 0xe3, 0x64, 0x5d, 0xc0, 0x8d, 0x7a, 0xfe, 0x01, 0x45, 0x98, 0x34, 0x3d, 0x26, 0x50, 0xd7, 0x33, 0xbb, 0xcf, 0xea, 0x53, 0x65, 0xb8, 0x4f, 0x51, 0x99, 0x91, 0x13, 0x32, 0xdd, 0x92, 0xd0, 0x22, 0xb2, 0xbd, 0x23, 0xed, 0xdf, 0x73, 0xea, 0x72, 0x02, 0x3d, 0x39, 0x38, 0x49, 0x18, 0x0a, 0xe7, 0x48, 0x96, 0xec, 0xce, 0x0c, 0x1a, 0x9f, 0xc5, 0x84, 0xfc, 0x95, 0x6c, 0x59, 0xb4, 0xda, 0x74, 0xb3, 0xd7, 0x94, 0xe4, 0x5c, 0xf3, 0x7f, 0xba, 0x17, 0x79, 0xf7, 0xdb, 0x1a, 0xd0, 0x51, 0xf5, 0xc6, 0xbd, 0x55, 0x1b, 0xcc, 0x67, 0x20, 0xc8, 0x70, 0x0d, 0xdc, 0x5d, 0x9d, 0xdd, 0x9e, 0x13, 0x6e, 0x4b, 0x07, 0x3b, 0x56, 0x34, 0x68, 0xe3, 0x9e, 0xa8, 0xa1, 0x46, 0xbb, 0x30, 0xb1, 0xc1, 0xef, 0xea, 0x86, 0xf7, 0x1f, 0x44, 0xee, 0xf5, 0x07, 0x73, 0x36, 0x78, 0xfd, 0x38, 0x43, 0xef, 0x7a, 0x93, 0x00, 0x4f, 0x6b, 0x69, 0xc5, 0x6a, 0x9d, 0xc7, 0x87, 0x99, 0xde, 0x19, 0xfa, 0x83, 0x65, 0x6e, 0x77, 0x5d, 0x09, 0x04, 0xb8, 0x7a, 0xfd, 0xc3, 0x6c, 0xb8, 0x48, 0xb4, 0x5a, 0x4b, 0x54, 0xb8, 0x52, 0xcc, 0x85, 0x9d, 0xd9, 0xa5, 0xa4, 0x49, 0x27, 0x56, 0x24, 0xfb, 0xc2, 0xf0, 0x81, 0x20, 0xa5, 0x00, 0xc7, 0xff, 0xd6, 0x9c, 0x08, 0x0f, 0xd4, 0xe4, 0x78, 0x96, 0xce, 0x53, 0xd5, 0x0b, 0xc3, 0x1a, 0xe5, 0xc9, 0xb2, 0x57, 0xea, 0x44, 0xd9, 0x74, 0x39, 0x6b, 0xd7, 0x73, 0x35, 0xd7, 0xb9, 0xa8, 0x25, 0x74, 0x90, 0xf2, 0x11, 0xd1, 0x65, 0xdc, 0xf7, 0x7d, 0x9a, 0x56, 0x01, 0x4b, 0x0d, 0x78, 0xe9, 0xd3, 0xe7, 0xae, 0x23, 0xe5, 0xa5, 0x1c, 0x8a, 0x0e, 0x95, 0xb6, 0xae, 0xdd, 0xdf, 0xcd, 0x89, 0xb7, 0x10, 0x54, 0x24, 0x69, 0x3e, 0xec, 0x66, 0x2b, 0x94, 0x3e, 0x6c, 0xcb, 0x70, 0x4c, 0xb9, 0xa8, 0x29, 0x97, 0xcd, 0xdb, 0x29, 0x3e, 0xd0, 0xbf, 0x5d, 0xa8, 0x55, 0x9d, 0x22, 0x3d, 0xb8, 0x84, 0xbc, 0xe2, 0xc4, 0x58, 0xe6, 0xbf, 0xd4, 0xd4, 0x99, 0xed, 0x85, 0x59, 0x5e, 0xb9, 0xc3, 0x8b, 0x78, 0x49, 0xd3, 0xea, 0xe3, 0x39, 0xb2, 0x5b, 0x37, 0x7a, 0xe9, 0x74, 0x14, 0x61, 0xb0, 0x05, 0x0f, 0x95, 0xca, 0xa6, 0xd7, 0x9e, 0xd6, 0x13, 0x7e, 0xda, 0xbc, 0x17, 0xee, 0x10, 0xcf, 0x10, 0xa4, 0x76, 0xd1, 0xff, 0xa7, 0xce, 0x5e, 0x66, 0xcd, 0x28, 0x12, 0x83, 0x73, 0x37, 0x59, 0x28, 0xac, 0x97, 0x3e, 0x82, 0xd6, 0x98, 0xd5, 0x34, 0xe2, 0xbf, 0xd8, 0xda, 0xad, 0x5e, 0x02, 0xdd, 0xe4, 0x50, 0xbb, 0x8f, 0x0d, 0x01, 0x36, 0x5c, 0xe0, 0x2d, 0xae, 0xa6, 0x09, 0xb9, 0xcf, 0x44, 0x36, 0x6b, 0x0c, 0xa9, 0x7f, 0x88, 0xd7, 0xd8, 0x6c, 0x98, 0xc9, 0x21, 0x70, 0xf7, 0x0d, 0x7e, 0x6d, 0x6b, 0x08, 0x09, 0xea, 0xbf, 0x95, 0xb1, 0xa3, 0x48, 0x73, 0xfc, 0xc0, 0xb8, 0x40, 0xee, 0xc6, 0xd0, 0xe1, 0xbb, 0x52, 0x95, 0x0e, 0xc7, 0xde, 0xc8, 0xe6, 0xcf, 0x51, 0x01, 0xfc, 0x69, 0xba, 0x75, 0x82, 0x32, 0x5f, 0x24, 0x5b, 0x60, 0xc0, 0x46, 0xc0, 0xc3, 0x07, 0x67, 0x25, 0x77, 0xaf, 0x2e, 0x4b, 0x88, 0xf5, 0xe6, 0xd7, 0x6b, 0xd3, 0x28, 0xa6, 0x92, 0x77, 0xc5, 0x02, 0x76, 0xbe, 0xe0, 0x70, 0x6e, 0xe8, 0xa0, 0x55, 0xb4, 0xfe, 0xfe, 0x8d, 0x57, 0x02, 0x80, 0xe3, 0x0e, 0xb4, 0x1b, 0xe0, 0xcb, 0xb2, 0xc8, 0x6c, 0xa9, 0x8a, 0xb8, 0x61, 0x9c, 0x87, 0x3e, 0x10, 0x25, 0x3e, 0x29, 0x68, 0x5b, 0x07, 0x7a, 0x29, 0xe6, 0x1b, 0x68, 0x24, 0x25, 0xbb, 0xfd, 0xec, 0xe0, 0xcf, 0x08, 0x20, 0x49, 0x36, 0x49, 0xdf, 0x6d, 0xb1, 0xf9, 0x17, 0xa2, 0xfb, 0xb3, 0xb0, 0x68, 0x1c, 0x2d, 0x4e, 0x8b, 0x95, 0xfa, 0x01, 0x1c, 0xea, 0x90, 0xd4, 0xf8, 0x3c, 0xcd, 0x17, 0xb0, 0x86, 0xd6, 0xbe, 0x41, 0xfa, 0x36, 0x7f, 0x0f, 0x12, 0xec, 0x3c, 0xb7, 0x38, 0x2e, 0xdb, 0x12, 0x0c, 0x6d, 0x88, 0x8e, 0x19, 0x97, 0x5c, 0xf4, 0xed, 0x11, 0x09, 0xfb, 0xda, 0x76, 0xe6, 0x5f, 0x16, 0x17, 0x43, 0xe6, 0x36, 0xab, 0x97, 0x36, 0x2d, 0x60, 0xf4, 0xf2, 0x94, 0xe3, 0x50, 0xe2, 0x42, 0x98, 0x32, 0x22, 0xde, 0x0f, 0x86, 0x83, 0x7d, 0xcf, 0x4a, 0x64, 0x91, 0xfc, 0x42, 0xea, 0xc2, 0xdf, 0x72, 0x33, 0xad, 0x8a, 0xc0, 0x20, 0x03, 0x32, 0xf8, 0x48, 0xdc, 0xe9, 0xed, 0x28, 0x34, 0x16, 0x84, 0xbc, 0xd2, 0xde, 0x47, 0x69, 0xf7, 0x65, 0x92, 0x28, 0x58, 0x30, 0x5e, 0xf9, 0xfe, 0x47, 0xff, 0x2d, 0xe3, 0xff, 0xf8, 0x37, 0xa5, 0xf2, 0x99, 0x7c, 0x86, 0xad, 0xfe, 0x92, 0x11, 0x19, 0x40, 0x45, 0x5b, 0x13, 0xaf, 0x87, 0x25, 0x74, 0x28, 0x8b, 0x34, 0x53, 0xcd, 0xc5, 0xb2, 0xde, 0x8c, 0x5a, 0xcc, 0x03, 0x2d, 0x88, 0x5e, 0xe3, 0x6a, 0x31, 0x14, 0x57, 0xdc, 0x9a, 0x05, 0x0a, 0xef, 0xa3, 0xb0, 0xcf, 0xda, 0xfe, 0xc1, 0x3b, 0x96, 0xb0, 0xa9, 0x0f, 0xdd, 0xbb, 0x7e, 0x71, 0xb8, 0x28, 0x0b, 0x79, 0x74, 0xf4, 0xcd, 0x70, 0x76, 0x1f, 0xcf, 0x60, 0x4d, 0x39, 0xb4, 0xac, 0x65, 0xc7, 0x23, 0x12, 0x04, 0xf1, 0xbf, 0x7f, 0xf1, 0xb5, 0x08, 0x87, 0x9b, 0x83, 0x15, 0x86, 0x3a, 0x19, 0x61, 0x87, 0x44, 0x19, 0xce, 0x8b, 0xac, 0xd3, 0xf2, 0x25, 0x75, 0x49, 0xc0, 0x0e, 0x97, 0x3b, 0x13, 0x12, 0x08, 0x83, 0xa0, 0x40, 0x48, 0x2d, 0x47, 0xb8, 0x7a, 0x68, 0xcd, 0x1d, 0x1d, 0xa8, 0x4f, 0xb4, 0x7a, 0x39, 0x0c, 0x13, 0xba, 0x38, 0x49, 0x33, 0x8e, 0x0e, 0x8c, 0x81, 0x16, 0x0c, 0x12, 0xb6, 0x1b, 0x07, 0x76, 0x67, 0xc1, 0x7a, 0xb7, 0x5a, 0x3b, 0x73, 0x5f, 0x6b, 0x96, 0x9c, 0xb4, 0x94, 0x25, 0x05, 0xaf, 0xb6, 0x8b, 0x2d, 0x4b, 0x82, 0x95, 0x88, 0xce, 0xc0, 0x31, 0x44, 0xa3, 0x69, 0x8d, 0x9d, 0xe4, 0x8b, 0xd8, 0x86, 0xd4, 0x63, 0x82, 0xe1, 0x98, 0x91, 0xb1, 0xd1, 0x6b, 0xf4, 0xb4, 0x79, 0xcf, 0xff, 0x2a, 0x5a, 0x6c, 0x50, 0x47, 0x83, 0x87, 0x90, 0xb8, 0x3b, 0xb1, 0xa6, 0x18, 0x33, 0x25, 0xc0, 0x8e, 0xbe, 0x27, 0x40, 0xea, 0x6f, 0x1e, 0x5c, 0x0b, 0x2c, 0x62, 0xf9, 0xf5, 0xf4, 0x4c, 0xf9, 0x46, 0x1a, 0x36, 0xe6, 0x74, 0x3f, 0x5e, 0x9c, 0x64, 0x33, 0xba, 0x4f, 0xc7, 0xee, 0x1e, 0x66, 0xf4, 0x29, 0xbe, 0xe0, 0x05, 0xbf, 0xad, 0x1b, 0x1b, 0xe4, 0x17, 0x2c, 0xe5, 0xf7, 0x44, 0xf1, 0xe6, 0x11, 0x05, 0x37, 0xa4, 0x5f, 0xd0, 0xaa, 0xb1, 0xc1, 0x49, 0x92, 0xf2, 0x8e, 0xc4, 0x37, 0xfe, 0x9f, 0xf4, 0x89, 0x22, 0x0c, 0x68, 0x06, 0xa9, 0x8e, 0x05, 0x04, 0x8a, 0xa9, 0x93, 0x18, 0xbe, 0x24, 0x0c, 0xc6, 0xbd, 0x6b, 0xa5, 0x1b, 0xbd, 0x6f, 0x78, 0x57, 0x13, 0xf0, 0xda, 0x23, 0x73, 0x1b, 0xf8, 0xcd, 0x08, 0x8c }, + .ds_encrypted_input_params_iv = { 0xbc, 0xea, 0xec, 0x15, 0x14, 0xa4, 0x09, 0x48, 0xc4, 0x3c, 0x64, 0xcb, 0xc9, 0x4b, 0x70, 0x32 }, + .ds_key_size = 3072, + .ds_result = { 0xeb, 0x17, 0x4c, 0xa9, 0x8d, 0x88, 0x53, 0x06, 0x8b, 0x55, 0x84, 0xc7, 0xcf, 0x89, 0x26, 0x17, 0x02, 0x2a, 0xab, 0x5c, 0x1b, 0xa6, 0x22, 0x6b, 0xdb, 0x16, 0xb4, 0x17, 0x97, 0xef, 0x41, 0x85, 0x23, 0x30, 0x2c, 0xa5, 0x13, 0x45, 0x48, 0x8d, 0x53, 0x84, 0x5c, 0xff, 0x0c, 0x23, 0x40, 0x10, 0x56, 0x0f, 0xf5, 0xc1, 0x1e, 0xe0, 0x6e, 0x14, 0xf8, 0xc4, 0x25, 0xe5, 0x35, 0x7e, 0xd6, 0xcc, 0xff, 0x08, 0xe2, 0xc7, 0xb9, 0x03, 0x5f, 0x2c, 0xc9, 0xea, 0x24, 0xa1, 0x27, 0x24, 0x41, 0x49, 0x7c, 0x71, 0x27, 0x84, 0x34, 0x42, 0x74, 0xfc, 0x95, 0x34, 0x1a, 0xdb, 0x46, 0xab, 0x4e, 0x19, 0x8d, 0x77, 0x3a, 0xdb, 0x74, 0x4c, 0x48, 0x20, 0x97, 0xd7, 0x75, 0xcb, 0xa2, 0x28, 0xd2, 0xfd, 0x6c, 0x53, 0x61, 0x71, 0xe4, 0x96, 0x93, 0x9d, 0x98, 0x07, 0xd0, 0x1b, 0x9f, 0x17, 0x1c, 0xf1, 0x32, 0xc1, 0x13, 0x5a, 0x84, 0x49, 0x19, 0x19, 0xc5, 0x36, 0xb2, 0xdb, 0xf7, 0x8b, 0x8d, 0x39, 0xdd, 0xc6, 0xdb, 0x2d, 0xcf, 0xd2, 0xbe, 0x38, 0x8b, 0x90, 0x37, 0xeb, 0x1b, 0x70, 0xed, 0x94, 0x3b, 0xad, 0x5c, 0x19, 0xe2, 0xbe, 0x76, 0xa4, 0xb2, 0x60, 0xc9, 0xd2, 0x6f, 0xb4, 0x01, 0xb1, 0xd7, 0x37, 0xc7, 0xb2, 0xfd, 0xfa, 0xd0, 0xf7, 0xb8, 0x10, 0x2d, 0x59, 0xde, 0x4d, 0x08, 0x25, 0xd1, 0x79, 0x69, 0xfc, 0x87, 0x1a, 0xf1, 0x41, 0x8a, 0x13, 0x31, 0xc4, 0xd4, 0x36, 0x3c, 0x24, 0xc2, 0xe1, 0x27, 0x85, 0x72, 0xe4, 0x92, 0x7a, 0x89, 0x93, 0x47, 0xc6, 0x9b, 0xaa, 0xe0, 0x12, 0xc1, 0x4b, 0x7d, 0xd1, 0xc9, 0xc7, 0x9a, 0xab, 0xa8, 0x68, 0x4d, 0x9e, 0xf4, 0xc4, 0x2e, 0x4b, 0xe6, 0x6d, 0x2a, 0x07, 0xa1, 0xc1, 0x4b, 0x5f, 0x84, 0xf6, 0xd9, 0x5c, 0x15, 0xc8, 0xcc, 0xa5, 0x60, 0x1b, 0xc1, 0x83, 0x9d, 0x18, 0x82, 0xbd, 0x07, 0xb7, 0xa3, 0xb0, 0x93, 0x03, 0x8e, 0x9a, 0x95, 0x3f, 0xe1, 0x4c, 0x6c, 0x21, 0x7e, 0xb3, 0xd7, 0xae, 0xf9, 0x6f, 0x4e, 0x4c, 0xfa, 0xa0, 0x2a, 0x46, 0xae, 0x3a, 0xe6, 0x93, 0xae, 0x1a, 0xfb, 0xa5, 0x2f, 0xad, 0x92, 0xa5, 0x12, 0x76, 0xd6, 0xb9, 0x93, 0xbb, 0xa2, 0x2a, 0x01, 0x14, 0x3a, 0xd7, 0x17, 0xd6, 0xfd, 0xc5, 0x75, 0x9d, 0x8e, 0x4f, 0xee, 0x2f, 0x9f, 0xfb, 0x71, 0x9a, 0x7e, 0xd9, 0xff, 0x95, 0xa0, 0x9f, 0x3d, 0x83, 0x91, 0xcc, 0x86, 0xc2, 0x5c, 0x68, 0xd3, 0x9d, 0x7f, 0x71, 0x54, 0x7a, 0xec, 0xe6, 0x40, 0xa5, 0xe5, 0xb7, 0x84, 0xd7, 0x56, 0x6c, 0x40, 0xb3, 0xa1, 0x9a, 0x9e, 0x50, 0x2b, 0x93, 0xfe, 0xca, 0xa6, 0x3d, 0x02, 0x6b, 0x31, 0x51, 0x87, 0x9d, 0xa7, 0x30, 0x82, 0x49, 0xe5, 0x26, 0xc7, 0xaf } } }; diff --git a/components/hal/test_apps/crypto/main/key_manager/rand_num.bin b/components/hal/test_apps/crypto/main/key_manager/rand_num.bin new file mode 100644 index 0000000000..16c97b3873 --- /dev/null +++ b/components/hal/test_apps/crypto/main/key_manager/rand_num.bin @@ -0,0 +1 @@ +ÿy/ãAâ•™çfIÑBŸXRæFn&ñS&6lñäV \ No newline at end of file diff --git a/components/hal/test_apps/crypto/main/key_manager/test_key_manager.c b/components/hal/test_apps/crypto/main/key_manager/test_key_manager.c index 2def4096e8..01643ff1a8 100644 --- a/components/hal/test_apps/crypto/main/key_manager/test_key_manager.c +++ b/components/hal/test_apps/crypto/main/key_manager/test_key_manager.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -25,9 +25,17 @@ #include "key_manager_test_cases.h" #include "esp_log.h" -// For ECDSA tests -#include "hal/ecdsa_hal.h" +#if SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY +#include "hal/ecdsa_types.h" +#endif +#if SOC_KEY_MANAGER_HMAC_KEY_DEPLOY +#include "hal/hmac_types.h" +#endif +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY +#include "ds/ds_types.h" +#endif +#if SOC_KEY_MANAGER_FE_KEY_DEPLOY const esp_partition_t *get_test_storage_partition(void) { /* This finds "storage" partition defined partition table */ @@ -35,32 +43,26 @@ const esp_partition_t *get_test_storage_partition(void) ESP_PARTITION_SUBTYPE_ANY, "storage"); if (!result) { /* means partition table set wrong */ - printf("ERROR in obtaining storage partition"); + ESP_LOGE("", "ERROR in obtaining storage partition"); return NULL; } return result; } -static void print_data_in_hex(const uint8_t *data, int size, const char *info_str) -{ - printf("%s: 0x", info_str); - for(int i = 0 ; i < size; i++) { - printf("%02x", data[i]); - } - printf("\n"); -} - static void test_xts_aes_key_aes_mode(test_data_aes_mode_t *test_data) { const esp_partition_t *partition = get_test_storage_partition(); ESP_ERROR_CHECK(esp_partition_erase_range(partition, 0, partition->size)); + uint8_t read_data[128]; for (int i = 0; i < TEST_COUNT; i++) { + memset(read_data, 0, sizeof(read_data)); uint32_t address = test_data->xts_test_data[i].data_offset; uint32_t data_size = test_data->xts_test_data[i].data_size; + ESP_ERROR_CHECK(esp_flash_write_encrypted(NULL, address, test_data->plaintext_data, data_size)); - static uint8_t read_data[128]; ESP_ERROR_CHECK(esp_flash_read(NULL, read_data, address, data_size)); + TEST_ASSERT_EQUAL_HEX8_ARRAY(test_data->xts_test_data[i].ciphertext, read_data, data_size); } } @@ -70,18 +72,20 @@ static void test_xts_aes_key_ecdh0_mode(test_data_ecdh0_mode_t *test_data) const esp_partition_t *partition = get_test_storage_partition(); ESP_ERROR_CHECK(esp_partition_erase_range(partition, 0, partition->size)); + uint8_t read_data[128] = { 0 }; uint32_t address = partition->address; uint32_t data_size = 32; - print_data_in_hex(test_data->plaintext_data, data_size, "Plaintext data"); + ESP_LOG_BUFFER_HEXDUMP("Plaintext data", test_data->plaintext_data, data_size, ESP_LOG_DEBUG); ESP_ERROR_CHECK(esp_flash_write_encrypted(NULL, address, test_data->plaintext_data, data_size)); - static uint8_t read_data[128]; ESP_ERROR_CHECK(esp_flash_read(NULL, read_data, address, data_size)); - print_data_in_hex(read_data, data_size, "Encrypted data"); + + ESP_LOG_BUFFER_HEXDUMP("Encrypted data", read_data, data_size, ESP_LOG_DEBUG); } -static void key_mgr_test_xts_aes_128(void) +#if SOC_FLASH_ENCRYPTION_XTS_AES_128 +static void key_mgr_test_xts_aes_128_aes_mode(void) { static esp_key_mgr_aes_key_config_t key_config; memcpy(key_config.k2_info, (uint8_t*) test_data_xts_aes_128.k2_info, KEY_MGR_K2_INFO_SIZE); @@ -95,9 +99,27 @@ static void key_mgr_test_xts_aes_128(void) TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); test_xts_aes_key_aes_mode(&test_data_xts_aes_128); TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); - } +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; + + static esp_key_mgr_key_recovery_info_t key_recovery_info; + static esp_key_mgr_ecdh0_info_t ecdh0_info; + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_ecdh0_mode(&key_config, &key_recovery_info, &ecdh0_info)); + + ESP_LOG_BUFFER_HEXDUMP("K2_G", ecdh0_info.k2_G[0], KEY_MGR_ECDH0_INFO_SIZE, ESP_LOG_DEBUG); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); + test_xts_aes_key_ecdh0_mode(&test_data_ecdh0); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); +} +#endif /* SOC_FLASH_ENCRYPTION_XTS_AES_128 */ + +#if SOC_FLASH_ENCRYPTION_XTS_AES_256 static void key_mgr_test_xts_aes_256_aes_mode(void) { static esp_key_mgr_aes_key_config_t key_config; @@ -115,11 +137,80 @@ static void key_mgr_test_xts_aes_256_aes_mode(void) TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); } -#ifdef SOC_ECDSA_SUPPORT_EXPORT_PUBKEY +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; + + static esp_key_mgr_key_recovery_info_t key_recovery_info; + static esp_key_mgr_ecdh0_info_t ecdh0_info; + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_ecdh0_mode(&key_config, &key_recovery_info, &ecdh0_info)); + + ESP_LOG_BUFFER_HEXDUMP("K2_G_0", ecdh0_info.k2_G[0], KEY_MGR_ECDH0_INFO_SIZE, ESP_LOG_DEBUG); + ESP_LOG_BUFFER_HEXDUMP("K2_G_1", ecdh0_info.k2_G[1], KEY_MGR_ECDH0_INFO_SIZE, ESP_LOG_DEBUG); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); + test_xts_aes_key_ecdh0_mode(&test_data_ecdh0); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); +} +#endif /* SOC_FLASH_ENCRYPTION_XTS_AES_256 */ + +#if CONFIG_CRYPTO_TEST_APP_ENABLE_FPGA_TESTS +static void test_xts_aes_key_random_mode(void) +{ + const esp_partition_t *partition = get_test_storage_partition(); + ESP_ERROR_CHECK(esp_partition_erase_range(partition, 0, partition->size)); + uint8_t plaintext_data[1024] = {[0 ... 1023] = 0xBE}; + const int write_size = 16; + for (int i = 0; i < sizeof(plaintext_data) / write_size; i++) { + ESP_LOGI("", " i = %d", i); + ESP_ERROR_CHECK(esp_flash_write_encrypted(NULL, partition->address + (i * write_size), plaintext_data, write_size)); + static uint8_t read_data[128]; + ESP_ERROR_CHECK(esp_partition_read(partition, write_size * i, read_data, write_size)); + TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext_data + (i * write_size), read_data, write_size); + } +} + +#if SOC_FLASH_ENCRYPTION_XTS_AES_128 +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; + + 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)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); + test_xts_aes_key_random_mode(); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); +} +#endif /* SOC_FLASH_ENCRYPTION_XTS_AES_128 */ + +#if SOC_FLASH_ENCRYPTION_XTS_AES_256 +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; + + 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)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); + test_xts_aes_key_random_mode(); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); +} +#endif /* SOC_FLASH_ENCRYPTION_XTS_AES_256 */ +#endif /* CONFIG_CRYPTO_TEST_APP_ENABLE_FPGA_TESTS */ +#endif /* SOC_KEY_MANAGER_FE_KEY_DEPLOY */ + +#if SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY +#if SOC_ECDSA_SUPPORT_EXPORT_PUBKEY extern void test_ecdsa_export_pubkey(bool is_p256, uint8_t *ecdsa_pub_x, uint8_t *ecdsa_pub_y, bool use_km_key); extern void test_ecdsa_export_pubkey_inner(bool is_p256, uint8_t *exported_pub_x, uint8_t *exported_pub_y, bool use_km_key, uint16_t *len); #endif +extern void test_ecdsa_sign(bool is_p256, uint8_t* sha, uint8_t* r_le, uint8_t* s_le, bool use_km_key, ecdsa_sign_type_t k_type); +extern int test_ecdsa_verify(bool is_p256, uint8_t* sha, uint8_t* r_le, uint8_t* s_le, uint8_t *pub_x, uint8_t *pub_y); extern void test_ecdsa_sign_and_verify(bool is_p256, uint8_t* sha, uint8_t* pub_x, uint8_t* pub_y, bool use_km_key, ecdsa_sign_type_t k_type); /* @@ -137,11 +228,6 @@ void test_ecdsa_key_aes_mode(test_data_aes_mode_t *ecdsa_test_data, ecdsa_sign_t #endif } - -extern void test_ecdsa_sign(bool is_p256, uint8_t* sha, uint8_t* r_le, uint8_t* s_le, bool use_km_key, ecdsa_sign_type_t k_type); - -extern int test_ecdsa_verify(bool is_p256, uint8_t* sha, uint8_t* r_le, uint8_t* s_le, uint8_t *pub_x, uint8_t *pub_y); - void key_mgr_test_ecdsa_key(bool is_p256, ecdsa_sign_type_t k_type) { uint8_t pub_x[32] = {}; @@ -151,18 +237,17 @@ void key_mgr_test_ecdsa_key(bool is_p256, ecdsa_sign_type_t k_type) test_ecdsa_sign(is_p256, sha256_digest, r_le, s_le, 1, k_type); - print_data_in_hex(sha256_digest, sizeof(sha256_digest), "ECDSA message sha256 digest"); - print_data_in_hex(r_le, sizeof(r_le), "ECDSA signature r_le"); - print_data_in_hex(s_le, sizeof(s_le), "ECDSA signature s_le"); + ESP_LOG_BUFFER_HEXDUMP("ECDSA message sha256 digest", sha256_digest, sizeof(sha256_digest), ESP_LOG_DEBUG); + ESP_LOG_BUFFER_HEXDUMP("ECDSA signature r_le", r_le, sizeof(r_le), ESP_LOG_DEBUG); + ESP_LOG_BUFFER_HEXDUMP("ECDSA signature s_le", s_le, sizeof(s_le), ESP_LOG_DEBUG); // Export the pubkey from ECDSA peripheral uint16_t pubkey_len = 0; test_ecdsa_export_pubkey_inner(is_p256, pub_x, pub_y, 1, &pubkey_len); - print_data_in_hex(pub_x, pubkey_len, "ECDSA key pubx"); - print_data_in_hex(pub_y, pubkey_len, "ECDSA key puby"); + ESP_LOG_BUFFER_HEXDUMP("ECDSA key pubx", pub_x, pubkey_len, ESP_LOG_DEBUG); + ESP_LOG_BUFFER_HEXDUMP("ECDSA key puby", pub_y, pubkey_len, ESP_LOG_DEBUG); TEST_ASSERT_EQUAL(0, test_ecdsa_verify(is_p256, sha256_digest, r_le, s_le, pub_x, pub_y)); - } static void key_mgr_test_ecdsa_p256_aes_mode(void) @@ -172,7 +257,7 @@ 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_KEY; + key_config.key_type = ESP_KEY_MGR_ECDSA_256_KEY; 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)); @@ -185,56 +270,16 @@ static void key_mgr_test_ecdsa_p256_aes_mode(void) TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); } -static void key_mgr_test_xts_aes_128_ecdh0_mode(void) -{ - printf("\nKey Manager ECDH0 deployment: XTS_AES_128 key\n"); - 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; - - static esp_key_mgr_key_recovery_info_t key_recovery_info; - static esp_key_mgr_ecdh0_info_t ecdh0_info; - TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_ecdh0_mode(&key_config, &key_recovery_info, &ecdh0_info)); - - print_data_in_hex(ecdh0_info.k2_G[0], KEY_MGR_ECDH0_INFO_SIZE, "K2_G"); - - TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); - test_xts_aes_key_ecdh0_mode(&test_data_ecdh0); - TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); -} - -static void key_mgr_test_xts_aes_256_ecdh0_mode(void) -{ - printf("\nKey Manager ECDH0 deployment: XTS_AES_256 key\n"); - 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; - - static esp_key_mgr_key_recovery_info_t key_recovery_info; - static esp_key_mgr_ecdh0_info_t ecdh0_info; - TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_ecdh0_mode(&key_config, &key_recovery_info, &ecdh0_info)); - - print_data_in_hex(ecdh0_info.k2_G[0], KEY_MGR_ECDH0_INFO_SIZE, "K2_G_0"); - print_data_in_hex(ecdh0_info.k2_G[1], KEY_MGR_ECDH0_INFO_SIZE, "K2_G_1"); - - TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); - test_xts_aes_key_ecdh0_mode(&test_data_ecdh0); - TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); -} - static void key_mgr_test_ecdsa_ecdh0_mode(void) { - printf("\nKey Manager ECDH0 deployment: ECDSA_256 key\n"); 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_KEY; + key_config.key_type = ESP_KEY_MGR_ECDSA_256_KEY; static esp_key_mgr_key_recovery_info_t key_recovery_info; static esp_key_mgr_ecdh0_info_t ecdh0_info; TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_ecdh0_mode(&key_config, &key_recovery_info, &ecdh0_info)); - - print_data_in_hex(ecdh0_info.k2_G[0], KEY_MGR_ECDH0_INFO_SIZE, "K2_G"); + ESP_LOG_BUFFER_HEXDUMP("K2_G", ecdh0_info.k2_G[0], KEY_MGR_ECDH0_INFO_SIZE, ESP_LOG_DEBUG); TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); #ifdef SOC_ECDSA_SUPPORT_DETERMINISTIC_MODE @@ -246,72 +291,142 @@ static void key_mgr_test_ecdsa_ecdh0_mode(void) static void key_mgr_test_ecdsa_random_mode(void) { - printf("\nKey Manager Random deployment: ECDSA_256 key\n"); static esp_key_mgr_random_key_config_t key_config; - key_config.key_type = ESP_KEY_MGR_ECDSA_KEY; + key_config.key_type = ESP_KEY_MGR_ECDSA_256_KEY; 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)); TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); - #ifdef SOC_ECDSA_SUPPORT_DETERMINISTIC_MODE key_mgr_test_ecdsa_key(1, ECDSA_K_TYPE_DETERMINISITIC); #endif key_mgr_test_ecdsa_key(1, ECDSA_K_TYPE_TRNG); - TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); } +#endif /* SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY */ -#if CONFIG_CRYPTO_TEST_APP_ENABLE_FPGA_TESTS +#if SOC_KEY_MANAGER_HMAC_KEY_DEPLOY +extern esp_err_t hmac_calculate(uint32_t key_id, const void *message, size_t message_len, uint8_t *hmac); -static void test_xts_aes_key_random_mode(void) +static void key_mgr_test_hmac_key_aes_mode(test_data_aes_mode_t *test_data) { - const esp_partition_t *partition = get_test_storage_partition(); - ESP_ERROR_CHECK(esp_partition_erase_range(partition, 0, partition->size)); - uint8_t plaintext_data[1024] = {[0 ... 1023] = 0xBE}; - const int write_size = 16; - for (int i = 0; i < sizeof(plaintext_data) / write_size; i++) { - printf("\n i = %d\n", i); - ESP_ERROR_CHECK(esp_flash_write_encrypted(NULL, partition->address + (i * write_size), plaintext_data, write_size)); - static uint8_t read_data[128]; - ESP_ERROR_CHECK(esp_partition_read(partition, write_size * i, read_data, write_size)); - TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext_data + (i * write_size), read_data, write_size); - } + uint8_t hmac[32] = {0}; + TEST_ASSERT_EQUAL(ESP_OK, hmac_calculate(HMAC_KEY_KM, test_data->hmac_test_data.message, sizeof(test_data->hmac_test_data.message), hmac)); + TEST_ASSERT_EQUAL_HEX8_ARRAY(test_data->hmac_test_data.hmac_result, hmac, sizeof(test_data->hmac_test_data.hmac_result)); +} + +static void key_mgr_test_hmac_key_ecdh0_mode(const uint8_t *message, size_t message_len) +{ + uint8_t hmac[32] = {0}; + TEST_ASSERT_EQUAL(ESP_OK, hmac_calculate(HMAC_KEY_KM, message, message_len, hmac)); + // We cannot verify the result here as the HMAC key deployed is unknown. +} + +static void key_mgr_test_hmac_key_aes_random_mode(const uint8_t *message, size_t message_len) +{ + uint8_t hmac[32] = {0}; + TEST_ASSERT_EQUAL(ESP_OK, hmac_calculate(HMAC_KEY_KM, message, message_len, hmac)); + // We cannot verify the result here as the HMAC key deployed is unknown. } -static void key_mgr_test_xts_aes_128_random_mode(void) +static void key_mgr_test_hmac_aes_mode(void) { - static esp_key_mgr_random_key_config_t key_config; - key_config.key_type = ESP_KEY_MGR_XTS_AES_128_KEY; + static esp_key_mgr_aes_key_config_t key_config; + memcpy(key_config.k2_info, (uint8_t*) test_data_hmac.k2_info, KEY_MGR_K2_INFO_SIZE); + memcpy(key_config.k1_encrypted, (uint8_t*) test_data_hmac.k1_encrypted, KEY_MGR_K1_ENCRYPTED_SIZE); + memcpy(key_config.sw_init_key, (uint8_t*) test_data_hmac.init_key, KEY_MGR_SW_INIT_KEY_SIZE); + key_config.use_pre_generated_sw_init_key = 1; + key_config.key_type = ESP_KEY_MGR_HMAC_KEY; 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)); - TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); - test_xts_aes_key_random_mode(); - TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_aes_mode(&key_config, &key_recovery_info)); + ESP_LOG_BUFFER_HEXDUMP("key_info", key_recovery_info.key_info, sizeof(esp_key_mgr_key_info_t), ESP_LOG_DEBUG); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); + key_mgr_test_hmac_key_aes_mode(&test_data_hmac); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); } -static void key_mgr_test_xts_aes_256_random_mode(void) +static void key_mgr_test_hmac_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_HMAC_KEY; + + static esp_key_mgr_key_recovery_info_t key_recovery_info; + static esp_key_mgr_ecdh0_info_t ecdh0_info; + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deploy_key_in_ecdh0_mode(&key_config, &key_recovery_info, &ecdh0_info)); + + ESP_LOG_BUFFER_HEXDUMP("K2_G", ecdh0_info.k2_G[0], KEY_MGR_ECDH0_INFO_SIZE, ESP_LOG_DEBUG); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); + key_mgr_test_hmac_key_ecdh0_mode(test_data_hmac.hmac_test_data.message, sizeof(test_data_hmac.hmac_test_data.message)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); +} + +static void key_mgr_test_hmac_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_HMAC_KEY; 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)); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); - test_xts_aes_key_random_mode(); + key_mgr_test_hmac_key_aes_random_mode(test_data_hmac.hmac_test_data.message, sizeof(test_data_hmac.hmac_test_data.message)); TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); } -#endif +#endif /* SOC_KEY_MANAGER_HMAC_KEY_DEPLOY */ + +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY +extern esp_err_t esp_ds_sign(const void *message, + const esp_ds_data_t *data, + uint32_t key_id, + void *signature); + +static void key_mgr_test_ds_key_aes_mode(test_data_aes_mode_t *test_data) +{ + esp_ds_data_t esp_ds_data = {0}; + esp_ds_data.rsa_length = test_data->ds_test_data.ds_key_size / 32 - 1; + memcpy(esp_ds_data.iv, test_data->ds_test_data.ds_encrypted_input_params_iv, sizeof(esp_ds_data.iv)); + memcpy(esp_ds_data.c, test_data->ds_test_data.ds_encrypted_input_params, sizeof(esp_ds_data.c)); + + uint8_t signature[4096 / 8] = {0}; // Max possible RSA signature size + + esp_err_t ds_r = esp_ds_sign(test_data->ds_test_data.ds_message, + &esp_ds_data, + HMAC_KEY_KM, + signature); + + TEST_ASSERT_EQUAL(ESP_OK, ds_r); + TEST_ASSERT_EQUAL_HEX8_ARRAY(test_data->ds_test_data.ds_result, signature, sizeof(test_data->ds_test_data.ds_result)); +} + +static void key_mgr_test_ds_aes_mode(void) +{ + static esp_key_mgr_aes_key_config_t key_config; + memcpy(key_config.k2_info, (uint8_t*) test_data_ds.k2_info, KEY_MGR_K2_INFO_SIZE); + memcpy(key_config.k1_encrypted, (uint8_t*) test_data_ds.k1_encrypted, KEY_MGR_K1_ENCRYPTED_SIZE); + memcpy(key_config.sw_init_key, (uint8_t*) test_data_ds.init_key, KEY_MGR_SW_INIT_KEY_SIZE); + key_config.use_pre_generated_sw_init_key = 1; + key_config.key_type = ESP_KEY_MGR_DS_KEY; + + 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)); + + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_activate_key(&key_recovery_info)); + key_mgr_test_ds_key_aes_mode(&test_data_ds); + TEST_ASSERT_EQUAL(ESP_OK, esp_key_mgr_deactivate_key(key_recovery_info.key_type)); +} +#endif /* SOC_KEY_MANAGER_DS_KEY_DEPLOY */ TEST_GROUP(key_manager); TEST_SETUP(key_manager) { test_utils_record_free_mem(); - TEST_ESP_OK(test_utils_set_leak_level(700, ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_GENERAL)); + TEST_ESP_OK(test_utils_set_leak_level(800, ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_GENERAL)); } TEST_TEAR_DOWN(key_manager) @@ -320,55 +435,124 @@ TEST_TEAR_DOWN(key_manager) test_utils_get_leak_level(ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_ALL)); } +#if SOC_KEY_MANAGER_FE_KEY_DEPLOY +#if SOC_FLASH_ENCRYPTION_XTS_AES_128 TEST(key_manager, xts_aes_128_key_aes_deployment) { - key_mgr_test_xts_aes_128(); + key_mgr_test_xts_aes_128_aes_mode(); } +TEST(key_manager, xts_key_128_ecdh0_deployment) +{ + key_mgr_test_xts_aes_128_ecdh0_mode(); +} + +#if CONFIG_CRYPTO_TEST_APP_ENABLE_FPGA_TESTS +TEST(key_manager, xts_key_128_random_deployment) +{ + key_mgr_test_xts_aes_128_random_mode(); +} +#endif /* CONFIG_CRYPTO_TEST_APP_ENABLE_FPGA_TESTS */ +#endif /* SOC_FLASH_ENCRYPTION_XTS_AES_128 */ + +#if SOC_FLASH_ENCRYPTION_XTS_AES_256 TEST(key_manager, xts_aes_256_key_aes_deployment) { key_mgr_test_xts_aes_256_aes_mode(); } -TEST(key_manager, ecdsa_key_aes_deployment) +TEST(key_manager, xts_key_256_ecdh0_deployment) +{ + key_mgr_test_xts_aes_256_ecdh0_mode(); +} + +#if CONFIG_CRYPTO_TEST_APP_ENABLE_FPGA_TESTS +TEST(key_manager, xts_key_256_random_deployment) +{ + key_mgr_test_xts_aes_256_random_mode(); +} +#endif /* CONFIG_CRYPTO_TEST_APP_ENABLE_FPGA_TESTS */ +#endif /* SOC_FLASH_ENCRYPTION_XTS_AES_256 */ +#endif /* SOC_KEY_MANAGER_FE_KEY_DEPLOY */ + +#if SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY +TEST(key_manager, ecdsa_p256_key_aes_deployment) { key_mgr_test_ecdsa_p256_aes_mode(); } -TEST(key_manager, xts_key_ecdh0_deployment) -{ - key_mgr_test_xts_aes_128_ecdh0_mode(); - key_mgr_test_xts_aes_256_ecdh0_mode(); -} - -TEST(key_manager, ecdsa_key_ecdh0_deployment) +TEST(key_manager, ecdsa_p256_key_ecdh0_deployment) { key_mgr_test_ecdsa_ecdh0_mode(); } -TEST(key_manager, ecdsa_key_random_deployment) +TEST(key_manager, ecdsa_p256_key_random_deployment) { key_mgr_test_ecdsa_random_mode(); } +#endif /* SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY */ -#if CONFIG_CRYPTO_TEST_APP_ENABLE_FPGA_TESTS -TEST(key_manager, xts_key_random_deployment) +#if SOC_KEY_MANAGER_HMAC_KEY_DEPLOY +TEST(key_manager, hmac_key_aes_deployment) { - key_mgr_test_xts_aes_128_random_mode(); - key_mgr_test_xts_aes_256_random_mode(); + key_mgr_test_hmac_aes_mode(); } -#endif + +TEST(key_manager, hmac_key_ecdh0_deployment) +{ + key_mgr_test_hmac_ecdh0_mode(); +} + +TEST(key_manager, hmac_key_random_deployment) +{ + key_mgr_test_hmac_random_mode(); +} +#endif /* SOC_KEY_MANAGER_HMAC_KEY_DEPLOY */ + +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY +TEST(key_manager, ds_key_aes_deployment) +{ + key_mgr_test_ds_aes_mode(); +} +#endif /* SOC_KEY_MANAGER_DS_KEY_DEPLOY */ TEST_GROUP_RUNNER(key_manager) { +#if SOC_KEY_MANAGER_FE_KEY_DEPLOY +#if SOC_FLASH_ENCRYPTION_XTS_AES_128 RUN_TEST_CASE(key_manager, xts_aes_128_key_aes_deployment); - RUN_TEST_CASE(key_manager, xts_aes_256_key_aes_deployment); - RUN_TEST_CASE(key_manager, ecdsa_key_aes_deployment); - RUN_TEST_CASE(key_manager, xts_key_ecdh0_deployment); - RUN_TEST_CASE(key_manager, ecdsa_key_ecdh0_deployment); - RUN_TEST_CASE(key_manager, ecdsa_key_random_deployment); + RUN_TEST_CASE(key_manager, xts_key_128_ecdh0_deployment); #if CONFIG_CRYPTO_TEST_APP_ENABLE_FPGA_TESTS - RUN_TEST_CASE(key_manager, xts_key_random_deployment); -#endif + // This tests expects Flash encryption to be enabled as the test compares the decrypted flash data with the plaintext data + RUN_TEST_CASE(key_manager, xts_key_128_random_deployment); +#endif /* CONFIG_CRYPTO_TEST_APP_ENABLE_FPGA_TESTS */ +#endif /* SOC_FLASH_ENCRYPTION_XTS_AES_128 */ +#if SOC_FLASH_ENCRYPTION_XTS_AES_256 + RUN_TEST_CASE(key_manager, xts_aes_256_key_aes_deployment); + RUN_TEST_CASE(key_manager, xts_key_256_ecdh0_deployment); +#if CONFIG_CRYPTO_TEST_APP_ENABLE_FPGA_TESTS + RUN_TEST_CASE(key_manager, xts_key_256_random_deployment); +#endif /* CONFIG_CRYPTO_TEST_APP_ENABLE_FPGA_TESTS */ +#endif /* SOC_FLASH_ENCRYPTION_XTS_AES_256 */ +#endif /* SOC_KEY_MANAGER_FE_KEY_DEPLOY */ + +#if SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY + RUN_TEST_CASE(key_manager, ecdsa_p256_key_aes_deployment); + RUN_TEST_CASE(key_manager, ecdsa_p256_key_ecdh0_deployment); + RUN_TEST_CASE(key_manager, ecdsa_p256_key_random_deployment); +#endif /* SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY */ + +#if SOC_KEY_MANAGER_HMAC_KEY_DEPLOY + RUN_TEST_CASE(key_manager, hmac_key_aes_deployment); + RUN_TEST_CASE(key_manager, hmac_key_ecdh0_deployment); + RUN_TEST_CASE(key_manager, hmac_key_random_deployment); +#endif /* SOC_KEY_MANAGER_HMAC_KEY_DEPLOY */ + +#if SOC_KEY_MANAGER_DS_KEY_DEPLOY + RUN_TEST_CASE(key_manager, ds_key_aes_deployment); + // Verifying deployment of a DS key using the ECDH0 and Random mode of the Key Manager + // is not possible as the deployed DS key is not known to user in these modes to + // pre-generate the ciphertext input data. +#endif /* SOC_KEY_MANAGER_DS_KEY_DEPLOY */ } diff --git a/components/hal/test_apps/crypto/main/mpi/test_mpi.c b/components/hal/test_apps/crypto/main/mpi/test_mpi.c index 029abe5343..d0c971e9f1 100644 --- a/components/hal/test_apps/crypto/main/mpi/test_mpi.c +++ b/components/hal/test_apps/crypto/main/mpi/test_mpi.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -19,17 +19,13 @@ #include "hal/mpi_hal.h" #include "hal/mpi_ll.h" #include "mpi_params.h" +#include "esp_crypto_periph_clk.h" #define _DEBUG_ 0 static void esp_mpi_enable_hardware_hw_op( void ) { - /* Enable RSA hardware */ - MPI_RCC_ATOMIC() { - mpi_ll_enable_bus_clock(true); - mpi_ll_reset_register(); - } - + esp_crypto_mpi_enable_periph_clk(true); mpi_hal_enable_hardware_hw_op(); } @@ -37,11 +33,7 @@ static void esp_mpi_enable_hardware_hw_op( void ) static void esp_mpi_disable_hardware_hw_op( void ) { mpi_hal_disable_hardware_hw_op(); - - /* Disable RSA hardware */ - MPI_RCC_ATOMIC() { - mpi_ll_enable_bus_clock(false); - } + esp_crypto_mpi_enable_periph_clk(false); } diff --git a/components/hal/test_apps/crypto/main/sha/sha_block.c b/components/hal/test_apps/crypto/main/sha/sha_block.c index 852e0efe33..e18745f25d 100644 --- a/components/hal/test_apps/crypto/main/sha/sha_block.c +++ b/components/hal/test_apps/crypto/main/sha/sha_block.c @@ -12,7 +12,7 @@ #include "soc/periph_defs.h" #include "esp_private/periph_ctrl.h" -#include "esp_private/esp_crypto_lock_internal.h" +#include "esp_crypto_periph_clk.h" #include "hal/sha_hal.h" #include "hal/sha_ll.h" #include "sha_block.h" @@ -68,10 +68,7 @@ static void sha1_update_block(sha1_ctx* ctx, esp_sha_type sha_type, const unsign if ( (ilen >= 64) || local_len) { /* Enable peripheral module */ - SHA_RCC_ATOMIC() { - sha_ll_enable_bus_clock(true); - sha_ll_reset_register(); - } + esp_crypto_sha_enable_periph_clk(true); sha_hal_wait_idle(); sha_hal_set_mode(sha_type); @@ -103,9 +100,7 @@ static void sha1_update_block(sha1_ctx* ctx, esp_sha_type sha_type, const unsign sha_hal_read_digest(sha_type, ctx->state); /* Disable peripheral module */ - SHA_RCC_ATOMIC() { - sha_ll_enable_bus_clock(false); - } + esp_crypto_sha_enable_periph_clk(false); } if ( ilen > 0 ) { @@ -172,10 +167,7 @@ static void sha256_update_block(sha256_ctx* ctx, esp_sha_type sha_type, const un if ( (ilen >= 64) || local_len) { /* Enable peripheral module */ - SHA_RCC_ATOMIC() { - sha_ll_enable_bus_clock(true); - sha_ll_reset_register(); - } + esp_crypto_sha_enable_periph_clk(true); sha_hal_wait_idle(); sha_hal_set_mode(sha_type); @@ -207,9 +199,7 @@ static void sha256_update_block(sha256_ctx* ctx, esp_sha_type sha_type, const un sha_hal_read_digest(sha_type, ctx->state); /* Disable peripheral module */ - SHA_RCC_ATOMIC() { - sha_ll_enable_bus_clock(false); - } + esp_crypto_sha_enable_periph_clk(false); } if ( ilen > 0 ) { @@ -321,10 +311,7 @@ static void sha512_update_block(sha512_ctx* ctx, esp_sha_type sha_type, const un if ( (ilen >= 128) || local_len) { /* Enable peripheral module */ - SHA_RCC_ATOMIC() { - sha_ll_enable_bus_clock(true); - sha_ll_reset_register(); - } + esp_crypto_sha_enable_periph_clk(true); sha_hal_wait_idle(); sha_hal_set_mode(sha_type); @@ -360,9 +347,7 @@ static void sha512_update_block(sha512_ctx* ctx, esp_sha_type sha_type, const un sha_hal_read_digest(sha_type, ctx->state); /* Disable peripheral module */ - SHA_RCC_ATOMIC() { - sha_ll_enable_bus_clock(false); - } + esp_crypto_sha_enable_periph_clk(false); } if ( ilen > 0 ) { diff --git a/components/mbedtls/port/bignum/bignum_alt.c b/components/mbedtls/port/bignum/bignum_alt.c index ceb263b8d5..5717faf3b4 100644 --- a/components/mbedtls/port/bignum/bignum_alt.c +++ b/components/mbedtls/port/bignum/bignum_alt.c @@ -24,8 +24,6 @@ void esp_mpi_enable_hardware_hw_op( void ) void esp_mpi_disable_hardware_hw_op( void ) { - mpi_hal_disable_hardware_hw_op(); - /* Disable RSA hardware */ esp_crypto_mpi_enable_periph_clk(false); diff --git a/components/mbedtls/test_apps/main/CMakeLists.txt b/components/mbedtls/test_apps/main/CMakeLists.txt index 7059105e28..a99a7c0520 100644 --- a/components/mbedtls/test_apps/main/CMakeLists.txt +++ b/components/mbedtls/test_apps/main/CMakeLists.txt @@ -7,7 +7,7 @@ set(TEST_CRTS "crts/server_cert_chain.pem" idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES efuse cmock test_utils mbedtls esp_timer unity spi_flash esp_psram + PRIV_REQUIRES efuse cmock test_utils mbedtls esp_timer unity spi_flash esp_psram esp_security EMBED_TXTFILES ${TEST_CRTS} WHOLE_ARCHIVE) diff --git a/components/mbedtls/test_apps/main/test_mbedtls_ecdsa.c b/components/mbedtls/test_apps/main/test_mbedtls_ecdsa.c index 1325e419c2..8cdc46fc73 100644 --- a/components/mbedtls/test_apps/main/test_mbedtls_ecdsa.c +++ b/components/mbedtls/test_apps/main/test_mbedtls_ecdsa.c @@ -205,20 +205,20 @@ const uint8_t ecdsa192_sign_pub_y[] = { /* Big endian */ const uint8_t init_key[] = { - 0x4d, 0x21, 0x64, 0x21, 0x8f, 0xa2, 0xe3, 0xa0, 0xab, 0x74, 0xb5, 0xab, 0x17, 0x9a, 0x5d, 0x08, 0x58, 0xf4, 0x22, 0x03, 0xbd, 0x52, 0xe7, 0x88, 0x3c, 0x22, 0x0f, 0x95, 0x89, 0x70, 0xe1, 0x93 + 0xee, 0x89, 0x95, 0xda, 0x3c, 0x8a, 0x43, 0x83, 0xa9, 0x4b, 0x25, 0x5b, 0x04, 0x7e, 0xf1, 0x57, 0xb8, 0xe8, 0x06, 0x45, 0x87, 0x76, 0xee, 0x1b, 0x4e, 0x2e, 0x55, 0xa7, 0x1f, 0x25, 0xe1, 0x94, }; /* Big endian */ const uint8_t k2_info[] = { - 0xd8, 0xcd, 0x04, 0x45, 0xb4, 0x45, 0xc4, 0x15, 0xf6, 0x40, 0x1c, 0x7d, 0x90, 0x1b, 0x99, 0xa4, 0x79, 0x6b, 0xfb, 0x5b, 0x2a, 0x40, 0x60, 0xe1, 0xc1, 0xe1, 0x48, 0xcd, 0x46, 0x6b, 0x9b, 0x48, 0xda, 0x7a, 0x70, 0x0a, 0x78, 0x0b, 0x9d, 0xf9, 0x0e, 0xed, 0x91, 0xfc, 0xa5, 0xc2, 0x96, 0x05, 0x91, 0x76, 0xdb, 0x68, 0x84, 0x5d, 0x5e, 0x5b, 0xa6, 0xe9, 0x6b, 0x3b, 0x12, 0x50, 0x05, 0xc3 + 0x8f, 0x96, 0x33, 0x47, 0xe1, 0xa5, 0x57, 0xe9, 0x2a, 0x51, 0xa9, 0xbe, 0x48, 0x84, 0x25, 0x4e, 0x6f, 0x50, 0x1c, 0x45, 0xdb, 0xb6, 0xfa, 0xeb, 0x35, 0xd2, 0x27, 0x91, 0x3f, 0x67, 0x57, 0xd9, 0xcb, 0x55, 0xe4, 0x2b, 0x18, 0x16, 0xe7, 0xce, 0x6c, 0xf2, 0x58, 0x71, 0x17, 0x76, 0x2a, 0x86, 0x05, 0xe7, 0x37, 0x45, 0x71, 0x34, 0xca, 0xaf, 0x60, 0x07, 0xdf, 0xf4, 0xd2, 0xee, 0x3d, 0x4b, }; -const uint8_t k1_ecdsa256_xts_encrypt[] = { - 0x9f, 0x64, 0x80, 0x16, 0xa3, 0xab, 0x26, 0x64, 0x9b, 0xe6, 0x86, 0xcd, 0xf5, 0x14, 0x11, 0xb9, 0xb0, 0xe9, 0x87, 0xf6, 0xfe, 0x1b, 0x98, 0x0f, 0x9c, 0x3e, 0x21, 0xa7, 0xfa, 0x53, 0x47, 0x60 +const uint8_t k1_ecdsa256_encrypt[] = { + 0xcb, 0x8b, 0x74, 0xfb, 0xdf, 0x8f, 0x52, 0x0a, 0xff, 0x00, 0xf2, 0x83, 0xfa, 0xdb, 0x34, 0x18, 0xbe, 0xae, 0xe2, 0x58, 0x75, 0x94, 0x69, 0x89, 0xdd, 0x72, 0xdb, 0x04, 0x2c, 0xad, 0x4e, 0x3a, }; -const uint8_t k1_ecdsa192_xts_encrypt[] = { - 0x54, 0xf5, 0x97, 0xb8, 0xff, 0x1d, 0x34, 0x85, 0x8d, 0xf1, 0x43, 0xaa, 0xc0, 0x0f, 0xe2, 0x4d, 0x0b, 0xee, 0xdd, 0x89, 0x31, 0x39, 0x1b, 0xbe, 0x9b, 0x55, 0x53, 0xe0, 0xc7, 0xd9, 0x79, 0xaf +const uint8_t k1_ecdsa192_encrypt[] = { + 0xde, 0xe9, 0x9c, 0x89, 0xf2, 0x3b, 0x29, 0xb7, 0x9e, 0x33, 0xec, 0x76, 0x75, 0x2f, 0x3e, 0xab, 0x61, 0x06, 0x4d, 0xea, 0x05, 0x2c, 0xc3, 0x29, 0x1c, 0x7f, 0xb7, 0x3d, 0xb8, 0x1c, 0xb2, 0x17, }; void test_ecdsa_sign(mbedtls_ecp_group_id id, const uint8_t *hash, const uint8_t *pub_x, const uint8_t *pub_y, bool is_deterministic, int efuse_key_block) @@ -273,8 +273,47 @@ TEST_CASE("mbedtls ECDSA signature generation on SECP256R1", "[mbedtls][efuse_ke test_ecdsa_sign(MBEDTLS_ECP_DP_SECP256R1, sha, ecdsa256_sign_pub_x, ecdsa256_sign_pub_y, false, SECP256R1_EFUSE_BLOCK); } -#ifdef SOC_ECDSA_SUPPORT_DETERMINISTIC_MODE +#if SOC_KEY_MANAGER_SUPPORTED +static void deploy_key_in_key_manager(const uint8_t *k1_encrypted, esp_key_mgr_key_type_t key_type) { + esp_key_mgr_aes_key_config_t *key_config = NULL; + key_config = heap_caps_calloc(1, sizeof(esp_key_mgr_aes_key_config_t), MALLOC_CAP_INTERNAL); + TEST_ASSERT_NOT_NULL(key_config); + key_config->key_type = key_type; + key_config->use_pre_generated_sw_init_key = 1; + memcpy(key_config->k2_info, (uint8_t*) k2_info, KEY_MGR_K2_INFO_SIZE); + memcpy(key_config->k1_encrypted[0], (uint8_t*) k1_encrypted, KEY_MGR_K1_ENCRYPTED_SIZE); + memcpy(key_config->sw_init_key, (uint8_t*) init_key, KEY_MGR_SW_INIT_KEY_SIZE); + + esp_key_mgr_key_recovery_info_t *key_info = NULL; + key_info = heap_caps_calloc(1, sizeof(esp_key_mgr_key_recovery_info_t), MALLOC_CAP_INTERNAL); + TEST_ASSERT_NOT_NULL(key_info); + + esp_key_mgr_deploy_key_in_aes_mode(key_config, key_info); + + ESP_LOGI(TAG, "Key deployed successfully"); + esp_key_mgr_activate_key(key_info); + + free(key_info); + free(key_config); +} + +TEST_CASE("mbedtls ECDSA signature generation on SECP192R1", "[mbedtls][key_manager_key]") +{ + deploy_key_in_key_manager(k1_ecdsa192_encrypt, ESP_KEY_MGR_ECDSA_192_KEY); + test_ecdsa_sign(MBEDTLS_ECP_DP_SECP192R1, sha, ecdsa192_sign_pub_x, ecdsa192_sign_pub_y, false, USE_ECDSA_KEY_FROM_KEY_MANAGER); + esp_key_mgr_deactivate_key(ESP_KEY_MGR_ECDSA_192_KEY); +} + +TEST_CASE("mbedtls ECDSA signature generation on SECP256R1", "[mbedtls][key_manager_key]") +{ + deploy_key_in_key_manager(k1_ecdsa256_encrypt, ESP_KEY_MGR_ECDSA_256_KEY); + test_ecdsa_sign(MBEDTLS_ECP_DP_SECP256R1, sha, ecdsa256_sign_pub_x, ecdsa256_sign_pub_y, false, USE_ECDSA_KEY_FROM_KEY_MANAGER); + esp_key_mgr_deactivate_key(ESP_KEY_MGR_ECDSA_256_KEY); +} +#endif /* SOC_KEY_MANAGER_SUPPORTED */ + +#ifdef SOC_ECDSA_SUPPORT_DETERMINISTIC_MODE TEST_CASE("mbedtls ECDSA deterministic signature generation on SECP192R1", "[mbedtls][efuse_key]") { if (!ecdsa_ll_is_deterministic_mode_supported()) { @@ -293,48 +332,32 @@ TEST_CASE("mbedtls ECDSA deterministic signature generation on SECP256R1", "[mbe } } +#if SOC_KEY_MANAGER_SUPPORTED +TEST_CASE("mbedtls ECDSA deterministic signature generation on SECP192R1", "[mbedtls][key_manager_key]") +{ + if (!ecdsa_ll_is_deterministic_mode_supported()) { + ESP_LOGI(TAG, "Skipping test because ECDSA deterministic mode is not supported."); + } else { + deploy_key_in_key_manager(k1_ecdsa192_encrypt, ESP_KEY_MGR_ECDSA_192_KEY); + test_ecdsa_sign(MBEDTLS_ECP_DP_SECP192R1, sha, ecdsa192_sign_pub_x, ecdsa192_sign_pub_y, true, USE_ECDSA_KEY_FROM_KEY_MANAGER); + esp_key_mgr_deactivate_key(ESP_KEY_MGR_ECDSA_192_KEY); + } +} + +TEST_CASE("mbedtls ECDSA deterministic signature generation on SECP256R1", "[mbedtls][key_manager_key]") +{ + if (!ecdsa_ll_is_deterministic_mode_supported()) { + ESP_LOGI(TAG, "Skipping test because ECDSA deterministic mode is not supported."); + } else { + deploy_key_in_key_manager(k1_ecdsa256_encrypt, ESP_KEY_MGR_ECDSA_256_KEY); + test_ecdsa_sign(MBEDTLS_ECP_DP_SECP256R1, sha, ecdsa256_sign_pub_x, ecdsa256_sign_pub_y, true, USE_ECDSA_KEY_FROM_KEY_MANAGER); + esp_key_mgr_deactivate_key(ESP_KEY_MGR_ECDSA_256_KEY); + } +} +#endif /* SOC_KEY_MANAGER_SUPPORTED */ #endif /* SOC_ECDSA_SUPPORT_DETERMINISTIC_MODE */ -#if SOC_KEY_MANAGER_SUPPORTED -void deploy_key_in_key_manager(const uint8_t *k1_encrypted) { - esp_key_mgr_aes_key_config_t *key_config; - - key_config = heap_caps_calloc(1, sizeof(esp_key_mgr_aes_key_config_t), MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(key_config); - memcpy(key_config->k2_info, (uint8_t*) k2_info, KEY_MGR_K2_INFO_SIZE); - memcpy(key_config->k1_encrypted[0], (uint8_t*) k1_encrypted, KEY_MGR_K1_ENCRYPTED_SIZE); - memcpy(key_config->sw_init_key, (uint8_t*) 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_KEY; - - esp_key_mgr_key_recovery_info_t *key_info; - key_info = heap_caps_calloc(1, sizeof(esp_key_mgr_key_recovery_info_t), MALLOC_CAP_INTERNAL); - TEST_ASSERT_NOT_NULL(key_config); - - esp_key_mgr_deploy_key_in_aes_mode(key_config, key_info); - printf("\nkey deployed successfully\n"); - esp_key_mgr_activate_key(key_info); - free(key_info); - free(key_config); -} - -TEST_CASE("mbedtls ECDSA signature generation on SECP192R1", "[mbedtls][key_manager_key]") -{ - deploy_key_in_key_manager(k1_ecdsa192_xts_encrypt); - test_ecdsa_sign(MBEDTLS_ECP_DP_SECP192R1, sha, ecdsa192_sign_pub_x, ecdsa192_sign_pub_y, false, USE_ECDSA_KEY_FROM_KEY_MANAGER); - esp_key_mgr_deactivate_key(ESP_KEY_MGR_ECDSA_KEY); -} - -TEST_CASE("mbedtls ECDSA signature generation on SECP256R1", "[mbedtls][key_manager_key]") -{ - deploy_key_in_key_manager(k1_ecdsa256_xts_encrypt); - test_ecdsa_sign(MBEDTLS_ECP_DP_SECP256R1, sha, ecdsa256_sign_pub_x, ecdsa256_sign_pub_y, false, USE_ECDSA_KEY_FROM_KEY_MANAGER); - esp_key_mgr_deactivate_key(ESP_KEY_MGR_ECDSA_KEY); -} -#endif - #ifdef SOC_ECDSA_SUPPORT_EXPORT_PUBKEY - void test_ecdsa_export_pubkey(mbedtls_ecp_group_id id, const uint8_t *pub_x, const uint8_t *pub_y, int efuse_key_block) { uint8_t export_pub_x[32] = {0}; @@ -344,9 +367,14 @@ void test_ecdsa_export_pubkey(mbedtls_ecp_group_id id, const uint8_t *pub_x, con esp_ecdsa_pk_conf_t pk_conf = { .grp_id = id, .load_pubkey = true, - .efuse_block = efuse_key_block, }; + if (efuse_key_block == USE_ECDSA_KEY_FROM_KEY_MANAGER) { + pk_conf.use_km_key = true; + } else { + pk_conf.efuse_block = efuse_key_block; + } + if (id == MBEDTLS_ECP_DP_SECP192R1) { len = 24; } else if (id == MBEDTLS_ECP_DP_SECP256R1) { @@ -382,18 +410,17 @@ TEST_CASE("mbedtls ECDSA export public key on SECP256R1", "[mbedtls][efuse_key]" #if SOC_KEY_MANAGER_SUPPORTED TEST_CASE("mbedtls ECDSA export public key on SECP192R1", "[mbedtls][key_manager_key]") { - deploy_key_in_key_manager(k1_ecdsa192_xts_encrypt); + deploy_key_in_key_manager(k1_ecdsa192_encrypt, ESP_KEY_MGR_ECDSA_192_KEY); test_ecdsa_export_pubkey(MBEDTLS_ECP_DP_SECP192R1, ecdsa192_sign_pub_x, ecdsa192_sign_pub_y, USE_ECDSA_KEY_FROM_KEY_MANAGER); - esp_key_mgr_deactivate_key(ESP_KEY_MGR_ECDSA_KEY); + esp_key_mgr_deactivate_key(ESP_KEY_MGR_ECDSA_192_KEY); } TEST_CASE("mbedtls ECDSA export public key on SECP256R1", "[mbedtls][key_manager_key]") { - deploy_key_in_key_manager(k1_ecdsa256_xts_encrypt); + deploy_key_in_key_manager(k1_ecdsa256_encrypt, ESP_KEY_MGR_ECDSA_256_KEY); test_ecdsa_export_pubkey(MBEDTLS_ECP_DP_SECP256R1, ecdsa256_sign_pub_x, ecdsa256_sign_pub_y, USE_ECDSA_KEY_FROM_KEY_MANAGER); - esp_key_mgr_deactivate_key(ESP_KEY_MGR_ECDSA_KEY); + esp_key_mgr_deactivate_key(ESP_KEY_MGR_ECDSA_256_KEY); } #endif #endif /* SOC_ECDSA_SUPPORT_EXPORT_PUBKEY */ - #endif /* CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN */ diff --git a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in index d68e7d8723..8e75e2282b 100644 --- a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in @@ -239,6 +239,14 @@ config SOC_RNG_SUPPORTED bool default y +config SOC_KEY_MANAGER_SUPPORTED + bool + default y + +config SOC_HUK_SUPPORTED + bool + default y + config SOC_MODEM_CLOCK_SUPPORTED bool default y @@ -1399,6 +1407,14 @@ config SOC_EFUSE_ECDSA_KEY_P384 bool default y +config SOC_HUK_MEM_NEEDS_RECHARGE + bool + default y + +config SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT + bool + default y + config SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY bool default y @@ -1407,6 +1423,14 @@ config SOC_KEY_MANAGER_FE_KEY_DEPLOY bool default y +config SOC_KEY_MANAGER_HMAC_KEY_DEPLOY + bool + default y + +config SOC_KEY_MANAGER_DS_KEY_DEPLOY + bool + default y + config SOC_SECURE_BOOT_V2_RSA bool default y diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index aab631a764..1236a27002 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -76,8 +76,8 @@ #define SOC_SPI_FLASH_SUPPORTED 1 // TODO: [ESP32C5] IDF-8715 #define SOC_ECDSA_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 -// #define SOC_KEY_MANAGER_SUPPORTED 1 // TODO: [ESP32C5] IDF-8621 -// #define SOC_HUK_SUPPORTED 1 // TODO: [ESP32C5] IDF-8617 +#define SOC_KEY_MANAGER_SUPPORTED 1 +#define SOC_HUK_SUPPORTED 1 #define SOC_MODEM_CLOCK_SUPPORTED 1 #define SOC_LIGHT_SLEEP_SUPPORTED 1 #define SOC_DEEP_SLEEP_SUPPORTED 1 @@ -540,9 +540,15 @@ #define SOC_EFUSE_ECDSA_KEY_P192 1 #define SOC_EFUSE_ECDSA_KEY_P384 1 +/*-------------------------- HUK CAPS----------------------------*/ +#define SOC_HUK_MEM_NEEDS_RECHARGE 1 + /*-------------------------- Key Manager CAPS----------------------------*/ -#define SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY 1 /*!< Key manager responsible to deploy ECDSA key */ -#define SOC_KEY_MANAGER_FE_KEY_DEPLOY 1 /*!< Key manager responsible to deploy Flash Encryption key */ +#define SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT 1 /*!< Key manager supports key deployment */ +#define SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY 1 /*!< Key manager responsible to deploy ECDSA key */ +#define SOC_KEY_MANAGER_FE_KEY_DEPLOY 1 /*!< Key manager responsible to deploy Flash Encryption key */ +#define SOC_KEY_MANAGER_HMAC_KEY_DEPLOY 1 /*!< Key manager responsible to deploy HMAC key */ +#define SOC_KEY_MANAGER_DS_KEY_DEPLOY 1 /*!< Key manager responsible to deploy DS key */ /*-------------------------- Secure Boot CAPS----------------------------*/ #define SOC_SECURE_BOOT_V2_RSA 1 diff --git a/components/soc/esp32c5/register/soc/keymng_reg.h b/components/soc/esp32c5/register/soc/keymng_reg.h index 66ab390373..e11f28548f 100644 --- a/components/soc/esp32c5/register/soc/keymng_reg.h +++ b/components/soc/esp32c5/register/soc/keymng_reg.h @@ -1,5 +1,5 @@ /** - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -148,20 +148,45 @@ extern "C" { #define KEYMNG_USE_EFUSE_KEY_V 0x0000001FU #define KEYMNG_USE_EFUSE_KEY_S 0 -/* KEYMNG_USE_EFUSE_KEY_ECDSA : R/W ;bitpos:[0] ;default: 1'd0 ; */ -/*description: Set this bit to choose efuse key instead of key manager deployed key for ecdsa.*/ +/** KEYMNG_USE_EFUSE_KEY_ECDSA : R/W; bitpos:[0]; default: 0; + * Set this bit to choose efuse key instead of key manager deployed key for ecdsa. + */ #define KEYMNG_USE_EFUSE_KEY_ECDSA (BIT(0)) -#define KEYMNG_USE_EFUSE_KEY_ECDSA_M ((KEYMNG_USE_EFUSE_KEY_ECDSA_V)<<(KEYMNG_USE_EFUSE_KEY_ECDSA_S)) -#define KEYMNG_USE_EFUSE_KEY_ECDSA_V 0x1 +#define KEYMNG_USE_EFUSE_KEY_ECDSA_M (KEYMNG_USE_EFUSE_KEY_ECDSA_V << KEYMNG_USE_EFUSE_KEY_ECDSA_S) +#define KEYMNG_USE_EFUSE_KEY_ECDSA_V 0x00000001U #define KEYMNG_USE_EFUSE_KEY_ECDSA_S 0 -/* KEYMNG_USE_EFUSE_KEY_FLASH : R/W ;bitpos:[1] ;default: 1'd0 ; */ -/*description: Set this bit to choose efuse key instead of key manager deployed key for flash.*/ +/** KEYMNG_USE_EFUSE_KEY_FLASH : R/W; bitpos:[1]; default: 0; + * Set this bit to choose efuse key instead of key manager deployed key for flash. + */ #define KEYMNG_USE_EFUSE_KEY_FLASH (BIT(1)) -#define KEYMNG_USE_EFUSE_KEY_FLASH_M ((KEYMNG_USE_EFUSE_KEY_FLASH_V)<<(KEYMNG_USE_EFUSE_KEY_FLASH_S)) -#define KEYMNG_USE_EFUSE_KEY_FLASH_V 0x1 +#define KEYMNG_USE_EFUSE_KEY_FLASH_M (KEYMNG_USE_EFUSE_KEY_FLASH_V << KEYMNG_USE_EFUSE_KEY_FLASH_S) +#define KEYMNG_USE_EFUSE_KEY_FLASH_V 0x00000001U #define KEYMNG_USE_EFUSE_KEY_FLASH_S 1 +/** KEYMNG_USE_EFUSE_KEY_HMAC : R/W; bitpos:[0]; default: 0; + * Set this bit to choose efuse key instead of key manager deployed key for hmac. + */ +#define KEYMNG_USE_EFUSE_KEY_HMAC (BIT(2)) +#define KEYMNG_USE_EFUSE_KEY_HMAC_M (KEYMNG_USE_EFUSE_KEY_HMAC_V << KEYMNG_USE_EFUSE_KEY_HMAC_S) +#define KEYMNG_USE_EFUSE_KEY_HMAC_V 0x00000001U +#define KEYMNG_USE_EFUSE_KEY_HMAC_S 2 + +/** KEYMNG_USE_EFUSE_KEY_DS : R/W; bitpos:[1]; default: 0; + * Set this bit to choose efuse key instead of key manager deployed key for ds. + */ +#define KEYMNG_USE_EFUSE_KEY_DS (BIT(3)) +#define KEYMNG_USE_EFUSE_KEY_DS_M (KEYMNG_USE_EFUSE_KEY_DS_V << KEYMNG_USE_EFUSE_KEY_DS_S) +#define KEYMNG_USE_EFUSE_KEY_DS_V 0x00000001U +#define KEYMNG_USE_EFUSE_KEY_DS_S 3 + +/** KEYMNG_USE_EFUSE_KEY_PSRAM : R/W; bitpos:[1]; default: 0; + * Set this bit to choose efuse key instead of key manager deployed key for psram. + */ +#define KEYMNG_USE_EFUSE_KEY_PSRAM (BIT(4)) +#define KEYMNG_USE_EFUSE_KEY_PSRAM_M (KEYMNG_USE_EFUSE_KEY_PSRAM_V << KEYMNG_USE_EFUSE_KEY_PSRAM_S) +#define KEYMNG_USE_EFUSE_KEY_PSRAM_V 0x00000001U +#define KEYMNG_USE_EFUSE_KEY_PSRAM_S 4 /** KEYMNG_RND_SWITCH_CYCLE : R/W; bitpos: [9:5]; default: 15; * The core clock cycle number to sample one rng input data. Please set it bigger than @@ -208,21 +233,41 @@ extern "C" { #define KEYMNG_USE_EFUSE_KEY_LOCK_V 0x0000001FU #define KEYMNG_USE_EFUSE_KEY_LOCK_S 0 -/* KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA : R/W1 ;bitpos:[0] ;default: 1'd0 ; */ -/*description: Write 1 to lock reg_use_efuse_key for esdsa*/ - +/** KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA : R/W1 ;bitpos:[0]; default: 0; + * Write 1 to lock reg_use_efuse_key for esdsa + */ #define KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA (BIT(0)) -#define KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_M ((KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_V)<<(KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_S)) -#define KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_V 0x1 +#define KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_M (KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_V << KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_S) +#define KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_V 0x00000001U #define KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_S 0 - -/* KEYMNG_USE_EFUSE_KEY_LOCK_FLASH : R/W1 ;bitpos:[1] ;default: 1'd0 ; */ -/*description: Write 1 to lock reg_use_efuse_key for FLASH*/ - +/** KEYMNG_USE_EFUSE_KEY_LOCK_FLASH : R/W1 ;bitpos:[1]; default: 0; + * Write 1 to lock reg_use_efuse_key for FLASH + */ #define KEYMNG_USE_EFUSE_KEY_LOCK_FLASH (BIT(1)) -#define KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_M ((KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_V)<<(KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_S)) -#define KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_V 0x1 +#define KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_M (KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_V << KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_S) +#define KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_V 0x00000001U #define KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_S 1 +/** KEYMNG_USE_EFUSE_KEY_LOCK_HMAC : R/W1 ;bitpos:[0]; default: 0; + * Write 1 to lock reg_use_efuse_key for hmac + */ +#define KEYMNG_USE_EFUSE_KEY_LOCK_HMAC (BIT(2)) +#define KEYMNG_USE_EFUSE_KEY_LOCK_HMAC_M (KEYMNG_USE_EFUSE_KEY_LOCK_HMAC_V << KEYMNG_USE_EFUSE_KEY_LOCK_HMAC_S) +#define KEYMNG_USE_EFUSE_KEY_LOCK_HMAC_V 0x00000001U +#define KEYMNG_USE_EFUSE_KEY_LOCK_HMAC_S 2 +/** KEYMNG_USE_EFUSE_KEY_LOCK_DS : R/W1 ;bitpos:[1]; default: 0; + * Write 1 to lock reg_use_efuse_key for ds + */ +#define KEYMNG_USE_EFUSE_KEY_LOCK_DS (BIT(3)) +#define KEYMNG_USE_EFUSE_KEY_LOCK_DS_M (KEYMNG_USE_EFUSE_KEY_LOCK_DS_V << KEYMNG_USE_EFUSE_KEY_LOCK_DS_S) +#define KEYMNG_USE_EFUSE_KEY_LOCK_DS_V 0x00000001U +#define KEYMNG_USE_EFUSE_KEY_LOCK_DS_S 3 +/** KEYMNG_USE_EFUSE_KEY_LOCK_PSRAM : R/W1 ;bitpos:[1]; default: 0; + * Write 1 to lock reg_use_efuse_key for PSRAM + */ +#define KEYMNG_USE_EFUSE_KEY_LOCK_PSRAM (BIT(4)) +#define KEYMNG_USE_EFUSE_KEY_LOCK_PSRAM_M (KEYMNG_USE_EFUSE_KEY_LOCK_PSRAM_V << KEYMNG_USE_EFUSE_KEY_LOCK_PSRAM_S) +#define KEYMNG_USE_EFUSE_KEY_LOCK_PSRAM_V 0x00000001U +#define KEYMNG_USE_EFUSE_KEY_LOCK_PSRAM_S 4 /** KEYMNG_RND_SWITCH_CYCLE_LOCK : R/W1; bitpos: [5]; default: 0; * Write 1 to lock reg_rnd_switch_cycle. @@ -266,9 +311,10 @@ extern "C" { #define KEYMNG_KGEN_MODE_V 0x00000007U #define KEYMNG_KGEN_MODE_S 0 /** KEYMNG_KEY_PURPOSE : R/W; bitpos: [6:3]; default: 0; - * Set this field to choose the key purpose. 1: ecdsa_key 2: flash_256_1_key. 3: - * flash_256_2_key. 4: flash_128_key. 6: hmac_key. 7: ds_key. 8: psram_256_1_key. 9: - * psram_256_2_key. 10: psram_128_key. Others: reserved. + * Set this field to choose the key purpose. 1: ecdsa_key_192. 2: ecdsa_key_256. 3: + * flash_256_1_key. 4: flash_256_2_key. 5: flash_128_key. 6: hmac_key. 7: ds_key. 8: + * psram_256_1_key. 9: psram_256_2_key. 10: psram_128_key. 11: ecdsa_key_384_l. 12: + * ecdsa_key_384_h. Others: reserved. */ #define KEYMNG_KEY_PURPOSE 0x0000000FU #define KEYMNG_KEY_PURPOSE_M (KEYMNG_KEY_PURPOSE_V << KEYMNG_KEY_PURPOSE_S) @@ -323,46 +369,62 @@ extern "C" { * Key Manager key status register */ #define KEYMNG_KEY_VLD_REG (DR_REG_KEYMNG_BASE + 0x30) -/** KEYMNG_KEY_ECDSA_VLD : RO; bitpos: [0]; default: 0; - * The status bit for key_ecdsa. 1: The key has been deployed correctly. 0: The key - * has not been deployed yet. +/** KEYMNG_KEY_ECDSA_192_VLD : RO; bitpos: [0]; default: 0; + * The status bit for key_ecdsa_192. 1: The key has been deployed correctly. 0: The + * key has not been deployed yet. */ -#define KEYMNG_KEY_ECDSA_VLD (BIT(0)) -#define KEYMNG_KEY_ECDSA_VLD_M (KEYMNG_KEY_ECDSA_VLD_V << KEYMNG_KEY_ECDSA_VLD_S) -#define KEYMNG_KEY_ECDSA_VLD_V 0x00000001U -#define KEYMNG_KEY_ECDSA_VLD_S 0 -/** KEYMNG_KEY_FLASH_VLD : RO; bitpos: [1]; default: 0; +#define KEYMNG_KEY_ECDSA_192_VLD (BIT(0)) +#define KEYMNG_KEY_ECDSA_192_VLD_M (KEYMNG_KEY_ECDSA_192_VLD_V << KEYMNG_KEY_ECDSA_192_VLD_S) +#define KEYMNG_KEY_ECDSA_192_VLD_V 0x00000001U +#define KEYMNG_KEY_ECDSA_192_VLD_S 0 +/** KEYMNG_KEY_ECDSA_256_VLD : RO; bitpos: [1]; default: 0; + * The status bit for key_ecdsa_256. 1: The key has been deployed correctly. 0: The + * key has not been deployed yet. + */ +#define KEYMNG_KEY_ECDSA_256_VLD (BIT(1)) +#define KEYMNG_KEY_ECDSA_256_VLD_M (KEYMNG_KEY_ECDSA_256_VLD_V << KEYMNG_KEY_ECDSA_256_VLD_S) +#define KEYMNG_KEY_ECDSA_256_VLD_V 0x00000001U +#define KEYMNG_KEY_ECDSA_256_VLD_S 1 +/** KEYMNG_KEY_FLASH_VLD : RO; bitpos: [2]; default: 0; * The status bit for key_flash. 1: The key has been deployed correctly. 0: The * key has not been deployed yet. */ -#define KEYMNG_KEY_FLASH_VLD (BIT(1)) +#define KEYMNG_KEY_FLASH_VLD (BIT(2)) #define KEYMNG_KEY_FLASH_VLD_M (KEYMNG_KEY_FLASH_VLD_V << KEYMNG_KEY_FLASH_VLD_S) #define KEYMNG_KEY_FLASH_VLD_V 0x00000001U -#define KEYMNG_KEY_FLASH_VLD_S 1 -/** KEYMNG_KEY_HMAC_VLD : RO; bitpos: [2]; default: 0; +#define KEYMNG_KEY_FLASH_VLD_S 2 +/** KEYMNG_KEY_HMAC_VLD : RO; bitpos: [3]; default: 0; * The status bit for key_hmac. 1: The key has been deployed correctly. 0: The key * has not been deployed yet. */ -#define KEYMNG_KEY_HMAC_VLD (BIT(2)) +#define KEYMNG_KEY_HMAC_VLD (BIT(3)) #define KEYMNG_KEY_HMAC_VLD_M (KEYMNG_KEY_HMAC_VLD_V << KEYMNG_KEY_HMAC_VLD_S) #define KEYMNG_KEY_HMAC_VLD_V 0x00000001U -#define KEYMNG_KEY_HMAC_VLD_S 2 -/** KEYMNG_KEY_DS_VLD : RO; bitpos: [3]; default: 0; +#define KEYMNG_KEY_HMAC_VLD_S 3 +/** KEYMNG_KEY_DS_VLD : RO; bitpos: [4]; default: 0; * The status bit for key_ds. 1: The key has been deployed correctly. 0: The * key has not been deployed yet. */ -#define KEYMNG_KEY_DS_VLD (BIT(3)) +#define KEYMNG_KEY_DS_VLD (BIT(4)) #define KEYMNG_KEY_DS_VLD_M (KEYMNG_KEY_DS_VLD_V << KEYMNG_KEY_DS_VLD_S) #define KEYMNG_KEY_DS_VLD_V 0x00000001U -#define KEYMNG_KEY_DS_VLD_S 3 -/** KEYMNG_KEY_PSRAM_VLD : RO; bitpos: [4]; default: 0; +#define KEYMNG_KEY_DS_VLD_S 4 +/** KEYMNG_KEY_PSRAM_VLD : RO; bitpos: [5]; default: 0; * The status bit for key_psram. 1: The key has been deployed correctly. 0: The key * has not been deployed yet. */ -#define KEYMNG_KEY_PSRAM_VLD (BIT(4)) +#define KEYMNG_KEY_PSRAM_VLD (BIT(5)) #define KEYMNG_KEY_PSRAM_VLD_M (KEYMNG_KEY_PSRAM_VLD_V << KEYMNG_KEY_PSRAM_VLD_S) #define KEYMNG_KEY_PSRAM_VLD_V 0x00000001U -#define KEYMNG_KEY_PSRAM_VLD_S 4 +#define KEYMNG_KEY_PSRAM_VLD_S 5 +/** KEYMNG_KEY_ECDSA_384_VLD : RO; bitpos: [6]; default: 0; + * The status bit for key_ecdsa_384. 1: The key has been deployed correctly. 0: The + * key has not been deployed yet. + */ +#define KEYMNG_KEY_ECDSA_384_VLD (BIT(6)) +#define KEYMNG_KEY_ECDSA_384_VLD_M (KEYMNG_KEY_ECDSA_384_VLD_V << KEYMNG_KEY_ECDSA_384_VLD_S) +#define KEYMNG_KEY_ECDSA_384_VLD_V 0x00000001U +#define KEYMNG_KEY_ECDSA_384_VLD_S 6 /** KEYMNG_HUK_VLD_REG register * Key Manager HUK status register @@ -380,7 +442,7 @@ extern "C" { * Version control register */ #define KEYMNG_DATE_REG (DR_REG_KEYMNG_BASE + 0xfc) -/** KEYMNG_DATE : R/W; bitpos: [27:0]; default: 36774224; +/** KEYMNG_DATE : R/W; bitpos: [27:0]; default: 37781824; * Key Manager version control register. */ #define KEYMNG_DATE 0x0FFFFFFFU diff --git a/components/soc/esp32c5/register/soc/keymng_reg_eco2.h b/components/soc/esp32c5/register/soc/keymng_reg_eco2.h deleted file mode 100644 index a385df2586..0000000000 --- a/components/soc/esp32c5/register/soc/keymng_reg_eco2.h +++ /dev/null @@ -1,395 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#pragma once - -#include -#include "soc/soc.h" -#ifdef __cplusplus -extern "C" { -#endif - -/** KEYMNG_CLK_REG register - * Key Manager clock gate control register - */ -#define KEYMNG_CLK_REG (DR_REG_KEYMNG_BASE + 0x4) -/** KEYMNG_REG_CG_FORCE_ON : R/W; bitpos: [0]; default: 1; - * Write 1 to force on register clock gate. - */ -#define KEYMNG_REG_CG_FORCE_ON (BIT(0)) -#define KEYMNG_REG_CG_FORCE_ON_M (KEYMNG_REG_CG_FORCE_ON_V << KEYMNG_REG_CG_FORCE_ON_S) -#define KEYMNG_REG_CG_FORCE_ON_V 0x00000001U -#define KEYMNG_REG_CG_FORCE_ON_S 0 -/** KEYMNG_MEM_CG_FORCE_ON : R/W; bitpos: [1]; default: 0; - * Write 1 to force on memory clock gate. - */ -#define KEYMNG_MEM_CG_FORCE_ON (BIT(1)) -#define KEYMNG_MEM_CG_FORCE_ON_M (KEYMNG_MEM_CG_FORCE_ON_V << KEYMNG_MEM_CG_FORCE_ON_S) -#define KEYMNG_MEM_CG_FORCE_ON_V 0x00000001U -#define KEYMNG_MEM_CG_FORCE_ON_S 1 - -/** KEYMNG_INT_RAW_REG register - * Key Manager interrupt raw register, valid in level. - */ -#define KEYMNG_INT_RAW_REG (DR_REG_KEYMNG_BASE + 0x8) -/** KEYMNG_PREP_DONE_INT_RAW : RO/WTC/SS; bitpos: [0]; default: 0; - * The raw interrupt status bit for the km_prep_done_int interrupt - */ -#define KEYMNG_PREP_DONE_INT_RAW (BIT(0)) -#define KEYMNG_PREP_DONE_INT_RAW_M (KEYMNG_PREP_DONE_INT_RAW_V << KEYMNG_PREP_DONE_INT_RAW_S) -#define KEYMNG_PREP_DONE_INT_RAW_V 0x00000001U -#define KEYMNG_PREP_DONE_INT_RAW_S 0 -/** KEYMNG_PROC_DONE_INT_RAW : RO/WTC/SS; bitpos: [1]; default: 0; - * The raw interrupt status bit for the km_proc_done_int interrupt - */ -#define KEYMNG_PROC_DONE_INT_RAW (BIT(1)) -#define KEYMNG_PROC_DONE_INT_RAW_M (KEYMNG_PROC_DONE_INT_RAW_V << KEYMNG_PROC_DONE_INT_RAW_S) -#define KEYMNG_PROC_DONE_INT_RAW_V 0x00000001U -#define KEYMNG_PROC_DONE_INT_RAW_S 1 -/** KEYMNG_POST_DONE_INT_RAW : RO/WTC/SS; bitpos: [2]; default: 0; - * The raw interrupt status bit for the km_post_done_int interrupt - */ -#define KEYMNG_POST_DONE_INT_RAW (BIT(2)) -#define KEYMNG_POST_DONE_INT_RAW_M (KEYMNG_POST_DONE_INT_RAW_V << KEYMNG_POST_DONE_INT_RAW_S) -#define KEYMNG_POST_DONE_INT_RAW_V 0x00000001U -#define KEYMNG_POST_DONE_INT_RAW_S 2 - -/** KEYMNG_INT_ST_REG register - * Key Manager interrupt status register. - */ -#define KEYMNG_INT_ST_REG (DR_REG_KEYMNG_BASE + 0xc) -/** KEYMNG_PREP_DONE_INT_ST : RO; bitpos: [0]; default: 0; - * The masked interrupt status bit for the km_prep_done_int interrupt - */ -#define KEYMNG_PREP_DONE_INT_ST (BIT(0)) -#define KEYMNG_PREP_DONE_INT_ST_M (KEYMNG_PREP_DONE_INT_ST_V << KEYMNG_PREP_DONE_INT_ST_S) -#define KEYMNG_PREP_DONE_INT_ST_V 0x00000001U -#define KEYMNG_PREP_DONE_INT_ST_S 0 -/** KEYMNG_PROC_DONE_INT_ST : RO; bitpos: [1]; default: 0; - * The masked interrupt status bit for the km_proc_done_int interrupt - */ -#define KEYMNG_PROC_DONE_INT_ST (BIT(1)) -#define KEYMNG_PROC_DONE_INT_ST_M (KEYMNG_PROC_DONE_INT_ST_V << KEYMNG_PROC_DONE_INT_ST_S) -#define KEYMNG_PROC_DONE_INT_ST_V 0x00000001U -#define KEYMNG_PROC_DONE_INT_ST_S 1 -/** KEYMNG_POST_DONE_INT_ST : RO; bitpos: [2]; default: 0; - * The masked interrupt status bit for the km_post_done_int interrupt - */ -#define KEYMNG_POST_DONE_INT_ST (BIT(2)) -#define KEYMNG_POST_DONE_INT_ST_M (KEYMNG_POST_DONE_INT_ST_V << KEYMNG_POST_DONE_INT_ST_S) -#define KEYMNG_POST_DONE_INT_ST_V 0x00000001U -#define KEYMNG_POST_DONE_INT_ST_S 2 - -/** KEYMNG_INT_ENA_REG register - * Key Manager interrupt enable register. - */ -#define KEYMNG_INT_ENA_REG (DR_REG_KEYMNG_BASE + 0x10) -/** KEYMNG_PREP_DONE_INT_ENA : R/W; bitpos: [0]; default: 0; - * The interrupt enable bit for the km_prep_done_int interrupt - */ -#define KEYMNG_PREP_DONE_INT_ENA (BIT(0)) -#define KEYMNG_PREP_DONE_INT_ENA_M (KEYMNG_PREP_DONE_INT_ENA_V << KEYMNG_PREP_DONE_INT_ENA_S) -#define KEYMNG_PREP_DONE_INT_ENA_V 0x00000001U -#define KEYMNG_PREP_DONE_INT_ENA_S 0 -/** KEYMNG_PROC_DONE_INT_ENA : R/W; bitpos: [1]; default: 0; - * The interrupt enable bit for the km_proc_done_int interrupt - */ -#define KEYMNG_PROC_DONE_INT_ENA (BIT(1)) -#define KEYMNG_PROC_DONE_INT_ENA_M (KEYMNG_PROC_DONE_INT_ENA_V << KEYMNG_PROC_DONE_INT_ENA_S) -#define KEYMNG_PROC_DONE_INT_ENA_V 0x00000001U -#define KEYMNG_PROC_DONE_INT_ENA_S 1 -/** KEYMNG_POST_DONE_INT_ENA : R/W; bitpos: [2]; default: 0; - * The interrupt enable bit for the km_post_done_int interrupt - */ -#define KEYMNG_POST_DONE_INT_ENA (BIT(2)) -#define KEYMNG_POST_DONE_INT_ENA_M (KEYMNG_POST_DONE_INT_ENA_V << KEYMNG_POST_DONE_INT_ENA_S) -#define KEYMNG_POST_DONE_INT_ENA_V 0x00000001U -#define KEYMNG_POST_DONE_INT_ENA_S 2 - -/** KEYMNG_INT_CLR_REG register - * Key Manager interrupt clear register. - */ -#define KEYMNG_INT_CLR_REG (DR_REG_KEYMNG_BASE + 0x14) -/** KEYMNG_PREP_DONE_INT_CLR : WT; bitpos: [0]; default: 0; - * Set this bit to clear the km_prep_done_int interrupt - */ -#define KEYMNG_PREP_DONE_INT_CLR (BIT(0)) -#define KEYMNG_PREP_DONE_INT_CLR_M (KEYMNG_PREP_DONE_INT_CLR_V << KEYMNG_PREP_DONE_INT_CLR_S) -#define KEYMNG_PREP_DONE_INT_CLR_V 0x00000001U -#define KEYMNG_PREP_DONE_INT_CLR_S 0 -/** KEYMNG_PROC_DONE_INT_CLR : WT; bitpos: [1]; default: 0; - * Set this bit to clear the km_proc_done_int interrupt - */ -#define KEYMNG_PROC_DONE_INT_CLR (BIT(1)) -#define KEYMNG_PROC_DONE_INT_CLR_M (KEYMNG_PROC_DONE_INT_CLR_V << KEYMNG_PROC_DONE_INT_CLR_S) -#define KEYMNG_PROC_DONE_INT_CLR_V 0x00000001U -#define KEYMNG_PROC_DONE_INT_CLR_S 1 -/** KEYMNG_POST_DONE_INT_CLR : WT; bitpos: [2]; default: 0; - * Set this bit to clear the km_post_done_int interrupt - */ -#define KEYMNG_POST_DONE_INT_CLR (BIT(2)) -#define KEYMNG_POST_DONE_INT_CLR_M (KEYMNG_POST_DONE_INT_CLR_V << KEYMNG_POST_DONE_INT_CLR_S) -#define KEYMNG_POST_DONE_INT_CLR_V 0x00000001U -#define KEYMNG_POST_DONE_INT_CLR_S 2 - -/** KEYMNG_STATIC_REG register - * Key Manager static configuration register - */ -#define KEYMNG_STATIC_REG (DR_REG_KEYMNG_BASE + 0x18) -/** KEYMNG_USE_EFUSE_KEY : R/W; bitpos: [4:0]; default: 0; - * Set each bit to choose efuse key instead of key manager deployed key. Each bit - * stands for a key type:bit 4 for psram_key; bit 3 for ds_key; bit 2 for hmac_key; - * bit 1 for flash_key; bit 0 for ecdsa_key - */ -#define KEYMNG_USE_EFUSE_KEY 0x0000001FU -#define KEYMNG_USE_EFUSE_KEY_M (KEYMNG_USE_EFUSE_KEY_V << KEYMNG_USE_EFUSE_KEY_S) -#define KEYMNG_USE_EFUSE_KEY_V 0x0000001FU -#define KEYMNG_USE_EFUSE_KEY_S 0 -/** KEYMNG_RND_SWITCH_CYCLE : R/W; bitpos: [9:5]; default: 15; - * The core clock cycle number to sample one rng input data. Please set it bigger than - * the clock cycle ratio: T_rng/T_km - */ -#define KEYMNG_RND_SWITCH_CYCLE 0x0000001FU -#define KEYMNG_RND_SWITCH_CYCLE_M (KEYMNG_RND_SWITCH_CYCLE_V << KEYMNG_RND_SWITCH_CYCLE_S) -#define KEYMNG_RND_SWITCH_CYCLE_V 0x0000001FU -#define KEYMNG_RND_SWITCH_CYCLE_S 5 -/** KEYMNG_USE_SW_INIT_KEY : R/W; bitpos: [10]; default: 0; - * Set this bit to use software written init key instead of efuse_init_key. - */ -#define KEYMNG_USE_SW_INIT_KEY (BIT(10)) -#define KEYMNG_USE_SW_INIT_KEY_M (KEYMNG_USE_SW_INIT_KEY_V << KEYMNG_USE_SW_INIT_KEY_S) -#define KEYMNG_USE_SW_INIT_KEY_V 0x00000001U -#define KEYMNG_USE_SW_INIT_KEY_S 10 -/** KEYMNG_FLASH_KEY_LEN : R/W; bitpos: [11]; default: 0; - * Set this bit to choose flash crypt using xts-aes-256 or xts-aes-128. 1: use - * xts-aes-256. 0: use xts-aes-128. - */ -#define KEYMNG_FLASH_KEY_LEN (BIT(11)) -#define KEYMNG_FLASH_KEY_LEN_M (KEYMNG_FLASH_KEY_LEN_V << KEYMNG_FLASH_KEY_LEN_S) -#define KEYMNG_FLASH_KEY_LEN_V 0x00000001U -#define KEYMNG_FLASH_KEY_LEN_S 11 -/** KEYMNG_PSRAM_KEY_LEN : R/W; bitpos: [12]; default: 0; - * Set this bit to choose psram crypt using xts-aes-256 or xts-aes-128. 1: use - * xts-aes-256. 0: use xts-aes-128. - */ -#define KEYMNG_PSRAM_KEY_LEN (BIT(12)) -#define KEYMNG_PSRAM_KEY_LEN_M (KEYMNG_PSRAM_KEY_LEN_V << KEYMNG_PSRAM_KEY_LEN_S) -#define KEYMNG_PSRAM_KEY_LEN_V 0x00000001U -#define KEYMNG_PSRAM_KEY_LEN_S 12 - -/** KEYMNG_LOCK_REG register - * Key Manager static configuration locker register - */ -#define KEYMNG_LOCK_REG (DR_REG_KEYMNG_BASE + 0x1c) -/** KEYMNG_USE_EFUSE_KEY_LOCK : R/W1; bitpos: [4:0]; default: 0; - * Write 1 to lock reg_use_efuse_key. Each bit locks the corresponding bit of - * reg_use_efuse_key. - */ -#define KEYMNG_USE_EFUSE_KEY_LOCK 0x0000001FU -#define KEYMNG_USE_EFUSE_KEY_LOCK_M (KEYMNG_USE_EFUSE_KEY_LOCK_V << KEYMNG_USE_EFUSE_KEY_LOCK_S) -#define KEYMNG_USE_EFUSE_KEY_LOCK_V 0x0000001FU -#define KEYMNG_USE_EFUSE_KEY_LOCK_S 0 -/** KEYMNG_RND_SWITCH_CYCLE_LOCK : R/W1; bitpos: [5]; default: 0; - * Write 1 to lock reg_rnd_switch_cycle. - */ -#define KEYMNG_RND_SWITCH_CYCLE_LOCK (BIT(5)) -#define KEYMNG_RND_SWITCH_CYCLE_LOCK_M (KEYMNG_RND_SWITCH_CYCLE_LOCK_V << KEYMNG_RND_SWITCH_CYCLE_LOCK_S) -#define KEYMNG_RND_SWITCH_CYCLE_LOCK_V 0x00000001U -#define KEYMNG_RND_SWITCH_CYCLE_LOCK_S 5 -/** KEYMNG_USE_SW_INIT_KEY_LOCK : R/W1; bitpos: [6]; default: 0; - * Write 1 to lock reg_use_sw_init_key. - */ -#define KEYMNG_USE_SW_INIT_KEY_LOCK (BIT(6)) -#define KEYMNG_USE_SW_INIT_KEY_LOCK_M (KEYMNG_USE_SW_INIT_KEY_LOCK_V << KEYMNG_USE_SW_INIT_KEY_LOCK_S) -#define KEYMNG_USE_SW_INIT_KEY_LOCK_V 0x00000001U -#define KEYMNG_USE_SW_INIT_KEY_LOCK_S 6 -/** KEYMNG_FLASH_KEY_LEN_LOCK : R/W1; bitpos: [7]; default: 0; - * Write 1 to lock reg_flash_key_len. - */ -#define KEYMNG_FLASH_KEY_LEN_LOCK (BIT(7)) -#define KEYMNG_FLASH_KEY_LEN_LOCK_M (KEYMNG_FLASH_KEY_LEN_LOCK_V << KEYMNG_FLASH_KEY_LEN_LOCK_S) -#define KEYMNG_FLASH_KEY_LEN_LOCK_V 0x00000001U -#define KEYMNG_FLASH_KEY_LEN_LOCK_S 7 -/** KEYMNG_PSRAM_KEY_LEN_LOCK : R/W1; bitpos: [8]; default: 0; - * Write 1 to lock reg_psram_key_len. - */ -#define KEYMNG_PSRAM_KEY_LEN_LOCK (BIT(8)) -#define KEYMNG_PSRAM_KEY_LEN_LOCK_M (KEYMNG_PSRAM_KEY_LEN_LOCK_V << KEYMNG_PSRAM_KEY_LEN_LOCK_S) -#define KEYMNG_PSRAM_KEY_LEN_LOCK_V 0x00000001U -#define KEYMNG_PSRAM_KEY_LEN_LOCK_S 8 - -/** KEYMNG_CONF_REG register - * Key Manager configuration register - */ -#define KEYMNG_CONF_REG (DR_REG_KEYMNG_BASE + 0x20) -/** KEYMNG_KGEN_MODE : R/W; bitpos: [2:0]; default: 0; - * Set this field to choose the key generator deployment mode. 0: random mode. 1: AES - * mode. 2: ECDH0 mode. 3: ECDH1 mode. 4: recover mode. 5: export mode. 6-7: reserved. - */ -#define KEYMNG_KGEN_MODE 0x00000007U -#define KEYMNG_KGEN_MODE_M (KEYMNG_KGEN_MODE_V << KEYMNG_KGEN_MODE_S) -#define KEYMNG_KGEN_MODE_V 0x00000007U -#define KEYMNG_KGEN_MODE_S 0 -/** KEYMNG_KEY_PURPOSE : R/W; bitpos: [6:3]; default: 0; - * Set this field to choose the key purpose. 1: ecdsa_key_192. 2: ecdsa_key_256. 3: - * flash_256_1_key. 4: flash_256_2_key. 5: flash_128_key. 6: hmac_key. 7: ds_key. 8: - * psram_256_1_key. 9: psram_256_2_key. 10: psram_128_key. 11: ecdsa_key_384_l. 12: - * ecdsa_key_384_h. Others: reserved. - */ -#define KEYMNG_KEY_PURPOSE 0x0000000FU -#define KEYMNG_KEY_PURPOSE_M (KEYMNG_KEY_PURPOSE_V << KEYMNG_KEY_PURPOSE_S) -#define KEYMNG_KEY_PURPOSE_V 0x0000000FU -#define KEYMNG_KEY_PURPOSE_S 3 - -/** KEYMNG_START_REG register - * Key Manager control register - */ -#define KEYMNG_START_REG (DR_REG_KEYMNG_BASE + 0x24) -/** KEYMNG_START : WT; bitpos: [0]; default: 0; - * Write 1 to continue Key Manager operation at LOAD/GAIN state. - */ -#define KEYMNG_START (BIT(0)) -#define KEYMNG_START_M (KEYMNG_START_V << KEYMNG_START_S) -#define KEYMNG_START_V 0x00000001U -#define KEYMNG_START_S 0 -/** KEYMNG_CONTINUE : WT; bitpos: [1]; default: 0; - * Write 1 to start Key Manager at IDLE state. - */ -#define KEYMNG_CONTINUE (BIT(1)) -#define KEYMNG_CONTINUE_M (KEYMNG_CONTINUE_V << KEYMNG_CONTINUE_S) -#define KEYMNG_CONTINUE_V 0x00000001U -#define KEYMNG_CONTINUE_S 1 - -/** KEYMNG_STATE_REG register - * Key Manager state register - */ -#define KEYMNG_STATE_REG (DR_REG_KEYMNG_BASE + 0x28) -/** KEYMNG_STATE : RO; bitpos: [1:0]; default: 0; - * The state of Key Manager. 0: IDLE. 1: LOAD. 2: GAIN. 3: BUSY. - */ -#define KEYMNG_STATE 0x00000003U -#define KEYMNG_STATE_M (KEYMNG_STATE_V << KEYMNG_STATE_S) -#define KEYMNG_STATE_V 0x00000003U -#define KEYMNG_STATE_S 0 - -/** KEYMNG_RESULT_REG register - * Key Manager operation result register - */ -#define KEYMNG_RESULT_REG (DR_REG_KEYMNG_BASE + 0x2c) -/** KEYMNG_PROC_RESULT : RO/SS; bitpos: [0]; default: 0; - * The procedure result bit of Key Manager, only valid when Key Manager procedure is - * done. 1: Key Manager procedure succeeded. 0: Key Manager procedure failed. - */ -#define KEYMNG_PROC_RESULT (BIT(0)) -#define KEYMNG_PROC_RESULT_M (KEYMNG_PROC_RESULT_V << KEYMNG_PROC_RESULT_S) -#define KEYMNG_PROC_RESULT_V 0x00000001U -#define KEYMNG_PROC_RESULT_S 0 - -/** KEYMNG_KEY_VLD_REG register - * Key Manager key status register - */ -#define KEYMNG_KEY_VLD_REG (DR_REG_KEYMNG_BASE + 0x30) -/** KEYMNG_KEY_ECDSA_192_VLD : RO; bitpos: [0]; default: 0; - * The status bit for key_ecdsa_192. 1: The key has been deployed correctly. 0: The - * key has not been deployed yet. - */ -#define KEYMNG_KEY_ECDSA_192_VLD (BIT(0)) -#define KEYMNG_KEY_ECDSA_192_VLD_M (KEYMNG_KEY_ECDSA_192_VLD_V << KEYMNG_KEY_ECDSA_192_VLD_S) -#define KEYMNG_KEY_ECDSA_192_VLD_V 0x00000001U -#define KEYMNG_KEY_ECDSA_192_VLD_S 0 -/** KEYMNG_KEY_ECDSA_256_VLD : RO; bitpos: [1]; default: 0; - * The status bit for key_ecdsa_256. 1: The key has been deployed correctly. 0: The - * key has not been deployed yet. - */ -#define KEYMNG_KEY_ECDSA_256_VLD (BIT(1)) -#define KEYMNG_KEY_ECDSA_256_VLD_M (KEYMNG_KEY_ECDSA_256_VLD_V << KEYMNG_KEY_ECDSA_256_VLD_S) -#define KEYMNG_KEY_ECDSA_256_VLD_V 0x00000001U -#define KEYMNG_KEY_ECDSA_256_VLD_S 1 -/** KEYMNG_KEY_FLASH_VLD : RO; bitpos: [2]; default: 0; - * The status bit for key_flash. 1: The key has been deployed correctly. 0: The - * key has not been deployed yet. - */ -#define KEYMNG_KEY_FLASH_VLD (BIT(2)) -#define KEYMNG_KEY_FLASH_VLD_M (KEYMNG_KEY_FLASH_VLD_V << KEYMNG_KEY_FLASH_VLD_S) -#define KEYMNG_KEY_FLASH_VLD_V 0x00000001U -#define KEYMNG_KEY_FLASH_VLD_S 2 -/** KEYMNG_KEY_HMAC_VLD : RO; bitpos: [3]; default: 0; - * The status bit for key_hmac. 1: The key has been deployed correctly. 0: The key - * has not been deployed yet. - */ -#define KEYMNG_KEY_HMAC_VLD (BIT(3)) -#define KEYMNG_KEY_HMAC_VLD_M (KEYMNG_KEY_HMAC_VLD_V << KEYMNG_KEY_HMAC_VLD_S) -#define KEYMNG_KEY_HMAC_VLD_V 0x00000001U -#define KEYMNG_KEY_HMAC_VLD_S 3 -/** KEYMNG_KEY_DS_VLD : RO; bitpos: [4]; default: 0; - * The status bit for key_ds. 1: The key has been deployed correctly. 0: The - * key has not been deployed yet. - */ -#define KEYMNG_KEY_DS_VLD (BIT(4)) -#define KEYMNG_KEY_DS_VLD_M (KEYMNG_KEY_DS_VLD_V << KEYMNG_KEY_DS_VLD_S) -#define KEYMNG_KEY_DS_VLD_V 0x00000001U -#define KEYMNG_KEY_DS_VLD_S 4 -/** KEYMNG_KEY_PSRAM_VLD : RO; bitpos: [5]; default: 0; - * The status bit for key_psram. 1: The key has been deployed correctly. 0: The key - * has not been deployed yet. - */ -#define KEYMNG_KEY_PSRAM_VLD (BIT(5)) -#define KEYMNG_KEY_PSRAM_VLD_M (KEYMNG_KEY_PSRAM_VLD_V << KEYMNG_KEY_PSRAM_VLD_S) -#define KEYMNG_KEY_PSRAM_VLD_V 0x00000001U -#define KEYMNG_KEY_PSRAM_VLD_S 5 -/** KEYMNG_KEY_ECDSA_384_VLD : RO; bitpos: [6]; default: 0; - * The status bit for key_ecdsa_384. 1: The key has been deployed correctly. 0: The - * key has not been deployed yet. - */ -#define KEYMNG_KEY_ECDSA_384_VLD (BIT(6)) -#define KEYMNG_KEY_ECDSA_384_VLD_M (KEYMNG_KEY_ECDSA_384_VLD_V << KEYMNG_KEY_ECDSA_384_VLD_S) -#define KEYMNG_KEY_ECDSA_384_VLD_V 0x00000001U -#define KEYMNG_KEY_ECDSA_384_VLD_S 6 - -/** KEYMNG_HUK_VLD_REG register - * Key Manager HUK status register - */ -#define KEYMNG_HUK_VLD_REG (DR_REG_KEYMNG_BASE + 0x34) -/** KEYMNG_HUK_VALID : RO; bitpos: [0]; default: 0; - * The HUK status. 0: HUK is not valid. 1: HUK is valid. - */ -#define KEYMNG_HUK_VALID (BIT(0)) -#define KEYMNG_HUK_VALID_M (KEYMNG_HUK_VALID_V << KEYMNG_HUK_VALID_S) -#define KEYMNG_HUK_VALID_V 0x00000001U -#define KEYMNG_HUK_VALID_S 0 - -/** KEYMNG_DATE_REG register - * Version control register - */ -#define KEYMNG_DATE_REG (DR_REG_KEYMNG_BASE + 0xfc) -/** KEYMNG_DATE : R/W; bitpos: [27:0]; default: 37781824; - * Key Manager version control register. - */ -#define KEYMNG_DATE 0x0FFFFFFFU -#define KEYMNG_DATE_M (KEYMNG_DATE_V << KEYMNG_DATE_S) -#define KEYMNG_DATE_V 0x0FFFFFFFU -#define KEYMNG_DATE_S 0 - -/** KEYMNG_ASSIST_INFO_MEM register - * The memory that stores assist key info. - */ -#define KEYMNG_ASSIST_INFO_MEM (DR_REG_KEYMNG_BASE + 0x100) -#define KEYMNG_ASSIST_INFO_MEM_SIZE_BYTES 64 - -/** KEYMNG_PUBLIC_INFO_MEM register - * The memory that stores public key info. - */ -#define KEYMNG_PUBLIC_INFO_MEM (DR_REG_KEYMNG_BASE + 0x140) -#define KEYMNG_PUBLIC_INFO_MEM_SIZE_BYTES 64 - -/** KEYMNG_SW_INIT_KEY_MEM register - * The memory that stores software written init key. - */ -#define KEYMNG_SW_INIT_KEY_MEM (DR_REG_KEYMNG_BASE + 0x180) -#define KEYMNG_SW_INIT_KEY_MEM_SIZE_BYTES 32 - -#ifdef __cplusplus -} -#endif diff --git a/components/soc/esp32c5/register/soc/keymng_struct.h b/components/soc/esp32c5/register/soc/keymng_struct.h index 2512497013..f32ab803a6 100644 --- a/components/soc/esp32c5/register/soc/keymng_struct.h +++ b/components/soc/esp32c5/register/soc/keymng_struct.h @@ -1,5 +1,5 @@ /** - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -202,9 +202,10 @@ typedef union { */ uint32_t kgen_mode:3; /** key_purpose : R/W; bitpos: [6:3]; default: 0; - * Set this field to choose the key purpose. 1: ecdsa_key 2: flash_256_1_key. 3: - * flash_256_2_key. 4: flash_128_key. 6: hmac_key. 7: ds_key. 8: psram_256_1_key. 9: - * psram_256_2_key. 10: psram_128_key. Others: reserved. + * Set this field to choose the key purpose. 1: ecdsa_key_192. 2: ecdsa_key_256. 3: + * flash_256_1_key. 4: flash_256_2_key. 5: flash_128_key. 6: hmac_key. 7: ds_key. 8: + * psram_256_1_key. 9: psram_256_2_key. 10: psram_128_key. 11: ecdsa_key_384_l. 12: + * ecdsa_key_384_h. Others: reserved. */ uint32_t key_purpose:4; uint32_t reserved_7:25; @@ -270,32 +271,42 @@ typedef union { */ typedef union { struct { - /** key_ecdsa_vld : RO; bitpos: [0]; default: 0; - * The status bit for key_ecdsa. 1: The key has been deployed correctly. 0: The key - * has not been deployed yet. + /** key_ecdsa_192_vld : RO; bitpos: [0]; default: 0; + * The status bit for key_ecdsa_192. 1: The key has been deployed correctly. 0: The + * key has not been deployed yet. */ - uint32_t key_ecdsa_vld:1; - /** key_flash_vld : RO; bitpos: [1]; default: 0; + uint32_t key_ecdsa_192_vld:1; + /** key_ecdsa_256_vld : RO; bitpos: [1]; default: 0; + * The status bit for key_ecdsa_256. 1: The key has been deployed correctly. 0: The + * key has not been deployed yet. + */ + uint32_t key_ecdsa_256_vld:1; + /** key_flash_vld : RO; bitpos: [2]; default: 0; * The status bit for key_flash. 1: The key has been deployed correctly. 0: The * key has not been deployed yet. */ uint32_t key_flash_vld:1; - /** key_hmac_vld : RO; bitpos: [2]; default: 0; + /** key_hmac_vld : RO; bitpos: [3]; default: 0; * The status bit for key_hmac. 1: The key has been deployed correctly. 0: The key * has not been deployed yet. */ uint32_t key_hmac_vld:1; - /** key_ds_vld : RO; bitpos: [3]; default: 0; + /** key_ds_vld : RO; bitpos: [4]; default: 0; * The status bit for key_ds. 1: The key has been deployed correctly. 0: The * key has not been deployed yet. */ uint32_t key_ds_vld:1; - /** key_psram_vld : RO; bitpos: [4]; default: 0; + /** key_psram_vld : RO; bitpos: [5]; default: 0; * The status bit for key_psram. 1: The key has been deployed correctly. 0: The key * has not been deployed yet. */ uint32_t key_psram_vld:1; - uint32_t reserved_5:27; + /** key_ecdsa_384_vld : RO; bitpos: [6]; default: 0; + * The status bit for key_ecdsa_384. 1: The key has been deployed correctly. 0: The + * key has not been deployed yet. + */ + uint32_t key_ecdsa_384_vld:1; + uint32_t reserved_7:25; }; uint32_t val; } keymng_key_vld_reg_t; @@ -321,7 +332,7 @@ typedef union { */ typedef union { struct { - /** date : R/W; bitpos: [27:0]; default: 36774224; + /** date : R/W; bitpos: [27:0]; default: 37781824; * Key Manager version control register. */ uint32_t date:28; @@ -338,7 +349,7 @@ typedef struct { volatile keymng_int_st_reg_t int_st; volatile keymng_int_ena_reg_t int_ena; volatile keymng_int_clr_reg_t int_clr; - volatile keymng_static_reg_t static_cfg; + volatile keymng_static_reg_t static_conf; volatile keymng_lock_reg_t lock; volatile keymng_conf_reg_t conf; volatile keymng_start_reg_t start; diff --git a/components/soc/esp32c5/register/soc/keymng_struct_eco2.h b/components/soc/esp32c5/register/soc/keymng_struct_eco2.h deleted file mode 100644 index faacfdf486..0000000000 --- a/components/soc/esp32c5/register/soc/keymng_struct_eco2.h +++ /dev/null @@ -1,375 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#pragma once - -#include -#ifdef __cplusplus -extern "C" { -#endif - -/** Group: Memory data */ - -/** Group: Clock gate register */ -/** Type of clk register - * Key Manager clock gate control register - */ -typedef union { - struct { - /** reg_cg_force_on : R/W; bitpos: [0]; default: 1; - * Write 1 to force on register clock gate. - */ - uint32_t reg_cg_force_on:1; - /** mem_cg_force_on : R/W; bitpos: [1]; default: 0; - * Write 1 to force on memory clock gate. - */ - uint32_t mem_cg_force_on:1; - uint32_t reserved_2:30; - }; - uint32_t val; -} keymng_clk_reg_t; - - -/** Group: Interrupt registers */ -/** Type of int_raw register - * Key Manager interrupt raw register, valid in level. - */ -typedef union { - struct { - /** prep_done_int_raw : RO/WTC/SS; bitpos: [0]; default: 0; - * The raw interrupt status bit for the km_prep_done_int interrupt - */ - uint32_t prep_done_int_raw:1; - /** proc_done_int_raw : RO/WTC/SS; bitpos: [1]; default: 0; - * The raw interrupt status bit for the km_proc_done_int interrupt - */ - uint32_t proc_done_int_raw:1; - /** post_done_int_raw : RO/WTC/SS; bitpos: [2]; default: 0; - * The raw interrupt status bit for the km_post_done_int interrupt - */ - uint32_t post_done_int_raw:1; - uint32_t reserved_3:29; - }; - uint32_t val; -} keymng_int_raw_reg_t; - -/** Type of int_st register - * Key Manager interrupt status register. - */ -typedef union { - struct { - /** prep_done_int_st : RO; bitpos: [0]; default: 0; - * The masked interrupt status bit for the km_prep_done_int interrupt - */ - uint32_t prep_done_int_st:1; - /** proc_done_int_st : RO; bitpos: [1]; default: 0; - * The masked interrupt status bit for the km_proc_done_int interrupt - */ - uint32_t proc_done_int_st:1; - /** post_done_int_st : RO; bitpos: [2]; default: 0; - * The masked interrupt status bit for the km_post_done_int interrupt - */ - uint32_t post_done_int_st:1; - uint32_t reserved_3:29; - }; - uint32_t val; -} keymng_int_st_reg_t; - -/** Type of int_ena register - * Key Manager interrupt enable register. - */ -typedef union { - struct { - /** prep_done_int_ena : R/W; bitpos: [0]; default: 0; - * The interrupt enable bit for the km_prep_done_int interrupt - */ - uint32_t prep_done_int_ena:1; - /** proc_done_int_ena : R/W; bitpos: [1]; default: 0; - * The interrupt enable bit for the km_proc_done_int interrupt - */ - uint32_t proc_done_int_ena:1; - /** post_done_int_ena : R/W; bitpos: [2]; default: 0; - * The interrupt enable bit for the km_post_done_int interrupt - */ - uint32_t post_done_int_ena:1; - uint32_t reserved_3:29; - }; - uint32_t val; -} keymng_int_ena_reg_t; - -/** Type of int_clr register - * Key Manager interrupt clear register. - */ -typedef union { - struct { - /** prep_done_int_clr : WT; bitpos: [0]; default: 0; - * Set this bit to clear the km_prep_done_int interrupt - */ - uint32_t prep_done_int_clr:1; - /** proc_done_int_clr : WT; bitpos: [1]; default: 0; - * Set this bit to clear the km_proc_done_int interrupt - */ - uint32_t proc_done_int_clr:1; - /** post_done_int_clr : WT; bitpos: [2]; default: 0; - * Set this bit to clear the km_post_done_int interrupt - */ - uint32_t post_done_int_clr:1; - uint32_t reserved_3:29; - }; - uint32_t val; -} keymng_int_clr_reg_t; - - -/** Group: Static configuration registers */ -/** Type of static register - * Key Manager static configuration register - */ -typedef union { - struct { - /** use_efuse_key : R/W; bitpos: [4:0]; default: 0; - * Set each bit to choose efuse key instead of key manager deployed key. Each bit - * stands for a key type:bit 4 for psram_key; bit 3 for ds_key; bit 2 for hmac_key; - * bit 1 for flash_key; bit 0 for ecdsa_key - */ - uint32_t use_efuse_key:5; - /** rnd_switch_cycle : R/W; bitpos: [9:5]; default: 15; - * The core clock cycle number to sample one rng input data. Please set it bigger than - * the clock cycle ratio: T_rng/T_km - */ - uint32_t rnd_switch_cycle:5; - /** use_sw_init_key : R/W; bitpos: [10]; default: 0; - * Set this bit to use software written init key instead of efuse_init_key. - */ - uint32_t use_sw_init_key:1; - /** flash_key_len : R/W; bitpos: [11]; default: 0; - * Set this bit to choose flash crypt using xts-aes-256 or xts-aes-128. 1: use - * xts-aes-256. 0: use xts-aes-128. - */ - uint32_t flash_key_len:1; - /** psram_key_len : R/W; bitpos: [12]; default: 0; - * Set this bit to choose psram crypt using xts-aes-256 or xts-aes-128. 1: use - * xts-aes-256. 0: use xts-aes-128. - */ - uint32_t psram_key_len:1; - uint32_t reserved_13:19; - }; - uint32_t val; -} keymng_static_reg_t; - -/** Type of lock register - * Key Manager static configuration locker register - */ -typedef union { - struct { - /** use_efuse_key_lock : R/W1; bitpos: [4:0]; default: 0; - * Write 1 to lock reg_use_efuse_key. Each bit locks the corresponding bit of - * reg_use_efuse_key. - */ - uint32_t use_efuse_key_lock:5; - /** rnd_switch_cycle_lock : R/W1; bitpos: [5]; default: 0; - * Write 1 to lock reg_rnd_switch_cycle. - */ - uint32_t rnd_switch_cycle_lock:1; - /** use_sw_init_key_lock : R/W1; bitpos: [6]; default: 0; - * Write 1 to lock reg_use_sw_init_key. - */ - uint32_t use_sw_init_key_lock:1; - /** flash_key_len_lock : R/W1; bitpos: [7]; default: 0; - * Write 1 to lock reg_flash_key_len. - */ - uint32_t flash_key_len_lock:1; - /** psram_key_len_lock : R/W1; bitpos: [8]; default: 0; - * Write 1 to lock reg_psram_key_len. - */ - uint32_t psram_key_len_lock:1; - uint32_t reserved_9:23; - }; - uint32_t val; -} keymng_lock_reg_t; - - -/** Group: Configuration registers */ -/** Type of conf register - * Key Manager configuration register - */ -typedef union { - struct { - /** kgen_mode : R/W; bitpos: [2:0]; default: 0; - * Set this field to choose the key generator deployment mode. 0: random mode. 1: AES - * mode. 2: ECDH0 mode. 3: ECDH1 mode. 4: recover mode. 5: export mode. 6-7: reserved. - */ - uint32_t kgen_mode:3; - /** key_purpose : R/W; bitpos: [6:3]; default: 0; - * Set this field to choose the key purpose. 1: ecdsa_key_192. 2: ecdsa_key_256. 3: - * flash_256_1_key. 4: flash_256_2_key. 5: flash_128_key. 6: hmac_key. 7: ds_key. 8: - * psram_256_1_key. 9: psram_256_2_key. 10: psram_128_key. 11: ecdsa_key_384_l. 12: - * ecdsa_key_384_h. Others: reserved. - */ - uint32_t key_purpose:4; - uint32_t reserved_7:25; - }; - uint32_t val; -} keymng_conf_reg_t; - - -/** Group: Control registers */ -/** Type of start register - * Key Manager control register - */ -typedef union { - struct { - /** start : WT; bitpos: [0]; default: 0; - * Write 1 to conti Key Manager operation at LOAD/GAIN state. - */ - uint32_t start:1; - /** conti : WT; bitpos: [1]; default: 0; - * Write 1 to start Key Manager at IDLE state. - */ - uint32_t conti:1; - uint32_t reserved_2:30; - }; - uint32_t val; -} keymng_start_reg_t; - - -/** Group: State registers */ -/** Type of state register - * Key Manager state register - */ -typedef union { - struct { - /** state : RO; bitpos: [1:0]; default: 0; - * The state of Key Manager. 0: IDLE. 1: LOAD. 2: GAIN. 3: BUSY. - */ - uint32_t state:2; - uint32_t reserved_2:30; - }; - uint32_t val; -} keymng_state_reg_t; - - -/** Group: Result registers */ -/** Type of result register - * Key Manager operation result register - */ -typedef union { - struct { - /** proc_result : RO/SS; bitpos: [0]; default: 0; - * The procedure result bit of Key Manager, only valid when Key Manager procedure is - * done. 1: Key Manager procedure succeeded. 0: Key Manager procedure failed. - */ - uint32_t proc_result:1; - uint32_t reserved_1:31; - }; - uint32_t val; -} keymng_result_reg_t; - -/** Type of key_vld register - * Key Manager key status register - */ -typedef union { - struct { - /** key_ecdsa_192_vld : RO; bitpos: [0]; default: 0; - * The status bit for key_ecdsa_192. 1: The key has been deployed correctly. 0: The - * key has not been deployed yet. - */ - uint32_t key_ecdsa_192_vld:1; - /** key_ecdsa_256_vld : RO; bitpos: [1]; default: 0; - * The status bit for key_ecdsa_256. 1: The key has been deployed correctly. 0: The - * key has not been deployed yet. - */ - uint32_t key_ecdsa_256_vld:1; - /** key_flash_vld : RO; bitpos: [2]; default: 0; - * The status bit for key_flash. 1: The key has been deployed correctly. 0: The - * key has not been deployed yet. - */ - uint32_t key_flash_vld:1; - /** key_hmac_vld : RO; bitpos: [3]; default: 0; - * The status bit for key_hmac. 1: The key has been deployed correctly. 0: The key - * has not been deployed yet. - */ - uint32_t key_hmac_vld:1; - /** key_ds_vld : RO; bitpos: [4]; default: 0; - * The status bit for key_ds. 1: The key has been deployed correctly. 0: The - * key has not been deployed yet. - */ - uint32_t key_ds_vld:1; - /** key_psram_vld : RO; bitpos: [5]; default: 0; - * The status bit for key_psram. 1: The key has been deployed correctly. 0: The key - * has not been deployed yet. - */ - uint32_t key_psram_vld:1; - /** key_ecdsa_384_vld : RO; bitpos: [6]; default: 0; - * The status bit for key_ecdsa_384. 1: The key has been deployed correctly. 0: The - * key has not been deployed yet. - */ - uint32_t key_ecdsa_384_vld:1; - uint32_t reserved_7:25; - }; - uint32_t val; -} keymng_key_vld_reg_t; - -/** Type of huk_vld register - * Key Manager HUK status register - */ -typedef union { - struct { - /** huk_valid : RO; bitpos: [0]; default: 0; - * The HUK status. 0: HUK is not valid. 1: HUK is valid. - */ - uint32_t huk_valid:1; - uint32_t reserved_1:31; - }; - uint32_t val; -} keymng_huk_vld_reg_t; - - -/** Group: Version register */ -/** Type of date register - * Version control register - */ -typedef union { - struct { - /** date : R/W; bitpos: [27:0]; default: 37781824; - * Key Manager version control register. - */ - uint32_t date:28; - uint32_t reserved_28:4; - }; - uint32_t val; -} keymng_date_reg_t; - - -typedef struct { - uint32_t reserved_000; - volatile keymng_clk_reg_t clk; - volatile keymng_int_raw_reg_t int_raw; - volatile keymng_int_st_reg_t int_st; - volatile keymng_int_ena_reg_t int_ena; - volatile keymng_int_clr_reg_t int_clr; - volatile keymng_static_reg_t static_conf; - volatile keymng_lock_reg_t lock; - volatile keymng_conf_reg_t conf; - volatile keymng_start_reg_t start; - volatile keymng_state_reg_t state; - volatile keymng_result_reg_t result; - volatile keymng_key_vld_reg_t key_vld; - volatile keymng_huk_vld_reg_t huk_vld; - uint32_t reserved_038[49]; - volatile keymng_date_reg_t date; - volatile uint32_t assist_info[16]; - volatile uint32_t public_info[16]; - volatile uint32_t sw_init_key[8]; -} keymng_dev_t; - -extern keymng_dev_t KEYMNG; - -#ifndef __cplusplus -_Static_assert(sizeof(keymng_dev_t) == 0x1a0, "Invalid size of keymng_dev_t structure"); -#endif - -#ifdef __cplusplus -} -#endif diff --git a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in index 2787ae062c..0527e1574f 100644 --- a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in @@ -1839,6 +1839,10 @@ config SOC_EFUSE_ECDSA_KEY bool default y +config SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT + bool + default y + config SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY bool default y diff --git a/components/soc/esp32p4/include/soc/soc_caps.h b/components/soc/esp32p4/include/soc/soc_caps.h index 27d05521b2..de74f28268 100644 --- a/components/soc/esp32p4/include/soc/soc_caps.h +++ b/components/soc/esp32p4/include/soc/soc_caps.h @@ -673,8 +673,10 @@ #define SOC_EFUSE_ECDSA_KEY 1 /*-------------------------- Key Manager CAPS----------------------------*/ -#define SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY 1 /*!< Key manager responsible to deploy ECDSA key */ -#define SOC_KEY_MANAGER_FE_KEY_DEPLOY 1 /*!< Key manager responsible to deploy Flash Encryption key */ +#define SOC_KEY_MANAGER_SUPPORT_KEY_DEPLOYMENT 1 /*!< Key manager supports key deployment */ +#define SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY 1 /*!< Key manager responsible to deploy ECDSA key */ +#define SOC_KEY_MANAGER_FE_KEY_DEPLOY 1 /*!< Key manager responsible to deploy Flash Encryption key */ + /*-------------------------- Secure Boot CAPS----------------------------*/ #define SOC_SECURE_BOOT_V2_RSA 1 #define SOC_SECURE_BOOT_V2_ECC 1 diff --git a/components/soc/esp32p4/register/soc/keymng_reg.h b/components/soc/esp32p4/register/soc/keymng_reg.h index a8f03edc6e..cfb0f9c12b 100644 --- a/components/soc/esp32p4/register/soc/keymng_reg.h +++ b/components/soc/esp32p4/register/soc/keymng_reg.h @@ -1,5 +1,5 @@ /** - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -239,6 +239,21 @@ extern "C" { #define KEYMNG_KEY_PURPOSE_V 0x0000000FU #define KEYMNG_KEY_PURPOSE_S 3 +#define KEYMNG_KEY_PURPOSE_ECDSA (BIT(0)) +#define KEYMNG_KEY_PURPOSE_ECDSA_M (KEYMNG_KEY_PURPOSE_ECDSA_V << KEYMNG_KEY_PURPOSE_ECDSA_S) +#define KEYMNG_KEY_PURPOSE_ECDSA_V 0x00000001U +#define KEYMNG_KEY_PURPOSE_ECDSA_S 0 + +#define KEYMNG_KEY_PURPOSE_XTS_AES_256_1 (BIT(1)) +#define KEYMNG_KEY_PURPOSE_XTS_AES_256_1_M (KEYMNG_KEY_PURPOSE_XTS_AES_256_1_V << KEYMNG_KEY_PURPOSE_XTS_AES_256_1_S) +#define KEYMNG_KEY_PURPOSE_XTS_AES_256_1_V 0x00000001U +#define KEYMNG_KEY_PURPOSE_XTS_AES_256_1_S 1 + +#define KEYMNG_KEY_PURPOSE_XTS_AES_256_2 (BIT(2)) +#define KEYMNG_KEY_PURPOSE_XTS_AES_256_2_M (KEYMNG_KEY_PURPOSE_XTS_AES_256_2_V << KEYMNG_KEY_PURPOSE_XTS_AES_256_2_S) +#define KEYMNG_KEY_PURPOSE_XTS_AES_256_2_V 0x00000001U +#define KEYMNG_KEY_PURPOSE_XTS_AES_256_2_S 2 + /** KEYMNG_START_REG register * Key Manager control register */