xref: /rk3399_ARM-atf/include/drivers/st/stm32_pka.h (revision b0fbc02aea76d31e749444da63b084e6b2bd089b)
1*b0fbc02aSNicolas Toromanoff /*
2*b0fbc02aSNicolas Toromanoff  * Copyright (c) 2022, STMicroelectronics - All Rights Reserved
3*b0fbc02aSNicolas Toromanoff  *
4*b0fbc02aSNicolas Toromanoff  * SPDX-License-Identifier: BSD-3-Clause
5*b0fbc02aSNicolas Toromanoff  */
6*b0fbc02aSNicolas Toromanoff 
7*b0fbc02aSNicolas Toromanoff #ifndef STM32_PKA_H
8*b0fbc02aSNicolas Toromanoff #define STM32_PKA_H
9*b0fbc02aSNicolas Toromanoff 
10*b0fbc02aSNicolas Toromanoff #include <stdint.h>
11*b0fbc02aSNicolas Toromanoff 
12*b0fbc02aSNicolas Toromanoff #if !PKA_USE_NIST_P256 && !PKA_USE_BRAINPOOL_P256R1 && !PKA_USE_BRAINPOOL_P256T1 && \
13*b0fbc02aSNicolas Toromanoff 	!PKA_USE_NIST_P521
14*b0fbc02aSNicolas Toromanoff #error "At least one ECDSA curve needs to be selected"
15*b0fbc02aSNicolas Toromanoff #endif
16*b0fbc02aSNicolas Toromanoff 
17*b0fbc02aSNicolas Toromanoff enum stm32_pka_ecdsa_curve_id {
18*b0fbc02aSNicolas Toromanoff #if PKA_USE_NIST_P256
19*b0fbc02aSNicolas Toromanoff 	PKA_NIST_P256,
20*b0fbc02aSNicolas Toromanoff #endif
21*b0fbc02aSNicolas Toromanoff #if PKA_USE_BRAINPOOL_P256R1
22*b0fbc02aSNicolas Toromanoff 	PKA_BRAINPOOL_P256R1,
23*b0fbc02aSNicolas Toromanoff #endif
24*b0fbc02aSNicolas Toromanoff #if PKA_USE_BRAINPOOL_P256T1
25*b0fbc02aSNicolas Toromanoff 	PKA_BRAINPOOL_P256T1,
26*b0fbc02aSNicolas Toromanoff #endif
27*b0fbc02aSNicolas Toromanoff #if PKA_USE_NIST_P521
28*b0fbc02aSNicolas Toromanoff 	PKA_NIST_P521,
29*b0fbc02aSNicolas Toromanoff #endif
30*b0fbc02aSNicolas Toromanoff };
31*b0fbc02aSNicolas Toromanoff 
32*b0fbc02aSNicolas Toromanoff struct stm32_pka_platdata {
33*b0fbc02aSNicolas Toromanoff 	uintptr_t base;
34*b0fbc02aSNicolas Toromanoff 	unsigned long clock_id;
35*b0fbc02aSNicolas Toromanoff 	unsigned int reset_id;
36*b0fbc02aSNicolas Toromanoff };
37*b0fbc02aSNicolas Toromanoff 
38*b0fbc02aSNicolas Toromanoff int stm32_pka_init(void);
39*b0fbc02aSNicolas Toromanoff int stm32_pka_ecdsa_verif(void *hash, unsigned int hash_size,
40*b0fbc02aSNicolas Toromanoff 			  void *sig_r_ptr, unsigned int sig_r_size,
41*b0fbc02aSNicolas Toromanoff 			  void *sig_s_ptr, unsigned int sig_s_size,
42*b0fbc02aSNicolas Toromanoff 			  void *pk_x_ptr, unsigned int pk_x_size,
43*b0fbc02aSNicolas Toromanoff 			  void *pk_y_ptr, unsigned int pk_y_size,
44*b0fbc02aSNicolas Toromanoff 			  enum stm32_pka_ecdsa_curve_id cid);
45*b0fbc02aSNicolas Toromanoff 
46*b0fbc02aSNicolas Toromanoff #endif /* STM32_PKA_H */
47