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 _SECURE_BOOT_GEN_DEFS_H
8 #define _SECURE_BOOT_GEN_DEFS_H
9 
10 #ifdef __cplusplus
11 extern "C"
12 {
13 #endif
14 
15 /*! @file
16 @brief This file contains all of the definitions and structures that are used for the secure boot.
17 */
18 
19 #include "cc_pal_sb_plat.h"
20 #include "cc_sec_defs.h"
21 
22 
23 /* General definitions */
24 /***********************/
25 
26 /*RSA definitions*/
27 #if (KEY_SIZE == 2048)
28 #define SB_RSA_MOD_SIZE_IN_WORDS		 64
29 #elif (KEY_SIZE == 3072)
30 #define SB_RSA_MOD_SIZE_IN_WORDS		96
31 #else
32 #error Unsupported CryptoCell key size requested
33 #endif
34 
35 #define SB_RSA_HW_PKI_PKA_BARRETT_MOD_TAG_SIZE_IN_WORDS 5
36 
37 
38 /*! Public key data structure. */
39 typedef struct {
40 	uint32_t N[SB_RSA_MOD_SIZE_IN_WORDS];				/*!< N public key, big endian representation. */
41 	uint32_t Np[SB_RSA_HW_PKI_PKA_BARRETT_MOD_TAG_SIZE_IN_WORDS];	/*!< Np (Barrett n' value). */
42 } CCSbNParams_t;
43 
44 /*! Signature structure. */
45 typedef struct {
46 	uint32_t sig[SB_RSA_MOD_SIZE_IN_WORDS];				/*!< RSA PSS signature. */
47 } CCSbSignature_t;
48 
49 
50 /********* Supported algorithms definitions ***********/
51 
52 /*! RSA supported algorithms */
53 /* Note: this applies to either 2k or 3k based on CryptoCell SBROM library
54  * version - it means 2k in version 1 and 3k in version 2 (yes, really).
55  */
56 typedef enum {
57 	RSA_PSS                = 0x01,			/*!< RSA PSS after hash SHA 256 */
58 	RSA_PKCS15	       = 0x02,			/*!< RSA PKX15 */
59 	RSA_Last               = 0x7FFFFFFF
60 } CCSbRsaAlg_t;
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif
67