17777dab0Sopenharmony_ci/* 27777dab0Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License. 57777dab0Sopenharmony_ci * You may obtain a copy of the License at 67777dab0Sopenharmony_ci * 77777dab0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87777dab0Sopenharmony_ci * 97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and 137777dab0Sopenharmony_ci * limitations under the License. 147777dab0Sopenharmony_ci */ 157777dab0Sopenharmony_ci 167777dab0Sopenharmony_ci#ifndef __TEE_HW_EXT_API_LEGACY_H__ 177777dab0Sopenharmony_ci#define __TEE_HW_EXT_API_LEGACY_H__ 187777dab0Sopenharmony_ci 197777dab0Sopenharmony_ci/** 207777dab0Sopenharmony_ci * @addtogroup TeeTrusted 217777dab0Sopenharmony_ci * @{ 227777dab0Sopenharmony_ci * 237777dab0Sopenharmony_ci * @brief TEE(Trusted Excution Environment) API. 247777dab0Sopenharmony_ci * Provides security capability APIs such as trusted storage, encryption and decryption, 257777dab0Sopenharmony_ci * and trusted time for trusted application development. 267777dab0Sopenharmony_ci * 277777dab0Sopenharmony_ci * @since 12 287777dab0Sopenharmony_ci */ 297777dab0Sopenharmony_ci 307777dab0Sopenharmony_ci/** 317777dab0Sopenharmony_ci * @file tee_hw_ext_api_legacy.h 327777dab0Sopenharmony_ci * 337777dab0Sopenharmony_ci * @brief Provides extended interfaces. 347777dab0Sopenharmony_ci * 357777dab0Sopenharmony_ci * @library NA 367777dab0Sopenharmony_ci * @kit TEEKit 377777dab0Sopenharmony_ci * @syscap SystemCapability.Tee.TeeClient 387777dab0Sopenharmony_ci * @since 12 397777dab0Sopenharmony_ci * @version 1.0 407777dab0Sopenharmony_ci */ 417777dab0Sopenharmony_ci 427777dab0Sopenharmony_ci#include "tee_defines.h" 437777dab0Sopenharmony_ci 447777dab0Sopenharmony_ci#ifdef __cplusplus 457777dab0Sopenharmony_ciextern "C" { 467777dab0Sopenharmony_ci#endif 477777dab0Sopenharmony_ci 487777dab0Sopenharmony_ci/** 497777dab0Sopenharmony_ci * @brief Derive key from device root key. 507777dab0Sopenharmony_ci * 517777dab0Sopenharmony_ci * @param salt [IN] Indicates the data for salt. 527777dab0Sopenharmony_ci * @param size [IN] Indicates the length of salt. 537777dab0Sopenharmony_ci * @param key [OUT] Indicates the pointer where key is saved. 547777dab0Sopenharmony_ci * @param key_size [IN] Indicates the size of the key, which must be integer times of 16. 557777dab0Sopenharmony_ci * 567777dab0Sopenharmony_ci * @return Returns {@code TEE_SUCCESS} if the operation is successful. 577777dab0Sopenharmony_ci * Returns {@code TEE_ERROR_BAD_PARAMETERS} if input parameter is incorrect. 587777dab0Sopenharmony_ci * Returns {@code TEE_ERROR_GENERIC} if the processing failed. 597777dab0Sopenharmony_ci * 607777dab0Sopenharmony_ci * @since 12 617777dab0Sopenharmony_ci * @version 1.0 627777dab0Sopenharmony_ci */ 637777dab0Sopenharmony_ciTEE_Result TEE_EXT_DeriveTARootKey(const uint8_t *salt, uint32_t size, uint8_t *key, uint32_t key_size); 647777dab0Sopenharmony_ci 657777dab0Sopenharmony_ci/** 667777dab0Sopenharmony_ci * @brief Derive key from device root key by HUK2. 677777dab0Sopenharmony_ci * @attention If the device does not support HUK2, the key is derived by HUK. 687777dab0Sopenharmony_ci * 697777dab0Sopenharmony_ci * @param salt [IN] Indicates the data for salt. 707777dab0Sopenharmony_ci * @param size [IN] Indicates the length of salt. 717777dab0Sopenharmony_ci * @param key [OUT] Indicates the pointer where key is saved. 727777dab0Sopenharmony_ci * @param key_size [IN] Indicates the size of the key, which must be integer times of 16. 737777dab0Sopenharmony_ci * 747777dab0Sopenharmony_ci * @return Returns {@code TEE_SUCCESS} if the operation is successful. 757777dab0Sopenharmony_ci * Returns {@code TEE_ERROR_BAD_PARAMETERS} if input parameter is incorrect. 767777dab0Sopenharmony_ci * Returns {@code TEE_ERROR_GENERIC} if the processing failed. 777777dab0Sopenharmony_ci * 787777dab0Sopenharmony_ci * @since 12 797777dab0Sopenharmony_ci * @version 1.0 807777dab0Sopenharmony_ci */ 817777dab0Sopenharmony_ciTEE_Result tee_ext_derive_ta_root_key_by_huk2(const uint8_t *salt, uint32_t size, uint8_t *key, uint32_t key_size); 827777dab0Sopenharmony_ci 837777dab0Sopenharmony_ci/** 847777dab0Sopenharmony_ci * @brief Derive key from device root key by HUK2. 857777dab0Sopenharmony_ci * @attention If the device does not support HUK2, the key is derived by HUK. 867777dab0Sopenharmony_ci * 877777dab0Sopenharmony_ci * @param secret [IN] Indicates the input secret. 887777dab0Sopenharmony_ci * @param secret_len [IN] Indicates the length of the input secret. 897777dab0Sopenharmony_ci * @param key [OUT] Indicates the derived key. 907777dab0Sopenharmony_ci * @param key_len [IN] Indicates the length of the derived key. 917777dab0Sopenharmony_ci * 927777dab0Sopenharmony_ci * @return Returns {@code TEE_SUCCESS} if the operation is successful. 937777dab0Sopenharmony_ci * Returns {@code TEE_ERROR_BAD_PARAMETERS} if input parameter is incorrect. 947777dab0Sopenharmony_ci * Returns {@code TEE_ERROR_GENERIC} if the processing failed. 957777dab0Sopenharmony_ci * 967777dab0Sopenharmony_ci * @since 12 977777dab0Sopenharmony_ci * @version 1.0 987777dab0Sopenharmony_ci */ 997777dab0Sopenharmony_ciTEE_Result tee_ext_root_derive_key2_by_huk2(const uint8_t *secret, uint32_t secret_len, uint8_t *key, uint32_t key_len); 1007777dab0Sopenharmony_ci 1017777dab0Sopenharmony_ci/** 1027777dab0Sopenharmony_ci * @brief Derive key from device root key and UUID of the current task by HUK2. 1037777dab0Sopenharmony_ci * @attention If the device does not support HUK2, the key is derived by HUK. 1047777dab0Sopenharmony_ci * 1057777dab0Sopenharmony_ci * @param salt [IN] Indicates the data for salt. 1067777dab0Sopenharmony_ci * @param size [IN] Indicates the length of salt. 1077777dab0Sopenharmony_ci * @param key [OUT] Indicates the pointer where key is saved. 1087777dab0Sopenharmony_ci * @param key_size [IN] Indicates the size of the generated key, fix-size 32 bytes. 1097777dab0Sopenharmony_ci * 1107777dab0Sopenharmony_ci * @return Returns {@code TEE_SUCCESS} if the operation is successful. 1117777dab0Sopenharmony_ci * Returns {@code TEE_ERROR_BAD_PARAMETERS} if input parameter is incorrect. 1127777dab0Sopenharmony_ci * Returns {@code TEE_ERROR_GENERIC} if the processing failed. 1137777dab0Sopenharmony_ci * 1147777dab0Sopenharmony_ci * @since 12 1157777dab0Sopenharmony_ci * @version 1.0 1167777dab0Sopenharmony_ci */ 1177777dab0Sopenharmony_ciTEE_Result tee_ext_root_uuid_derive_key_by_huk2(const uint8_t *salt, uint32_t size, uint8_t *key, uint32_t key_size); 1187777dab0Sopenharmony_ci 1197777dab0Sopenharmony_ci#ifdef __cplusplus 1207777dab0Sopenharmony_ci} 1217777dab0Sopenharmony_ci#endif 1227777dab0Sopenharmony_ci/** @} */ 1237777dab0Sopenharmony_ci#endif 124