esp_crypto_lock.c
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 /* Lock for the SHA peripheral, also used by the HMAC and DS peripheral */ 20 static _lock_t s_crypto_sha_lock; 21 22 /* Lock for the AES peripheral, also used by DS peripheral */ 23 static _lock_t s_crypto_aes_lock; 24 25 /* Lock for the MPI/RSA peripheral, also used by the DS peripheral */ 26 static _lock_t s_crypto_mpi_lock; 27 28 void esp_crypto_sha_lock_acquire(void) 29 { 30 _lock_acquire(&s_crypto_sha_lock); 31 } 32 33 void esp_crypto_sha_lock_release(void) 34 { 35 _lock_release(&s_crypto_sha_lock); 36 } 37 38 void esp_crypto_aes_lock_acquire(void) 39 { 40 _lock_acquire(&s_crypto_aes_lock); 41 } 42 43 void esp_crypto_aes_lock_release(void) 44 { 45 _lock_release(&s_crypto_aes_lock); 46 } 47 48 void esp_crypto_mpi_lock_acquire(void) 49 { 50 _lock_acquire(&s_crypto_mpi_lock); 51 } 52 53 void esp_crypto_mpi_lock_release(void) 54 { 55 _lock_release(&s_crypto_mpi_lock); 56 }