Software APIs
boot_svc_ownership_history.h
1// Copyright lowRISC contributors (OpenTitan project).
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOT_SVC_BOOT_SVC_OWNERSHIP_HISTORY_H_
6#define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOT_SVC_BOOT_SVC_OWNERSHIP_HISTORY_H_
7
8#include <stdint.h>
9
11#include "sw/device/silicon_creator/lib/boot_svc/boot_svc_header.h"
12#include "sw/device/silicon_creator/lib/error.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif // __cplusplus
17
18enum {
19 /** Ownership history request: `HIST`. */
20 kBootSvcOwnershipHistoryReqType = 0x54534948,
21 /** Ownership history response: `TSIH`. */
22 kBootSvcOwnershipHistoryResType = 0x48495354,
23};
24
25/**
26 * An Ownership History request.
27 */
29 /**
30 * Boot services message header.
31 */
32 boot_svc_header_t header;
33} boot_svc_ownership_history_req_t;
34
35OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_history_req_t, header, 0);
36OT_ASSERT_SIZE(boot_svc_ownership_history_req_t, CHIP_BOOT_SVC_MSG_HEADER_SIZE);
37
38/**
39 * An Ownership History response.
40 */
42 /**
43 * Boot services message header.
44 */
45 boot_svc_header_t header;
46 /**
47 * Response status from the ROM_EXT.
48 */
49 uint32_t status;
50 /**
51 * Digest of all prior owner keys.
52 */
53 uint32_t history_digest[8];
54} boot_svc_ownership_history_res_t;
55
56OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_history_res_t, header, 0);
57OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_history_res_t, status,
59OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_history_res_t, history_digest,
61OT_ASSERT_SIZE(boot_svc_ownership_history_res_t, 80);
62
63/**
64 * Initialize an ownership history request.
65 *
66 * @param[out] msg Output buffer for the message.
67 */
68void boot_svc_ownership_history_req_init(boot_svc_ownership_history_req_t *msg);
69
70/**
71 * Initialize an ownership history response.
72 *
73 * @param status Reponse from the ROM_EXT after receiving the request.
74 * @param history_digest Digest of all prior owner keys.
75 * The digest is computed each time there is an ownership transfer.
76 * The new digest is SHA256(previous_digest || new_owner_key).
77 * @param[out] msg Output buffer for the message.
78 */
79void boot_svc_ownership_history_res_init(rom_error_t status,
80 const uint32_t *history_digest,
81 boot_svc_ownership_history_res_t *msg);
82
83#ifdef __cplusplus
84} // extern "C"
85#endif // __cplusplus
86
87#endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOT_SVC_BOOT_SVC_OWNERSHIP_HISTORY_H_