1 /* 2 * Copyright (C) 2022 Huawei Technologies Co., Ltd. 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 #ifndef CHINADRM_SRE_CHINADRM_H 13 #define CHINADRM_SRE_CHINADRM_H 14 15 #include <stdint.h> 16 #include <tee_defines.h> 17 struct cdrm_params { 18 uint8_t *pkey; 19 uint32_t pkey_len; 20 uint8_t *iv; 21 uint32_t iv_len; 22 uint8_t *input_buffer; 23 uint32_t input_len; 24 uint8_t *output_buffer; 25 uint32_t *output_len; 26 void *context; 27 uint32_t alg; 28 }; 29 30 struct cdrm_trans_params { 31 uint64_t pkey; 32 uint64_t iv; 33 uint64_t input_buffer; 34 uint64_t output_buffer; 35 uint64_t output_len; 36 uint64_t context; 37 uint32_t pkey_len; 38 uint32_t iv_len; 39 uint32_t input_len; 40 uint32_t alg; 41 }; 42 43 /* 44 * Do aes key wrap operation. 45 * @param params [IN/OUT] The cdrm_params structure contains key/iv/input/output info 46 * 47 * @return TEE_SUCCESS: Do aes key wrap operation success 48 * @return others: Do aes key wrap operation failed 49 */ 50 TEE_Result aes_key_wrap(struct cdrm_params *params); 51 52 /* 53 * Do aes key unwrap operation. 54 * 55 * @param params [IN/OUT] The cdrm_params structure contains key/iv/input/output info 56 * 57 * @return TEE_SUCCESS: Do aes key unwrap operation success 58 * @return others: Do aes key unwrap operation failed 59 */ 60 TEE_Result aes_key_unwrap(struct cdrm_params *params); 61 62 #endif 63