Commit Graph

151 Commits

Author SHA1 Message Date
Gaurav Shah
a82bf268b2 VBoot Reference: Add kernel rollback prevention and choosing logic.
Also adds tests for kernel rollback prevention.

Review URL: http://codereview.chromium.org/1320010
2010-03-26 10:38:08 -07:00
Gaurav Shah
3199eed3d3 Move test utility functions to a common place.
Also removes the dev_mode flag from Firmware Image verification as key signature for the firmware should be checked whether or not dev mode is enabled.

BUG=670
TEST=All tests still pass.

Merge remote branch 'refs/remotes/origin/master' into fixtests

Fix tests, remove dev mode. Move common code.

Review URL: http://codereview.chromium.org/1280002
2010-03-25 13:04:45 -07:00
Gaurav Shah
7853971362 Add another missing header to remove compile time error.
Interestingly, the compile failure is only caused on the buildbot and not my build machine.

Review URL: http://codereview.chromium.org/1239006
2010-03-24 17:13:24 -07:00
Gaurav Shah
0df08373a2 Add missing header.
This should fix the test build problems.

Review URL: http://codereview.chromium.org/1219007
2010-03-24 14:22:41 -07:00
Gaurav Shah
ce0cc30e55 VBoot Reference: Add version checking to for preventing rollbacks.
This CL adds a new function VerifyFirmwareDriver_f() means to be a part of the RO firmware which determine which copy of the firmware to boot from. It is meant to ensure that a particular firmware is only booted if 1) it verifies successfully, 2) its version is newer or equal to current stored version. In addition, the driver function also updates the stored version if needed.

Currently I am using the TLCL API with stub calls, (in fact, most of the TPM interaction is done in rollback_index.c which implements the actual version query/update API) used by the firmware.

Review URL: http://codereview.chromium.org/1241002
2010-03-24 13:48:55 -07:00
Gaurav Shah
1e56693763 Fix test return values (otherwise, autotest mistakenly thinks it failed).
Review URL: http://codereview.chromium.org/1138006
2010-03-22 18:25:11 -07:00
Gaurav Shah
13937119e6 Vboot Reference: Add kernel image verification benchmark.
Refactor duplicate code for the firmware image benchmark. Also fixes some functions that manipulate kernel blobs (use uint64_t instead if int).

Review URL: http://codereview.chromium.org/1079009
2010-03-22 17:59:09 -07:00
Gaurav Shah
e268eefd6a Vboot Reference: Add a firmware verification benchmark.
The benchmark calculates the time taken to verify a firmware image of various sizes for various combinations of signature algorithm. This is meant to be called through autotest.

Review URL: http://codereview.chromium.org/1127007
2010-03-22 16:02:12 -07:00
Gaurav Shah
445925fe0f Vboot Reference: Spring cleaning of test scripts.
Moved duplicated code to "common.sh". Make directory detection more robust.

Review URL: http://codereview.chromium.org/1101004
2010-03-19 16:19:09 -07:00
Gaurav Shah
528a2c113e Add --describe flag to {firmware|kernel}_utility.
This spews out useful information about a verified boot firmware/kernel image. Also adds a helper function to calculate header checksum. That code was being duplicated at multiple places.

Review URL: http://codereview.chromium.org/1088001
2010-03-18 13:10:10 -07:00
Gaurav Shah
ccaa90f735 Add fuzz testing driver programs for kernel and firmware verification.
The driver programs are useful in quick and dirty fuzz testing of the verification code with blind smartfuzzers like Bunny (http://code.google.com/p/bunny-the-fuzzer/).

Also fixes a bug with image generation in kernel_utility.

Tests: All existing tests still pass. VerifyKernel() and VerifyFirmware() can successfully verify images generated by {firmware|kernel}_utility.

Review URL: http://codereview.chromium.org/975007
2010-03-17 20:40:23 -07:00
Gaurav Shah
4f39386902 Add a command line string field to verified boot kernel config image.
Also some cleanup of duplicated code.

BUG=670
TEST=Existing image verification tests still pass.

Review URL: http://codereview.chromium.org/874006
2010-03-12 18:13:24 -08:00
Gaurav Shah
259de40640 VBoot Reference: Fix many memory leaks.
Fix memory leaks found using Valgrind, adds sanity checking to RSAPublicKey parsing code to prevent crazy behavior.

Review URL: http://codereview.chromium.org/858008
2010-03-12 17:42:03 -08:00
Gaurav Shah
48ed9b87eb Vboot Reference: Initialize local pointers with NULL.
I tried this with the build_autotest.sh and the test built successfully this time. Hopefully this is the end of the autotest compile errors.

Review URL: http://codereview.chromium.org/874003
2010-03-11 16:31:35 -08:00
Gaurav Shah
16ca324d43 Check return value on write() to fix warning.
Review URL: http://codereview.chromium.org/861003
2010-03-11 13:41:25 -08:00
Gaurav Shah
0a8864f494 Enable SHA1 optimizations (faster bit twiddling) and SHA2 optimizations (loop unroll).
Review URL: http://codereview.chromium.org/850002
2010-03-11 10:29:09 -08:00
Gaurav Shah
456678b0c4 Vboot Reference: Make length types explicitly sized.
Review URL: http://codereview.chromium.org/744002
2010-03-10 18:38:45 -08:00
Gaurav Shah
a6fb7a6f5c Include missing header.
This should fix the building error on the buildbot.

Review URL: http://codereview.chromium.org/668100
2010-03-04 15:00:50 -08:00
Gaurav Shah
cb3d22e971 Fix RSA verification test.
I previously refactored some of the signature generation code to directly use the OpenSSL library instead of invoking the "openssl" command line utility. The signature_digest command line utility got lost in the process. This restores the utility which in turn fixes the RSA verification test.

Review URL: http://codereview.chromium.org/669040
2010-03-04 10:22:36 -08:00
Gaurav Shah
80d129b89d Vboot Reference: Kernel Boot signing utility.
Fixes a unallocated memory bug in ReadKernelImage(). Some renaming of variables for consistency.

Review URL: http://codereview.chromium.org/669014
2010-03-03 17:58:43 -08:00
Gaurav Shah
56c9f4dfa7 Add a README and turn-on optimizations.
Review URL: http://codereview.chromium.org/665009
2010-03-03 13:15:53 -08:00
Gaurav Shah
f5564fa98c Vboot Reference: Refactor Code.
This CL does the following:
1) It adds a SignatureBuf function which uses the OpenSSL library to generate RSA signature. This is more robust than the previous way of invoking the command line "openssl" utility and capturing its output. No more unnecessary temporary files for signature operations.
2) It adds functions that allow direct manipulation of binary verified Firmware and Kernel Image blobs in memory.
3) It changes the structure field members for FirmwareImage to make it consistent with KernelImage. Now it's clearer which key is used when.
4) Minor bug fixes and slightly improved API for dealing verified boot firmware and kernel images.
5) Renames the RSA_verify function to prevent conflicts with OpenSSL since it's linked into the firmware utility binary.

Review URL: http://codereview.chromium.org/661353
2010-03-02 15:40:01 -08:00
Gaurav Shah
444e1e19f2 Make SHA benchmark output follow convention.
Review URL: http://codereview.chromium.org/660317
2010-03-01 20:25:03 -08:00
Gaurav Shah
c7daf38f70 Fix a typo in the RSA benchmark.
Also fix error handling in RSAPublicKeyFromBuf().

BUG=1210
TEST=none

Review URL: http://codereview.chromium.org/660310
2010-03-01 20:24:37 -08:00
Gaurav Shah
cae5fa613a Refactor siglen_map[] to store key size in bytes instead of 32-bit words.
Review URL: http://codereview.chromium.org/660261
2010-02-28 20:02:29 -08:00
Gaurav Shah
f67bcaa9a6 Vboot Reference: Add functions to verify signed kernel images.
BUG=670
TEST=Adds kernel_image_test which tests the new functions.

The kernel image verification pretty much exactly mirror the already existing firmware image verification functions except with a few different/additional fields in a signed kernel image. The firmware signing key is the root key equivalent for kernel images.

This CL also moves the image verification tests to a different script. There's some additional cleanup of the code that I will be submitting separately after this and another pending patches get LGTMed and land.

Review URL: http://codereview.chromium.org/660161
2010-02-28 19:18:24 -08:00
Gaurav Shah
8b95c70373 Make crypto benchmark output compatible with autotest.
Review URL: http://codereview.chromium.org/660228
2010-02-28 12:50:29 -08:00
Gaurav Shah
3d4cb84ab6 use uint16_max.
Review URL: http://codereview.chromium.org/661221
2010-02-26 15:39:21 -08:00
Gaurav Shah
23a2f3a6c5 Vboot reference: A basic user-land verified boot firmware signing and verification utility.
This is a first cut at what I envision as a utility we can use to manage our firmware/kernel signing needs. Currently, it implements firmware signing (given a binary image, create a verified boot header) and verification (given a verified boot image, verify it using the given public root key).

This CL also fixes the ReadFirmwareImage function from firmware_image to make it more consistent and fixes some bugs.

Review URL: http://codereview.chromium.org/652216
2010-02-26 15:09:43 -08:00
Gaurav Shah
7d122e2a47 Add a test for RSA PKCS #1 v1.5 signature verification.
This test checks that signatures with improper padding do not get accepted by the RSA signature verification implementation.

Review URL: http://codereview.chromium.org/661038
2010-02-24 16:41:32 -08:00
Gaurav Shah
08df9b88a3 Vboot Reference: Add the "real" reference firmware verification function (VerifyFirmware).
The old VerifyFirmware function (now called VerifyFirmwareImage) works on the FirmwareImage structure. This CL adds a verification function which can be used directly on packed binary verified boot firmware blobs. This function can be used as the reference implementation for verified boot in firmware. In addition, all functions that work on FirmwareImage structure have been renames to distinguish them from those which work on binary firmware blobs.

In addition, this adds some new crypto utility functions and refactors old ones.
BUG=670
TEST=Added tests for the new function and they pass.

Review URL: http://codereview.chromium.org/650105
2010-02-23 16:16:23 -08:00
Gaurav Shah
4a3189fb26 Vboot Reference: Make firmware image verification test handle errors gracefully.
The test should bail immediately on an unrecoverable error.

Review URL: http://codereview.chromium.org/647027
2010-02-18 10:53:05 -08:00
Gaurav Shah
52898d3c26 Vboot Reference: Add a RSA verify benchmark.
In addtion, add test cases and a script to generate them for benchmarking. Also fixes a path problem with the run_rsa_tests.sh script.

Review URL: http://codereview.chromium.org/626011
2010-02-17 16:37:33 -08:00
Gaurav Shah
27bfc8be07 Vboot Reference: Conditionally set Makefile CC variable so that it cross-compiles.
Review URL: http://codereview.chromium.org/629003
2010-02-17 14:19:24 -08:00
Gaurav Shah
7ca31f3e4d Vboot Reference: Misc style fixes to Makefile and fix testing script.
Review URL: http://codereview.chromium.org/600114
2010-02-16 19:04:11 -08:00
Gaurav Shah
431b98886e Data structure and interface for manipulating and handing firmware images for verified boot.
Review URL: http://codereview.chromium.org/564020
2010-02-12 15:54:37 -08:00
Gaurav Shah
1a055adf7b VBoot Reference: Make RSA verification test script return the right error code.
Also rename and modify run_tests.sh to only run the RSA verification tests. The SHA message digest tests must now be invoked separately.

Review URL: http://codereview.chromium.org/596080
2010-02-12 13:05:03 -08:00
Gaurav Shah
cc1dd99ae7 SHA* digest function speed test.
BUG=1210
TEST=This is a test,

Review URL: http://codereview.chromium.org/596079
2010-02-12 11:21:18 -08:00
Gaurav Shah
6f555397b1 Make verify_data return the correct error code.
Review URL: http://codereview.chromium.org/600093
2010-02-11 21:04:49 -08:00
Gaurav Shah
e3ef9c9f40 Vboot Reference: Move test key generation to a separate script and add sample test keys.
Key generation takes a long time. This will be useful in driving the cryptosuite through autotest.

Review URL: http://codereview.chromium.org/604016
2010-02-10 23:07:02 -08:00
Gaurav Shah
1f81a6f936 Refactor code from test/ to utils/ since they are not just used by tests.
Also, adds a simple analog of verify_data.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/578025
2010-02-06 14:34:31 -08:00
Gaurav Shah
355031b445 Fix lost variable declarations due to a botched merge on the previous push.
Also remove the len parameter to read_RSAkey since it's not used or required any more.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/579009
2010-02-05 15:00:23 -08:00
Gaurav Shah
290e0788fb Add generic wrappers for performing message digest operations.
A DigestContext structure now wraps state for all the SHA* algorithms. Replaced the old SHA*_file functions to use these new wrappers. Also moved the digest utility functions from tests/ to crypto/.

BUG=670
TEST=Modified existing tests to use the new wrappers and they pass.

Review URL: http://codereview.chromium.org/579007
2010-02-05 14:37:30 -08:00
Gaurav Shah
e178fd9e34 Add some convenience/helper functions for RSA. Modify test utility to use the new function.
BUG=670
TEST=RSA verification test using the convenience function is passes.

Review URL: http://codereview.chromium.org/575019
2010-02-05 11:44:58 -08:00
Gaurav Shah
d067712ff9 Add a StatefulMemcpy which can be used to safely and iteratively copy blocks of memory.
Review URL: http://codereview.chromium.org/572024
2010-02-04 19:35:03 -08:00
Gaurav Shah
73bfa0768e Make SHA* function prototypes consistent.
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/572025
2010-02-04 19:08:06 -08:00
Gaurav Shah
3a878528da Fix copyright header on padding.h.
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/570038
2010-02-04 18:58:48 -08:00
Gaurav Shah
d857f2a71c Minor fix to the "clean" Makefile target.
Review URL: http://codereview.chromium.org/549223
2010-02-01 16:58:33 -08:00
Gaurav Shah
8bf29d8ea1 Utility to output digests in format suitable for RSA signatures.
The current stable version of OpenSSL(0.9.8d) does not support RSA signature with SHA-256 and SHA-512 message digests. This utility outputs the hash of file data in a format suitable for use with the "openssl" command-line tool fir generating RSA signatures.

Also modified the tests to use this to generate RSA signature rather than "openssl pkeyutl" which is not supported on current stable version of OpenSSL.

Review URL: http://codereview.chromium.org/552227
2010-01-28 19:43:24 -08:00
Gaurav Shah
321f310040 Refactor SHA*_file functions into a separate file. Generate them using a C macro.
Review URL: http://codereview.chromium.org/558025
2010-01-28 16:59:42 -08:00