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 dstb_api.h 29 * 30 * @brief Provides the API about Distributed TEE service. 31 * 32 * @library NA 33 * @kit TEEKit 34 * @syscap SystemCapability.Tee.TeeClient 35 * @since 20 36 */ 37 38 #ifndef DSTB_API_H 39 #define DSTB_API_H 40 41 #include <stdint.h> 42 #include <tee_defines.h> 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 /** 49 * @brief Enumerates device ID types. 50 * 51 * @since 20 52 */ 53 enum devid_type { 54 /** Network ID */ 55 DEVID_NETID = 0, 56 /** Device ID */ 57 DEVID_UDID = 1, 58 }; 59 60 /** 61 * @brief Defines device information. 62 * 63 * @since 20 64 */ 65 struct device_info { 66 /** Enumerated variable for device ID type */ 67 enum devid_type devid_type; 68 /** Device ID value */ 69 char *devid; 70 }; 71 72 /** 73 * @brief Enumerates the negotiation conditions. 74 * 75 * @since 20 76 */ 77 enum nego_condition { 78 /** check whether local has record of peer. If no, start negatiation. */ 79 CHECK_LOCAL = 0, 80 /** check local and peer have records of each other. If no, start negotiation. */ 81 CHECK_BOTH = 1, 82 /** start negotiation with no condition. */ 83 NO_CHECK = 2, 84 }; 85 86 /** 87 * @brief Generate share key by distributed TEE. 88 * 89 * @param devid_info [OUT]The peer devid, can be networkid or deviceid. 90 * @param salt [IN]The salt should be random, same as peer if caller want to generate same share key. 91 * @param salt_len [IN]The length of the salt buffer. 92 * @param info [IN]The entra information for generate share key, same as peer if caller want to generate same share key. 93 * @param info_len [IN]The length of the information buffer. 94 * @param key [OUT]The result key. 95 * @param key_len [IN]The length of the result key. 96 * 97 * @return Returns {@code TEE_SUCCESS} if the operation is successful. 98 * Returns other information otherwise. 99 * 100 * @since 20 101 */ 102 TEE_Result tee_dstb_gen_sharekey(struct device_info *devid_info, const uint8_t *salt, uint32_t salt_len, 103 const uint8_t *info, uint32_t info_len, uint8_t *key, uint32_t key_len); 104 105 /** 106 * @brief The pre-negotiation interface about distributed TEE service . 107 * 108 * @param devid_info [OUT]The peer devid, can be networkid or deviceid. 109 * @param cond [IN]Pre-negotiation conditions. 110 * 111 * @return Returns {@code TEE_SUCCESS} if the operation is successful. 112 * Returns other information otherwise. 113 * 114 * @since 20 115 */ 116 TEE_Result tee_dstb_pre_attestation(struct device_info *devid_info, enum nego_condition cond); 117 118 #ifdef __cplusplus 119 } 120 #endif 121 122 #endif 123 /** @} */