1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 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 /** 17 * @addtogroup TeeTrusted 18 * @{ 19 * 20 * @brief TEE(Trusted Excution Environment) API. 21 * Provides security capability APIs such as trusted storage, encryption and decryption, 22 * and trusted time for trusted application development. 23 * 24 * @since 20 25 */ 26 27 /** 28 * @file tee_crypto_hal.h 29 * 30 * @brief Provides APIs for cryptographic operations. 31 * 32 * You can use these APIs to implement encryption and decryption. 33 * 34 * @library NA 35 * @kit TEEKit 36 * @syscap SystemCapability.Tee.TeeClient 37 * @since 20 38 */ 39 40 #ifndef TEE_CRYPTO_HAL_H 41 #define TEE_CRYPTO_HAL_H 42 43 #include "tee_crypto_api.h" 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 /** 50 * @brief Enumerates the types of the crypto engine. 51 * 52 * @since 20 53 */ 54 enum CRYPTO_ENGINE { 55 /** The hardware-based DX crypto engine. */ 56 DX_CRYPTO = 0, 57 /** The hardware-based MSPE crypto engine. */ 58 EPS_CRYPTO = 1, 59 /** The software-based crypto engine, such as OpenSSL. */ 60 SOFT_CRYPTO = 2, 61 /** The SEC crypto engine, commonly employed in vehicle platforms. */ 62 SEC_CRYPTO = 3, 63 /** The maximum value of the crypto engine. */ 64 CRYPTO_ENGINE_MAX = 1024, 65 }; 66 67 /** 68 * @brief Sets the encryption and decryption engines to an operation. 69 * 70 * @param operation Indicates the handle of the operation to set. 71 * @param crypto Indicates the engines to set. 72 * 73 * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 74 * Returns <b>TEE_ERROR_BAD_PARAMETERS</b> if <b>operation</b> is null or <b>crypto</b> is invalid. 75 * 76 * @since 20 77 */ 78 TEE_Result TEE_SetCryptoFlag(TEE_OperationHandle operation, uint32_t crypto); 79 80 /** 81 * @brief Sets the encryption and decryption engines to an object. 82 * 83 * @param object Indicates the handle of the object to set. 84 * @param crypto Indicates the engines to set. 85 * 86 * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 87 * Returns <b>TEE_ERROR_BAD_PARAMETERS</b> if <b>object</b> is null or <b>crypto</b> is invalid. 88 * 89 * @since 20 90 */ 91 TEE_Result TEE_SetObjectFlag(TEE_ObjectHandle object, uint32_t crypto); 92 93 #ifdef __cplusplus 94 } 95 #endif 96 97 #endif 98 /** @} */