blob: 4150572ebcff664b0e5f76b55e9a973db7f863af [file] [log] [blame]
Randall Spangler539cbc22014-06-18 14:15:04 -07001#!/bin/bash
2
3# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6#
7# End-to-end test for vboot2 firmware verification
8
9# Load common constants and variables.
10. "$(dirname "$0")/common.sh"
11
12set -e
13
14echo 'Creating test firmware'
15
16# Run tests in a dedicated directory for easy cleanup or debugging.
17DIR="${TEST_DIR}/vb2fw_test_dir"
18[ -d "$DIR" ] || mkdir -p "$DIR"
19echo "Testing vb2_verify_fw in $DIR"
20cd "$DIR"
21
22# Dummy firmware body
23echo 'This is a test firmware body. This is only a test. Lalalalala' \
24 > body.test
25
26# Pack keys using original vboot utilities
Bill Richardsona1d9fe62014-09-05 12:52:27 -070027${FUTILITY} vbutil_key --pack rootkey.test \
Randall Spangler539cbc22014-06-18 14:15:04 -070028 --key ${TESTKEY_DIR}/key_rsa8192.keyb --algorithm 11
Bill Richardsona1d9fe62014-09-05 12:52:27 -070029${FUTILITY} vbutil_key --pack fwsubkey.test \
Randall Spangler539cbc22014-06-18 14:15:04 -070030 --key ${TESTKEY_DIR}/key_rsa4096.keyb --algorithm 7
Bill Richardsona1d9fe62014-09-05 12:52:27 -070031${FUTILITY} vbutil_key --pack kernkey.test \
Randall Spangler539cbc22014-06-18 14:15:04 -070032 --key ${TESTKEY_DIR}/key_rsa2048.keyb --algorithm 4
33
34# Create a GBB with the root key
Bill Richardsona1d9fe62014-09-05 12:52:27 -070035${FUTILITY} gbb_utility -c 128,2400,0,0 gbb.test
36${FUTILITY} gbb_utility gbb.test -s --hwid='Test GBB' \
37 --rootkey=rootkey.test
Randall Spangler539cbc22014-06-18 14:15:04 -070038
39# Keyblock with firmware subkey is signed by root key
Bill Richardsona1d9fe62014-09-05 12:52:27 -070040${FUTILITY} vbutil_keyblock --pack keyblock.test \
Randall Spangler539cbc22014-06-18 14:15:04 -070041 --datapubkey fwsubkey.test \
42 --signprivate ${TESTKEY_DIR}/key_rsa8192.sha512.vbprivk
43
44# Firmware preamble is signed with the firmware subkey
Bill Richardsona1d9fe62014-09-05 12:52:27 -070045${FUTILITY} vbutil_firmware \
Randall Spangler539cbc22014-06-18 14:15:04 -070046 --vblock vblock.test \
47 --keyblock keyblock.test \
48 --signprivate ${TESTKEY_DIR}/key_rsa4096.sha256.vbprivk \
49 --fv body.test \
50 --version 1 \
51 --kernelkey kernkey.test
52
53echo 'Verifying test firmware using vb2_verify_fw'
54
Bill Richardson5fb14632015-01-27 13:59:35 -080055# Verify the firmware using vboot2 checks
56${BUILD_RUN}/tests/vb20_verify_fw gbb.test vblock.test body.test
Randall Spangler539cbc22014-06-18 14:15:04 -070057
58happy 'vb2_verify_fw succeeded'