| 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 * Functions for generating and manipulating a verified boot firmware image. | 5 * Functions for generating and manipulating a verified boot firmware image. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "firmware_image.h" | 8 #include "firmware_image.h" |
| 9 | 9 |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 if(st.remaining_len != 0) { /* Overrun or underrun. */ | 128 if(st.remaining_len != 0) { /* Overrun or underrun. */ |
| 129 Free(firmware_buf); | 129 Free(firmware_buf); |
| 130 return NULL; | 130 return NULL; |
| 131 } | 131 } |
| 132 | 132 |
| 133 Free(firmware_buf); | 133 Free(firmware_buf); |
| 134 return image; | 134 return image; |
| 135 } | 135 } |
| 136 | 136 |
| 137 int GetFirmwareHeaderLen(const FirmwareImage* image) { | 137 int GetFirmwareHeaderLen(const FirmwareImage* image) { |
| 138 return (FIELD_LEN(header_len) + FIELD_LEN(header_len) + | 138 return (FIELD_LEN(header_len) + FIELD_LEN(firmware_sign_algorithm) + |
| 139 RSAProcessedKeySize(image->firmware_sign_algorithm) + | 139 RSAProcessedKeySize(image->firmware_sign_algorithm) + |
| 140 FIELD_LEN(firmware_key_version) + FIELD_LEN(header_checksum)); | 140 FIELD_LEN(firmware_key_version) + FIELD_LEN(header_checksum)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 uint8_t* GetFirmwareHeaderBlob(const FirmwareImage* image) { | 143 uint8_t* GetFirmwareHeaderBlob(const FirmwareImage* image) { |
| 144 uint8_t* header_blob = NULL; | 144 uint8_t* header_blob = NULL; |
| 145 MemcpyState st; | 145 MemcpyState st; |
| 146 | 146 |
| 147 header_blob = (uint8_t*) Malloc(GetFirmwareHeaderLen(image)); | 147 header_blob = (uint8_t*) Malloc(GetFirmwareHeaderLen(image)); |
| 148 st.remaining_len = GetFirmwareHeaderLen(image); | 148 st.remaining_len = GetFirmwareHeaderLen(image); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 if (!(firmware_signature = SignatureBuf(image->firmware_data, | 579 if (!(firmware_signature = SignatureBuf(image->firmware_data, |
| 580 image->firmware_len, | 580 image->firmware_len, |
| 581 signing_key_file, | 581 signing_key_file, |
| 582 image->firmware_sign_algorithm))) | 582 image->firmware_sign_algorithm))) |
| 583 return 0; | 583 return 0; |
| 584 image->firmware_signature = (uint8_t*) Malloc(signature_len); | 584 image->firmware_signature = (uint8_t*) Malloc(signature_len); |
| 585 Memcpy(image->firmware_signature, firmware_signature, signature_len); | 585 Memcpy(image->firmware_signature, firmware_signature, signature_len); |
| 586 Free(firmware_signature); | 586 Free(firmware_signature); |
| 587 return 1; | 587 return 1; |
| 588 } | 588 } |
| OLD | NEW |