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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 void FirmwareUtility::OutputSignedImage(void) { | 150 void FirmwareUtility::OutputSignedImage(void) { |
151 if (image_) { | 151 if (image_) { |
152 if (!WriteFirmwareImage(out_file_.c_str(), image_)) { | 152 if (!WriteFirmwareImage(out_file_.c_str(), image_)) { |
153 cerr << "Couldn't write verified boot image to file " | 153 cerr << "Couldn't write verified boot image to file " |
154 << out_file_ <<".\n"; | 154 << out_file_ <<".\n"; |
155 } | 155 } |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 bool FirmwareUtility::GenerateSignedImage(void) { | 159 bool FirmwareUtility::GenerateSignedImage(void) { |
160 uint32_t firmware_sign_key_pub_len; | 160 uint64_t firmware_sign_key_pub_len; |
161 uint8_t* header_checksum; | 161 uint8_t* header_checksum; |
162 DigestContext ctx; | 162 DigestContext ctx; |
163 image_ = FirmwareImageNew(); | 163 image_ = FirmwareImageNew(); |
164 | 164 |
165 Memcpy(image_->magic, FIRMWARE_MAGIC, FIRMWARE_MAGIC_SIZE); | 165 Memcpy(image_->magic, FIRMWARE_MAGIC, FIRMWARE_MAGIC_SIZE); |
166 | 166 |
167 // Copy pre-processed public signing key. | 167 // Copy pre-processed public signing key. |
168 image_->firmware_sign_algorithm = (uint16_t) firmware_sign_algorithm_; | 168 image_->firmware_sign_algorithm = (uint16_t) firmware_sign_algorithm_; |
169 image_->firmware_sign_key = BufferFromFile( | 169 image_->firmware_sign_key = BufferFromFile( |
170 firmware_key_pub_file_.c_str(), | 170 firmware_key_pub_file_.c_str(), |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } | 300 } |
301 if (fu.is_verify()) { | 301 if (fu.is_verify()) { |
302 cerr << "Verification "; | 302 cerr << "Verification "; |
303 if (fu.VerifySignedImage()) | 303 if (fu.VerifySignedImage()) |
304 cerr << "SUCCESS.\n"; | 304 cerr << "SUCCESS.\n"; |
305 else | 305 else |
306 cerr << "FAILURE.\n"; | 306 cerr << "FAILURE.\n"; |
307 } | 307 } |
308 return 0; | 308 return 0; |
309 } | 309 } |
OLD | NEW |