Commit Graph

507 Commits

Author SHA1 Message Date
Nicolas Boichat
7c5d3b2240 futility: rwsig: Add support for images with FMAP
If an FMAP is detected in the rwsig image file, use it
to determine the location of:
 - RW region
 - RW signature
 - public key in RO region

futility show uses that information to verify the signature,
and futility sign uses it is correctly resign the image,
and replace the public key a well.

This also adds tests for this use case. hammer_dev.bin sample
image uses huge RO public key and RW signature regions to make
sure all keys up to RSA-8192 can be used.

BRANCH=none
BUG=chrome-os-partner:62321
TEST=make -j
TEST=./build/futility/futility --debug show \
                    --pubkey hammer.vbpubk2 hammer.bin
TEST=./build/futility/futility --debug show hammer.bin
TEST=cp hammer.bin hammer.bin.orig
     ./build/futility/futility --debug sign \
       --prikey hammer.vbprik2 hammer.bin
     diff hammer.bin hammer.bin.orig => identical
TEST=openssl genrsa -3 -out hammer2.pem 2048
     futility create --desc="Hammer 2nd key" hammer2.pem \
       hammer2
     ./build/futility/futility --debug sign \
       --version 2 --prikey hammer2.vbprik2 hammer.bin
     These 2 commands succeed, but show different keys:
     ./build/futility/futility --debug show hammer.bin
     ./build/futility/futility --debug show hammer.bin.orig
TEST=make runtests

Change-Id: I2cebc421eaf97d1b92c9a58afc238d41487d0f6d
Reviewed-on: https://chromium-review.googlesource.com/445536
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-25 10:32:03 -08:00
Nicolas Boichat
83bd850f3f vboot_reference: Add support for 2048-bit exponent 3 keys
This also adds the required tests (keys, testcases).

BRANCH=none
BUG=chromium:684354
TEST=make runtests

Change-Id: I5e148f8792ea325f813d76089271f3c4bcc2935d
Reviewed-on: https://chromium-review.googlesource.com/438951
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-18 00:39:28 -08:00
Nicolas Boichat
f310106030 tests: Add simple test for rwsig images
This tests that futility can correctly create and verify rwsig images.
Note that we do not test RSA 8192, as the signature is longer than
1024 bytes, and the test logic would need to be changed.

BRANCH=none
BUG=chromium:684354
TEST=make runfutiltests

Change-Id: I690e59fe8fa3e273dd81176211c58e1677fa720f
Reviewed-on: https://chromium-review.googlesource.com/438950
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-11 04:21:57 -08:00
Nicolas Boichat
3ac811d4a5 gen_test_keys.sh: Fixup key_index when keys already exist
BRANCH=none
BUG=chromium:684354
TEST=rm tests/testkeys/key_rsa2048*; make genkeys -j8

Change-Id: I6c75d2d54faf7a02c8fc4ef1ccc8647809c1aae8
Reviewed-on: https://chromium-review.googlesource.com/438949
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-11 02:42:02 -08:00
Nicolas Boichat
d02ae3899c Makefile: Add gentestcases target
This calls gen_test_cases.sh in the proper environment.

Also, prevent gen_test_cases.sh from overriding test_file, to
provide stable signature (and avoid large git diff for no reason).

BRANCH=none
BUG=chromium:684354
TEST=make gentestcases -j8; git diff => no changes

Change-Id: I556285fd1a07a4d84f4ebd3fd7881ae06743716e
Reviewed-on: https://chromium-review.googlesource.com/439064
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-11 02:42:01 -08:00
Mike Frysinger
62461d719f image_signing: support signing of OCI containers
BUG=chromium:660209
TEST=`./sign_official_build.sh oci-container fastboot/ ../tests/devkeys` works
TEST=signing an image inserted the container pubkey
BRANCH=None

Change-Id: I75793b03e93f2c18b1495a3ec729ad04d2e17401
Reviewed-on: https://chromium-review.googlesource.com/427538
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
2017-01-14 20:19:06 -08:00
Randall Spangler
21015898b3 firmware: replace VBDEBUG(()) macro with VB2_DEBUG()
The original VBDEBUG macro used doubly-nested parens to work with
MSVC, which didn't support varargs in macros.  We now only use more
modern compilers, so replace it with the VB2_DEBUG macro and get rid
of the ugly and fragile double parens.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; build_packages --board=reef chromeos-firmware

Change-Id: Ifc0cb0733b14daaa1fde095fab7da4215a538c77
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/425133
Reviewed-by: Shelley Chen <shchen@chromium.org>
2017-01-12 15:56:27 -08:00
Randall Spangler
ad7a75531e firmware: Remove LoadKernelParams from APIs
This cleans up the vboot functions which handle display so they don't
need to pass it around.  Eventually, it'll be absorbed by vb2_context.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; build_packages --board=reef chromeos-firmware; boot reef

Change-Id: I58169dfd37abe657f9b9aa339cc72ffa398329e0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414288
Reviewed-by: Shelley Chen <shchen@chromium.org>
2017-01-12 15:56:24 -08:00
ChromeOS Developer
284bf5549a firmware: Refactor and clean up ec_sync
Previously, the EC software sync process called VbDisplayScreen() from
several function calls deep.  Refactor software sync so that the UI
decisions are at a higher level (in ec_sync_all.c) and isolated from
the low-level EC software sync functionality (in ec_sync.c).

This is one in a series of changes which are more clearly separating
out the UI, to make it easier to support multiple UI across a range of
devices.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; build_packages --board=reef chromeos-firmware; boot reef

Change-Id: I40597abeb5b0cc8f5d8fc2098e4acbed4bf59bf6
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/411921
Reviewed-by: Shelley Chen <shchen@chromium.org>
2017-01-12 15:56:22 -08:00
Randall Spangler
e4136dcaa0 vboot: Pass vb2 context and use vboot2 NV routines
Passing the vb2 context around allows using more of the vb2 functions in
future changes, and prepares for a future where we directly use the
context as it was set up in firmware verification.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I8efa606dbdec5d195b66eb899e76fdc84337ad36
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/404997
Reviewed-by: Shelley Chen <shchen@chromium.org>
2016-12-22 12:09:26 -08:00
Randall Spangler
2603675460 vboot: Split ec software sync to its own file
This was previously done inside vboot_api_kernel.  But it has nothing to
do with kernel verification; that's just the only place where we could
easily put it given that vboot (currently) owns the firmware UI.

No outwardly-visible functionality changes.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I8a434eb4449a5a86b129ecac61ad81d0ad55549c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/404920
2016-12-20 21:56:56 -08:00
Randall Spangler
eedd429358 vboot: Remove LoadKernel() LBA size/count checks
Now that LoadKernel() uses a stream API for its partition data, it
doesn't care about those fields.  They're blindly passed to
cgptlib_internal, which does similar checks in CheckParameters() and
CheckHeader().  So, don't duplicate the checks.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I72375496e5df7b7c17df25d358f2555fe41fe520
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/407053
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-11-15 11:25:41 -08:00
Randall Spangler
f182401b97 vboot: Split partition and vblock verification from LoadKernel()
LoadKernel() was a big function which did everything from looping over
partitions on a drive to loading the data within them to calling the
low-level verification functions on that data.  Split it apart into more
manageable chunks.  This also reduces indentation of the inner parts of
the code, whic increases readability.

No outwardly-visible functionality changes.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: Iea79e70163f5d9f1a9d0d897e4a9bacc925a742d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/404919
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-11-14 16:42:19 -08:00
Furquan Shaikh
95b2d6ca2b recovery: Add new recovery reason to train memory and reboot
This new recovery reason will instruct the calling firmware in
vboot_select_and_load_kernel to reboot the device (under the assumption
that training of memory has already been performed by the firmware). On
seeing the return code VBERROR_REBOOT_REQUESTED, calling firmware should
perform a reboot.

BUG=chrome-os-partner:59352
BRANCH=None
TEST=make -j runtests successful

Change-Id: I110a735e612665cb2378bd71ca01a111edaf58e3
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/407656
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-11-08 02:52:45 -08:00
Randall Spangler
6e3931d1f6 vboot: Add vb2_unpack_key_buffer
Previously, vb2_unpack_key() actually unpacked a key buffer.  Callers
that had a vb2_packed_key had to typecast it back to a uint8_t buffer to
unpack it.  Rename vb2_unpack_key() to vb2_unpack_key_buffer(), and make
vb2_unpack_key() unpack a vb2_packed_key.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge;
     emerge-samus and boot it

Change-Id: I9ee38a819c59cc58a72ead78cf5ddf3d0f301ae7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400906
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-11-06 02:34:03 +00:00
Randall Spangler
559a110f33 vboot: use malloc and free directly
Originally, vboot1 code used VbExMalloc() and VbExFree() since it needed
to talk to EFI firmware that didn't have standard malloc() and free().
Now, coreboot and depthcharge implement them as wrappers around those
standard calls.  vboot2 code already calls them directly, so let vboot1
code do that too.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I49ad0e32e38d278dc3589bfaf494bcf0e4b0a4bd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400905
2016-11-06 02:33:50 +00:00
Randall Spangler
47eeaa6e4a vboot: remove unused stateful_util
Now that the vboot1 cryptolib code is gone, nothing uses stateful_util.
Remove it and its unit tests.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I75b6014be00c5266545db10e87c1d9485fd1444b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400904
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-11-06 02:33:37 +00:00
Randall Spangler
13c0776aab vboot: Remove the remainder of vb1 cryptolib
At this point, all that's left are a few constants in the cryptolib
header files, and they're only used by host-side code.  So move them to
a host-side header file and get rid of cryptolib.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I2235f0e84e13fef313afe54e749b73744b157884
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400903
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-11-06 02:33:19 +00:00
Randall Spangler
46a382d613 vboot: Remove vboot1 cryptolib padding source
The old vboot1 cryptolib hard-coded many of its padding arrays in a
padding.c file.  Use the equivalent vboot2 apis instead.

This change is almost exclusively on the host and test side; the only
firmware impact is on a single line of debug output.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: If689ffd92f0255847bea2424950da4547b2c0df3
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400902
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-11-06 02:33:02 +00:00
Daisuke Nojiri
754ebdb8c3 Output stderr when run_test_scripts.sh fail
This change makes run_test_scripts.sh dump stderr to the terminal
so that the failed test can be debugged. This is necessary to
analyze a failing test on build servers.

BUG=none
BRANCH=none
TEST=sudo FEATURES=test emerge vboot_reference && FEATURES=test
USE=minimal emerge-samus vboot_reference && make runtests

Change-Id: Id9ae0fb174cfe382ec30a1175f54c0891543c46e
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/403428
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-11-01 10:26:32 -07:00
Randall Spangler
5a9f498182 host,test: Remove unneeded vb1 rsa functions
Another in a continued stream of refactoring.  This change removes more
of the vb1 rsa library code and associated tests, in favor of their vb2
equivalents.  This change touches only host-side code and its tests, not
firmware.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I1973bc2f03c60da62232e30bab0fa5fe791b6b34
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400901
2016-10-29 19:41:09 -07:00
Randall Spangler
13b109762a vboot: use vb2 verification functions for kernel verification
This removes old vboot1 functions in favor of the new vboot2 functions.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: Idc64f7714bbd9d4fa82d14b6b5d73d71c61de854
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400900
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-10-29 19:41:08 -07:00
Randall Spangler
49e517d818 vboot: use vb2_safe_memcmp instead of SafeMemcmp
No need to have two implementations of this now.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I18bac928eb09971c37f3e1d7cbfd2009999b1f31
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400899
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-10-29 00:57:07 +00:00
Randall Spangler
bf6263d529 vboot: use vb2_crc8 instead of Crc8
No need to have two implementations of this now.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: Id3348eae80c5d85451981a44729164ff59f88648
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/399121
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-10-23 13:33:39 -07:00
Randall Spangler
664096bd1a vboot: use standard memcmp, memcpy, memset
Originally, we didn't trust the firmware to provide these functions from
a standard library.  Now, with coreboot, we do.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I4e624c40085f2b665275a38624340b2f6aabcf11
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/399120
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-10-23 13:33:38 -07:00
Daisuke Nojiri
3875e6191f bdb: Add --load_address to futility-bdb --create
This change makes futility-bdb --create take --load_address parameter,
which sets the load address field in the BDB header.

BUG=chromium:649554
BRANCH=none
TEST=make runtests
$ futility bdb --resign test/futility/data/bin.bdb --data_version 2
then futility show --type bdb test/futility/data/bin.bdb

Change-Id: Ib4dec86c2a043e0989c91bbc01f39776e3630e4c
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/399594
Commit-Ready: Daisuke Nojiri <dnojiri@google.com>
Tested-by: Daisuke Nojiri <dnojiri@google.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-19 11:38:52 -07:00
Daisuke Nojiri
77d9dd0dd5 bdb: Add --data_version to futility-bdb --resign
This change makes futility-bdb command take --data_version parameter.

BUG=chromium:649554
BRANCH=none
TEST=make runtests
$ futility bdb --resign test/futility/data/bin.bdb --data_version 2
then futility show --type bdb test/futility/data/bin.bdb

Change-Id: I567d5879555f4ae7382fc47ef79135e7a13b7600
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/399593
Commit-Ready: Daisuke Nojiri <dnojiri@google.com>
Tested-by: Daisuke Nojiri <dnojiri@google.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-19 11:38:50 -07:00
Daisuke Nojiri
6858261b27 bdb: Enable futility show to dump data header info
This change makes futility show command to dump data header information
in a BDB. # of hashes is used to verify 'futility bdb --add' can add a
hash in the unit test.

BUG=chromium:649554
BRANCH=none
TEST=make runtests. run futility show tests/futility/data/bdb.bin

BDB Header:
  Struct Version: 0x1:0x0
  BDB key digest: c7895611c24efb2249d97376189eeee07def6bcd8ab162a3850d279354f08ddf
            size: 1176
Data Header:
  Struct Version: 0x1:0x0
  # of Hashes:    2
  Hash Entry Size:56
  Signed Size:    272
  Description:
Hash #0:
  Offset:       0x2
  Size:         35
  Partition:    3
  Type:         1
  Load Address: 0x4
  Digest:       72bcf33f448465f035bd58e4b61501db925e67c89feb4a70cb909d8b425861f4
Hash #1:
  Offset:       0x2
  Size:         35
  Partition:    3
  Type:         1
  Load Address: 0x4
  Digest:       72bcf33f448465f035bd58e4b61501db925e67c89feb4a70cb909d8b425861f4

Change-Id: I88934b761236f36a5d607c96f6f2543a62e50b68
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/392949
2016-10-14 01:02:18 -07:00
Daisuke Nojiri
3b55afa94e Fix test_bdb.sh
test_bdb.sh is failing because sp-rw.bin is missing. Adding sp-rw.bin.

BUG=none
BRANCH=none
TEST=make runtests

Change-Id: I7cb892077e424bdfa5f723051a7ebbbda04f14c2
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/396393
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-12 06:30:03 -07:00
Daisuke Nojiri
dc96c6c018 bdb: Add bdb_get_hash_by_index
bdb_get_hash_by_index returns a hash entry from a BDB using an index.
bdb_get_hash is also renamed to bdb_get_hash_by_type. bdb_get_hash
is deprecated. Callers are expected to call bdb_get_hash_by_index(buf, 0)
instead.

BUG=none
BRANCH=none
TEST=make runtests

Change-Id: Id99926123c0ac9094574eb057c63f79eceda2867
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/392947
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-11 10:56:54 -07:00
Daisuke Nojiri
985ad0e115 bdb: Add --ignore_key_digest option to futility bdb --verify
When --ignore_key_digest is specified, futility bdb --verify command
returns success even if the key digest didn't match. Warning message
will be printed to remind the digest wasn't checked.

BUG=chromium:649554
BRANCH=none
TEST=Tested as follows:
$ build/futility/futility bdb --verify tests/futility/data/bdb.bin \
--ignore_key_digest
BDB is valid. Key digest doesn't match but ignored.
$ echo $?
0

Change-Id: I996b0a4f7bbbcf546e2d958f28c5ee8fb251fb99
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/392946
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-11 10:56:52 -07:00
Daisuke Nojiri
93159a2250 test: Make TEST_EQ print either 'comment' or 'desc'
Currently, test macros print out 'desc' regardless 'comment' is specified
or not. This patch makes TEST_EQ print 'desc' only if 'comment' is not
supplied.

BUG=none
BRANCH=none
TEST=make runtests

Change-Id: I9cc3c9a9561534352ae0315dfea983f2c212b909
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/388859
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-05 17:11:30 -07:00
Daisuke Nojiri
c3f8de399b bdb: Add test for futility bdb --resign
BUG=chromium:649554
BRANCH=none
TEST=make runtests

Change-Id: Id33911a1a05375f860c38ee6df3f98fa59066acf
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/388734
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-05 17:11:28 -07:00
Daisuke Nojiri
9e8d3746ac bdb: Add test for futility bdb --add
BUG=chromium:649554
BRANCH=none
TEST=make runtests

Change-Id: Ie774a64e9abd6de8f0f96567f6f6a2e930a8624c
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/388733
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-05 17:11:27 -07:00
Daisuke Nojiri
aa77ae1b09 bdb: Add test for futility bdb --create and --verify
This script will be testing futility bdb command.

BUG=chromium:649554
BRANCH=none
TEST=make runtests

Change-Id: I3c5b9f9564b3cc67cac4eca02798b8146feeb072
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/388732
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-05 17:11:25 -07:00
Daisuke Nojiri
c3daa95c50 bdb: Make 'futility show' support BDB
This patch makes futility show command support boot block descriptor (BDB)
of the common boot flow.

BUG=chromium:649554
BRANCH=none
TEST=make runtests. Ran futility show bdb.bin.

Change-Id: I5f199a32ab1c268351e822e37ed39e41ae19bc7a
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/388631
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-04 21:19:12 -07:00
Daisuke Nojiri
84928a0baa bdb: Assign different codes for data validation errors
This patch adds BDB_ERROR_DATA_CHECK_SIG and BD_ERROR_DATA_SIGNED_SIZE
to distiniguish data signature validation errors.

'futility bdb --resign' uses these to decide whether to resign is needed
or not.

BUG=chromium:649554
BRANCH=none
TEST=make runtests

Change-Id: I19137801ece2424ae575092c51d02664c8b73ba3
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/386795
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-04 00:33:18 -07:00
Randall Spangler
770202f0c7 Fix more coverity warnings
Assorted minor code issues, which we should fix so any new errors stand
out more.

BUG=chromium:643769
BRANCH=none
TEST=make runtests

Change-Id: I82ece2de948ef224115c408bdfc09445d3da119b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/390337
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-10-01 00:04:39 -07:00
Daisuke Nojiri
626e0b034d bdb: Add secret deriving code for SP-RO
This patch adds code which dervies secrets from BDS. It's supposed to be
done by SP-RO, hence the code is mostly useful for testing (or emulation).

vba_extend_secrets_ro takes a function pointer to a hash extend
function. It'll be used to try different sha256 extend algorithms.

BUG=chromium:649555
BRANCH=none
TEST=make runtests

Change-Id: I8fef6b851fb84686d8bcdd948b36160016687c51
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/384354
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-01 00:01:10 -07:00
Daisuke Nojiri
01fb293825 bdb: Make bdb_verify accept null pointer for key digest
If key digest matching is not required (i.e. verify-bdb-key efuse
flag is not set), bdb_verify skips digest matching. This change makes
bdb_verify accept null pointer for the key digest parameter.

BUG=chromium:649555
BRANCH=none
TEST=make runtests

Change-Id: I14e5bd02526684b7b7bca1e1701cf04056df83ea
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/385538
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-01 00:01:09 -07:00
Daisuke Nojiri
d0e3d7e1fa test: Print either 'comment' or 'desc'
Currently, test macros print out 'desc' regardless 'comment' is specified
or not. This patch makes 'desc' printed out only if 'comment' is not
supplied.

BUG=none
BRANCH=none
TEST=make runtests

Change-Id: I146d681b0d3cb7d41c7f80b71c59418a0250fc17
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/385159
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-09-24 16:22:34 -07:00
Randall Spangler
f87aa72d4b tests: Fix coverity warnings
Assorted minor code issues, which we should fix so any new errors stand
out more.

BUG=chromium:643769
BRANCH=none
TEST=make runtests

Change-Id: I927571f8a30794c70228506afe4da3eda86f765b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/383953
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-15 16:16:13 -07:00
Mike Frysinger
6c18af5017 cgpt: add support for managing the legacy boot gpt bit
Bit 2 in the GPT partition attributes has been allocated as the legacy
bios boot (equivalent to the "active" or "boot" flag in MBR).  If we
try to boot images on newer x86 systems, syslinux dies because it can't
find any GPT partition marked bootable.

Update the various parts of cgpt add & show to manage this bit.  Now we
can run:
	cgpt add -i 12 -B 1 chromiumos_image.bin
And the EFI partition will be marked bootable.

BUG=chromium:644845
TEST=vboot_reference unittests pass
TEST=booted an amd64-generic disk image via USB on a generic laptop
BRANCH=None

Change-Id: I78e17b8df5b0c61e9e2d8a3c703e6d5ad230fe92
Reviewed-on: https://chromium-review.googlesource.com/382411
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-09-08 15:36:23 -07:00
Hung-Te Lin
61c4ee12be tests: Prevent testing dev_firmware* if the keys do not exist.
In CL:378661 we removed dev_firmware* from tests/devkey but that also makes
futility unit tests to fail.

This changes signing test scripts to first check if dev_firmware* keys exist,
and only use it (and test ZGB signing results) if available.

BRANCH=none
BUG=chrome-os-partner:52568,chrome-os-partner:56917
TEST=make runfutiltests; make runtests;
     add dev_firmware* back; run tests again and success.

Change-Id: If42c8404baf183edf5c8dbeadf537efa8ad571ec
Reviewed-on: https://chromium-review.googlesource.com/381151
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-09-07 00:16:54 -07:00
Randall Spangler
5c537e3ea8 futility: use vboot2 functions for kernel preamble
Another in a long series of refactoring changes to replace old vboot1
code with its vboot2 equivalent.  Futility changes only; no change to
firmware.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: I7be813b82820674e975db13d5e540e49bdea028d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/366057
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-06 22:02:21 -07:00
Randall Spangler
7d0cc747c7 vboot: Remove vboot1 host signature functions
These have been superseded by their vboot2 equivalents.  No firmware
changes; host-only.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: I36b5d3357767f32489efb7e480049620dcc0fce4
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363970
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-06 22:02:19 -07:00
Randall Spangler
a62ffa8d61 vboot: replace CreateKernelPreamble() with vboot2 equivalent
Continued refactoring of host library to kernel style / vboot2 structs.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: Ifed376812ed7690eea1ec0dfab958e836f7724a0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363951
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-06 22:02:18 -07:00
Randall Spangler
f7559e4b46 futility: Use vboot 2.0 APIs for public keys
This replaces calls to the old vboot 1 APIs with their vboot 2.0
equivalents.

BUG=chromium:611535
BRANCH=none
TEST=make runtests

Change-Id: Ieb1a127577c6428c47ac088c3aaa0d0dad6275a8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/356541
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-09-02 01:28:37 -07:00
Hung-Te Lin
df2bd9b1e7 tests: Remove dev_firmware.* keyblock and keys from devkey set.
The dev_firmware* was created for legacy devices having different RW
firmware - A for devmode and B for normal, like Alex and ZGB.
All other Chromebooks, including the CR48, were not doing that.

Signer scripts relied on checking if RW A/B are equivalent to decide if
they should select <dev_firmware* for A, firmware* for B> or <firmware*
(normal) for both A and B>. This worked for a long time until Skylake
family joined.

Skylake FSP has some limitation that we have to execute code in-place,
which leads to making RW A != B (due to addresses and offsets), and
triggers signer to incorrectly use dev_firmware*.

The production images are using keyset folders on signerbot, which only
Alex/ZGB keyset folders have dev_firmware*; so the images for Skylake
boards are signed correctly. But for people running firmware related
tests using tests/devkey keyset, for example
platform/dev/fm_and_key_version_test_prep.sh, having dev_firmware* in
devkey may produce incorrect output.

There is currently no easy way for signer scripts to figure out if the
image should use dev_firmware or not except looking into keyset folder.
Since Alex and ZGB are pretty old and no one plans to run key change
tests anymore on them, the recommended solution is to remove
dev_firmware.* from devkeys folder.

BRANCH=none
BUG=chrome-os-partner:52568
TEST=platform/dev/fm_and_key_version_test_prep.sh -b sentry -i \
     /tmp/chromiumos_test_image.bin -f  8530.69.0 -s /tmp/image.bin -v \
     Google_Sentry.7820.156.0

Change-Id: Ief37dd482875efc8e808460f3ad00041b5f3b3a2
Reviewed-on: https://chromium-review.googlesource.com/378661
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2016-09-01 19:52:40 -07:00
Victor Hsieh
7573ff7efb Add script to sign Android image
sign_android_image.sh is the main script that signs the image. It makes
similar changes to an image like the Android official signing tool
(sign_target_files_apks.py) does, but more Chrome OS specific.

TEST=./sign_official_build.sh recovery recovery_image.bin \
         ../../tests/devkeys/ out_img
TEST=Same above but with a recovery image without Android image.
     Android signing was skipping.
TEST=Same above but with a M53 image.  Android signing was skipped.
TEST=Unpack the image and diff the before and after.  Looks correct.
BUG=b:29915721

Change-Id: I0ae5f0ad8d2b05e485d60262558517ea563bf527
Reviewed-on: https://chromium-review.googlesource.com/366794
Commit-Ready: Victor Hsieh <victorhsieh@chromium.org>
Tested-by: Victor Hsieh <victorhsieh@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2016-08-15 15:19:52 -07:00