xref: /rk3399_ARM-atf/include/lib/psa/measured_boot.h (revision d797665ccef759852dff63bdb75898119577b524)
1758c6471STamas Ban /*
2d9506028STamas Ban  * Copyright (c) 2022-2024, Arm Limited. All rights reserved.
3758c6471STamas Ban  *
4758c6471STamas Ban  * SPDX-License-Identifier: BSD-3-Clause
5758c6471STamas Ban  *
6758c6471STamas Ban  */
7758c6471STamas Ban 
8758c6471STamas Ban #ifndef PSA_MEASURED_BOOT_H
9758c6471STamas Ban #define PSA_MEASURED_BOOT_H
10758c6471STamas Ban 
11758c6471STamas Ban #include <stdbool.h>
12758c6471STamas Ban #include <stddef.h>
13758c6471STamas Ban #include <stdint.h>
14758c6471STamas Ban 
15758c6471STamas Ban #include "psa/error.h"
16758c6471STamas Ban 
17758c6471STamas Ban /**
18758c6471STamas Ban  * Extends and stores a measurement to the requested slot.
19758c6471STamas Ban  *
20758c6471STamas Ban  * index			Slot number in which measurement is to be stored
21758c6471STamas Ban  * signer_id			Pointer to signer_id buffer.
2285a14bc0SDavid Vincze  * signer_id_size		Size of the signer_id in bytes.
23758c6471STamas Ban  * version			Pointer to version buffer.
24b85bcb8eSJimmy Brisson  * version_size			Size of the version string in bytes.
25758c6471STamas Ban  * measurement_algo		Algorithm identifier used for measurement.
26758c6471STamas Ban  * sw_type			Pointer to sw_type buffer.
27b85bcb8eSJimmy Brisson  * sw_type_size			Size of the sw_type string in bytes.
28758c6471STamas Ban  * measurement_value		Pointer to measurement_value buffer.
2985a14bc0SDavid Vincze  * measurement_value_size	Size of the measurement_value in bytes.
30758c6471STamas Ban  * lock_measurement		Boolean flag requesting whether the measurement
31758c6471STamas Ban  *				is to be locked.
32758c6471STamas Ban  *
33758c6471STamas Ban  * PSA_SUCCESS:
34758c6471STamas Ban  *	- Success.
35758c6471STamas Ban  * PSA_ERROR_INVALID_ARGUMENT:
36758c6471STamas Ban  *	- The size of any argument is invalid OR
37758c6471STamas Ban  *	- Input Measurement value is NULL OR
38758c6471STamas Ban  *	- Input Signer ID is NULL OR
39758c6471STamas Ban  *	- Requested slot index is invalid.
40758c6471STamas Ban  * PSA_ERROR_BAD_STATE:
41758c6471STamas Ban  *	- Request to lock, when slot is already locked.
42758c6471STamas Ban  * PSA_ERROR_NOT_PERMITTED:
43758c6471STamas Ban  *	- When the requested slot is not accessible to the caller.
44758c6471STamas Ban  */
45758c6471STamas Ban 
46*d797665cSTamas Ban /* Not a standard PSA API, just an extension therefore use the 'rse_' prefix
47758c6471STamas Ban  * rather than the usual 'psa_'.
48758c6471STamas Ban  */
49758c6471STamas Ban psa_status_t
50*d797665cSTamas Ban rse_measured_boot_extend_measurement(uint8_t index,
51758c6471STamas Ban 				     const uint8_t *signer_id,
52758c6471STamas Ban 				     size_t signer_id_size,
53758c6471STamas Ban 				     const uint8_t *version,
54758c6471STamas Ban 				     size_t version_size,
55758c6471STamas Ban 				     uint32_t measurement_algo,
56758c6471STamas Ban 				     const uint8_t *sw_type,
57758c6471STamas Ban 				     size_t sw_type_size,
58758c6471STamas Ban 				     const uint8_t *measurement_value,
59758c6471STamas Ban 				     size_t measurement_value_size,
60758c6471STamas Ban 				     bool lock_measurement);
61758c6471STamas Ban 
626d0525aaSMate Toth-Pal /**
636d0525aaSMate Toth-Pal  * Retrieves a measurement from the requested slot.
646d0525aaSMate Toth-Pal  *
656d0525aaSMate Toth-Pal  * index			Slot number from which measurement is to be
666d0525aaSMate Toth-Pal  *				retrieved.
676d0525aaSMate Toth-Pal  * signer_id			Pointer to signer_id buffer.
686d0525aaSMate Toth-Pal  * signer_id_size		Size of the signer_id buffer in bytes.
696d0525aaSMate Toth-Pal  * signer_id_len		On success, number of bytes that make up
706d0525aaSMate Toth-Pal  * 				signer_id.
716d0525aaSMate Toth-Pal  * version			Pointer to version buffer.
726d0525aaSMate Toth-Pal  * version_size			Size of the version buffer in bytes.
736d0525aaSMate Toth-Pal  * version_len			On success, number of bytes that makeup the
746d0525aaSMate Toth-Pal  * 				version.
756d0525aaSMate Toth-Pal  * measurement_algo		Pointer to measurement_algo.
766d0525aaSMate Toth-Pal  * sw_type			Pointer to sw_type buffer.
776d0525aaSMate Toth-Pal  * sw_type_size			Size of the sw_type buffer in bytes.
786d0525aaSMate Toth-Pal  * sw_type_len			On success, number of bytes that makeup the
796d0525aaSMate Toth-Pal  * 				sw_type.
806d0525aaSMate Toth-Pal  * measurement_value		Pointer to measurement_value buffer.
816d0525aaSMate Toth-Pal  * measurement_value_size	Size of the measurement_value buffer in bytes.
826d0525aaSMate Toth-Pal  * measurement_value_len	On success, number of bytes that make up the
836d0525aaSMate Toth-Pal  * 				measurement_value.
846d0525aaSMate Toth-Pal  * is_locked			Pointer to lock status of requested measurement
856d0525aaSMate Toth-Pal  * 				slot.
866d0525aaSMate Toth-Pal  *
876d0525aaSMate Toth-Pal  * PSA_SUCCESS
886d0525aaSMate Toth-Pal  *	- Success.
896d0525aaSMate Toth-Pal  * PSA_ERROR_INVALID_ARGUMENT
906d0525aaSMate Toth-Pal  *	- The size of at least one of the output buffers is incorrect or the
916d0525aaSMate Toth-Pal  *	  requested slot index is invalid.
926d0525aaSMate Toth-Pal  * PSA_ERROR_DOES_NOT_EXIST
936d0525aaSMate Toth-Pal  *	- The requested slot is empty, does not contain a measurement.
946d0525aaSMate Toth-Pal  */
95*d797665cSTamas Ban psa_status_t rse_measured_boot_read_measurement(uint8_t index,
966d0525aaSMate Toth-Pal 					uint8_t *signer_id,
976d0525aaSMate Toth-Pal 					size_t signer_id_size,
986d0525aaSMate Toth-Pal 					size_t *signer_id_len,
996d0525aaSMate Toth-Pal 					uint8_t *version,
1006d0525aaSMate Toth-Pal 					size_t version_size,
1016d0525aaSMate Toth-Pal 					size_t *version_len,
1026d0525aaSMate Toth-Pal 					uint32_t *measurement_algo,
1036d0525aaSMate Toth-Pal 					uint8_t *sw_type,
1046d0525aaSMate Toth-Pal 					size_t sw_type_size,
1056d0525aaSMate Toth-Pal 					size_t *sw_type_len,
1066d0525aaSMate Toth-Pal 					uint8_t *measurement_value,
1076d0525aaSMate Toth-Pal 					size_t measurement_value_size,
1086d0525aaSMate Toth-Pal 					size_t *measurement_value_len,
1096d0525aaSMate Toth-Pal 					bool *is_locked);
1106d0525aaSMate Toth-Pal 
111758c6471STamas Ban #endif /* PSA_MEASURED_BOOT_H */
112