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

Side by Side Diff: tests/firmware_verify_benchmark.c

Issue 2871033: Switch to using .vbprivk for signing everything now. (Closed) Base URL: ssh://git@chromiumos-git//vboot_reference.git
Patch Set: Okay, now tests pass again. Created 10 years, 5 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 * Timing benchmark for verifying a firmware image. 5 * Timing benchmark for verifying a firmware image.
6 */ 6 */
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) 54 for (i = 0; i < NUM_SIZES_TO_TEST; ++i)
55 firmware_blobs[i] = NULL; 55 firmware_blobs[i] = NULL;
56 56
57 key_size = siglen_map[algorithm] * 8; /* in bits. */ 57 key_size = siglen_map[algorithm] * 8; /* in bits. */
58 snprintf(firmware_sign_key_file, FILE_NAME_SIZE, "testkeys/key_rsa%d.pem", 58 snprintf(firmware_sign_key_file, FILE_NAME_SIZE, "testkeys/key_rsa%d.pem",
59 key_size); 59 key_size);
60 60
61 snprintf(file_name, FILE_NAME_SIZE, "testkeys/key_rsa%d.keyb", key_size); 61 snprintf(file_name, FILE_NAME_SIZE, "testkeys/key_rsa%d.keyb", key_size);
62 firmware_sign_key = BufferFromFile(file_name, &len); 62 firmware_sign_key = BufferFromFile(file_name, &len);
63 if (!firmware_sign_key) { 63 if (!firmware_sign_key) {
64 debug("Couldn't read pre-processed firmware signing key.\n"); 64 VBDEBUG(("Couldn't read pre-processed firmware signing key.\n"));
65 error_code = 1; 65 error_code = 1;
66 goto cleanup; 66 goto cleanup;
67 } 67 }
68 68
69 /* Generate test images. */ 69 /* Generate test images. */
70 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) { 70 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) {
71 firmware_blobs[i] = (uint8_t*) Malloc(g_firmware_sizes_to_test[i]); 71 firmware_blobs[i] = (uint8_t*) Malloc(g_firmware_sizes_to_test[i]);
72 Memset(firmware_blobs[i], 'F', g_firmware_sizes_to_test[i]); 72 Memset(firmware_blobs[i], 'F', g_firmware_sizes_to_test[i]);
73 verification_blobs[i] = GenerateTestVerificationBlob( 73 verification_blobs[i] = GenerateTestVerificationBlob(
74 algorithm, 74 algorithm,
75 firmware_sign_key, 75 firmware_sign_key,
76 1, /* firmware key version. */ 76 1, /* firmware key version. */
77 1, /* firmware version. */ 77 1, /* firmware version. */
78 g_firmware_sizes_to_test[i], 78 g_firmware_sizes_to_test[i],
79 "testkeys/key_rsa8192.pem", 79 "testkeys/key_rsa8192.pem",
80 firmware_sign_key_file); 80 firmware_sign_key_file);
81 if (!firmware_blobs[i]) { 81 if (!firmware_blobs[i]) {
82 debug("Couldn't generate test firmware images.\n"); 82 VBDEBUG(("Couldn't generate test firmware images.\n"));
83 error_code = 1; 83 error_code = 1;
84 goto cleanup; 84 goto cleanup;
85 } 85 }
86 } 86 }
87 87
88 /* Get pre-processed key used for verification. */ 88 /* Get pre-processed key used for verification. */
89 root_key_blob = BufferFromFile("testkeys/key_rsa8192.keyb", &len); 89 root_key_blob = BufferFromFile("testkeys/key_rsa8192.keyb", &len);
90 if (!root_key_blob) { 90 if (!root_key_blob) {
91 debug("Couldn't read pre-processed rootkey.\n"); 91 VBDEBUG(("Couldn't read pre-processed rootkey.\n"));
92 error_code = 1; 92 error_code = 1;
93 goto cleanup; 93 goto cleanup;
94 } 94 }
95 95
96 /* Now run the timing tests. */ 96 /* Now run the timing tests. */
97 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) { 97 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) {
98 StartTimer(&ct); 98 StartTimer(&ct);
99 for (j = 0; j < NUM_OPERATIONS; ++j) { 99 for (j = 0; j < NUM_OPERATIONS; ++j) {
100 if (VERIFY_FIRMWARE_SUCCESS != 100 if (VERIFY_FIRMWARE_SUCCESS !=
101 VerifyFirmware(root_key_blob, 101 VerifyFirmware(root_key_blob,
102 verification_blobs[i], 102 verification_blobs[i],
103 firmware_blobs[i])) 103 firmware_blobs[i]))
104 debug("Warning: Firmware Verification Failed.\n"); 104 VBDEBUG(("Warning: Firmware Verification Failed.\n"));
105 } 105 }
106 StopTimer(&ct); 106 StopTimer(&ct);
107 msecs = (float) GetDurationMsecs(&ct) / NUM_OPERATIONS; 107 msecs = (float) GetDurationMsecs(&ct) / NUM_OPERATIONS;
108 fprintf(stderr, 108 fprintf(stderr,
109 "# Firmware (%s, Algo = %s):" 109 "# Firmware (%s, Algo = %s):"
110 "\t%.02f ms/verification\n", 110 "\t%.02f ms/verification\n",
111 g_firmware_size_labels[i], 111 g_firmware_size_labels[i],
112 algo_strings[algorithm], 112 algo_strings[algorithm],
113 msecs); 113 msecs);
114 fprintf(stdout, "ms_firmware_%s_rsa%d_%s:%.02f\n", 114 fprintf(stdout, "ms_firmware_%s_rsa%d_%s:%.02f\n",
(...skipping 14 matching lines...) Expand all
129 129
130 130
131 int main(int argc, char* argv[]) { 131 int main(int argc, char* argv[]) {
132 int i, error_code = 0; 132 int i, error_code = 0;
133 for (i = 0; i < kNumAlgorithms; ++i) { 133 for (i = 0; i < kNumAlgorithms; ++i) {
134 if (0 != (error_code = SpeedTestAlgorithm(i))) 134 if (0 != (error_code = SpeedTestAlgorithm(i)))
135 return error_code; 135 return error_code;
136 } 136 }
137 return 0; 137 return 0;
138 } 138 }
OLDNEW
« no previous file with comments | « tests/big_kernel_tests.c ('k') | tests/kernel_rollback_tests.c » ('j') | utility/vbutil_key.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698