1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2024 HiSilicon Limited. 4 */ 5 #ifndef __HPRE_MONTGOMERY_H__ 6 #define __HPRE_MONTGOMERY_H__ 7 8 #include <stdint.h> 9 #include <tee_api_types.h> 10 #include <types_ext.h> 11 12 #define HPRE_X_KEY_PARAM_NUM 3 13 #define X25519_KEY_BITS 256 14 #define X448_KEY_BITS 448 15 #define HPRE_HW_X25519_KBITS 256 16 #define HPRE_HW_X448_KBITS 576 17 #define HPRE_MONTGOMERY_TOTAL_BUF_SIZE(key_bytes) ((key_bytes) * 5) 18 #define HPRE_X_KEY_SIZE(hsz) ((hsz) * HPRE_X_KEY_PARAM_NUM) 19 20 struct hpre_montgomery_msg { 21 uint8_t *key; 22 paddr_t key_dma; 23 uint8_t *in; 24 paddr_t in_dma; 25 uint8_t *out; 26 paddr_t out_dma; 27 uint32_t alg_type; 28 uint32_t key_bytes; 29 uint32_t curve_bytes; 30 uint32_t x_bytes; 31 uint32_t result; 32 }; 33 34 #endif 35