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 struct hpre_ecc_dh { 15 uint32_t d_bytes; 16 uint32_t x_bytes; 17 uint32_t y_bytes; 18 uint32_t rx_bytes; 19 uint32_t ry_bytes; 20 }; 21 22 struct hpre_ecc_sign { 23 uint32_t d_bytes; 24 uint32_t e_bytes; 25 uint32_t k_bytes; 26 uint32_t r_bytes; 27 uint32_t s_bytes; 28 }; 29 30 struct hpre_ecc_verify { 31 uint32_t pubx_bytes; 32 uint32_t puby_bytes; 33 uint32_t e_bytes; 34 uint32_t s_bytes; 35 uint32_t r_bytes; 36 }; 37 38 struct hpre_sm2_enc { 39 uint32_t pubx_bytes; 40 uint32_t puby_bytes; 41 uint32_t k_bytes; 42 uint32_t m_bytes; 43 uint32_t c1x_bytes; 44 uint32_t c1y_bytes; 45 uint32_t c2_bytes; 46 uint32_t c3_bytes; 47 }; 48 49 struct hpre_sm2_dec { 50 uint32_t d_bytes; 51 uint32_t c1x_bytes; 52 uint32_t c1y_bytes; 53 uint32_t c2_bytes; 54 uint32_t c3_bytes; 55 uint32_t m_bytes; 56 }; 57 58 struct hpre_ecc_msg { 59 uint8_t *key; 60 paddr_t key_dma; 61 uint8_t *in; 62 paddr_t in_dma; 63 uint8_t *out; 64 paddr_t out_dma; 65 uint8_t alg_type; 66 uint32_t key_bytes; 67 uint32_t curve_bytes; 68 uint32_t result; 69 uint32_t sm2_mlen; 70 bool sm2_sp; 71 union { 72 struct hpre_ecc_dh ecc_dh; 73 struct hpre_ecc_sign ecc_sign; 74 struct hpre_ecc_verify ecc_verify; 75 struct hpre_sm2_enc sm2_enc; 76 struct hpre_sm2_dec sm2_dec; 77 } param_size; 78 }; 79 80 #endif 81