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 @file
9 @brief This file contains user-defined functions, definitions and TBS header struct.
10 */
11 
12 #ifndef _CC_PAL_X509_DEFS_H
13 #define _CC_PAL_X509_DEFS_H
14 
15 
16 
17 #ifdef __cplusplus
18 extern "C"
19 {
20 #endif
21 
22 #include "cc_crypto_x509_common_defs.h"
23 
24 #define CC_CERT_USER_DATA_KEY_OFFSET        0
25 #define CC_CERT_USER_DATA_PRIM_OFFSET       1
26 #define CC_CERT_USER_DATA_SECOND_OFFSET     2
27 
28 /*!
29 @brief This function checks validity period and should be implemented by customer.
30        It receives start and end validity period as input. It also receives an indication flag for each period. If the flag is not 1,
31        the value of current period was not defined by the user.
32 
33 @return CC_OK On success.
34 @return A non-zero value from sbrom_bsv_error.h on failure.
35 */
36 CCError_t CC_PalVerifyCertValidity(char *pNotBeforeStr, /*!< [in] Pointer to the start period string. */
37     uint32_t notBeforeStrSize, /*!< [in] Size of the start period string. */
38     uint8_t notBeforeStrFlag, /*!< [in] Start period definition flag indication. */
39     char *pNotAfterStr,/*!< [in] Pointer to the end period string. */
40     uint32_t notAfterStrSize,/*!< [in] Size of the end period string. */
41     uint8_t notAfterStrFlag); /*!< [in] Start period definition Flag indication. */
42 
43 
44 
45 /*! x509 Certificate user's data. This data is outputed after the certificate passed validation */
46 typedef struct {
47     uint8_t   setSerialNum;                                   /*! Definition flag of certificate serial number. */
48     uint32_t  serialNum;                                      /*! Value of  certificate serial number. */
49     uint8_t   setIssuerName;                                  /*! Definition flag of certificate issuer name. */
50     char      IssuerName[X509_ISSUER_NAME_MAX_STRING_SIZE+1];   /*! String of certificate issuer name. */
51     uint8_t   setSubjectName;                                 /*! Definition flag of certificate subject name. */
52     char      SubjectName[X509_SUBJECT_NAME_MAX_STRING_SIZE+1]; /*! String of certificate subject name. */
53     uint8_t   setNotBeforeStr;                                /*! Definition flag of start validity period.  */
54     char      NotBeforeStr[X509_VALIDITY_PERIOD_MAX_STRING_SIZE+1]; /*! String of start validity period. */
55     uint8_t   setNotAfterStr;                                     /*! Definition flag of end validity period.  */
56     char      NotAfterStr[X509_VALIDITY_PERIOD_MAX_STRING_SIZE+1]; /*! String of end validity period. */
57 #ifdef CC_SB_CERT_USER_DATA_EXT
58     uint8_t   userData[X509_USER_DATA_MAX_SIZE_BYTES*3];           /*! Byte array containing the user's data from the certificate, only valid if the ROM was
59                                        compiled with CC_CONFIG_SB_CERT_USER_DATA_EXT = 1.
60                                        This structure is used by secure debug and secure boot. In case of secure debug
61                                        there are 3 buffers of user's data: key, primary debug, secondary debug*/
62 #endif
63 }CCX509CertHeaderInfo_t;
64 
65 
66 #ifdef __cplusplus
67 }
68 #endif
69 
70 #endif
71 
72 
73