Soby Mathew | 1ae83bc | 2017-05-10 11:48:40 +0100 | [diff] [blame] | 1 | /* |
Gilad Ben-Yossef | a6e5342 | 2019-09-15 13:29:29 +0300 | [diff] [blame] | 2 | * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. |
Soby Mathew | 1ae83bc | 2017-05-10 11:48:40 +0100 | [diff] [blame] | 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*/ |
Gilad Ben-Yossef | a6e5342 | 2019-09-15 13:29:29 +0300 | [diff] [blame] | 27 | #if (KEY_SIZE == 2048) |
Soby Mathew | 1ae83bc | 2017-05-10 11:48:40 +0100 | [diff] [blame] | 28 | #define SB_RSA_MOD_SIZE_IN_WORDS 64 |
Gilad Ben-Yossef | a6e5342 | 2019-09-15 13:29:29 +0300 | [diff] [blame] | 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 | |
Soby Mathew | 1ae83bc | 2017-05-10 11:48:40 +0100 | [diff] [blame] | 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 */ |
Gilad Ben-Yossef | a6e5342 | 2019-09-15 13:29:29 +0300 | [diff] [blame] | 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 | */ |
Soby Mathew | 1ae83bc | 2017-05-10 11:48:40 +0100 | [diff] [blame] | 56 | typedef enum { |
Gilad Ben-Yossef | a6e5342 | 2019-09-15 13:29:29 +0300 | [diff] [blame] | 57 | RSA_PSS = 0x01, /*!< RSA PSS after hash SHA 256 */ |
| 58 | RSA_PKCS15 = 0x02, /*!< RSA PKX15 */ |
Soby Mathew | 1ae83bc | 2017-05-10 11:48:40 +0100 | [diff] [blame] | 59 | RSA_Last = 0x7FFFFFFF |
| 60 | } CCSbRsaAlg_t; |
| 61 | |
| 62 | #ifdef __cplusplus |
| 63 | } |
| 64 | #endif |
| 65 | |
| 66 | #endif |