diff options
author | Julius Werner <jwerner@chromium.org> | 2022-05-19 14:06:25 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-25 20:29:32 +0000 |
commit | ff1f3b91c31706d1e73a82ec928fd9bdd080f96f (patch) | |
tree | 17b01cf60b5ec4ce100b329f748bcc266528510c | |
parent | d14e1c4b4ec45c8d23adf88aaff460d758275d66 (diff) | |
download | vboot-ff1f3b91c31706d1e73a82ec928fd9bdd080f96f.tar.gz |
futility: gscvd: Allow passing board ID in ASCII
In many places (e.g. go/cros-dlm), we treat GSC board IDs as a 4-letter
ASCII string rather than a hexadecimal number. To relieve people of the
need to manually convert between formats when copy&pasting IDs, this
patch makes the `gscvd` command accept both versions.
BRANCH=none
BUG=b:229015103
TEST=futility gscvd -b GVLR
Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: I50fa73f5a14d2747c3e1b15e5dc3fbfcb2391f47
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3656349
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r-- | futility/cmd_gscvd.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/futility/cmd_gscvd.c b/futility/cmd_gscvd.c index 659716ae..57e79ef6 100644 --- a/futility/cmd_gscvd.c +++ b/futility/cmd_gscvd.c @@ -88,8 +88,10 @@ static const char usage[] = " This option takes special care\n" " to exclude the HWID (and its\n" " digest) from this range.\n" - " -b|--board_id <hex value> The Board ID of the board for which\n" - " the image is being signed\n" + " -b|--board_id <string|hex> The Board ID of the board for\n" + " which the image is signed.\n" + " Can be passed as a 4-letter\n" + " string or a hexadecimal number.\n" " -r|--root_pub_key <file> The main public key, in .vbpubk\n" " format, used to verify platform\n" " key\n" @@ -993,9 +995,17 @@ static int do_gscvd(int argc, char *argv[]) char *e; long long bid; + if (strlen(optarg) == 4) { + board_id = optarg[0] << 24 | + optarg[1] << 16 | + optarg[2] << 8 | + optarg[3]; + break; + } + bid = strtoull(optarg, &e, 16); if (*e || (bid >= UINT32_MAX)) { - ERROR("Board ID value '%s' is invalid\n", + ERROR("Cannot parse Board ID '%s'\n", optarg); errorcount++; } else { |