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_time_api.h 29 * 30 * @brief Provides APIs for managing the Trusted Execution Environment (TEE) time. 31 * 32 * You can use these APIs to implement time-related features in a TEE. 33 * 34 * @library NA 35 * @kit TEEKit 36 * @syscap SystemCapability.Tee.TeeClient 37 * @since 20 38 */ 39 40 #ifndef __TEE_TIME_API_H 41 #define __TEE_TIME_API_H 42 43 #include "tee_defines.h" 44 #include "tee_rtc_time_api.h" 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /** 51 * @brief Get current TEE system rtc time. 52 * 53 * @param time [OUT] current TEE system rtc time. 54 * 55 * @since 20 56 */ 57 void get_sys_rtc_time(TEE_Time *time); 58 59 /** 60 * @brief Obtains the current TEE system time. 61 * 62 * @param time Indicates the pointer to the current system time obtained. 63 * 64 * @since 20 65 */ 66 void TEE_GetSystemTime(TEE_Time *time); 67 68 /** 69 * @brief Waits for the specified period of time, in milliseconds. 70 * 71 * @param timeout Indicates the period of time to wait, in milliseconds. 72 * 73 * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 74 * @return Returns <b>TEE_ERROR_CANCEL</b> if the wait is canceled. 75 * @return Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if the memory is not sufficient to complete the operation. 76 * 77 * @since 20 78 */ 79 TEE_Result TEE_Wait(uint32_t timeout); 80 81 /** 82 * @brief Obtains the persistent time of this trusted application (TA). 83 * 84 * @param time Indicates the pointer to the persistent time of the TA. 85 * 86 * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 87 * @return Returns <b>TEE_ERROR_TIME_NOT_SET</b> if the persistent time has not been set. 88 * @return Returns <b>TEE_ERROR_TIME_NEEDS_RESET</b> if the persistent time is corrupted and 89 * the application is not longer trusted. 90 * @return Returns <b>TEE_ERROR_OVERFLOW</b> if the number of seconds in the TA persistent time 91 * exceeds the range of <b>uint32_t</b>. 92 * @return Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if the memory is not sufficient to complete the operation. 93 * 94 * @since 20 95 */ 96 TEE_Result TEE_GetTAPersistentTime(TEE_Time *time); 97 98 /** 99 * @brief Sets the persistent time for this TA. 100 * 101 * @param time Indicates the pointer to the persistent time of the TA. 102 * 103 * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 104 * @return Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if the memory is not sufficient to complete the operation. 105 * @return Returns <b>TEE_ERROR_STORAGE_NO_SPACE</b> if the storage space is not sufficient to complete the operation. 106 * 107 * @since 20 108 */ 109 TEE_Result TEE_SetTAPersistentTime(TEE_Time *time); 110 111 /** 112 * @brief Obtains the current Rich Execution Environment (REE) system time. 113 * 114 * @param time Indicates the pointer to the REE system time obtained. 115 * 116 * @since 20 117 */ 118 void TEE_GetREETime(TEE_Time *time); 119 120 #ifdef __cplusplus 121 } 122 #endif 123 124 #endif 125 /** @} */