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 * Tests for checking firmware rollback-prevention logic. | 5 * Tests for checking firmware rollback-prevention logic. |
6 */ | 6 */ |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 | 10 |
11 #include "file_keys.h" | 11 #include "file_keys.h" |
12 #include "firmware_image.h" | 12 #include "firmware_image.h" |
13 #include "rsa_utility.h" | 13 #include "rsa_utility.h" |
14 #include "utility.h" | 14 #include "utility.h" |
15 #include "rollback_index.h" | 15 #include "rollback_index.h" |
16 #include "test_common.h" | 16 #include "test_common.h" |
17 | 17 |
| 18 const char* kRootKeyPublicFile = "testkeys/key_rsa8192.keyb"; |
| 19 |
18 /* Tests that check for correctness of the VerifyFirmwareDriver_f() logic | 20 /* Tests that check for correctness of the VerifyFirmwareDriver_f() logic |
19 * and rollback prevention. */ | 21 * and rollback prevention. */ |
20 void VerifyFirmwareDriverTest(void) { | 22 void VerifyFirmwareDriverTest(void) { |
21 uint8_t* valid_firmwareA = NULL; | 23 uint8_t* valid_firmwareA = NULL; |
22 uint8_t* valid_firmwareB = NULL; | 24 uint8_t* valid_firmwareB = NULL; |
23 uint8_t* corrupt_firmwareA = NULL; | 25 uint8_t* corrupt_firmwareA = NULL; |
24 uint8_t* corrupt_firmwareB = NULL; | 26 uint8_t* corrupt_firmwareB = NULL; |
25 uint64_t len; | 27 uint64_t len; |
26 uint8_t* root_key_pub = BufferFromFile("testkeys/key_rsa8192.keyb", | 28 uint8_t* root_key_pub = BufferFromFile(kRootKeyPublicFile, &len); |
27 &len); | |
28 | 29 |
29 /* Initialize rollback index state. */ | 30 /* Initialize rollback index state. */ |
30 g_firmware_key_version = 1; | 31 g_firmware_key_version = 1; |
31 g_firmware_version = 1; | 32 g_firmware_version = 1; |
32 | 33 |
33 valid_firmwareA = GenerateRollbackTestFirmwareBlob(1, 1, 0); | 34 valid_firmwareA = GenerateRollbackTestFirmwareBlob(1, 1, 0); |
34 valid_firmwareB = GenerateRollbackTestFirmwareBlob(1, 1, 0); | 35 valid_firmwareB = GenerateRollbackTestFirmwareBlob(1, 1, 0); |
35 corrupt_firmwareA = GenerateRollbackTestFirmwareBlob(1, 1, 1); | 36 corrupt_firmwareA = GenerateRollbackTestFirmwareBlob(1, 1, 1); |
36 corrupt_firmwareB = GenerateRollbackTestFirmwareBlob(1, 1, 1); | 37 corrupt_firmwareB = GenerateRollbackTestFirmwareBlob(1, 1, 1); |
37 | 38 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 Free(corrupt_firmwareB); | 70 Free(corrupt_firmwareB); |
70 } | 71 } |
71 | 72 |
72 int main(int argc, char* argv[]) { | 73 int main(int argc, char* argv[]) { |
73 int error_code = 0; | 74 int error_code = 0; |
74 VerifyFirmwareDriverTest(); | 75 VerifyFirmwareDriverTest(); |
75 if (!gTestSuccess) | 76 if (!gTestSuccess) |
76 error_code = 255; | 77 error_code = 255; |
77 return error_code; | 78 return error_code; |
78 } | 79 } |
OLD | NEW |