README 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. This directory contains a reference implementation for Chrome OS
  2. verified boot in firmware.
  3. ----------
  4. Directory Structure
  5. ----------
  6. The source is organized into distinct modules -
  7. firmware/
  8. Contains ONLY the code required by the BIOS to validate the secure boot
  9. components. There shouldn't be any code in here that signs or generates
  10. images. BIOS should require ONLY this directory to implement secure boot.
  11. Refer to firmware/README for futher details.
  12. cgpt/
  13. Utility to read/write/modify GPT partitions. Similar to GNU parted or any
  14. other GPT tool, but this has support for Chrome OS extensions.
  15. host/
  16. Miscellaneous functions needed by userland utilities.
  17. futility/
  18. The "firmware utility" tool, used to create, sign, and validate Chrome OS
  19. images.
  20. utility/
  21. Random other utilities, not necesssarily related to verified boot as such.
  22. tests/
  23. User-land tests and benchmarks that test the reference implementation.
  24. Please have a look at these if you'd like to understand how to use the
  25. reference implementation.
  26. build/
  27. The output directory where the generated files will be placed, and where
  28. tests are run.
  29. scripts/
  30. Tools and scripts used to generate and use new signing keypairs. These are
  31. typically used only on a secure machine.
  32. --------------------
  33. Building and testing
  34. --------------------
  35. The suite can be built on the host or in the chroot environment.
  36. Building on the host could fail if certain packages are not installed. If
  37. there are host environment build problems due to missing .h files, try
  38. researching what packages the files belong to and install the missing packages
  39. before reporting a problem.
  40. The commands are the more-or-less expected ones:
  41. make
  42. make runtests
  43. make install [ DESTDIR=/usr/local ]
  44. ----------
  45. Some useful utilities:
  46. ----------
  47. futility vbutil_key Convert a public key into .vbpubk format
  48. futility vbutil_keyblock Wrap a public key inside a signature and checksum
  49. futility vbutil_firmware Create a .vblock with signature info for a
  50. firmware image
  51. futility vbutil_kernel Pack a kernel image, bootloader, and config into
  52. a signed binary
  53. dumpRSAPublicKey Dump RSA Public key (from a DER-encoded X509
  54. certificate) in a format suitable for use by
  55. RSAVerify* functions in crypto/.
  56. verify_data.c Verify a given signature on a given file.
  57. ----------
  58. Generating a signed firmware image:
  59. ----------
  60. * Step 0: Build the tools, install them somewhere.
  61. * Step 1: Generate RSA root and signing keys.
  62. The root key is always 8192 bits.
  63. $ openssl genrsa -F4 -out root_key.pem 8192
  64. The signing key can be between 1024-8192 bits.
  65. $ openssl genrsa -F4 -out signing_key.pem <1024|2048|4096|8192>
  66. Note: The -F4 option must be specified to generate RSA keys with a public
  67. exponent of 65535. RSA keys with 3 as a public exponent (the default)
  68. won't work.
  69. * Step 2: Generate pre-processed public versions of the above keys using
  70. dumpRSAPublicKey. This utility expects an x509 certificate as
  71. input, and emits an intermediate representation for further
  72. processing.
  73. $ openssl req -batch -new -x509 -key root_key.pem -out root_key.crt
  74. $ openssl req -batch -new -x509 -key signing_key.pem -out signing_key.crt
  75. $ dumpRSAPublicKey root_key.crt > root_key.keyb
  76. $ dumpRSAPublicKey signing_key.crt > signing_key.keyb
  77. ************** TODO: STUFF PAST HERE IS OUT OF DATE ***************
  78. At this point we have all the requisite keys needed to generate a signed
  79. firmware image.
  80. .pem RSA Public/Private Key Pair
  81. .crt X509 Key Certificate
  82. .keyb Pre-processed RSA Public Key
  83. * Step 3: Use utility/firmware_utility to generate a signed firmare blob.
  84. $ utility/firmware_utility --generate \
  85. --root_key root_key.pem \
  86. --firmware_sign_key signing_key.pem \
  87. --firmware_sign_key_pub signing_key.keyb \
  88. --firmware_sign_algorithm <algoid> \
  89. --firmware_key_version 1 \
  90. --firmware_version 1 \
  91. --in <firmware blob file> \
  92. --out <output file>
  93. Where <algoid> is based on the signature algorithm to use for firmware
  94. signining. The list of <algoid> specifications can be output by running
  95. 'utility/firmware_utility' without any arguments.
  96. Note: --firmware_key_version and --firmware_version are part of a signed
  97. image and are used to prevent rollbacks to older version. For testing,
  98. they can just be set to valid values.
  99. * Step 4: Verify that this image verifies.
  100. $ utility/firmware_utility --verify \
  101. --in <signed firmware image>
  102. --root_key_pub root_key.keyb
  103. Verification SUCCESS.
  104. Note: The verification functions expects a pointer to the
  105. pre-processed public root key as input. For testing purposes,
  106. root_key.keyb can be stored in RW part of the firmware. For the
  107. final firmware, this will be a fixed public key which cannot be
  108. changed and must be stored in RO firmware.
  109. ----------
  110. Generating a signed kernel image:
  111. ----------
  112. The steps for generating a signed kernel image are similar to that of
  113. a firmware image. Since verification is chained - RO firmware verifies
  114. RW firmware which verifies the kernel, only the keys change. An additional
  115. kernel signing key must be generated. The firmware signing generated above
  116. is the root key equivalent for signed kernel images.