1 // Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #include <sys/lock.h> 16 17 #include "esp_crypto_lock.h" 18 19 /* Single lock for SHA and AES engine which both use the crypto DMA */ 20 21 static _lock_t s_crypto_dma_lock; 22 23 /* Lock for the MPI/RSA peripheral, also used by the DS peripheral */ 24 static _lock_t s_crypto_mpi_lock; 25 esp_crypto_dma_lock_acquire(void)26void esp_crypto_dma_lock_acquire(void) 27 { 28 _lock_acquire(&s_crypto_dma_lock); 29 } 30 esp_crypto_dma_lock_release(void)31void esp_crypto_dma_lock_release(void) 32 { 33 _lock_release(&s_crypto_dma_lock); 34 } 35 esp_crypto_mpi_lock_acquire(void)36void esp_crypto_mpi_lock_acquire(void) 37 { 38 _lock_acquire(&s_crypto_mpi_lock); 39 } 40 esp_crypto_mpi_lock_release(void)41void esp_crypto_mpi_lock_release(void) 42 { 43 _lock_release(&s_crypto_mpi_lock); 44 } 45