1 /*
2  * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef RSA_H
8 #define RSA_H
9 
10 /*
11  * All the includes that are needed for code using this module to
12  * compile correctly should be #included here.
13  */
14 
15 #ifdef __cplusplus
16 extern "C"
17 {
18 #endif
19 
20 #include "cc_pal_types.h"
21 
22 /************************ Defines ******************************/
23 
24 /* the modulus size in bits */
25 #if (KEY_SIZE == 2048)
26 #define RSA_MOD_SIZE_IN_BITS				2048UL
27 #elif (KEY_SIZE == 3072)
28 #define RSA_MOD_SIZE_IN_BITS				3072UL
29 #else
30 #error Unsupported CryptoCell key size requested
31 #endif
32 
33 #define RSA_MOD_SIZE_IN_BYTES				(CALC_FULL_BYTES(RSA_MOD_SIZE_IN_BITS))
34 #define RSA_MOD_SIZE_IN_WORDS				(CALC_FULL_32BIT_WORDS(RSA_MOD_SIZE_IN_BITS))
35 #define RSA_MOD_SIZE_IN_256BITS				(RSA_MOD_SIZE_IN_WORDS/8)
36 #define RSA_EXP_SIZE_IN_BITS				17UL
37 #define RSA_EXP_SIZE_IN_BYTES				(CALC_FULL_BYTES(RSA_EXP_SIZE_IN_BITS))
38 
39 /*
40  * @brief The RSA_CalcNp calculates Np value and saves it into Np_ptr:
41  *
42  *
43 
44  * @param[in] hwBaseAddress -	HW base address. Relevant for HW
45  *				implementation, for SW it is ignored.
46  * @N_ptr[in]               -	The pointer to the modulus buffer.
47  * @Np_ptr[out]             -	pointer to Np vector buffer. Its size must be >= 160.
48  */
49 void RSA_CalcNp(unsigned long hwBaseAddress,
50 		uint32_t *N_ptr,
51 		uint32_t *Np_ptr);
52 
53 #ifdef __cplusplus
54 }
55 #endif
56 
57 #endif
58