diff options
author | Bill Richardson <wfrichar@chromium.org> | 2015-03-26 15:59:06 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-03-31 06:30:36 +0000 |
commit | b5a439241fee558631d466cfa5203dd447504427 (patch) | |
tree | 523b6e169df13c71fbbb240d41253813b33aa726 /futility/vb2_helper.c | |
parent | 091c7b17f09f287da115ca247d39e7128158a581 (diff) | |
download | vboot-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/vb2_helper.c')
-rw-r--r-- | futility/vb2_helper.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/futility/vb2_helper.c b/futility/vb2_helper.c index c10190ff..4ee0a28b 100644 --- a/futility/vb2_helper.c +++ b/futility/vb2_helper.c @@ -22,6 +22,33 @@ #include "file_type.h" #include "futility.h" +int vb2_lookup_hash_alg(const char *str, enum vb2_hash_algorithm *alg) +{ + const struct vb2_text_vs_enum *entry; + uint32_t val; + char *e; + + /* try string first */ + entry = vb2_lookup_by_name(vb2_text_vs_hash, str); + if (entry) { + *alg = entry->num; + return 1; + } + + /* fine, try number */ + val = strtoul(str, &e, 0); + if (!*str || (e && *e)) + /* that's not a number */ + return 0; + + if (!vb2_lookup_by_num(vb2_text_vs_hash, val)) + /* That's not a valid alg */ + return 0; + + *alg = val; + return 1; +} + enum futil_file_type ft_recognize_vb2_key(uint8_t *buf, uint32_t len) { struct vb2_public_key pubkey; |