1 /*
2  * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <sys/lock.h>
8 
9 #include "esp_crypto_lock.h"
10 
11 /* Single lock for SHA and AES engine which both use the crypto DMA */
12 
13 static _lock_t s_crypto_dma_lock;
14 
15 /* Lock for the MPI/RSA peripheral, also used by the DS peripheral */
16 static _lock_t s_crypto_mpi_lock;
17 
esp_crypto_dma_lock_acquire(void)18 void esp_crypto_dma_lock_acquire(void)
19 {
20     _lock_acquire(&s_crypto_dma_lock);
21 }
22 
esp_crypto_dma_lock_release(void)23 void esp_crypto_dma_lock_release(void)
24 {
25     _lock_release(&s_crypto_dma_lock);
26 }
27 
esp_crypto_mpi_lock_acquire(void)28 void esp_crypto_mpi_lock_acquire(void)
29 {
30     _lock_acquire(&s_crypto_mpi_lock);
31 }
32 
esp_crypto_mpi_lock_release(void)33 void esp_crypto_mpi_lock_release(void)
34 {
35     _lock_release(&s_crypto_mpi_lock);
36 }
37