mirror of
https://github.com/espressif/esp-idf.git
synced 2026-06-11 11:42:39 +02:00
crypto: DS uses RSA peripheral, added shared lock
This commit is contained in:
@@ -100,7 +100,7 @@ static inline bool valid_key_length(const esp_aes_context *ctx)
|
||||
void esp_aes_acquire_hardware( void )
|
||||
{
|
||||
/* Need to lock DMA since it is shared with SHA block */
|
||||
esp_crypto_lock_acquire();
|
||||
esp_crypto_dma_lock_acquire();
|
||||
|
||||
/* Enable AES hardware */
|
||||
periph_module_enable(PERIPH_AES_DMA_MODULE);
|
||||
@@ -112,7 +112,7 @@ void esp_aes_release_hardware( void )
|
||||
/* Disable AES hardware */
|
||||
periph_module_disable(PERIPH_AES_DMA_MODULE);
|
||||
|
||||
esp_crypto_lock_release();
|
||||
esp_crypto_dma_lock_release();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/periph_defs.h"
|
||||
#include <sys/param.h>
|
||||
#include "esp_crypto_lock.h"
|
||||
|
||||
size_t esp_mpi_hardware_words(size_t words)
|
||||
{
|
||||
@@ -35,6 +36,8 @@ size_t esp_mpi_hardware_words(size_t words)
|
||||
|
||||
void esp_mpi_enable_hardware_hw_op( void )
|
||||
{
|
||||
esp_crypto_mpi_lock_acquire();
|
||||
|
||||
/* Enable RSA hardware */
|
||||
periph_module_enable(PERIPH_RSA_MODULE);
|
||||
|
||||
@@ -51,6 +54,8 @@ void esp_mpi_disable_hardware_hw_op( void )
|
||||
|
||||
/* Disable RSA hardware */
|
||||
periph_module_disable(PERIPH_RSA_MODULE);
|
||||
|
||||
esp_crypto_mpi_lock_release();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ inline static size_t state_length(esp_sha_type type)
|
||||
/* Enable SHA peripheral and then lock it */
|
||||
void esp_sha_acquire_hardware()
|
||||
{
|
||||
esp_crypto_lock_acquire();
|
||||
esp_crypto_dma_lock_acquire();
|
||||
|
||||
/* Enable SHA and DMA hardware */
|
||||
periph_module_enable(PERIPH_SHA_DMA_MODULE);
|
||||
@@ -113,7 +113,7 @@ void esp_sha_release_hardware()
|
||||
/* Disable SHA and DMA hardware */
|
||||
periph_module_disable(PERIPH_SHA_DMA_MODULE);
|
||||
|
||||
esp_crypto_lock_release();
|
||||
esp_crypto_dma_lock_release();
|
||||
}
|
||||
|
||||
/* Busy wait until SHA is idle */
|
||||
|
||||
Reference in New Issue
Block a user