1 /*
2  * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7  /*!
8  @addtogroup cc_sb_image_verifier
9  @{
10  */
11 
12 /*!
13  @file
14  @brief This file contains definitions used for the Secure Boot and Secure
15  Debug APIs.
16  */
17 
18 
19 #ifndef _BOOT_IMAGES_VERIFIER_DEF_H
20 #define _BOOT_IMAGES_VERIFIER_DEF_H
21 
22 #ifdef __cplusplus
23 extern "C"
24 {
25 #endif
26 
27 #include "cc_pal_types.h"
28 
29 /*! The maximal number of SW images per content certificate. */
30 #define CC_SB_MAX_NUM_OF_IMAGES 16
31 
32 #ifdef CC_SB_X509_CERT_SUPPORTED
33 /*! The maximal size of an X.509 certificate in bytes.*/
34 #define CC_SB_MAX_CERT_SIZE_IN_BYTES    (0xB10)
35 #else
36 /*! The maximal size of an Arm proprietary certificate in bytes. */
37 #define CC_SB_MAX_CERT_SIZE_IN_BYTES    (0x700)
38 #endif
39 /*! The maximal size of a certificate in words.*/
40 #define CC_SB_MAX_CERT_SIZE_IN_WORDS    (CC_SB_MAX_CERT_SIZE_IN_BYTES/CC_32BIT_WORD_SIZE)
41 
42 /*! The size of the Secure Debug workspace in bytes. This workspace is used
43 to store RSA parameters. For example, modulus and signature. */
44 #define CC_SB_MIN_DBG_WORKSPACE_SIZE_IN_BYTES   (0x350)
45 
46 /*!
47  @brief The minimal size of the Secure Boot workspace in bytes.
48 
49  The Secure Boot APIs use a temporary workspace for processing the data that
50  is read from the flash, before loading the SW modules to their designated
51  memory addresses. This workspace must be large enough to accommodate the size
52  of the certificates, and twice the size of the data that is read from flash
53  in each processing round.
54 
55  The definition of \c CC_SB_MIN_WORKSPACE_SIZE_IN_BYTES is comprised of
56  \c CC_DOUBLE_BUFFER_MAX_SIZE_IN_BYTES and additional space for the
57  certificate itself, which resides in the workspace at the same time the SW
58  images data is processed.\n
59  It is assumed that the optimal size of the data to read in each processing
60  round is 4KB, based on the standard flash-memory page size. Therefore, the
61  size of the double buffer, \c CC_CONFIG_SB_DOUBLE_BUFFER_MAX_SIZE_IN_BYTES,
62  is defined by default as 8KB in the project configuration file. This can be
63  changed to accommodate the optimal value in different environments.
64  \c CC_DOUBLE_BUFFER_MAX_SIZE_IN_BYTES is defined by the Boot Services
65  makefile as equal to \c CC_CONFIG_SB_DOUBLE_BUFFER_MAX_SIZE_IN_BYTES.
66 
67  @note When writing code that uses the Secure Boot APIs, and includes the
68  bootimagesverifier_def.h file, the value of
69  \c CC_DOUBLE_BUFFER_MAX_SIZE_IN_BYTES must be defined by your makefile to be
70  exactly the same value as was used when compiling the SBROM library.
71  Additionally, \c CC_SB_X509_CERT_SUPPORTED must be defined in the Makefile,
72  according to the definition of \c CC_CONFIG_SB_X509_CERT_SUPPORTED. \par
73 
74  @note The size of \c CC_DOUBLE_BUFFER_MAX_SIZE_IN_BYTES must be a multiple of
75  the hash SHA-256 block size of 64 bytes. \par
76 */
77 #define CC_SB_MIN_WORKSPACE_SIZE_IN_BYTES   (CC_SB_MAX_CERT_SIZE_IN_BYTES + CC_MAX(CC_SB_MIN_DBG_WORKSPACE_SIZE_IN_BYTES, CC_DOUBLE_BUFFER_MAX_SIZE_IN_BYTES))
78 
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84  /*!
85  @}
86  */
87 #endif
88 
89 
90