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 | 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" |
11 #include "rsa.h" | 11 #include "rsa.h" |
| 12 #include "rsa_utility.h" |
12 #include "timer_utils.h" | 13 #include "timer_utils.h" |
13 #include "utility.h" | 14 #include "utility.h" |
14 | 15 |
15 #define FILE_NAME_SIZE 128 | 16 #define FILE_NAME_SIZE 128 |
16 #define NUM_OPERATIONS 100 /* Number of signature operations to time. */ | 17 #define NUM_OPERATIONS 100 /* Number of signature operations to time. */ |
17 | 18 |
18 int SpeedTestAlgorithm(int algorithm) { | 19 int SpeedTestAlgorithm(int algorithm) { |
19 int i, key_size; | 20 int i, key_size; |
20 int error_code = 0; | 21 int error_code = 0; |
21 double speed, msecs; | 22 double speed, msecs; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 speed = 1000.0 / msecs ; | 74 speed = 1000.0 / msecs ; |
74 fprintf(stderr, "# rsa%d/%s:\tTime taken per verification = %.02f ms," | 75 fprintf(stderr, "# rsa%d/%s:\tTime taken per verification = %.02f ms," |
75 " Speed = %.02f verifications/s\n", key_size, sha_strings[algorithm], | 76 " Speed = %.02f verifications/s\n", key_size, sha_strings[algorithm], |
76 msecs, speed); | 77 msecs, speed); |
77 fprintf(stdout, "ms_rsa%d_%s:%.02f\n", key_size, sha_strings[algorithm], | 78 fprintf(stdout, "ms_rsa%d_%s:%.02f\n", key_size, sha_strings[algorithm], |
78 msecs); | 79 msecs); |
79 | 80 |
80 failure: | 81 failure: |
81 Free(signature); | 82 Free(signature); |
82 Free(digest); | 83 Free(digest); |
83 Free(key); | 84 RSAPublicKeyFree(key); |
84 return error_code; | 85 return error_code; |
85 } | 86 } |
86 | 87 |
87 int main(int argc, char* argv[]) { | 88 int main(int argc, char* argv[]) { |
88 int i; | 89 int i; |
89 int error_code = 0; | 90 int error_code = 0; |
90 for (i = 0; i < kNumAlgorithms; ++i) { | 91 for (i = 0; i < kNumAlgorithms; ++i) { |
91 if(SpeedTestAlgorithm(i)) | 92 if(SpeedTestAlgorithm(i)) |
92 error_code = 1; | 93 error_code = 1; |
93 } | 94 } |
94 return error_code; | 95 return error_code; |
95 } | 96 } |
OLD | NEW |