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 * Common functions used by tests. | 5 * Common functions used by tests. |
6 */ | 6 */ |
7 | 7 |
8 #include "test_common.h" | 8 #include "test_common.h" |
9 | 9 |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 /* Populate firmware and preamble with dummy data. */ | 60 /* Populate firmware and preamble with dummy data. */ |
61 image->firmware_version = firmware_version; | 61 image->firmware_version = firmware_version; |
62 image->firmware_len = firmware_len; | 62 image->firmware_len = firmware_len; |
63 image->preamble_signature = image->firmware_signature = NULL; | 63 image->preamble_signature = image->firmware_signature = NULL; |
64 Memset(image->preamble, 'P', FIRMWARE_PREAMBLE_SIZE); | 64 Memset(image->preamble, 'P', FIRMWARE_PREAMBLE_SIZE); |
65 image->firmware_data = Malloc(image->firmware_len); | 65 image->firmware_data = Malloc(image->firmware_len); |
66 Memset(image->firmware_data, firmware_data_fill_char, image->firmware_len); | 66 Memset(image->firmware_data, firmware_data_fill_char, image->firmware_len); |
67 | 67 |
68 /* Generate and populate signatures. */ | 68 /* Generate and populate signatures. */ |
69 if (!AddFirmwareKeySignature(image, root_key_file)) { | 69 if (!AddFirmwareKeySignature(image, root_key_file)) { |
70 fprintf(stderr, "Couldn't create key signature.\n"); | 70 debug("Couldn't create key signature.\n"); |
71 FirmwareImageFree(image); | 71 FirmwareImageFree(image); |
72 return NULL; | 72 return NULL; |
73 } | 73 } |
74 | 74 |
75 if (!AddFirmwareSignature(image, firmware_key_file)) { | 75 if (!AddFirmwareSignature(image, firmware_key_file)) { |
76 fprintf(stderr, "Couldn't create firmware and preamble signature.\n"); | 76 debug("Couldn't create firmware and preamble signature.\n"); |
77 FirmwareImageFree(image); | 77 FirmwareImageFree(image); |
78 return NULL; | 78 return NULL; |
79 } | 79 } |
80 return image; | 80 return image; |
81 } | 81 } |
82 | 82 |
83 uint8_t* GenerateTestFirmwareBlob(int algorithm, | 83 uint8_t* GenerateTestFirmwareBlob(int algorithm, |
84 const uint8_t* firmware_sign_key, | 84 const uint8_t* firmware_sign_key, |
85 int firmware_key_version, | 85 int firmware_key_version, |
86 int firmware_version, | 86 int firmware_version, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 Memset(image->options.cmd_line, 0, sizeof(image->options.cmd_line)); | 171 Memset(image->options.cmd_line, 0, sizeof(image->options.cmd_line)); |
172 image->options.kernel_len = kernel_len; | 172 image->options.kernel_len = kernel_len; |
173 image->options.kernel_load_addr = 0; | 173 image->options.kernel_load_addr = 0; |
174 image->options.kernel_entry_addr = 0; | 174 image->options.kernel_entry_addr = 0; |
175 image->kernel_key_signature = image->kernel_signature = NULL; | 175 image->kernel_key_signature = image->kernel_signature = NULL; |
176 image->kernel_data = Malloc(kernel_len); | 176 image->kernel_data = Malloc(kernel_len); |
177 Memset(image->kernel_data, kernel_data_fill_char, kernel_len); | 177 Memset(image->kernel_data, kernel_data_fill_char, kernel_len); |
178 | 178 |
179 /* Generate and populate signatures. */ | 179 /* Generate and populate signatures. */ |
180 if (!AddKernelKeySignature(image, firmware_key_file)) { | 180 if (!AddKernelKeySignature(image, firmware_key_file)) { |
181 fprintf(stderr, "Couldn't create key signature.\n"); | 181 debug("Couldn't create key signature.\n"); |
182 KernelImageFree(image); | 182 KernelImageFree(image); |
183 return NULL; | 183 return NULL; |
184 } | 184 } |
185 | 185 |
186 if (!AddKernelSignature(image, kernel_key_file)) { | 186 if (!AddKernelSignature(image, kernel_key_file)) { |
187 fprintf(stderr, "Couldn't create kernel option and kernel signature.\n"); | 187 debug("Couldn't create kernel option and kernel signature.\n"); |
188 KernelImageFree(image); | 188 KernelImageFree(image); |
189 return NULL; | 189 return NULL; |
190 } | 190 } |
191 | 191 |
192 return image; | 192 return image; |
193 } | 193 } |
194 | 194 |
195 uint8_t* GenerateTestKernelBlob(int firmware_sign_algorithm, | 195 uint8_t* GenerateTestKernelBlob(int firmware_sign_algorithm, |
196 int kernel_sign_algorithm, | 196 int kernel_sign_algorithm, |
197 const uint8_t* kernel_sign_key, | 197 const uint8_t* kernel_sign_key, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 if (!image) | 242 if (!image) |
243 return NULL; | 243 return NULL; |
244 if (is_corrupt) { | 244 if (is_corrupt) { |
245 /* Invalidate image. */ | 245 /* Invalidate image. */ |
246 Memset(image->kernel_data, 'X', image->options.kernel_len); | 246 Memset(image->kernel_data, 'X', image->options.kernel_len); |
247 } | 247 } |
248 kernel_blob = GetKernelBlob(image, &len); | 248 kernel_blob = GetKernelBlob(image, &len); |
249 KernelImageFree(image); | 249 KernelImageFree(image); |
250 return kernel_blob; | 250 return kernel_blob; |
251 } | 251 } |
OLD | NEW |