Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/platform/vboot_reference/tests/verify_kernel_fuzz_driver.c

Issue 975007: Add fuzz testing driver programs for kernel and firmware verification. (Closed)
Patch Set: Remove fuzz_testcaases directory. Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 *
5 * Utility for aiding fuzz testing of kernel image verification code.
6 */
7
8 #include <stdio.h>
9
10 #include "file_keys.h"
11 #include "kernel_image.h"
12 #include "utility.h"
13
14 int VerifySignedKernel(const char* image_file,
15 const char* firmware_key_file) {
16 int error, error_code = 0;
17 uint64_t len;
18 uint8_t* kernel_blob = BufferFromFile(image_file, &len);
19 uint8_t* firmware_key_blob = BufferFromFile(firmware_key_file, &len);
20
21 if (!firmware_key_blob) {
22 fprintf(stderr, "Couldn't read pre-processed public firmware key.\n");
23 error_code = 1;
24 }
25
26 if (!error_code && !kernel_blob) {
27 fprintf(stderr, "Couldn't read kernel image or malformed image.\n");
28 error_code = 1;
29 }
30
31 if (!error_code && (error = VerifyKernel(firmware_key_blob, kernel_blob,
32 0))) { /* Trusted Mode. */
33 fprintf(stderr, "%s\n", VerifyKernelErrorString(error));
34 error_code = 1;
35 }
36 Free(firmware_key_blob);
37 Free(kernel_blob);
38 if (error_code)
39 return 0;
40 return 1;
41 }
42
43 int main(int argc, char* argv[]) {
44 if (argc != 3) {
45 fprintf(stderr, "Usage: %s <image_to_verify> <firmware_keyb>\n", argv[0]);
46 return -1;
47 }
48 if (VerifySignedKernel(argv[1], argv[2])) {
49 fprintf(stderr, "Verification SUCCESS!\n");
50 return 0;
51 }
52 else {
53 fprintf(stderr, "Verification FAILURE!\n");
54 return -1;
55 }
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698