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
This commit is contained in:
Gaurav Shah
2010-03-17 20:40:23 -07:00
parent 4f39386902
commit ccaa90f735
6 changed files with 203 additions and 9 deletions

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Utility for manipulating verified boot firmware images.
// Utility for manipulating verified boot kernel images.
//
#include "kernel_utility.h"
@@ -55,7 +55,7 @@ KernelUtility::~KernelUtility() {
void KernelUtility::PrintUsage(void) {
cerr <<
"Utility to generate/verify a verified boot kernel image\n\n"
"Usage: firmware_utility <--generate|--verify> [OPTIONS]\n\n"
"Usage: kernel_utility <--generate|--verify> [OPTIONS]\n\n"
"For \"--verify\", required OPTIONS are:\n"
"--in <infile>\t\t\tVerified boot kernel image to verify.\n"
"--firmware_key_pub <pubkeyfile>\tPre-processed public firmware key "
@@ -227,7 +227,11 @@ bool KernelUtility::GenerateSignedImage(void) {
sizeof(image_->header_version));
DigestUpdate(&ctx, reinterpret_cast<uint8_t*>(&image_->header_len),
sizeof(image_->header_len));
DigestUpdate(&ctx, reinterpret_cast<uint8_t*>(&image_->kernel_sign_algorithm),
DigestUpdate(&ctx,
reinterpret_cast<uint8_t*>(&image_->firmware_sign_algorithm),
sizeof(image_->firmware_sign_algorithm));
DigestUpdate(&ctx,
reinterpret_cast<uint8_t*>(&image_->kernel_sign_algorithm),
sizeof(image_->kernel_sign_algorithm));
DigestUpdate(&ctx, reinterpret_cast<uint8_t*>(&image_->kernel_key_version),
sizeof(image_->kernel_key_version));
@@ -248,12 +252,12 @@ bool KernelUtility::GenerateSignedImage(void) {
return false;
// Generate and add the signatures.
if (!AddKernelKeySignature(image_, firmware_key_file_.c_str())) {
cerr << "Couldn't write key signature to verified boot image.\n";
cerr << "Couldn't write key signature to verified boot kernel image.\n";
return false;
}
if (!AddKernelSignature(image_, kernel_key_file_.c_str())) {
cerr << "Couldn't write firmware signature to verified boot image.\n";
cerr << "Couldn't write firmware signature to verified boot kernel image.\n";
return false;
}
return true;
@@ -270,7 +274,7 @@ bool KernelUtility::VerifySignedImage(void) {
}
if (!image_) {
cerr << "Couldn't read firmware image or malformed image.\n";
cerr << "Couldn't read kernel image or malformed image.\n";
return false;
}
if (!(error = VerifyKernelImage(firmware_key_pub_, image_, 0)))