1 /* 2 * Copyright (c) 2024 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 #ifndef __TEE_TIME_API_H 17 #define __TEE_TIME_API_H 18 19 /** 20 * @addtogroup TeeTrusted 21 * @{ 22 * 23 * @brief TEE(Trusted Excution Environment) API. 24 * Provides security capability APIs such as trusted storage, encryption and decryption, 25 * and trusted time for trusted application development. 26 * 27 * @since 12 28 */ 29 30 /** 31 * @file tee_time_api.h 32 * 33 * @brief Provides APIs for managing the Trusted Execution Environment (TEE) time. 34 * 35 * You can use these APIs to implement time-related features in a TEE. 36 * 37 * @library NA 38 * @kit TEE Kit 39 * @syscap SystemCapability.Tee.TeeClient 40 * @since 12 41 * @version 1.0 42 */ 43 44 #include "tee_defines.h" 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /** 51 * @brief Obtains the current TEE system time. 52 * 53 * @param time Indicates the pointer to the current system time obtained. 54 * 55 * @since 12 56 * @version 1.0 57 */ 58 void TEE_GetSystemTime(TEE_Time *time); 59 60 /** 61 * @brief Waits for the specified period of time, in milliseconds. 62 * 63 * @param timeout Indicates the period of time to wait, in milliseconds. 64 * 65 * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 66 * @return Returns <b>TEE_ERROR_CANCEL</b> if the wait is canceled. 67 * @return Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if the memory is not sufficient to complete the operation. 68 * 69 * @since 12 70 * @version 1.0 71 */ 72 TEE_Result TEE_Wait(uint32_t timeout); 73 74 /** 75 * @brief Obtains the persistent time of this trusted application (TA). 76 * 77 * @param time Indicates the pointer to the persistent time of the TA. 78 * 79 * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 80 * @return Returns <b>TEE_ERROR_TIME_NOT_SET</b> if the persistent time has not been set. 81 * @return Returns <b>TEE_ERROR_TIME_NEEDS_RESET</b> if the persistent time is corrupted and 82 * the application is not longer trusted. 83 * @return Returns <b>TEE_ERROR_OVERFLOW</b> if the number of seconds in the TA persistent time 84 * exceeds the range of <b>uint32_t</b>. 85 * @return Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if the memory is not sufficient to complete the operation. 86 * 87 * @since 12 88 * @version 1.0 89 */ 90 TEE_Result TEE_GetTAPersistentTime(TEE_Time *time); 91 92 /** 93 * @brief Sets the persistent time for this TA. 94 * 95 * @param time Indicates the pointer to the persistent time of the TA. 96 * 97 * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 98 * @return Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if the memory is not sufficient to complete the operation. 99 * @return Returns <b>TEE_ERROR_STORAGE_NO_SPACE</b> if the storage space is not sufficient to complete the operation. 100 * 101 * @since 12 102 * @version 1.0 103 */ 104 TEE_Result TEE_SetTAPersistentTime(TEE_Time *time); 105 106 /** 107 * @brief Obtains the current Rich Execution Environment (REE) system time. 108 * 109 * @param time Indicates the pointer to the REE system time obtained. 110 * 111 * @since 12 112 * @version 1.0 113 */ 114 void TEE_GetREETime(TEE_Time *time); 115 116 /** 117 * @brief Obtains the string format of the current Rich Execution Environment (REE) system time. 118 * 119 * @param tim_str Indicates the REE system time string. 120 * @param time_str_len Indicates the length of the string. 121 * 122 * @since 12 123 * @version 1.0 124 */ 125 void TEE_GetREETimeStr(char *tim_str, uint32_t time_str_len); 126 127 #ifdef __cplusplus 128 } 129 #endif 130 /** @} */ 131 #endif 132