OLD | NEW |
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // Calculate header checksum. | 196 // Calculate header checksum. |
197 CalculateFirmwareHeaderChecksum(image_, image_->header_checksum); | 197 CalculateFirmwareHeaderChecksum(image_, image_->header_checksum); |
198 | 198 |
199 image_->firmware_version = firmware_version_; | 199 image_->firmware_version = firmware_version_; |
200 image_->firmware_len = 0; | 200 image_->firmware_len = 0; |
201 // TODO(gauravsh): Populate this with the right bytes once we decide | 201 // TODO(gauravsh): Populate this with the right bytes once we decide |
202 // what goes into the preamble. | 202 // what goes into the preamble. |
203 Memset(image_->preamble, 'P', FIRMWARE_PREAMBLE_SIZE); | 203 Memset(image_->preamble, 'P', FIRMWARE_PREAMBLE_SIZE); |
204 image_->firmware_data = BufferFromFile(in_file_.c_str(), | 204 image_->firmware_data = BufferFromFile(in_file_.c_str(), |
205 &image_->firmware_len); | 205 &image_->firmware_len); |
206 if (!image_) | 206 if (!image_->firmware_data) |
207 return false; | 207 return false; |
208 // Generate and add the signatures. | 208 // Generate and add the signatures. |
209 if (!AddFirmwareKeySignature(image_, root_key_file_.c_str())) { | 209 if (!AddFirmwareKeySignature(image_, root_key_file_.c_str())) { |
210 cerr << "Couldn't write key signature to verified boot image.\n"; | 210 cerr << "Couldn't write key signature to verified boot image.\n"; |
211 return false; | 211 return false; |
212 } | 212 } |
213 | 213 |
214 if (!AddFirmwareSignature(image_, firmware_key_file_.c_str())) { | 214 if (!AddFirmwareSignature(image_, firmware_key_file_.c_str())) { |
215 cerr << "Couldn't write firmware signature to verified boot image.\n"; | 215 cerr << "Couldn't write firmware signature to verified boot image.\n"; |
216 return false; | 216 return false; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 312 } |
313 if (fu.is_verify()) { | 313 if (fu.is_verify()) { |
314 cerr << "Verification "; | 314 cerr << "Verification "; |
315 if (fu.VerifySignedImage()) | 315 if (fu.VerifySignedImage()) |
316 cerr << "SUCCESS.\n"; | 316 cerr << "SUCCESS.\n"; |
317 else | 317 else |
318 cerr << "FAILURE.\n"; | 318 cerr << "FAILURE.\n"; |
319 } | 319 } |
320 return 0; | 320 return 0; |
321 } | 321 } |
OLD | NEW |