diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-08-18 15:10:39 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-08-18 15:10:39 +0200 |
commit | af99085b7163fdded4dfad94fd2a98231bc12209 (patch) | |
tree | c055728c186a49be04c4381bf10f890eaba482c6 | |
parent | ec8162bdf0db6282fbf507e6da72b056119c7805 (diff) | |
download | gnunet-af99085b7163fdded4dfad94fd2a98231bc12209.tar.gz gnunet-af99085b7163fdded4dfad94fd2a98231bc12209.zip |
benchmark collection awk scripts
-rw-r--r-- | contrib/benchmark/collect_ops.awk | 45 | ||||
-rw-r--r-- | contrib/benchmark/collect_urls.awk | 47 | ||||
-rw-r--r-- | src/util/benchmark.c | 59 | ||||
-rw-r--r-- | src/util/benchmark.h | 59 | ||||
-rw-r--r-- | src/util/crypto_ecc.c | 59 | ||||
-rw-r--r-- | src/util/crypto_hash.c | 13 | ||||
-rw-r--r-- | src/util/crypto_hkdf.c | 4 | ||||
-rw-r--r-- | src/util/crypto_rsa.c | 21 |
8 files changed, 287 insertions, 20 deletions
diff --git a/contrib/benchmark/collect_ops.awk b/contrib/benchmark/collect_ops.awk new file mode 100644 index 000000000..b34fcc723 --- /dev/null +++ b/contrib/benchmark/collect_ops.awk | |||
@@ -0,0 +1,45 @@ | |||
1 | # This file is part of GNUnet | ||
2 | # Copyright (C) 2018 GNUnet e.V. | ||
3 | # | ||
4 | # GNUnet is free software: you can redistribute it and/or modify it | ||
5 | # under the terms of the GNU Affero General Public License as published | ||
6 | # by the Free Software Foundation, either version 3 of the License, or | ||
7 | # (at your option) any later version. | ||
8 | # | ||
9 | # GNUnet is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # Affero General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU Affero General Public License | ||
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | |||
18 | # Aggregate benchmarking data from multiple threads/processes | ||
19 | # generated by util/benchmark.c. | ||
20 | # | ||
21 | # Can be used as | ||
22 | # awk -f collect_ops.awk gnunet-benchmark-ops-*.txt | ||
23 | |||
24 | |||
25 | # records are of the following form: | ||
26 | # op <op> count <count> time_us <time_us> | ||
27 | { | ||
28 | op[$2]["count"] += $4; | ||
29 | op[$2]["time_us"] += $6; | ||
30 | } | ||
31 | |||
32 | function avg(s, c) { | ||
33 | if (c == 0) { | ||
34 | return 0; | ||
35 | } else { | ||
36 | return s / c; | ||
37 | } | ||
38 | } | ||
39 | |||
40 | END { | ||
41 | for (x in op) { | ||
42 | print "op", x, "count", op[x]["count"], "time_us", op[x]["time_us"], \ | ||
43 | "time_avg_us", avg(op[x]["time_us"], op[x]["count"]); | ||
44 | } | ||
45 | } | ||
diff --git a/contrib/benchmark/collect_urls.awk b/contrib/benchmark/collect_urls.awk new file mode 100644 index 000000000..27424b2b8 --- /dev/null +++ b/contrib/benchmark/collect_urls.awk | |||
@@ -0,0 +1,47 @@ | |||
1 | # records are of the following form: | ||
2 | # This file is part of GNUnet | ||
3 | # Copyright (C) 2018 GNUnet e.V. | ||
4 | # | ||
5 | # GNUnet is free software: you can redistribute it and/or modify it | ||
6 | # under the terms of the GNU Affero General Public License as published | ||
7 | # by the Free Software Foundation, either version 3 of the License, or | ||
8 | # (at your option) any later version. | ||
9 | # | ||
10 | # GNUnet is distributed in the hope that it will be useful, but | ||
11 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | # Affero General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU Affero General Public License | ||
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | |||
19 | # Aggregate benchmarking data from multiple threads/processes | ||
20 | # generated by util/benchmark.c. | ||
21 | # | ||
22 | # Can be used as | ||
23 | # awk -f collect_ops.awk gnunet-benchmark-ops-*.txt | ||
24 | # url <url> status <status> count <count> time_us <time_us> | ||
25 | |||
26 | { | ||
27 | url[$2][$4]["count"] += $6; | ||
28 | url[$2][$4]["time_us"] += $8; | ||
29 | } | ||
30 | |||
31 | function avg(s, c) { | ||
32 | if (c == 0) { | ||
33 | return 0; | ||
34 | } else { | ||
35 | return s / c; | ||
36 | } | ||
37 | } | ||
38 | |||
39 | END { | ||
40 | for (x in url) { | ||
41 | for (y in url[x]) { | ||
42 | print "url", x, "status", y, \ | ||
43 | "count", url[x][y]["count"], "time_us", url[x][y]["time_us"], \ | ||
44 | "time_avg_us", avg(url[x][y]["time_us"], url[x][y]["count"]); | ||
45 | } | ||
46 | } | ||
47 | } | ||
diff --git a/src/util/benchmark.c b/src/util/benchmark.c index daed7cd2b..f832931ee 100644 --- a/src/util/benchmark.c +++ b/src/util/benchmark.c | |||
@@ -50,9 +50,22 @@ write_benchmark_data (struct BenchmarkData *bd) | |||
50 | struct GNUNET_DISK_FileHandle *fh; | 50 | struct GNUNET_DISK_FileHandle *fh; |
51 | pid_t pid = getpid (); | 51 | pid_t pid = getpid (); |
52 | pid_t tid = syscall (SYS_gettid); | 52 | pid_t tid = syscall (SYS_gettid); |
53 | char *benchmark_dir; | ||
53 | char *s; | 54 | char *s; |
54 | 55 | ||
55 | GNUNET_asprintf (&s, "gnunet-benchmark-%llu-%llu.txt", | 56 | benchmark_dir = getenv ("GNUNET_BENCHMARK_DIR"); |
57 | |||
58 | if (NULL == benchmark_dir) | ||
59 | return; | ||
60 | |||
61 | if (GNUNET_OK != GNUNET_DISK_directory_create (benchmark_dir)) | ||
62 | { | ||
63 | GNUNET_break (0); | ||
64 | return; | ||
65 | } | ||
66 | |||
67 | GNUNET_asprintf (&s, "%s/gnunet-benchmark-ops-%llu-%llu.txt", | ||
68 | benchmark_dir, | ||
56 | (unsigned long long) pid, | 69 | (unsigned long long) pid, |
57 | (unsigned long long) tid); | 70 | (unsigned long long) tid); |
58 | 71 | ||
@@ -65,14 +78,46 @@ write_benchmark_data (struct BenchmarkData *bd) | |||
65 | GNUNET_assert (NULL != fh); | 78 | GNUNET_assert (NULL != fh); |
66 | GNUNET_free (s); | 79 | GNUNET_free (s); |
67 | 80 | ||
68 | GNUNET_asprintf (&s, "eddsa_sign_count %llu", | 81 | #define WRITE_BENCHMARK_OP(opname) do { \ |
69 | (unsigned long long) bd->eddsa_sign_count); | 82 | GNUNET_asprintf (&s, "op " #opname " count %llu time_us %llu\n", \ |
70 | GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s, strlen (s))); | 83 | (unsigned long long) bd->opname##_count, \ |
71 | GNUNET_free (s); | 84 | (unsigned long long) bd->opname##_time.rel_value_us); \ |
85 | GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s, strlen (s))); \ | ||
86 | GNUNET_free (s); \ | ||
87 | } while (0) | ||
88 | |||
89 | WRITE_BENCHMARK_OP (ecc_ecdh); | ||
90 | WRITE_BENCHMARK_OP (ecdh_eddsa); | ||
91 | WRITE_BENCHMARK_OP (ecdhe_key_create); | ||
92 | WRITE_BENCHMARK_OP (ecdhe_key_get_public); | ||
93 | WRITE_BENCHMARK_OP (ecdsa_ecdh); | ||
94 | WRITE_BENCHMARK_OP (ecdsa_key_create); | ||
95 | WRITE_BENCHMARK_OP (ecdsa_key_get_public); | ||
96 | WRITE_BENCHMARK_OP (ecdsa_sign); | ||
97 | WRITE_BENCHMARK_OP (ecdsa_verify); | ||
98 | WRITE_BENCHMARK_OP (eddsa_ecdh); | ||
99 | WRITE_BENCHMARK_OP (eddsa_key_create); | ||
100 | WRITE_BENCHMARK_OP (eddsa_key_get_public); | ||
101 | WRITE_BENCHMARK_OP (eddsa_sign); | ||
102 | WRITE_BENCHMARK_OP (eddsa_verify); | ||
103 | WRITE_BENCHMARK_OP (hash); | ||
104 | WRITE_BENCHMARK_OP (hash_context_finish); | ||
105 | WRITE_BENCHMARK_OP (hash_context_read); | ||
106 | WRITE_BENCHMARK_OP (hash_context_start); | ||
107 | WRITE_BENCHMARK_OP (hkdf); | ||
108 | WRITE_BENCHMARK_OP (rsa_blind); | ||
109 | WRITE_BENCHMARK_OP (rsa_private_key_create); | ||
110 | WRITE_BENCHMARK_OP (rsa_private_key_get_public); | ||
111 | WRITE_BENCHMARK_OP (rsa_sign_blinded); | ||
112 | WRITE_BENCHMARK_OP (rsa_unblind); | ||
113 | WRITE_BENCHMARK_OP (rsa_verify); | ||
114 | |||
115 | #undef WRITE_BENCHMARK_OP | ||
72 | 116 | ||
73 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); | 117 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); |
74 | 118 | ||
75 | GNUNET_asprintf (&s, "gnunet-benchmark-urls-%llu-%llu.txt", | 119 | GNUNET_asprintf (&s, "%s/gnunet-benchmark-urls-%llu-%llu.txt", |
120 | benchmark_dir, | ||
76 | (unsigned long long) pid, | 121 | (unsigned long long) pid, |
77 | (unsigned long long) tid); | 122 | (unsigned long long) tid); |
78 | 123 | ||
@@ -137,7 +182,7 @@ thread_destructor (void *cls) | |||
137 | * Initialize the thread-local variable key for benchmark data. | 182 | * Initialize the thread-local variable key for benchmark data. |
138 | */ | 183 | */ |
139 | static void | 184 | static void |
140 | make_key() | 185 | make_key () |
141 | { | 186 | { |
142 | (void) pthread_key_create (&key, &thread_destructor); | 187 | (void) pthread_key_create (&key, &thread_destructor); |
143 | } | 188 | } |
diff --git a/src/util/benchmark.h b/src/util/benchmark.h index 6e00906c4..145d7cee7 100644 --- a/src/util/benchmark.h +++ b/src/util/benchmark.h | |||
@@ -33,6 +33,25 @@ | |||
33 | */ | 33 | */ |
34 | #define MAX_BENCHMARK_URL_LEN 128 | 34 | #define MAX_BENCHMARK_URL_LEN 128 |
35 | 35 | ||
36 | #if ENABLE_BENCHMARK | ||
37 | #define BENCHMARK_START(opname) \ | ||
38 | struct GNUNET_TIME_Absolute _benchmark_##opname##_start = GNUNET_TIME_absolute_get () | ||
39 | #define BENCHMARK_END(opname) do { \ | ||
40 | { \ | ||
41 | struct GNUNET_TIME_Absolute _benchmark_##opname##_end = GNUNET_TIME_absolute_get (); \ | ||
42 | struct BenchmarkData *bd = get_benchmark_data (); \ | ||
43 | bd->opname##_count++; \ | ||
44 | bd->opname##_time = \ | ||
45 | GNUNET_TIME_relative_add (bd->opname##_time, \ | ||
46 | GNUNET_TIME_absolute_get_difference (_benchmark_##opname##_start, \ | ||
47 | _benchmark_##opname##_end)); \ | ||
48 | } \ | ||
49 | } while (0) | ||
50 | #else | ||
51 | #define BENCHMARK_START(opname) do { } while (0) | ||
52 | #define BENCHMARK_END(opname) do { } while (0) | ||
53 | #endif | ||
54 | |||
36 | 55 | ||
37 | /** | 56 | /** |
38 | * Struct for benchmark data for one URL. | 57 | * Struct for benchmark data for one URL. |
@@ -70,20 +89,40 @@ struct UrlRequestData | |||
70 | struct GNUNET_TIME_Relative time_min; | 89 | struct GNUNET_TIME_Relative time_min; |
71 | }; | 90 | }; |
72 | 91 | ||
92 | #define GNUNET_DECLARE_BENCHMARK_OP(opname) \ | ||
93 | uint64_t opname##_count; \ | ||
94 | struct GNUNET_TIME_Relative opname##_time | ||
95 | |||
73 | /** | 96 | /** |
74 | * Thread-local struct for benchmarking data. | 97 | * Thread-local struct for benchmarking data. |
75 | */ | 98 | */ |
76 | struct BenchmarkData | 99 | struct BenchmarkData |
77 | { | 100 | { |
78 | /** | 101 | GNUNET_DECLARE_BENCHMARK_OP (ecc_ecdh); |
79 | * Number of eddsa_sign operations. | 102 | GNUNET_DECLARE_BENCHMARK_OP (ecdh_eddsa); |
80 | */ | 103 | GNUNET_DECLARE_BENCHMARK_OP (ecdhe_key_create); |
81 | uint64_t eddsa_sign_count; | 104 | GNUNET_DECLARE_BENCHMARK_OP (ecdhe_key_get_public); |
82 | 105 | GNUNET_DECLARE_BENCHMARK_OP (ecdsa_ecdh); | |
83 | /** | 106 | GNUNET_DECLARE_BENCHMARK_OP (ecdsa_key_create); |
84 | * Time spent in eddsa_sign. | 107 | GNUNET_DECLARE_BENCHMARK_OP (ecdsa_key_get_public); |
85 | */ | 108 | GNUNET_DECLARE_BENCHMARK_OP (ecdsa_sign); |
86 | struct GNUNET_TIME_Relative eddsa_sign_time; | 109 | GNUNET_DECLARE_BENCHMARK_OP (ecdsa_verify); |
110 | GNUNET_DECLARE_BENCHMARK_OP (eddsa_ecdh); | ||
111 | GNUNET_DECLARE_BENCHMARK_OP (eddsa_key_create); | ||
112 | GNUNET_DECLARE_BENCHMARK_OP (eddsa_key_get_public); | ||
113 | GNUNET_DECLARE_BENCHMARK_OP (eddsa_sign); | ||
114 | GNUNET_DECLARE_BENCHMARK_OP (eddsa_verify); | ||
115 | GNUNET_DECLARE_BENCHMARK_OP (hash); | ||
116 | GNUNET_DECLARE_BENCHMARK_OP (hash_context_finish); | ||
117 | GNUNET_DECLARE_BENCHMARK_OP (hash_context_read); | ||
118 | GNUNET_DECLARE_BENCHMARK_OP (hash_context_start); | ||
119 | GNUNET_DECLARE_BENCHMARK_OP (hkdf); | ||
120 | GNUNET_DECLARE_BENCHMARK_OP (rsa_blind); | ||
121 | GNUNET_DECLARE_BENCHMARK_OP (rsa_private_key_create); | ||
122 | GNUNET_DECLARE_BENCHMARK_OP (rsa_private_key_get_public); | ||
123 | GNUNET_DECLARE_BENCHMARK_OP (rsa_sign_blinded); | ||
124 | GNUNET_DECLARE_BENCHMARK_OP (rsa_unblind); | ||
125 | GNUNET_DECLARE_BENCHMARK_OP (rsa_verify); | ||
87 | 126 | ||
88 | struct UrlRequestData *urd; | 127 | struct UrlRequestData *urd; |
89 | 128 | ||
@@ -92,6 +131,8 @@ struct BenchmarkData | |||
92 | unsigned int urd_capacity; | 131 | unsigned int urd_capacity; |
93 | }; | 132 | }; |
94 | 133 | ||
134 | #undef GNUNET_DECLARE_BENCHMARK_OP | ||
135 | |||
95 | 136 | ||
96 | /** | 137 | /** |
97 | * Acquire the benchmark data for the current thread, allocate if necessary. | 138 | * Acquire the benchmark data for the current thread, allocate if necessary. |
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c index ca2aa40ad..9902f276d 100644 --- a/src/util/crypto_ecc.c +++ b/src/util/crypto_ecc.c | |||
@@ -226,6 +226,8 @@ GNUNET_CRYPTO_ecdsa_key_get_public (const struct GNUNET_CRYPTO_EcdsaPrivateKey * | |||
226 | gcry_ctx_t ctx; | 226 | gcry_ctx_t ctx; |
227 | gcry_mpi_t q; | 227 | gcry_mpi_t q; |
228 | 228 | ||
229 | BENCHMARK_START (ecdsa_key_get_public); | ||
230 | |||
229 | sexp = decode_private_ecdsa_key (priv); | 231 | sexp = decode_private_ecdsa_key (priv); |
230 | GNUNET_assert (NULL != sexp); | 232 | GNUNET_assert (NULL != sexp); |
231 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, sexp, NULL)); | 233 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, sexp, NULL)); |
@@ -235,6 +237,8 @@ GNUNET_CRYPTO_ecdsa_key_get_public (const struct GNUNET_CRYPTO_EcdsaPrivateKey * | |||
235 | GNUNET_CRYPTO_mpi_print_unsigned (pub->q_y, sizeof (pub->q_y), q); | 237 | GNUNET_CRYPTO_mpi_print_unsigned (pub->q_y, sizeof (pub->q_y), q); |
236 | gcry_mpi_release (q); | 238 | gcry_mpi_release (q); |
237 | gcry_ctx_release (ctx); | 239 | gcry_ctx_release (ctx); |
240 | |||
241 | BENCHMARK_END (ecdsa_key_get_public); | ||
238 | } | 242 | } |
239 | 243 | ||
240 | 244 | ||
@@ -252,6 +256,8 @@ GNUNET_CRYPTO_eddsa_key_get_public (const struct GNUNET_CRYPTO_EddsaPrivateKey * | |||
252 | gcry_ctx_t ctx; | 256 | gcry_ctx_t ctx; |
253 | gcry_mpi_t q; | 257 | gcry_mpi_t q; |
254 | 258 | ||
259 | BENCHMARK_START (eddsa_key_get_public); | ||
260 | |||
255 | sexp = decode_private_eddsa_key (priv); | 261 | sexp = decode_private_eddsa_key (priv); |
256 | GNUNET_assert (NULL != sexp); | 262 | GNUNET_assert (NULL != sexp); |
257 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, sexp, NULL)); | 263 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, sexp, NULL)); |
@@ -261,6 +267,8 @@ GNUNET_CRYPTO_eddsa_key_get_public (const struct GNUNET_CRYPTO_EddsaPrivateKey * | |||
261 | GNUNET_CRYPTO_mpi_print_unsigned (pub->q_y, sizeof (pub->q_y), q); | 267 | GNUNET_CRYPTO_mpi_print_unsigned (pub->q_y, sizeof (pub->q_y), q); |
262 | gcry_mpi_release (q); | 268 | gcry_mpi_release (q); |
263 | gcry_ctx_release (ctx); | 269 | gcry_ctx_release (ctx); |
270 | |||
271 | BENCHMARK_END (eddsa_key_get_public); | ||
264 | } | 272 | } |
265 | 273 | ||
266 | 274 | ||
@@ -278,6 +286,8 @@ GNUNET_CRYPTO_ecdhe_key_get_public (const struct GNUNET_CRYPTO_EcdhePrivateKey * | |||
278 | gcry_ctx_t ctx; | 286 | gcry_ctx_t ctx; |
279 | gcry_mpi_t q; | 287 | gcry_mpi_t q; |
280 | 288 | ||
289 | BENCHMARK_START (ecdhe_key_get_public); | ||
290 | |||
281 | sexp = decode_private_ecdhe_key (priv); | 291 | sexp = decode_private_ecdhe_key (priv); |
282 | GNUNET_assert (NULL != sexp); | 292 | GNUNET_assert (NULL != sexp); |
283 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, sexp, NULL)); | 293 | GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, sexp, NULL)); |
@@ -287,6 +297,8 @@ GNUNET_CRYPTO_ecdhe_key_get_public (const struct GNUNET_CRYPTO_EcdhePrivateKey * | |||
287 | GNUNET_CRYPTO_mpi_print_unsigned (pub->q_y, sizeof (pub->q_y), q); | 297 | GNUNET_CRYPTO_mpi_print_unsigned (pub->q_y, sizeof (pub->q_y), q); |
288 | gcry_mpi_release (q); | 298 | gcry_mpi_release (q); |
289 | gcry_ctx_release (ctx); | 299 | gcry_ctx_release (ctx); |
300 | |||
301 | BENCHMARK_END (ecdhe_key_get_public); | ||
290 | } | 302 | } |
291 | 303 | ||
292 | 304 | ||
@@ -556,6 +568,8 @@ GNUNET_CRYPTO_ecdhe_key_create2 (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | |||
556 | gcry_mpi_t d; | 568 | gcry_mpi_t d; |
557 | int rc; | 569 | int rc; |
558 | 570 | ||
571 | BENCHMARK_START (ecdhe_key_create); | ||
572 | |||
559 | /* NOTE: For libgcrypt >= 1.7, we do not need the 'eddsa' flag here, | 573 | /* NOTE: For libgcrypt >= 1.7, we do not need the 'eddsa' flag here, |
560 | but should also be harmless. For libgcrypt < 1.7, using 'eddsa' | 574 | but should also be harmless. For libgcrypt < 1.7, using 'eddsa' |
561 | disables an expensive key testing routine. We do not want to run | 575 | disables an expensive key testing routine. We do not want to run |
@@ -592,6 +606,9 @@ GNUNET_CRYPTO_ecdhe_key_create2 (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | |||
592 | gcry_sexp_release (priv_sexp); | 606 | gcry_sexp_release (priv_sexp); |
593 | GNUNET_CRYPTO_mpi_print_unsigned (pk->d, sizeof (pk->d), d); | 607 | GNUNET_CRYPTO_mpi_print_unsigned (pk->d, sizeof (pk->d), d); |
594 | gcry_mpi_release (d); | 608 | gcry_mpi_release (d); |
609 | |||
610 | BENCHMARK_END (ecdhe_key_create); | ||
611 | |||
595 | return GNUNET_OK; | 612 | return GNUNET_OK; |
596 | } | 613 | } |
597 | 614 | ||
@@ -610,6 +627,8 @@ GNUNET_CRYPTO_ecdsa_key_create () | |||
610 | gcry_mpi_t d; | 627 | gcry_mpi_t d; |
611 | int rc; | 628 | int rc; |
612 | 629 | ||
630 | BENCHMARK_START (ecdsa_key_create); | ||
631 | |||
613 | if (0 != (rc = gcry_sexp_build (&s_keyparam, NULL, | 632 | if (0 != (rc = gcry_sexp_build (&s_keyparam, NULL, |
614 | "(genkey(ecc(curve \"" CURVE "\")" | 633 | "(genkey(ecc(curve \"" CURVE "\")" |
615 | "(flags)))"))) | 634 | "(flags)))"))) |
@@ -642,6 +661,9 @@ GNUNET_CRYPTO_ecdsa_key_create () | |||
642 | priv = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey); | 661 | priv = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey); |
643 | GNUNET_CRYPTO_mpi_print_unsigned (priv->d, sizeof (priv->d), d); | 662 | GNUNET_CRYPTO_mpi_print_unsigned (priv->d, sizeof (priv->d), d); |
644 | gcry_mpi_release (d); | 663 | gcry_mpi_release (d); |
664 | |||
665 | BENCHMARK_END (ecdsa_key_create); | ||
666 | |||
645 | return priv; | 667 | return priv; |
646 | } | 668 | } |
647 | 669 | ||
@@ -659,6 +681,8 @@ GNUNET_CRYPTO_eddsa_key_create () | |||
659 | gcry_mpi_t d; | 681 | gcry_mpi_t d; |
660 | int rc; | 682 | int rc; |
661 | 683 | ||
684 | BENCHMARK_START (eddsa_key_create); | ||
685 | |||
662 | #if CRYPTO_BUG | 686 | #if CRYPTO_BUG |
663 | again: | 687 | again: |
664 | #endif | 688 | #endif |
@@ -705,6 +729,8 @@ GNUNET_CRYPTO_eddsa_key_create () | |||
705 | } | 729 | } |
706 | #endif | 730 | #endif |
707 | 731 | ||
732 | BENCHMARK_END (eddsa_key_create); | ||
733 | |||
708 | return priv; | 734 | return priv; |
709 | } | 735 | } |
710 | 736 | ||
@@ -824,6 +850,8 @@ GNUNET_CRYPTO_ecdsa_sign (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | |||
824 | int rc; | 850 | int rc; |
825 | gcry_mpi_t rs[2]; | 851 | gcry_mpi_t rs[2]; |
826 | 852 | ||
853 | BENCHMARK_START (ecdsa_sign); | ||
854 | |||
827 | priv_sexp = decode_private_ecdsa_key (priv); | 855 | priv_sexp = decode_private_ecdsa_key (priv); |
828 | data = data_to_ecdsa_value (purpose); | 856 | data = data_to_ecdsa_value (purpose); |
829 | if (0 != (rc = gcry_pk_sign (&sig_sexp, data, priv_sexp))) | 857 | if (0 != (rc = gcry_pk_sign (&sig_sexp, data, priv_sexp))) |
@@ -851,6 +879,9 @@ GNUNET_CRYPTO_ecdsa_sign (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | |||
851 | GNUNET_CRYPTO_mpi_print_unsigned (sig->s, sizeof (sig->s), rs[1]); | 879 | GNUNET_CRYPTO_mpi_print_unsigned (sig->s, sizeof (sig->s), rs[1]); |
852 | gcry_mpi_release (rs[0]); | 880 | gcry_mpi_release (rs[0]); |
853 | gcry_mpi_release (rs[1]); | 881 | gcry_mpi_release (rs[1]); |
882 | |||
883 | BENCHMARK_END (ecdsa_sign); | ||
884 | |||
854 | return GNUNET_OK; | 885 | return GNUNET_OK; |
855 | } | 886 | } |
856 | 887 | ||
@@ -874,10 +905,7 @@ GNUNET_CRYPTO_eddsa_sign (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
874 | int rc; | 905 | int rc; |
875 | gcry_mpi_t rs[2]; | 906 | gcry_mpi_t rs[2]; |
876 | 907 | ||
877 | #if ENABLE_BENCHMARK | 908 | BENCHMARK_START (eddsa_sign); |
878 | struct BenchmarkData *bd = get_benchmark_data (); | ||
879 | bd->eddsa_sign_count++; | ||
880 | #endif | ||
881 | 909 | ||
882 | priv_sexp = decode_private_eddsa_key (priv); | 910 | priv_sexp = decode_private_eddsa_key (priv); |
883 | data = data_to_eddsa_value (purpose); | 911 | data = data_to_eddsa_value (purpose); |
@@ -906,6 +934,9 @@ GNUNET_CRYPTO_eddsa_sign (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
906 | GNUNET_CRYPTO_mpi_print_unsigned (sig->s, sizeof (sig->s), rs[1]); | 934 | GNUNET_CRYPTO_mpi_print_unsigned (sig->s, sizeof (sig->s), rs[1]); |
907 | gcry_mpi_release (rs[0]); | 935 | gcry_mpi_release (rs[0]); |
908 | gcry_mpi_release (rs[1]); | 936 | gcry_mpi_release (rs[1]); |
937 | |||
938 | BENCHMARK_END (eddsa_sign); | ||
939 | |||
909 | return GNUNET_OK; | 940 | return GNUNET_OK; |
910 | } | 941 | } |
911 | 942 | ||
@@ -930,6 +961,8 @@ GNUNET_CRYPTO_ecdsa_verify (uint32_t purpose, | |||
930 | gcry_sexp_t pub_sexpr; | 961 | gcry_sexp_t pub_sexpr; |
931 | int rc; | 962 | int rc; |
932 | 963 | ||
964 | BENCHMARK_START (ecdsa_verify); | ||
965 | |||
933 | if (purpose != ntohl (validate->purpose)) | 966 | if (purpose != ntohl (validate->purpose)) |
934 | return GNUNET_SYSERR; /* purpose mismatch */ | 967 | return GNUNET_SYSERR; /* purpose mismatch */ |
935 | 968 | ||
@@ -960,8 +993,10 @@ GNUNET_CRYPTO_ecdsa_verify (uint32_t purpose, | |||
960 | LOG (GNUNET_ERROR_TYPE_INFO, | 993 | LOG (GNUNET_ERROR_TYPE_INFO, |
961 | _("ECDSA signature verification failed at %s:%d: %s\n"), __FILE__, | 994 | _("ECDSA signature verification failed at %s:%d: %s\n"), __FILE__, |
962 | __LINE__, gcry_strerror (rc)); | 995 | __LINE__, gcry_strerror (rc)); |
996 | BENCHMARK_END (ecdsa_verify); | ||
963 | return GNUNET_SYSERR; | 997 | return GNUNET_SYSERR; |
964 | } | 998 | } |
999 | BENCHMARK_END (ecdsa_verify); | ||
965 | return GNUNET_OK; | 1000 | return GNUNET_OK; |
966 | } | 1001 | } |
967 | 1002 | ||
@@ -987,6 +1022,8 @@ GNUNET_CRYPTO_eddsa_verify (uint32_t purpose, | |||
987 | gcry_sexp_t pub_sexpr; | 1022 | gcry_sexp_t pub_sexpr; |
988 | int rc; | 1023 | int rc; |
989 | 1024 | ||
1025 | BENCHMARK_START (eddsa_verify); | ||
1026 | |||
990 | if (purpose != ntohl (validate->purpose)) | 1027 | if (purpose != ntohl (validate->purpose)) |
991 | return GNUNET_SYSERR; /* purpose mismatch */ | 1028 | return GNUNET_SYSERR; /* purpose mismatch */ |
992 | 1029 | ||
@@ -1017,8 +1054,10 @@ GNUNET_CRYPTO_eddsa_verify (uint32_t purpose, | |||
1017 | LOG (GNUNET_ERROR_TYPE_INFO, | 1054 | LOG (GNUNET_ERROR_TYPE_INFO, |
1018 | _("EdDSA signature verification failed at %s:%d: %s\n"), __FILE__, | 1055 | _("EdDSA signature verification failed at %s:%d: %s\n"), __FILE__, |
1019 | __LINE__, gcry_strerror (rc)); | 1056 | __LINE__, gcry_strerror (rc)); |
1057 | BENCHMARK_END (eddsa_verify); | ||
1020 | return GNUNET_SYSERR; | 1058 | return GNUNET_SYSERR; |
1021 | } | 1059 | } |
1060 | BENCHMARK_END (eddsa_verify); | ||
1022 | return GNUNET_OK; | 1061 | return GNUNET_OK; |
1023 | } | 1062 | } |
1024 | 1063 | ||
@@ -1045,6 +1084,8 @@ GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1045 | unsigned char xbuf[256 / 8]; | 1084 | unsigned char xbuf[256 / 8]; |
1046 | size_t rsize; | 1085 | size_t rsize; |
1047 | 1086 | ||
1087 | BENCHMARK_START (ecc_ecdh); | ||
1088 | |||
1048 | /* first, extract the q = dP value from the public key */ | 1089 | /* first, extract the q = dP value from the public key */ |
1049 | if (0 != gcry_sexp_build (&pub_sexpr, NULL, | 1090 | if (0 != gcry_sexp_build (&pub_sexpr, NULL, |
1050 | "(public-key(ecc(curve " CURVE ")(q %b)))", | 1091 | "(public-key(ecc(curve " CURVE ")(q %b)))", |
@@ -1088,6 +1129,7 @@ GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1088 | rsize, | 1129 | rsize, |
1089 | key_material); | 1130 | key_material); |
1090 | gcry_mpi_release (result_x); | 1131 | gcry_mpi_release (result_x); |
1132 | BENCHMARK_END (ecc_ecdh); | ||
1091 | return GNUNET_OK; | 1133 | return GNUNET_OK; |
1092 | } | 1134 | } |
1093 | 1135 | ||
@@ -1371,6 +1413,8 @@ GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
1371 | gcry_sexp_t pub_sexpr; | 1413 | gcry_sexp_t pub_sexpr; |
1372 | int ret; | 1414 | int ret; |
1373 | 1415 | ||
1416 | BENCHMARK_START (eddsa_ecdh); | ||
1417 | |||
1374 | /* first, extract the q = dP value from the public key */ | 1418 | /* first, extract the q = dP value from the public key */ |
1375 | if (0 != gcry_sexp_build (&pub_sexpr, NULL, | 1419 | if (0 != gcry_sexp_build (&pub_sexpr, NULL, |
1376 | "(public-key(ecc(curve " CURVE ")(q %b)))", | 1420 | "(public-key(ecc(curve " CURVE ")(q %b)))", |
@@ -1398,6 +1442,7 @@ GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
1398 | key_material); | 1442 | key_material); |
1399 | gcry_mpi_point_release (result); | 1443 | gcry_mpi_point_release (result); |
1400 | gcry_ctx_release (ctx); | 1444 | gcry_ctx_release (ctx); |
1445 | BENCHMARK_END (eddsa_ecdh); | ||
1401 | return ret; | 1446 | return ret; |
1402 | } | 1447 | } |
1403 | 1448 | ||
@@ -1424,6 +1469,8 @@ GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | |||
1424 | gcry_sexp_t pub_sexpr; | 1469 | gcry_sexp_t pub_sexpr; |
1425 | int ret; | 1470 | int ret; |
1426 | 1471 | ||
1472 | BENCHMARK_START (ecdsa_ecdh); | ||
1473 | |||
1427 | /* first, extract the q = dP value from the public key */ | 1474 | /* first, extract the q = dP value from the public key */ |
1428 | if (0 != gcry_sexp_build (&pub_sexpr, NULL, | 1475 | if (0 != gcry_sexp_build (&pub_sexpr, NULL, |
1429 | "(public-key(ecc(curve " CURVE ")(q %b)))", | 1476 | "(public-key(ecc(curve " CURVE ")(q %b)))", |
@@ -1448,6 +1495,7 @@ GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | |||
1448 | key_material); | 1495 | key_material); |
1449 | gcry_mpi_point_release (result); | 1496 | gcry_mpi_point_release (result); |
1450 | gcry_ctx_release (ctx); | 1497 | gcry_ctx_release (ctx); |
1498 | BENCHMARK_END (ecdsa_ecdh); | ||
1451 | return ret; | 1499 | return ret; |
1452 | } | 1500 | } |
1453 | 1501 | ||
@@ -1475,6 +1523,8 @@ GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1475 | gcry_sexp_t pub_sexpr; | 1523 | gcry_sexp_t pub_sexpr; |
1476 | int ret; | 1524 | int ret; |
1477 | 1525 | ||
1526 | BENCHMARK_START (ecdh_eddsa); | ||
1527 | |||
1478 | /* first, extract the q = dP value from the public key */ | 1528 | /* first, extract the q = dP value from the public key */ |
1479 | if (0 != gcry_sexp_build (&pub_sexpr, NULL, | 1529 | if (0 != gcry_sexp_build (&pub_sexpr, NULL, |
1480 | "(public-key(ecc(curve " CURVE ")(q %b)))", | 1530 | "(public-key(ecc(curve " CURVE ")(q %b)))", |
@@ -1499,6 +1549,7 @@ GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1499 | key_material); | 1549 | key_material); |
1500 | gcry_mpi_point_release (result); | 1550 | gcry_mpi_point_release (result); |
1501 | gcry_ctx_release (ctx); | 1551 | gcry_ctx_release (ctx); |
1552 | BENCHMARK_END (ecdh_eddsa); | ||
1502 | return ret; | 1553 | return ret; |
1503 | } | 1554 | } |
1504 | 1555 | ||
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index fe1f58df7..cd36fbbd7 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_crypto_lib.h" | 25 | #include "gnunet_crypto_lib.h" |
26 | #include "gnunet_strings_lib.h" | 26 | #include "gnunet_strings_lib.h" |
27 | #include "benchmark.h" | ||
27 | #include <gcrypt.h> | 28 | #include <gcrypt.h> |
28 | 29 | ||
29 | #define LOG(kind,...) GNUNET_log_from (kind, "util-crypto-hash", __VA_ARGS__) | 30 | #define LOG(kind,...) GNUNET_log_from (kind, "util-crypto-hash", __VA_ARGS__) |
@@ -42,7 +43,9 @@ GNUNET_CRYPTO_hash (const void *block, | |||
42 | size_t size, | 43 | size_t size, |
43 | struct GNUNET_HashCode *ret) | 44 | struct GNUNET_HashCode *ret) |
44 | { | 45 | { |
46 | BENCHMARK_START (hash); | ||
45 | gcry_md_hash_buffer (GCRY_MD_SHA512, ret, block, size); | 47 | gcry_md_hash_buffer (GCRY_MD_SHA512, ret, block, size); |
48 | BENCHMARK_END (hash); | ||
46 | } | 49 | } |
47 | 50 | ||
48 | 51 | ||
@@ -442,11 +445,16 @@ GNUNET_CRYPTO_hash_context_start () | |||
442 | { | 445 | { |
443 | struct GNUNET_HashContext *hc; | 446 | struct GNUNET_HashContext *hc; |
444 | 447 | ||
448 | BENCHMARK_START (hash_context_start); | ||
449 | |||
445 | hc = GNUNET_new (struct GNUNET_HashContext); | 450 | hc = GNUNET_new (struct GNUNET_HashContext); |
446 | GNUNET_assert (0 == | 451 | GNUNET_assert (0 == |
447 | gcry_md_open (&hc->hd, | 452 | gcry_md_open (&hc->hd, |
448 | GCRY_MD_SHA512, | 453 | GCRY_MD_SHA512, |
449 | 0)); | 454 | 0)); |
455 | |||
456 | BENCHMARK_END (hash_context_start); | ||
457 | |||
450 | return hc; | 458 | return hc; |
451 | } | 459 | } |
452 | 460 | ||
@@ -463,7 +471,9 @@ GNUNET_CRYPTO_hash_context_read (struct GNUNET_HashContext *hc, | |||
463 | const void *buf, | 471 | const void *buf, |
464 | size_t size) | 472 | size_t size) |
465 | { | 473 | { |
474 | BENCHMARK_START (hash_context_read); | ||
466 | gcry_md_write (hc->hd, buf, size); | 475 | gcry_md_write (hc->hd, buf, size); |
476 | BENCHMARK_END (hash_context_read); | ||
467 | } | 477 | } |
468 | 478 | ||
469 | 479 | ||
@@ -479,12 +489,15 @@ GNUNET_CRYPTO_hash_context_finish (struct GNUNET_HashContext *hc, | |||
479 | { | 489 | { |
480 | const void *res = gcry_md_read (hc->hd, 0); | 490 | const void *res = gcry_md_read (hc->hd, 0); |
481 | 491 | ||
492 | BENCHMARK_START (hash_context_finish); | ||
493 | |||
482 | GNUNET_assert (NULL != res); | 494 | GNUNET_assert (NULL != res); |
483 | if (NULL != r_hash) | 495 | if (NULL != r_hash) |
484 | GNUNET_memcpy (r_hash, | 496 | GNUNET_memcpy (r_hash, |
485 | res, | 497 | res, |
486 | sizeof (struct GNUNET_HashCode)); | 498 | sizeof (struct GNUNET_HashCode)); |
487 | GNUNET_CRYPTO_hash_context_abort (hc); | 499 | GNUNET_CRYPTO_hash_context_abort (hc); |
500 | BENCHMARK_END (hash_context_finish); | ||
488 | } | 501 | } |
489 | 502 | ||
490 | 503 | ||
diff --git a/src/util/crypto_hkdf.c b/src/util/crypto_hkdf.c index f04d3e675..6dae13840 100644 --- a/src/util/crypto_hkdf.c +++ b/src/util/crypto_hkdf.c | |||
@@ -52,6 +52,7 @@ | |||
52 | 52 | ||
53 | #if GNUNET_BUILD | 53 | #if GNUNET_BUILD |
54 | #include "platform.h" | 54 | #include "platform.h" |
55 | #include "benchmark.h" | ||
55 | #include "gnunet_crypto_lib.h" | 56 | #include "gnunet_crypto_lib.h" |
56 | #else | 57 | #else |
57 | #define GNUNET_NO 0 | 58 | #define GNUNET_NO 0 |
@@ -155,6 +156,8 @@ GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, int xtr_algo, int prf_algo, | |||
155 | size_t ctx_len; | 156 | size_t ctx_len; |
156 | va_list args; | 157 | va_list args; |
157 | 158 | ||
159 | BENCHMARK_START (hkdf); | ||
160 | |||
158 | if (0 == k) | 161 | if (0 == k) |
159 | return GNUNET_SYSERR; | 162 | return GNUNET_SYSERR; |
160 | if (GPG_ERR_NO_ERROR != | 163 | if (GPG_ERR_NO_ERROR != |
@@ -265,6 +268,7 @@ hkdf_error: | |||
265 | hkdf_ok: | 268 | hkdf_ok: |
266 | gcry_md_close (xtr); | 269 | gcry_md_close (xtr); |
267 | gcry_md_close (prf); | 270 | gcry_md_close (prf); |
271 | BENCHMARK_END (hkdf); | ||
268 | return ret; | 272 | return ret; |
269 | } | 273 | } |
270 | 274 | ||
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index 1225aba73..26c33d5f3 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include <gcrypt.h> | 27 | #include <gcrypt.h> |
28 | #include "gnunet_crypto_lib.h" | 28 | #include "gnunet_crypto_lib.h" |
29 | #include "benchmark.h" | ||
29 | 30 | ||
30 | #define LOG(kind,...) GNUNET_log_from (kind, "util-crypto-rsa", __VA_ARGS__) | 31 | #define LOG(kind,...) GNUNET_log_from (kind, "util-crypto-rsa", __VA_ARGS__) |
31 | 32 | ||
@@ -149,6 +150,8 @@ GNUNET_CRYPTO_rsa_private_key_create (unsigned int len) | |||
149 | gcry_sexp_t s_key; | 150 | gcry_sexp_t s_key; |
150 | gcry_sexp_t s_keyparam; | 151 | gcry_sexp_t s_keyparam; |
151 | 152 | ||
153 | BENCHMARK_START (rsa_private_key_create); | ||
154 | |||
152 | GNUNET_assert (0 == | 155 | GNUNET_assert (0 == |
153 | gcry_sexp_build (&s_keyparam, | 156 | gcry_sexp_build (&s_keyparam, |
154 | NULL, | 157 | NULL, |
@@ -164,6 +167,7 @@ GNUNET_CRYPTO_rsa_private_key_create (unsigned int len) | |||
164 | #endif | 167 | #endif |
165 | ret = GNUNET_new (struct GNUNET_CRYPTO_RsaPrivateKey); | 168 | ret = GNUNET_new (struct GNUNET_CRYPTO_RsaPrivateKey); |
166 | ret->sexp = s_key; | 169 | ret->sexp = s_key; |
170 | BENCHMARK_END (rsa_private_key_create); | ||
167 | return ret; | 171 | return ret; |
168 | } | 172 | } |
169 | 173 | ||
@@ -261,6 +265,8 @@ GNUNET_CRYPTO_rsa_private_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateK | |||
261 | int rc; | 265 | int rc; |
262 | gcry_sexp_t result; | 266 | gcry_sexp_t result; |
263 | 267 | ||
268 | BENCHMARK_START (rsa_private_key_get_public); | ||
269 | |||
264 | rc = key_from_sexp (ne, priv->sexp, "public-key", "ne"); | 270 | rc = key_from_sexp (ne, priv->sexp, "public-key", "ne"); |
265 | if (0 != rc) | 271 | if (0 != rc) |
266 | rc = key_from_sexp (ne, priv->sexp, "private-key", "ne"); | 272 | rc = key_from_sexp (ne, priv->sexp, "private-key", "ne"); |
@@ -280,6 +286,7 @@ GNUNET_CRYPTO_rsa_private_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateK | |||
280 | gcry_mpi_release (ne[1]); | 286 | gcry_mpi_release (ne[1]); |
281 | pub = GNUNET_new (struct GNUNET_CRYPTO_RsaPublicKey); | 287 | pub = GNUNET_new (struct GNUNET_CRYPTO_RsaPublicKey); |
282 | pub->sexp = result; | 288 | pub->sexp = result; |
289 | BENCHMARK_END (rsa_private_key_get_public); | ||
283 | return pub; | 290 | return pub; |
284 | } | 291 | } |
285 | 292 | ||
@@ -736,6 +743,8 @@ GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, | |||
736 | gcry_mpi_t data_r_e; | 743 | gcry_mpi_t data_r_e; |
737 | int ret; | 744 | int ret; |
738 | 745 | ||
746 | BENCHMARK_START (rsa_blind); | ||
747 | |||
739 | GNUNET_assert (buf != NULL && buf_size != NULL); | 748 | GNUNET_assert (buf != NULL && buf_size != NULL); |
740 | ret = key_from_sexp (ne, pkey->sexp, "public-key", "ne"); | 749 | ret = key_from_sexp (ne, pkey->sexp, "public-key", "ne"); |
741 | if (0 != ret) | 750 | if (0 != ret) |
@@ -778,6 +787,8 @@ GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, | |||
778 | gcry_mpi_release (data_r_e); | 787 | gcry_mpi_release (data_r_e); |
779 | return GNUNET_YES; | 788 | return GNUNET_YES; |
780 | 789 | ||
790 | BENCHMARK_END (rsa_blind); | ||
791 | |||
781 | rsa_gcd_validate_failure: | 792 | rsa_gcd_validate_failure: |
782 | /* We know the RSA key is malicious here, so warn the wallet. */ | 793 | /* We know the RSA key is malicious here, so warn the wallet. */ |
783 | /* GNUNET_break_op (0); */ | 794 | /* GNUNET_break_op (0); */ |
@@ -885,6 +896,8 @@ GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | |||
885 | gcry_mpi_t v = NULL; | 896 | gcry_mpi_t v = NULL; |
886 | struct GNUNET_CRYPTO_RsaSignature *sig; | 897 | struct GNUNET_CRYPTO_RsaSignature *sig; |
887 | 898 | ||
899 | BENCHMARK_START (rsa_sign_blinded); | ||
900 | |||
888 | GNUNET_assert (0 == | 901 | GNUNET_assert (0 == |
889 | gcry_mpi_scan (&v, | 902 | gcry_mpi_scan (&v, |
890 | GCRYMPI_FMT_USG, | 903 | GCRYMPI_FMT_USG, |
@@ -894,6 +907,7 @@ GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | |||
894 | 907 | ||
895 | sig = rsa_sign_mpi (key, v); | 908 | sig = rsa_sign_mpi (key, v); |
896 | gcry_mpi_release (v); | 909 | gcry_mpi_release (v); |
910 | BENCHMARK_END (rsa_sign_blinded); | ||
897 | return sig; | 911 | return sig; |
898 | } | 912 | } |
899 | 913 | ||
@@ -1059,6 +1073,8 @@ GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, | |||
1059 | int ret; | 1073 | int ret; |
1060 | struct GNUNET_CRYPTO_RsaSignature *sret; | 1074 | struct GNUNET_CRYPTO_RsaSignature *sret; |
1061 | 1075 | ||
1076 | BENCHMARK_START (rsa_unblind); | ||
1077 | |||
1062 | ret = key_from_sexp (&n, pkey->sexp, "public-key", "n"); | 1078 | ret = key_from_sexp (&n, pkey->sexp, "public-key", "n"); |
1063 | if (0 != ret) | 1079 | if (0 != ret) |
1064 | ret = key_from_sexp (&n, pkey->sexp, "rsa", "n"); | 1080 | ret = key_from_sexp (&n, pkey->sexp, "rsa", "n"); |
@@ -1120,6 +1136,7 @@ GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, | |||
1120 | "(sig-val (rsa (s %M)))", | 1136 | "(sig-val (rsa (s %M)))", |
1121 | ubsig)); | 1137 | ubsig)); |
1122 | gcry_mpi_release (ubsig); | 1138 | gcry_mpi_release (ubsig); |
1139 | BENCHMARK_END (rsa_unblind); | ||
1123 | return sret; | 1140 | return sret; |
1124 | } | 1141 | } |
1125 | 1142 | ||
@@ -1142,6 +1159,8 @@ GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash, | |||
1142 | gcry_mpi_t r; | 1159 | gcry_mpi_t r; |
1143 | int rc; | 1160 | int rc; |
1144 | 1161 | ||
1162 | BENCHMARK_START (rsa_verify); | ||
1163 | |||
1145 | r = rsa_full_domain_hash (pkey, hash); | 1164 | r = rsa_full_domain_hash (pkey, hash); |
1146 | if (NULL == r) { | 1165 | if (NULL == r) { |
1147 | GNUNET_break_op (0); | 1166 | GNUNET_break_op (0); |
@@ -1169,7 +1188,9 @@ GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash, | |||
1169 | __LINE__, | 1188 | __LINE__, |
1170 | gcry_strerror (rc)); | 1189 | gcry_strerror (rc)); |
1171 | return GNUNET_SYSERR; | 1190 | return GNUNET_SYSERR; |
1191 | BENCHMARK_END (rsa_verify); | ||
1172 | } | 1192 | } |
1193 | BENCHMARK_END (rsa_verify); | ||
1173 | return GNUNET_OK; | 1194 | return GNUNET_OK; |
1174 | } | 1195 | } |
1175 | 1196 | ||