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