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

Side by Side Diff: src/platform/vboot_reference/tests/firmware_image_tests.c

Issue 652216: Vboot reference: A basic user-land verified boot firmware signing and verification utility. (Closed)
Patch Set: Style fixes. Segfault fix. Created 10 years, 9 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
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 * Tests for firmware image library. 5 * Tests for firmware image library.
6 */ 6 */
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 success = 0; 147 success = 0;
148 if (!TEST_EQ(VerifyFirmwareImage(root_key, image, DEV_MODE_DISABLED), 148 if (!TEST_EQ(VerifyFirmwareImage(root_key, image, DEV_MODE_DISABLED),
149 VERIFY_FIRMWARE_ROOT_SIGNATURE_FAILED, 149 VERIFY_FIRMWARE_ROOT_SIGNATURE_FAILED,
150 "FirmwareImage Root Signature Tamper Verification (Trusted)")) 150 "FirmwareImage Root Signature Tamper Verification (Trusted)"))
151 success = 0; 151 success = 0;
152 152
153 return success; 153 return success;
154 } 154 }
155 155
156 int main(int argc, char* argv[]) { 156 int main(int argc, char* argv[]) {
157 int len; 157 uint32_t len;
158 uint8_t* sign_key_buf = NULL; 158 uint8_t* sign_key_buf = NULL;
159 uint8_t* root_key_blob = NULL; 159 uint8_t* root_key_blob = NULL;
160 uint8_t* firmware_blob = NULL; 160 uint8_t* firmware_blob = NULL;
161 FirmwareImage* image = NULL; 161 FirmwareImage* image = NULL;
162 RSAPublicKey* root_key = NULL; 162 RSAPublicKey* root_key = NULL;
163 int error_code = 1; 163 int error_code = 1;
164 char* tmp_firmwareblob_file = ".tmpFirmwareBlob"; 164 char* tmp_firmwareblob_file = ".tmpFirmwareBlob";
165 165
166 if(argc != 6) { 166 if(argc != 6) {
167 fprintf(stderr, "Usage: %s <algorithm> <root key> <processed root pubkey>" 167 fprintf(stderr, "Usage: %s <algorithm> <root key> <processed root pubkey>"
168 " <signing key> <processed signing key>\n", argv[0]); 168 " <signing key> <processed signing key>\n", argv[0]);
169 return -1; 169 return -1;
170 } 170 }
171 171
172 /* Read verification keys and create a test image. */ 172 /* Read verification keys and create a test image. */
173 root_key = RSAPublicKeyFromFile(argv[3]); 173 root_key = RSAPublicKeyFromFile(argv[3]);
174 root_key_blob = BufferFromFile(argv[3], &len); 174 root_key_blob = BufferFromFile(argv[3], &len);
175 sign_key_buf = BufferFromFile(argv[5], &len); 175 sign_key_buf = BufferFromFile(argv[5], &len);
176 image = GenerateTestFirmwareImage(atoi(argv[1]), sign_key_buf, 1, 176 image = GenerateTestFirmwareImage(atoi(argv[1]), sign_key_buf, 1,
177 1, 1000); 177 1, 1000);
178 178
179 if (!root_key || !sign_key_buf || !image) { 179 if (!root_key || !sign_key_buf || !image) {
180 error_code = 1; 180 error_code = 1;
181 goto failure; 181 goto failure;
182 } 182 }
183 183
184 /* Generate and populate signatures. */ 184 /* Generate and populate signatures. */
185 if (!AddKeySignature(image, argv[2])) { 185 if (!AddFirmwareKeySignature(image, argv[2])) {
186 fprintf(stderr, "Couldn't create key signature.\n"); 186 fprintf(stderr, "Couldn't create key signature.\n");
187 error_code = 1; 187 error_code = 1;
188 goto failure; 188 goto failure;
189 } 189 }
190 190
191 if (!AddFirmwareSignature(image, argv[4], image->sign_algorithm)) { 191 if (!AddFirmwareSignature(image, argv[4], image->sign_algorithm)) {
192 fprintf(stderr, "Couldn't create firmware and preamble signature.\n"); 192 fprintf(stderr, "Couldn't create firmware and preamble signature.\n");
193 error_code = 1; 193 error_code = 1;
194 goto failure; 194 goto failure;
195 } 195 }
(...skipping 24 matching lines...) Expand all
220 220
221 failure: 221 failure:
222 Free(firmware_blob); 222 Free(firmware_blob);
223 Free(image); 223 Free(image);
224 Free(sign_key_buf); 224 Free(sign_key_buf);
225 Free(root_key_blob); 225 Free(root_key_blob);
226 Free(root_key); 226 Free(root_key);
227 227
228 return error_code; 228 return error_code;
229 } 229 }
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/include/firmware_utility.h ('k') | src/platform/vboot_reference/tests/rsa_verify_benchmark.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698