1 /*
2  * Copyright (c) 2024, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef DICE_PROT_ENV_H
8 #define DICE_PROT_ENV_H
9 
10 #include <stdbool.h>
11 #include <stddef.h>
12 #include <stdint.h>
13 
14 #include <drivers/measured_boot/metadata.h>
15 
16 #define DPE_INVALID_ID	UINT32_MAX
17 
18 struct dpe_metadata {
19 	unsigned int id;
20 	uint32_t cert_id;
21 	uint8_t signer_id[SIGNER_ID_MAX_SIZE];
22 	size_t  signer_id_size;
23 	uint8_t version[VERSION_MAX_SIZE];
24 	size_t  version_size;
25 	uint8_t sw_type[SW_TYPE_MAX_SIZE];
26 	size_t  sw_type_size;
27 	bool allow_new_context_to_derive;
28 	bool retain_parent_context;
29 	bool create_certificate;
30 	void *pk_oid;
31 };
32 
33 void dpe_init(struct dpe_metadata *metadata);
34 
35 /* Returns 0 in case of success otherwise -1. */
36 int dpe_measure_and_record(struct dpe_metadata *metadata,
37 			   uintptr_t data_base, uint32_t data_size,
38 			   uint32_t data_id);
39 
40 int dpe_set_signer_id(struct dpe_metadata *metadata,
41 		      const void *pk_oid, const void *pk_ptr, size_t pk_len);
42 
43 /* Child components inherit their first valid context handle from their parents.
44  * How to share context handle is platform specific.
45  */
46 void plat_dpe_share_context_handle(int *ctx_handle);
47 void plat_dpe_get_context_handle(int *ctx_handle);
48 
49 #endif /* DICE_PROT_ENV_H */
50