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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 uint8_t* corrupt_firmwareA = NULL; | 23 uint8_t* corrupt_firmwareA = NULL; |
24 uint8_t* corrupt_firmwareB = NULL; | 24 uint8_t* corrupt_firmwareB = NULL; |
25 uint64_t len; | 25 uint64_t len; |
26 uint8_t* root_key_pub = BufferFromFile("testkeys/key_rsa8192.keyb", | 26 uint8_t* root_key_pub = BufferFromFile("testkeys/key_rsa8192.keyb", |
27 &len); | 27 &len); |
28 | 28 |
29 /* Initialize rollback index state. */ | 29 /* Initialize rollback index state. */ |
30 g_firmware_key_version = 1; | 30 g_firmware_key_version = 1; |
31 g_firmware_version = 1; | 31 g_firmware_version = 1; |
32 | 32 |
33 valid_firmwareA = GenerateRollbackTestImage(1, 1, 0); | 33 valid_firmwareA = GenerateRollbackTestFirmwareBlob(1, 1, 0); |
34 valid_firmwareB = GenerateRollbackTestImage(1, 1, 0); | 34 valid_firmwareB = GenerateRollbackTestFirmwareBlob(1, 1, 0); |
35 corrupt_firmwareA = GenerateRollbackTestImage(1, 1, 1); | 35 corrupt_firmwareA = GenerateRollbackTestFirmwareBlob(1, 1, 1); |
36 corrupt_firmwareB = GenerateRollbackTestImage(1, 1, 1); | 36 corrupt_firmwareB = GenerateRollbackTestFirmwareBlob(1, 1, 1); |
37 | 37 |
38 TEST_EQ(VerifyFirmwareDriver_f(root_key_pub, | 38 TEST_EQ(VerifyFirmwareDriver_f(root_key_pub, |
39 valid_firmwareA, valid_firmwareB), | 39 valid_firmwareA, valid_firmwareB), |
40 BOOT_FIRMWARE_A_CONTINUE, | 40 BOOT_FIRMWARE_A_CONTINUE, |
41 "Firmware A (Valid with current version), " | 41 "Firmware A (Valid with current version), " |
42 "Firmware B (Valid with current version)"); | 42 "Firmware B (Valid with current version)"); |
43 TEST_EQ(VerifyFirmwareDriver_f(root_key_pub, | 43 TEST_EQ(VerifyFirmwareDriver_f(root_key_pub, |
44 corrupt_firmwareA, valid_firmwareB), | 44 corrupt_firmwareA, valid_firmwareB), |
45 BOOT_FIRMWARE_B_CONTINUE, | 45 BOOT_FIRMWARE_B_CONTINUE, |
46 "Firmware A (Corrupt with current version), " | 46 "Firmware A (Corrupt with current version), " |
(...skipping 22 matching lines...) Expand all Loading... |
69 Free(corrupt_firmwareB); | 69 Free(corrupt_firmwareB); |
70 } | 70 } |
71 | 71 |
72 int main(int argc, char* argv[]) { | 72 int main(int argc, char* argv[]) { |
73 int error_code = 0; | 73 int error_code = 0; |
74 VerifyFirmwareDriverTest(); | 74 VerifyFirmwareDriverTest(); |
75 if (!gTestSuccess) | 75 if (!gTestSuccess) |
76 error_code = 255; | 76 error_code = 255; |
77 return error_code; | 77 return error_code; |
78 } | 78 } |
OLD | NEW |