summaryrefslogtreecommitdiff
path: root/futility/cmd_create.c
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2015-03-26 15:59:06 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-03-31 06:30:36 +0000
commitb5a439241fee558631d466cfa5203dd447504427 (patch)
tree523b6e169df13c71fbbb240d41253813b33aa726 /futility/cmd_create.c
parent091c7b17f09f287da115ca247d39e7128158a581 (diff)
downloadvboot-b5a439241fee558631d466cfa5203dd447504427.tar.gz
futility: add support for usbpd1 images
The USB Type-C chargers released with Samus ("Pixel (2015)") have upgradable firmware. Those firmware images are currently signed by some custom scripts. This adds support for those images to futility, so that those custom scripts can be replaced. Note that due to space considerations, the usbpd firmware images don't have room for handy things like an FMAP or headers for the signatures. Accordingly, all the normally variable factors (image size, signature algorithms, etc.) are hard coded and the image itself just looks like a bunch of random numbers. Because of this: 1. There's no way to recognize this type of file, and nothing to display about it. 2. You have to give the "--type usbpd1" arg to the sign command. 3. I'm designating this file type "v1" because I hope that the firmware for any future adapters will be more readily identifiable. BUG=chromium:231574 BRANCH=none TEST=make runtests This adds a new test that signs usbpd1 firmware images using futility, and compares the result to the same files signed by the custom scripts, ensuring that they are bitwise identical. Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: Idbe061db5b3c8e474ada47b40bcbe04bbecdba3a Reviewed-on: https://chromium-review.googlesource.com/262899 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'futility/cmd_create.c')
-rw-r--r--futility/cmd_create.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/futility/cmd_create.c b/futility/cmd_create.c
index c919eab3..e3fafd30 100644
--- a/futility/cmd_create.c
+++ b/futility/cmd_create.c
@@ -23,6 +23,7 @@
#include "host_misc2.h"
#include "futility.h"
+#include "futility_options.h"
/* Command line options */
enum {
@@ -283,7 +284,6 @@ static int do_create(int argc, char *argv[])
int errorcnt = 0;
char *e, *s;
int i, r, len, remove_ext = 0;
- const struct vb2_text_vs_enum *entry;
while ((i = getopt_long(argc, argv, "", long_opts, NULL)) != -1) {
switch (i) {
@@ -311,28 +311,13 @@ static int do_create(int argc, char *argv[])
break;
case OPT_HASH_ALG:
- /* try string first */
- entry = vb2_lookup_by_name(vb2_text_vs_hash, optarg);
- if (entry) {
- opt_hash_alg = entry->num;
- break;
- }
- /* fine, try number */
- opt_hash_alg = strtoul(optarg, &e, 0);
- if (!*optarg || (e && *e)) {
+ if (!vb2_lookup_hash_alg(optarg, &opt_hash_alg)) {
fprintf(stderr,
"invalid hash_alg \"%s\"\n", optarg);
errorcnt++;
- break;
- }
- if (!vb2_lookup_by_num(vb2_text_vs_hash,
- opt_hash_alg)) {
- fprintf(stderr,
- "Hash algorithm %d is unsupported\n",
- opt_hash_alg);
- errorcnt++;
}
break;
+
case OPT_HELP:
print_help(argc, argv);
return !!errorcnt;