Skip to content

Commit 5fbf362

Browse files
ashncookcjevans-google
authored andcommitted
Add provisioning command library and CLI.
1 parent a338adf commit 5fbf362

File tree

10 files changed

+1326
-0
lines changed

10 files changed

+1326
-0
lines changed

examples/BUILD

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
22
load("@rules_cc//cc:cc_library.bzl", "cc_library")
3+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
34

45
package(default_visibility = ["//visibility:public"])
56

@@ -29,6 +30,49 @@ config_setting(
2930
},
3031
)
3132

33+
cc_library(
34+
name = "htool_cmd",
35+
srcs = ["htool_cmd.c"],
36+
hdrs = ["htool_cmd.h"],
37+
deps = ["//:git_version"],
38+
)
39+
40+
cc_library(
41+
name = "htool_macros",
42+
hdrs = ["htool_macros.h"],
43+
)
44+
45+
cc_library(
46+
name = "htool_header",
47+
hdrs = ["htool.h"],
48+
)
49+
50+
cc_library(
51+
name = "htool_security_version",
52+
srcs = ["htool_security_version.c"],
53+
hdrs = ["htool_security_version.h"],
54+
deps = [
55+
":host_commands",
56+
":htool_header",
57+
"//protocol:host_cmd",
58+
],
59+
)
60+
61+
cc_library(
62+
name = "htool_provisioning",
63+
srcs = ["htool_provisioning.c"],
64+
hdrs = ["htool_provisioning.h"],
65+
deps = [
66+
":host_commands",
67+
":htool_cmd",
68+
":htool_header",
69+
":htool_macros",
70+
":htool_security_version",
71+
"//protocol:host_cmd",
72+
"//transports:libhoth_device",
73+
],
74+
)
75+
3276
cc_binary(
3377
name = "htool",
3478
srcs = [
@@ -81,6 +125,8 @@ cc_binary(
81125
"htool_update_failure_reasons.h",
82126
"htool_usb.c",
83127
"htool_usb.h",
128+
"htool_provisioning.c",
129+
"htool_provisioning.h",
84130
],
85131
deps = [
86132
":host_commands",
@@ -114,3 +160,18 @@ cc_binary(
114160
"//conditions:default": [],
115161
}),
116162
)
163+
164+
cc_test(
165+
name = "htool_provisioning_test",
166+
srcs = ["htool_provisioning_test.cc"],
167+
deps = [
168+
":htool_cmd",
169+
":htool_provisioning",
170+
":htool_security_version",
171+
"//protocol:host_cmd",
172+
"//protocol/test:libhoth_device_mock",
173+
"//transports:libhoth_device",
174+
"//examples/test:test_util",
175+
"@googletest//:gtest",
176+
"@googletest//:gtest_main", ],
177+
)

examples/host_commands.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,4 +395,7 @@ struct hoth_response_target_control {
395395
}
396396
#endif
397397

398+
// Host Command for Provisioning Commands
399+
#define HOTH_PRV_CMD_HOTH_PROVISIONING_LOG 0x0040
400+
398401
#endif // LIBHOTH_EXAMPLES_HOST_COMMANDS_H_

examples/htool.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "htool_panic.h"
3939
#include "htool_payload.h"
4040
#include "htool_payload_update.h"
41+
#include "htool_provisioning.h"
4142
#include "htool_raw_host_command.h"
4243
#include "htool_rot_usb.h"
4344
#include "htool_sbs_dual.h"
@@ -1520,6 +1521,27 @@ static const struct htool_cmd CMDS[] = {
15201521
.params = (const struct htool_param[]){{}},
15211522
.func = htool_tpm_spi_probe,
15221523
},
1524+
{
1525+
.verbs = (const char*[]){"provisioning", "read", NULL},
1526+
.desc = "Get Provisioning Log",
1527+
.func = htool_get_provisioning_log,
1528+
.params =
1529+
(const struct htool_param[]){
1530+
{HTOOL_FLAG_VALUE, .name = "output", .default_value="",
1531+
.desc = "The output file which will contain the provisioning log."},
1532+
{}},
1533+
},
1534+
{
1535+
.verbs = (const char*[]){"provisioning", "validate_and_sign", NULL},
1536+
.desc = "Validate and Sign the provisioning log",
1537+
.func = htool_validate_and_sign,
1538+
.params = (const struct htool_param[]){
1539+
{HTOOL_FLAG_VALUE, .name="perso_blob", .default_value="",
1540+
.desc="The perso blob file."},
1541+
{HTOOL_FLAG_VALUE, .name="output", .default_value="",
1542+
.desc="The signed cert file."},
1543+
{}},
1544+
},
15231545
{},
15241546
};
15251547

0 commit comments

Comments
 (0)