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

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

Issue 1519008: VBoot Reference: 18 Exabytes ought to be enough for everybody (Closed)
Patch Set: Use symbolic constants. Created 10 years, 8 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
(Empty)
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
3 * found in the LICENSE file.
4 *
5 * Tests if firmware image library deals with very large firmware. This
6 * is a quick and dirty test for detecting integer overflow issues.
7 */
8
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 #include "file_keys.h"
13 #include "firmware_image.h"
14 #include "rsa_utility.h"
15 #include "test_common.h"
16 #include "utility.h"
17
18 /* Choose a firmware size greater than the range of 32-bits unsigned. */
19 #define BIG_FIRMWARE_SIZE ((uint64_t) 0x100000000)
20
21 #define ROOT_KEY_BASE_NAME "testkeys/key_rsa8192"
22 #define FIRMWARE_KEY_BASE_NAME "testkeys/key_rsa1024"
23
24 const char* kRootKeyPublicFile = ROOT_KEY_BASE_NAME ".keyb";
25 const char* kRootKeyFile = ROOT_KEY_BASE_NAME ".pem";
26 const char* kFirmwareKeyPublicFile = FIRMWARE_KEY_BASE_NAME ".keyb";
27 const char* kFirmwareKeyFile = FIRMWARE_KEY_BASE_NAME ".pem";
28
29 int BigFirmwareTest(void) {
30 int error_code = 0;
31 uint64_t len;
32 uint8_t* firmware_blob = NULL;
33 RSAPublicKey* root_key = RSAPublicKeyFromFile(kRootKeyPublicFile);
34 uint8_t* root_key_blob = BufferFromFile(kRootKeyPublicFile, &len);
35 uint8_t* firmware_sign_key_buf= BufferFromFile(kFirmwareKeyPublicFile, &len);
36 fprintf(stderr, "Generating Big FirmwareImage...");
37 FirmwareImage* image =
38 GenerateTestFirmwareImage(0, /* RSA1024/SHA1 */
39 firmware_sign_key_buf,
40 1, /* Firmware Key Version. */
41 1, /* Firmware Version */
42 BIG_FIRMWARE_SIZE,
43 kRootKeyFile,
44 kFirmwareKeyFile,
45 'F'); /* Firmware data fill. */
46 if (!root_key || !root_key_blob || !firmware_sign_key_buf || !image) {
47 error_code = 1;
48 goto cleanup;
49 }
50 fprintf(stderr, "Done.\n");
51 TEST_EQ(VerifyFirmwareImage(root_key, image),
52 VERIFY_FIRMWARE_SUCCESS,
53 "Big FirmwareImage Verification");
54 firmware_blob = GetFirmwareBlob(image, &len);
55 TEST_EQ(VerifyFirmware(root_key_blob, firmware_blob),
56 VERIFY_FIRMWARE_SUCCESS,
57 "Big Firmware Blob Verification");
58
59 cleanup:
60 Free(firmware_blob);
61 FirmwareImageFree(image);
62 Free(firmware_sign_key_buf);
63 RSAPublicKeyFree(root_key);
64 return error_code;
65 }
66
67 int main(int argc, char* argv[1])
68 {
69 int error_code = 0;
70 error_code = BigFirmwareTest();
71 if (!gTestSuccess)
72 error_code = 255;
73 return error_code;
74 }
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/tests/Makefile ('k') | src/platform/vboot_reference/tests/big_kernel_tests.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698