1 /* 2 * Copyright (c) 2022 ASR Microelectronics (Shanghai) Co., Ltd. All rights reserved. 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 16 #ifndef _LEGA_HW_COMMON_H_ 17 #define _LEGA_HW_COMMON_H_ 18 19 #if defined(ALIOS_SUPPORT) 20 #include "lega_rhino.h" 21 22 #elif defined(HARMONYOS_SUPPORT) 23 #include "lega_rtos.h" 24 #elif defined(SYSTEM_SUPPORT_OS) 25 #include "lega_rtos_api.h" 26 #endif 27 extern lega_mutex_t HwSecurityMutex; 28 #define LEGA_HW_OK (0) 29 #define LEGA_HW_ERR (-1) 30 31 /*! 32 HASH operation mode 33 */ 34 typedef enum { 35 LEGA_HASH_SHA1_mode = 0, /* !< SHA1 */ 36 LEGA_HASH_SHA224_mode = 1, /* !< SHA224 */ 37 LEGA_HASH_SHA256_mode = 2, /* !< SHA256 */ 38 LEGA_HASH_SHA384_mode = 3, /* !< SHA384 */ 39 LEGA_HASH_SHA512_mode = 4, /* !< SHA512 */ 40 LEGA_HASH_MD5_mode = 5, /* !< MD5 */ 41 42 LEGA_HASH_NumOfModes, 43 LEGA_HASH_OperationModeLast = 0x7FFFFFFF, 44 } LEGA_HASH_OperationMode_t; 45 46 /*! Defines the HASH result buffer. */ 47 typedef uint32_t LEGA_HASH_Result_t[16]; 48 49 extern uint8_t *rndContext_ptr; 50 extern uint8_t *rndWorkBuff_ptr; 51 extern int hw_lib_init_flag; 52 53 int lega_hw_lib_init(void); 54 int lega_hw_lib_deinit(void); 55 int lega_security_engine_init(void); 56 int lega_security_engine_deinit(void); 57 58 #endif // _LEGA_HW_COMMON_H_