1 /*
2  * Copyright 2022 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #include "fsl_romapi_nboot.h"
9 #include "fsl_romapi.h"
10 
11 #define NBOOT_API_TREE ((nboot_interface_t *)(((uint32_t *)ROM_API_TREE_ADDR)[4]))
12 
romapi_rng_generate_random(uint8_t * output,size_t outputByteLen)13 romapi_status_t romapi_rng_generate_random(uint8_t *output, size_t outputByteLen)
14 {
15     assert(NBOOT_API_TREE);
16     return NBOOT_API_TREE->rng_generate_random(output, outputByteLen);
17 }
18 
nboot_context_init(nboot_context_t * context)19 nboot_status_t nboot_context_init(nboot_context_t *context)
20 {
21     assert(NBOOT_API_TREE);
22     return NBOOT_API_TREE->context_init(context);
23 }
24 
nboot_context_deinit(nboot_context_t * context)25 nboot_status_t nboot_context_deinit(nboot_context_t *context)
26 {
27     assert(NBOOT_API_TREE);
28     return NBOOT_API_TREE->context_deinit(context);
29 }
30 
nboot_sb3_load_manifest(nboot_context_t * context,uint32_t * manifest,nboot_sb3_load_manifest_parms_t * parms)31 nboot_status_protected_t nboot_sb3_load_manifest(nboot_context_t *context,
32                                                  uint32_t *manifest,
33                                                  nboot_sb3_load_manifest_parms_t *parms)
34 {
35     assert(NBOOT_API_TREE);
36     return NBOOT_API_TREE->sb3_load_manifest(context, manifest, parms);
37 }
38 
nboot_sb3_load_block(nboot_context_t * context,uint32_t * block)39 nboot_status_protected_t nboot_sb3_load_block(nboot_context_t *context, uint32_t *block)
40 {
41     assert(NBOOT_API_TREE);
42     return NBOOT_API_TREE->sb3_load_block(context, block);
43 }
44 
nboot_img_authenticate_ecdsa(nboot_context_t * context,uint8_t imageStartAddress[],nboot_bool_t * isSignatureVerified,nboot_img_auth_ecdsa_parms_t * parms)45 nboot_status_protected_t nboot_img_authenticate_ecdsa(nboot_context_t *context,
46                                                       uint8_t imageStartAddress[],
47                                                       nboot_bool_t *isSignatureVerified,
48                                                       nboot_img_auth_ecdsa_parms_t *parms)
49 {
50     assert(NBOOT_API_TREE);
51     return NBOOT_API_TREE->img_authenticate_ecdsa(context, imageStartAddress, isSignatureVerified, parms);
52 }
53