blob: 825214d20f83b74d837f4aaf839743657e30a372 [file] [log] [blame]
Soby Mathew1ae83bc2017-05-10 11:48:40 +01001/*
Gilad Ben-Yossefa6e53422019-09-15 13:29:29 +03002 * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
Soby Mathew1ae83bc2017-05-10 11:48:40 +01003 *
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
16extern "C"
17{
18#endif
19
20#include "cc_pal_types.h"
21
22/************************ Defines ******************************/
23
Gilad Ben-Yossefa6e53422019-09-15 13:29:29 +030024/* the modulus size in bits */
25#if (KEY_SIZE == 2048)
Soby Mathew1ae83bc2017-05-10 11:48:40 +010026#define RSA_MOD_SIZE_IN_BITS 2048UL
Gilad Ben-Yossefa6e53422019-09-15 13:29:29 +030027#elif (KEY_SIZE == 3072)
28#define RSA_MOD_SIZE_IN_BITS 3072UL
29#else
30#error Unsupported CryptoCell key size requested
31#endif
32
Soby Mathew1ae83bc2017-05-10 11:48:40 +010033#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
Soby Mathew1ae83bc2017-05-10 11:48:40 +010039/*
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 */
49void 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