diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-09-03 14:19:46 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-09-03 14:19:46 +0000 |
commit | 526a96f0b6eb60899a1eaa2b281b2728980c5ee0 (patch) | |
tree | c8aade8e658e7bae319f9c94f80cb517f18ae946 /src/util/crypto_rsa.c | |
parent | 8049927717b940abf3af8e697eb381871a3ca3d5 (diff) | |
download | gnunet-526a96f0b6eb60899a1eaa2b281b2728980c5ee0.tar.gz gnunet-526a96f0b6eb60899a1eaa2b281b2728980c5ee0.zip |
-add benchmark for RSA crypto
Diffstat (limited to 'src/util/crypto_rsa.c')
-rw-r--r-- | src/util/crypto_rsa.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index 3b36cc341..bde77ad56 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -608,7 +608,7 @@ GNUNET_CRYPTO_rsa_blinding_key_encode (const struct GNUNET_CRYPTO_rsa_BlindingKe | |||
608 | */ | 608 | */ |
609 | struct GNUNET_CRYPTO_rsa_BlindingKey * | 609 | struct GNUNET_CRYPTO_rsa_BlindingKey * |
610 | GNUNET_CRYPTO_rsa_blinding_key_decode (const char *buf, | 610 | GNUNET_CRYPTO_rsa_blinding_key_decode (const char *buf, |
611 | size_t len) | 611 | size_t len) |
612 | { | 612 | { |
613 | struct GNUNET_CRYPTO_rsa_BlindingKey *bkey; | 613 | struct GNUNET_CRYPTO_rsa_BlindingKey *bkey; |
614 | size_t rsize; | 614 | size_t rsize; |
@@ -753,6 +753,7 @@ GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_rsa_PrivateKey *key, | |||
753 | size_t msg_len) | 753 | size_t msg_len) |
754 | { | 754 | { |
755 | struct GNUNET_CRYPTO_rsa_Signature *sig; | 755 | struct GNUNET_CRYPTO_rsa_Signature *sig; |
756 | struct GNUNET_CRYPTO_rsa_PublicKey *public_key; | ||
756 | gcry_sexp_t result; | 757 | gcry_sexp_t result; |
757 | gcry_sexp_t data; | 758 | gcry_sexp_t data; |
758 | 759 | ||
@@ -766,6 +767,23 @@ GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_rsa_PrivateKey *key, | |||
766 | GNUNET_break (0); | 767 | GNUNET_break (0); |
767 | return NULL; | 768 | return NULL; |
768 | } | 769 | } |
770 | |||
771 | /* verify signature (guards against Lenstra's attack with fault injection...) */ | ||
772 | public_key = GNUNET_CRYPTO_rsa_private_key_get_public (key); | ||
773 | if (0 != | ||
774 | gcry_pk_verify (result, | ||
775 | data, | ||
776 | public_key->sexp)) | ||
777 | { | ||
778 | GNUNET_break (0); | ||
779 | GNUNET_CRYPTO_rsa_public_key_free (public_key); | ||
780 | gcry_sexp_release (data); | ||
781 | gcry_sexp_release (result); | ||
782 | return NULL; | ||
783 | } | ||
784 | GNUNET_CRYPTO_rsa_public_key_free (public_key); | ||
785 | |||
786 | /* return signature */ | ||
769 | gcry_sexp_release (data); | 787 | gcry_sexp_release (data); |
770 | sig = GNUNET_new (struct GNUNET_CRYPTO_rsa_Signature); | 788 | sig = GNUNET_new (struct GNUNET_CRYPTO_rsa_Signature); |
771 | sig->sexp = result; | 789 | sig->sexp = result; |