1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2022-2024, HiSilicon Technologies Co., Ltd. 4 */ 5 6 #ifndef __HPRE_ECC_H__ 7 #define __HPRE_ECC_H__ 8 9 #include <stdbool.h> 10 #include <stdint.h> 11 #include <tee_api_types.h> 12 #include <types_ext.h> 13 14 enum ecc_verify_status { 15 ECC_VERIFY_ERR = 0, 16 ECC_VERIFY_SUCCESS = 1, 17 }; 18 19 struct hpre_ecc_dh { 20 uint32_t d_bytes; 21 uint32_t x_bytes; 22 uint32_t y_bytes; 23 uint32_t rx_bytes; 24 uint32_t ry_bytes; 25 }; 26 27 struct hpre_ecc_sign { 28 uint32_t d_bytes; 29 uint32_t e_bytes; 30 uint32_t k_bytes; 31 uint32_t r_bytes; 32 uint32_t s_bytes; 33 }; 34 35 struct hpre_ecc_verify { 36 uint32_t pubx_bytes; 37 uint32_t puby_bytes; 38 uint32_t e_bytes; 39 uint32_t s_bytes; 40 uint32_t r_bytes; 41 }; 42 43 struct hpre_sm2_enc { 44 uint32_t pubx_bytes; 45 uint32_t puby_bytes; 46 uint32_t k_bytes; 47 uint32_t m_bytes; 48 uint32_t c1x_bytes; 49 uint32_t c1y_bytes; 50 uint32_t c2_bytes; 51 uint32_t c3_bytes; 52 }; 53 54 struct hpre_sm2_dec { 55 uint32_t d_bytes; 56 uint32_t c1x_bytes; 57 uint32_t c1y_bytes; 58 uint32_t c2_bytes; 59 uint32_t c3_bytes; 60 uint32_t m_bytes; 61 }; 62 63 struct hpre_ecc_msg { 64 uint8_t *key; 65 paddr_t key_dma; 66 uint8_t *in; 67 paddr_t in_dma; 68 uint8_t *out; 69 paddr_t out_dma; 70 uint8_t alg_type; 71 uint32_t key_bytes; 72 uint32_t curve_bytes; 73 uint32_t result; 74 uint32_t sm2_mlen; 75 bool sm2_sp; 76 union { 77 struct hpre_ecc_dh ecc_dh; 78 struct hpre_ecc_sign ecc_sign; 79 struct hpre_ecc_verify ecc_verify; 80 struct hpre_sm2_enc sm2_enc; 81 struct hpre_sm2_dec sm2_dec; 82 } param_size; 83 }; 84 85 #endif 86