Software APIs
boot_svc_ownership_unlock.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_UNLOCK_H_
6 #define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOT_SVC_BOOT_SVC_OWNERSHIP_UNLOCK_H_
7 
8 #include <stdint.h>
9 
12 #include "sw/device/silicon_creator/lib/boot_svc/boot_svc_header.h"
13 #include "sw/device/silicon_creator/lib/error.h"
14 #include "sw/device/silicon_creator/lib/nonce.h"
15 #include "sw/device/silicon_creator/lib/ownership/datatypes.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif // __cplusplus
20 
21 enum {
22  // ASCII: ANY
23  kBootSvcUnlockAny = 0x00594e41,
24  // ASCII: ENDO
25  kBootSvcUnlockEndorsed = 0x4f444e45,
26  // ASCII: UPD
27  kBootSvcUnlockUpdate = 0x00445055,
28  // ASCII: ABRT
29  kBootSvcUnlockAbort = 0x54524241,
30 
31  /** Ownership unlock request: `UNLK`. */
32  kBootSvcOwnershipUnlockReqType = 0x4b4c4e55,
33  /** Ownership unlock response: `KLNU`. */
34  kBootSvcOwnershipUnlockResType = 0x554e4c4b,
35 };
36 
37 /**
38  * An ownership unlock request.
39  */
41  /**
42  * Boot services message header.
43  */
45  /**
46  * Unlock mode: Any, Endorsed, Update or Abort.
47  */
48  uint32_t unlock_mode;
49  /**
50  * The 64-bit ID subfield of the full 256-bit device ID.
51  */
52  uint32_t din[2];
53  /**
54  * Reserved for future use.
55  */
56  uint32_t reserved[8];
57  /**
58  * The current ownership nonce.
59  */
61  /**
62  * The public key of the next owner (for endorsed mode).
63  */
65  /**
66  * Signature over [unlock_mode..next_owner_key]
67  */
69 
71 
86 
87 /**
88  * An ownership unlock response.
89  */
91  /**
92  * Boot services message header.
93  */
95  /**
96  * Response status from the ROM_EXT.
97  */
98  rom_error_t status;
100 
105 
106 /**
107  * Initialize an ownership unlock request.
108  *
109  * @param[out] msg Output buffer for the message.
110  */
111 void boot_svc_ownership_unlock_req_init(uint32_t unlock_mode, nonce_t nonce,
112  const owner_key_t *next_owner_key,
113  const owner_signature_t *signature,
115 
116 /**
117  * Initialize an ownership unlock response.
118  *
119  * @param status Reponse from the ROM_EXT after receiving the request.
120  * @param[out] msg Output buffer for the message.
121  */
122 void boot_svc_ownership_unlock_res_init(rom_error_t status,
124 
125 #ifdef __cplusplus
126 } // extern "C"
127 #endif // __cplusplus
128 
129 #endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOT_SVC_BOOT_SVC_OWNERSHIP_UNLOCK_H_