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

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

Issue 661353: Vboot Reference: Refactor Code. (Closed)
Patch Set: Review Fixes. 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 5
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "file_keys.h" 9 #include "file_keys.h"
10 #include "padding.h" 10 #include "padding.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 key_size, sha_strings[algorithm]); 57 key_size, sha_strings[algorithm]);
58 signature = BufferFromFile(file_name, &sig_len); 58 signature = BufferFromFile(file_name, &sig_len);
59 if (!signature) { 59 if (!signature) {
60 fprintf(stderr, "Couldn't read signature file.\n"); 60 fprintf(stderr, "Couldn't read signature file.\n");
61 error_code = 1; 61 error_code = 1;
62 goto failure; 62 goto failure;
63 } 63 }
64 64
65 StartTimer(&ct); 65 StartTimer(&ct);
66 for (i = 0; i < NUM_OPERATIONS; i++) { 66 for (i = 0; i < NUM_OPERATIONS; i++) {
67 if (!RSA_verify(key, signature, sig_len, algorithm, digest)) 67 if (!RSAVerify(key, signature, sig_len, algorithm, digest))
68 fprintf(stderr, "Warning: Signature Check Failed.\n"); 68 fprintf(stderr, "Warning: Signature Check Failed.\n");
69 } 69 }
70 StopTimer(&ct); 70 StopTimer(&ct);
71 71
72 msecs = (float) GetDurationMsecs(&ct) / NUM_OPERATIONS; 72 msecs = (float) GetDurationMsecs(&ct) / NUM_OPERATIONS;
73 speed = 1000.0 / msecs ; 73 speed = 1000.0 / msecs ;
74 fprintf(stderr, "# rsa%d/%s:\tTime taken per verification = %.02f ms," 74 fprintf(stderr, "# rsa%d/%s:\tTime taken per verification = %.02f ms,"
75 " Speed = %.02f verifications/s\n", key_size, sha_strings[algorithm], 75 " Speed = %.02f verifications/s\n", key_size, sha_strings[algorithm],
76 msecs, speed); 76 msecs, speed);
77 fprintf(stdout, "rsa%d/%s:%.02f\n", key_size, sha_strings[algorithm], msecs); 77 fprintf(stdout, "rsa%d/%s:%.02f\n", key_size, sha_strings[algorithm], msecs);
78 78
79 failure: 79 failure:
80 Free(signature); 80 Free(signature);
81 Free(digest); 81 Free(digest);
82 Free(key); 82 Free(key);
83 return error_code; 83 return error_code;
84 } 84 }
85 85
86 int main(int argc, char* argv[]) { 86 int main(int argc, char* argv[]) {
87 int i; 87 int i;
88 int error_code = 0; 88 int error_code = 0;
89 for (i = 0; i < kNumAlgorithms; ++i) { 89 for (i = 0; i < kNumAlgorithms; ++i) {
90 if(SpeedTestAlgorithm(i)) 90 if(SpeedTestAlgorithm(i))
91 error_code = 1; 91 error_code = 1;
92 } 92 }
93 return error_code; 93 return error_code;
94 } 94 }
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/tests/rsa_padding_test.c ('k') | src/platform/vboot_reference/utils/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698