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

Side by Side Diff: src/platform/vboot_reference/utility/firmware_utility.cc

Issue 1525032: Add a --vblock option to firmware_utility to only output the verification block. (Closed)
Patch Set: fix typo Created 10 years, 8 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
« no previous file with comments | « no previous file | src/platform/vboot_reference/utility/include/firmware_utility.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Utility for manipulating verified boot firmware images. 5 // Utility for manipulating verified boot firmware images.
6 // 6 //
7 7
8 #include "firmware_utility.h" 8 #include "firmware_utility.h"
9 9
10 #include <errno.h> 10 #include <errno.h>
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 "For \"--generate\", required OPTIONS are:\n" 55 "For \"--generate\", required OPTIONS are:\n"
56 "--root_key <privkeyfile>\tPrivate root key file\n" 56 "--root_key <privkeyfile>\tPrivate root key file\n"
57 "--firmware_sign_key <privkeyfile>\tPrivate signing key file\n" 57 "--firmware_sign_key <privkeyfile>\tPrivate signing key file\n"
58 "--firmware_sign_key_pub <pubkeyfile>\tPre-processed public signing" 58 "--firmware_sign_key_pub <pubkeyfile>\tPre-processed public signing"
59 " key\n" 59 " key\n"
60 "--firmware_sign_algorithm <algoid>\tSigning algorithm to use\n" 60 "--firmware_sign_algorithm <algoid>\tSigning algorithm to use\n"
61 "--firmware_key_version <version#>\tSigning Key Version#\n" 61 "--firmware_key_version <version#>\tSigning Key Version#\n"
62 "--firmware_version <version#>\tFirmware Version#\n" 62 "--firmware_version <version#>\tFirmware Version#\n"
63 "--in <infile>\t\t\tFirmware Image to sign\n" 63 "--in <infile>\t\t\tFirmware Image to sign\n"
64 "--out <outfile>\t\t\tOutput file for verified boot firmware image\n\n" 64 "--out <outfile>\t\t\tOutput file for verified boot firmware image\n\n"
65 "Optional:\n"
66 " --vblock\t\t\tJust output the verification block\n\n"
65 "<algoid> (for --sign-algorithm) is one of the following:\n"; 67 "<algoid> (for --sign-algorithm) is one of the following:\n";
68
66 for (int i = 0; i < kNumAlgorithms; i++) { 69 for (int i = 0; i < kNumAlgorithms; i++) {
67 cerr << i << " for " << algo_strings[i] << "\n"; 70 cerr << i << " for " << algo_strings[i] << "\n";
68 } 71 }
69 cerr << "\n\n"; 72 cerr << "\n\n";
70 } 73 }
71 74
72 bool FirmwareUtility::ParseCmdLineOptions(int argc, char* argv[]) { 75 bool FirmwareUtility::ParseCmdLineOptions(int argc, char* argv[]) {
73 int option_index; 76 int option_index;
74 static struct option long_options[] = { 77 static struct option long_options[] = {
75 {"root_key", 1, 0, 0}, 78 {"root_key", 1, 0, 0},
76 {"root_key_pub", 1, 0, 0}, 79 {"root_key_pub", 1, 0, 0},
77 {"firmware_sign_key", 1, 0, 0}, 80 {"firmware_sign_key", 1, 0, 0},
78 {"firmware_sign_key_pub", 1, 0, 0}, 81 {"firmware_sign_key_pub", 1, 0, 0},
79 {"firmware_sign_algorithm", 1, 0, 0}, 82 {"firmware_sign_algorithm", 1, 0, 0},
80 {"firmware_key_version", 1, 0, 0}, 83 {"firmware_key_version", 1, 0, 0},
81 {"firmware_version", 1, 0, 0}, 84 {"firmware_version", 1, 0, 0},
82 {"in", 1, 0, 0}, 85 {"in", 1, 0, 0},
83 {"out", 1, 0, 0}, 86 {"out", 1, 0, 0},
84 {"generate", 0, 0, 0}, 87 {"generate", 0, 0, 0},
85 {"verify", 0, 0, 0}, 88 {"verify", 0, 0, 0},
86 {"describe", 0, 0, 0}, 89 {"describe", 0, 0, 0},
90 {"vblock", 0, 0, 0},
87 {NULL, 0, 0, 0} 91 {NULL, 0, 0, 0}
88 }; 92 };
89 while (1) { 93 while (1) {
90 int i = getopt_long(argc, argv, "", long_options, &option_index); 94 int i = getopt_long(argc, argv, "", long_options, &option_index);
91 if (-1 == i) // Done with option processing. 95 if (-1 == i) // Done with option processing.
92 break; 96 break;
93 if ('?' == i) // Invalid option found. 97 if ('?' == i) // Invalid option found.
94 return false; 98 return false;
95 99
96 if (0 == i) { 100 if (0 == i) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 break; 140 break;
137 case 9: // generate 141 case 9: // generate
138 is_generate_ = true; 142 is_generate_ = true;
139 break; 143 break;
140 case 10: // verify 144 case 10: // verify
141 is_verify_ = true; 145 is_verify_ = true;
142 break; 146 break;
143 case 11: // describe 147 case 11: // describe
144 is_describe_ = true; 148 is_describe_ = true;
145 break; 149 break;
150 case 12: // vblock
151 is_only_vblock_ = true;
152 break;
146 } 153 }
147 } 154 }
148 } 155 }
149 return CheckOptions(); 156 return CheckOptions();
150 } 157 }
151 158
152 159
153 void FirmwareUtility::OutputSignedImage(void) { 160 void FirmwareUtility::OutputSignedImage(void) {
154 if (image_) { 161 if (image_) {
155 if (!WriteFirmwareImage(out_file_.c_str(), image_)) { 162 if (!WriteFirmwareImage(out_file_.c_str(), image_, is_only_vblock_)) {
156 cerr << "Couldn't write verified boot image to file " 163 cerr << "Couldn't write verified boot image to file "
157 << out_file_ <<".\n"; 164 << out_file_ <<".\n";
158 } 165 }
159 } 166 }
160 } 167 }
161 168
162 void FirmwareUtility::DescribeSignedImage(void) { 169 void FirmwareUtility::DescribeSignedImage(void) {
163 image_ = ReadFirmwareImage(in_file_.c_str()); 170 image_ = ReadFirmwareImage(in_file_.c_str());
164 if (!image_) { 171 if (!image_) {
165 cerr << "Couldn't read firmware image or malformed image.\n"; 172 cerr << "Couldn't read firmware image or malformed image.\n";
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 311 }
305 if (fu.is_verify()) { 312 if (fu.is_verify()) {
306 cerr << "Verification "; 313 cerr << "Verification ";
307 if (fu.VerifySignedImage()) 314 if (fu.VerifySignedImage())
308 cerr << "SUCCESS.\n"; 315 cerr << "SUCCESS.\n";
309 else 316 else
310 cerr << "FAILURE.\n"; 317 cerr << "FAILURE.\n";
311 } 318 }
312 return 0; 319 return 0;
313 } 320 }
OLDNEW
« no previous file with comments | « no previous file | src/platform/vboot_reference/utility/include/firmware_utility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698