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 #ifndef _COMMON_CERT_PARSER_H
9 #define _COMMON_CERT_PARSER_H
10 
11 #include "secdebug_defs.h"
12 
13 /* IMPORATNT NOTE:  The certificate body may not be word aligned.
14    For proprietary it is aligned but for x.509 we can not guarantee that */
15 typedef struct {
16         CCSbCertTypes_t certType;
17         CCSbCertHeader_t certHeader;
18         uint8_t     *pCertBody;
19         uint32_t certBodySize;
20 } CertFieldsInfo_t;
21 
22 typedef struct {
23         uint32_t   *pBuffer;
24         uint32_t   bufferSize;
25 } BufferInfo32_t;
26 
27 CCError_t CCCertSecDbgParse(uint32_t   *pDebugCertPkg,
28                             uint32_t   certPkgSize,
29                             BufferInfo32_t  *pKeyCert,       // out
30                             BufferInfo32_t  *pEnablerCert,   // out
31                             BufferInfo32_t  *pDeveloperCert); // out
32 
33 uint32_t CCCertLoadCertificate(CCSbFlashReadFunc flashRead_func,
34                                void *userContext,
35                                CCAddr_t certAddress,
36                                uint32_t *pCert,
37                                uint32_t *pCertBufferWordSize);
38 
39 /**
40    @brief This function copy N, Np (CCSbNParams_t) and signature
41    (certificate start address + sizeof certificate in certificate header) from the certificate to workspace.
42    Return pointer to certificate header CCSbCertHeader_t, and pointer to cert body sizeof()
43 
44  */
45 CCError_t CCCertFieldsParse(BufferInfo32_t  *pCertInfo,
46                             BufferInfo32_t  *pWorkspaceInfo,
47                             CertFieldsInfo_t  *pCertFields,
48                             uint32_t    **ppCertStartSign,
49                             uint32_t    *pCertSignedSize,
50                             BufferInfo32_t  *pX509HeaderInfo);
51 
52 
53 #endif
54 
55 
56