mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 12:10:59 +00:00
Merge branch 'feature/crypto_reserve_gdma_ch' into 'master'
aes/sha: use a shared lazy allocated GDMA channel for AES and SHA Closes IDF-2856 See merge request espressif/esp-idf!12507
This commit is contained in:
@@ -17,8 +17,8 @@
|
||||
#include "esp_crypto_lock.h"
|
||||
|
||||
/* Lock overview:
|
||||
SHA: independent
|
||||
AES: independent
|
||||
SHA: peripheral independent, but DMA is shared with AES
|
||||
AES: peripheral independent, but DMA is shared with SHA
|
||||
MPI/RSA: independent
|
||||
HMAC: needs SHA
|
||||
DS: needs HMAC (which needs SHA), AES and MPI
|
||||
@@ -30,24 +30,21 @@ static _lock_t s_crypto_ds_lock;
|
||||
/* Lock for HMAC peripheral */
|
||||
static _lock_t s_crypto_hmac_lock;
|
||||
|
||||
/* Lock for the SHA peripheral, also used by the HMAC and DS peripheral */
|
||||
static _lock_t s_crypto_sha_lock;
|
||||
|
||||
/* Lock for the AES peripheral, also used by DS peripheral */
|
||||
static _lock_t s_crypto_aes_lock;
|
||||
|
||||
/* Lock for the MPI/RSA peripheral, also used by the DS peripheral */
|
||||
static _lock_t s_crypto_mpi_lock;
|
||||
|
||||
/* Single lock for SHA and AES, sharing a reserved GDMA channel */
|
||||
static _lock_t s_crypto_sha_aes_lock;
|
||||
|
||||
void esp_crypto_hmac_lock_acquire(void)
|
||||
{
|
||||
_lock_acquire(&s_crypto_hmac_lock);
|
||||
esp_crypto_sha_lock_acquire();
|
||||
esp_crypto_sha_aes_lock_acquire();
|
||||
}
|
||||
|
||||
void esp_crypto_hmac_lock_release(void)
|
||||
{
|
||||
esp_crypto_sha_lock_release();
|
||||
esp_crypto_sha_aes_lock_release();
|
||||
_lock_release(&s_crypto_hmac_lock);
|
||||
}
|
||||
|
||||
@@ -55,36 +52,24 @@ void esp_crypto_ds_lock_acquire(void)
|
||||
{
|
||||
_lock_acquire(&s_crypto_ds_lock);
|
||||
esp_crypto_hmac_lock_acquire();
|
||||
esp_crypto_aes_lock_acquire();
|
||||
esp_crypto_mpi_lock_acquire();
|
||||
}
|
||||
|
||||
void esp_crypto_ds_lock_release(void)
|
||||
{
|
||||
esp_crypto_mpi_lock_release();
|
||||
esp_crypto_aes_lock_release();
|
||||
esp_crypto_hmac_lock_release();
|
||||
_lock_release(&s_crypto_ds_lock);
|
||||
}
|
||||
|
||||
void esp_crypto_sha_lock_acquire(void)
|
||||
void esp_crypto_sha_aes_lock_acquire(void)
|
||||
{
|
||||
_lock_acquire(&s_crypto_sha_lock);
|
||||
_lock_acquire(&s_crypto_sha_aes_lock);
|
||||
}
|
||||
|
||||
void esp_crypto_sha_lock_release(void)
|
||||
void esp_crypto_sha_aes_lock_release(void)
|
||||
{
|
||||
_lock_release(&s_crypto_sha_lock);
|
||||
}
|
||||
|
||||
void esp_crypto_aes_lock_acquire(void)
|
||||
{
|
||||
_lock_acquire(&s_crypto_aes_lock);
|
||||
}
|
||||
|
||||
void esp_crypto_aes_lock_release(void)
|
||||
{
|
||||
_lock_release(&s_crypto_aes_lock);
|
||||
_lock_release(&s_crypto_sha_aes_lock);
|
||||
}
|
||||
|
||||
void esp_crypto_mpi_lock_acquire(void)
|
||||
|
@@ -47,28 +47,17 @@ void esp_crypto_ds_lock_acquire(void);
|
||||
void esp_crypto_ds_lock_release(void);
|
||||
|
||||
/**
|
||||
* @brief Acquire lock for the SHA cryptography peripheral.
|
||||
* @brief Acquire lock for the SHA and AES cryptography peripheral.
|
||||
*
|
||||
*/
|
||||
void esp_crypto_sha_lock_acquire(void);
|
||||
void esp_crypto_sha_aes_lock_acquire(void);
|
||||
|
||||
/**
|
||||
* @brief Release lock for the SHA cryptography peripheral.
|
||||
* @brief Release lock for the SHA and AES cryptography peripheral.
|
||||
*
|
||||
*/
|
||||
void esp_crypto_sha_lock_release(void);
|
||||
void esp_crypto_sha_aes_lock_release(void);
|
||||
|
||||
/**
|
||||
* @brief Acquire lock for the aes cryptography peripheral.
|
||||
*
|
||||
*/
|
||||
void esp_crypto_aes_lock_acquire(void);
|
||||
|
||||
/**
|
||||
* @brief Release lock for the aes cryptography peripheral.
|
||||
*
|
||||
*/
|
||||
void esp_crypto_aes_lock_release(void);
|
||||
|
||||
/**
|
||||
* @brief Acquire lock for the mpi cryptography peripheral.
|
||||
|
Reference in New Issue
Block a user