1 /*
2  * Copyright 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <lk/compiler.h>
20 #include <stdint.h>
21 
22 /* Note: The definitive source for the message interface here is is in
23  * trusty/user/app/secretkeeper/lib.rs (TIPC port details) and
24  * system/secretkeeper/core/src/ta/bootloader.rs (message format).
25  * This is a manual translation into C.
26  */
27 
28 #define SECRETKEEPER_BL_PORT "com.android.trusty.secretkeeper.bootloader"
29 
30 /**
31  * enum secretkeeper_cmd - Secretkeeper commands.
32  * @SECRETKEEPER_RESPONSE_MARKER: Bit indicating that this is a response.
33  * @SECRETKEEPER_CMD_GET_IDENTITY: Get the per-boot identity (public key) of
34  *                                 Secretkeeper.
35  */
36 enum secretkeeper_cmd {
37     SECRETKEEPER_RESPONSE_MARKER = 0x1u << 31,
38     SECRETKEEPER_CMD_GET_IDENTITY = 1,
39 };
40 
41 /**
42  * struct secretkeeper_req_hdr - Generic header for all Secretkeeper requests.
43  * Note that all fields are stored in network byte order (big endian).
44  * @cmd:       The command to be run. Commands are described in
45  *             enum secretkeeper_cmd.
46  */
47 struct secretkeeper_req_hdr {
48     uint32_t cmd;
49 };
50 STATIC_ASSERT(sizeof(struct secretkeeper_req_hdr) == 4);
51 
52 /**
53  * struct secretkeeper_resp_hdr - Generic header for all Secretkeeper responses.
54  * Note that all fields are stored in network byte order (big endian).
55  * Any response payload immediately follows this struct.
56  * @cmd:          Command identifier - %SECRETKEEPER_RESPONSE_MARKER or'ed with
57  *                the command identifier of the corresponding request.
58  * @error_code:   0 if the request succeeded, or an indication of how it failed.
59  */
60 struct secretkeeper_resp_hdr {
61     uint32_t cmd;
62     uint32_t error_code;
63 };
64 STATIC_ASSERT(sizeof(struct secretkeeper_resp_hdr) == 8);
65