diff options
Diffstat (limited to 'src/util/crypto_rsa.c')
-rw-r--r-- | src/util/crypto_rsa.c | 21 |
1 files changed, 21 insertions, 0 deletions
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 | ||