mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-04 00:51:42 +01:00 
			
		
		
		
	Merge branch 'esp32p4/add_aes_support' into 'master'
feat: add AES support for ESP32-P4 Closes IDF-6519 See merge request espressif/esp-idf!26429
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
 | 
			
		||||
 * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 */
 | 
			
		||||
@@ -9,6 +9,7 @@
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include "soc/hwcrypto_reg.h"
 | 
			
		||||
#include "soc/system_struct.h"
 | 
			
		||||
#include "hal/aes_types.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
@@ -25,6 +26,35 @@ typedef enum {
 | 
			
		||||
    ESP_AES_STATE_DONE,     /* Transform completed */
 | 
			
		||||
} esp_aes_state_t;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Enable the bus clock for AES peripheral module
 | 
			
		||||
 *
 | 
			
		||||
 * @param enable true to enable the module, false to disable the module
 | 
			
		||||
 */
 | 
			
		||||
static inline void aes_ll_enable_bus_clock(bool enable)
 | 
			
		||||
{
 | 
			
		||||
    SYSTEM.perip_clk_en1.reg_crypto_aes_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 aes_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; aes_ll_enable_bus_clock(__VA_ARGS__)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Reset the AES peripheral module
 | 
			
		||||
 */
 | 
			
		||||
static inline void aes_ll_reset_register(void)
 | 
			
		||||
{
 | 
			
		||||
    SYSTEM.perip_rst_en1.reg_crypto_aes_rst = 1;
 | 
			
		||||
    SYSTEM.perip_rst_en1.reg_crypto_aes_rst = 0;
 | 
			
		||||
 | 
			
		||||
    // Clear reset on digital signature also, otherwise AES is held in reset
 | 
			
		||||
    SYSTEM.perip_rst_en1.reg_crypto_ds_rst = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// 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 aes_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; aes_ll_reset_register(__VA_ARGS__)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Write the encryption/decryption key to hardware
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user