1 /* 2 * Copyright (c) 2017, 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 ion bits */ 25 #define RSA_MOD_SIZE_IN_BITS 2048UL 26 #define RSA_MOD_SIZE_IN_BYTES (CALC_FULL_BYTES(RSA_MOD_SIZE_IN_BITS)) 27 #define RSA_MOD_SIZE_IN_WORDS (CALC_FULL_32BIT_WORDS(RSA_MOD_SIZE_IN_BITS)) 28 #define RSA_MOD_SIZE_IN_256BITS (RSA_MOD_SIZE_IN_WORDS/8) 29 #define RSA_EXP_SIZE_IN_BITS 17UL 30 #define RSA_EXP_SIZE_IN_BYTES (CALC_FULL_BYTES(RSA_EXP_SIZE_IN_BITS)) 31 32 /* size of buffer for Barrett modulus tag NP, used in PKA algorithms */ 33 #define RSA_HW_PKI_PKA_BARRETT_MOD_TAG_SIZE_IN_BITS 132 34 #define RSA_HW_PKI_PKA_BARRETT_MOD_TAG_SIZE_IN_BYTES (CALC_FULL_BYTES(RSA_HW_PKI_PKA_BARRETT_MOD_TAG_SIZE_IN_BITS)) 35 #define RSA_HW_PKI_PKA_BARRETT_MOD_TAG_SIZE_IN_WORDS (CALC_FULL_32BIT_WORDS(RSA_HW_PKI_PKA_BARRETT_MOD_TAG_SIZE_IN_BITS)) 36 37 /* 38 * @brief The RSA_CalcNp calculates Np value and saves it into Np_ptr: 39 * 40 * 41 42 * @param[in] hwBaseAddress - HW base address. Relevant for HW 43 * implementation, for SW it is ignored. 44 * @N_ptr[in] - The pointer to the modulus buffer. 45 * @Np_ptr[out] - pointer to Np vector buffer. Its size must be >= 160. 46 */ 47 void RSA_CalcNp(unsigned long hwBaseAddress, 48 uint32_t *N_ptr, 49 uint32_t *Np_ptr); 50 51 #ifdef __cplusplus 52 } 53 #endif 54 55 #endif 56