vb2_firmware_tests.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. #
  6. # End-to-end test for vboot2 firmware verification
  7. # Load common constants and variables.
  8. . "$(dirname "$0")/common.sh"
  9. set -e
  10. echo 'Creating test firmware'
  11. # Run tests in a dedicated directory for easy cleanup or debugging.
  12. DIR="${TEST_DIR}/vb2fw_test_dir"
  13. [ -d "$DIR" ] || mkdir -p "$DIR"
  14. echo "Testing vb2_verify_fw in $DIR"
  15. cd "$DIR"
  16. # Dummy firmware body
  17. echo 'This is a test firmware body. This is only a test. Lalalalala' \
  18. > body.test
  19. # Pack keys using original vboot utilities
  20. ${FUTILITY} vbutil_key --pack rootkey.test \
  21. --key ${TESTKEY_DIR}/key_rsa8192.keyb --algorithm 11
  22. ${FUTILITY} vbutil_key --pack fwsubkey.test \
  23. --key ${TESTKEY_DIR}/key_rsa4096.keyb --algorithm 7
  24. ${FUTILITY} vbutil_key --pack kernkey.test \
  25. --key ${TESTKEY_DIR}/key_rsa2048.keyb --algorithm 4
  26. # Create a GBB with the root key
  27. ${FUTILITY} gbb_utility -c 128,2400,0,0 gbb.test
  28. ${FUTILITY} gbb_utility gbb.test -s --hwid='Test GBB' \
  29. --rootkey=rootkey.test
  30. # Keyblock with firmware subkey is signed by root key
  31. ${FUTILITY} vbutil_keyblock --pack keyblock.test \
  32. --datapubkey fwsubkey.test \
  33. --signprivate ${TESTKEY_DIR}/key_rsa8192.sha512.vbprivk
  34. # Firmware preamble is signed with the firmware subkey
  35. ${FUTILITY} vbutil_firmware \
  36. --vblock vblock.test \
  37. --keyblock keyblock.test \
  38. --signprivate ${TESTKEY_DIR}/key_rsa4096.sha256.vbprivk \
  39. --fv body.test \
  40. --version 1 \
  41. --kernelkey kernkey.test
  42. echo 'Verifying test firmware using vb2_verify_fw'
  43. # Verify the firmware using vboot2 checks
  44. ${BUILD_RUN}/tests/vb20_verify_fw gbb.test vblock.test body.test
  45. happy 'vb2_verify_fw succeeded'