1 /*
2  * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef _SECURE_BOOT_BASE_FUNC_H
8 #define _SECURE_BOOT_BASE_FUNC_H
9 
10 
11 #ifdef __cplusplus
12 extern "C"
13 {
14 #endif
15 
16 #include "secureboot_parser_gen_defs.h"
17 
18 
19 /*----------------------------
20       PUBLIC FUNCTIONS
21 -----------------------------------*/
22 
23 
24 /**
25  * @brief This function calculates the HASH over the PubKey (N, big endian) || Np (reversed - little endian).
26  *
27  * @param[in] hwBaseAddr -  CryptoCell base address
28  * @param[in] NAndRevNp_ptr - pointer to N public key and Np in the certificate
29  * @param[out] hashResult - a pointer to HASH of the public key
30  *
31  * @return CCError_t - On success the value CC_OK is returned,
32  *         on failure - a value from BootImagesVerifier_error.h
33  */
34 CCError_t CCSbCalcPublicKeyHASH(unsigned long hwBaseAddress,
35                 uint32_t *NAndRevNp_ptr,
36                 uint32_t *hashResult);
37 
38 /**
39  * @brief This function calculates the HASH over the PubKey (N, big endian) || Np (reversed - little endian).
40  *        The function gets the Public key pointer and Np (Barrett n value) from the certificate calculates hash on it and
41  *    compare it to the HASH from the OTP/NVM.
42  *
43  * @param[in] hwBaseAddr -  CryptoCell base address
44  * @param[in] NAndRevNp_ptr - pointer to N public key and Np in the certificate
45  * @param[in] NHASH_ptr - a pointer to HASH of the public key
46  * @param[in] HashSize - hash size (to compare)
47  *
48  * @return CCError_t - On success the value CC_OK is returned,
49  *         on failure - a value from BootImagesVerifier_error.h
50  */
51 CCError_t CCSbCalcPublicKeyHASHAndCompare(unsigned long hwBaseAddress,
52                          uint32_t *NAndRevNp_ptr,
53                          uint32_t *NHASH_ptr,
54                          uint32_t HashSize);
55 
56 /**
57  * @brief This function calculates the HASH over the given data and than verify
58  *    RSA signature on that hashed data
59  *
60  * @param[in] hwBaseAddr -  CryptoCell base address
61  * @param[in] pData - pointer to the data to be verified
62  * @param[in] pNParams - a pointer to the public key parameters
63  * @param[in] pSignature - a pointer to the signature structure
64  * @param[in] sizeOfData - size of the data to calculate the HASH on (in bytes)
65  * @param[in] sigAlg - signature algorithm to use
66  *
67  * @return CCError_t - On success the value CC_OK is returned,
68  *         on failure - a value from BootImagesVerifier_error.h
69 CCError_t CCSbVerifySignature(unsigned long hwBaseAddress,
70                 uint32_t *pData,
71                 CCSbNParams_t *pNParams,
72                 CCSbSignature_t *pSignature,
73                 uint32_t sizeOfData,
74                 CCSbSignAlg_t sigAlg);
75 
76 
77  */
78 CCError_t CCSbVerifySignature(unsigned long hwBaseAddress,
79                 uint32_t *pData,
80                 CCSbNParams_t *pNParams,
81                 CCSbSignature_t *pSignature,
82                 uint32_t sizeOfData,
83                 CCSbSignAlg_t sigAlg);
84 
85 
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif
92 
93 
94