X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futil%2Fperf_crypto_rsa.c;h=685389206f8d74ff7617c68517748fa7ed738d45;hb=31adcb0e020b7861ee7f306a6e2fac0df9b10290;hp=70cd785b5a6294cf2240990b80a91f375e2a9c32;hpb=1733de7305720882b8745e82b51b6ff47c10099e;p=oweals%2Fgnunet.git diff --git a/src/util/perf_crypto_rsa.c b/src/util/perf_crypto_rsa.c index 70cd785b5..685389206 100644 --- a/src/util/perf_crypto_rsa.c +++ b/src/util/perf_crypto_rsa.c @@ -2,20 +2,20 @@ This file is part of GNUnet. Copyright (C) 2014 GNUnet e.V. - GNUnet is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3, or (at your - option) any later version. + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . - You should have received a copy of the GNU General Public License - along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: AGPL3.0-or-later */ /** @@ -41,7 +41,7 @@ eval (unsigned int len) struct GNUNET_CRYPTO_RsaSignature *rsig; struct GNUNET_CRYPTO_RsaPublicKey *public_key; struct GNUNET_CRYPTO_RsaPrivateKey *private_key; - struct GNUNET_CRYPTO_rsa_BlindingKey *bkey; + struct GNUNET_CRYPTO_RsaBlindingKeySecret bsec[10]; unsigned int i; char sbuf[128]; char *bbuf; @@ -68,12 +68,13 @@ eval (unsigned int len) (start).rel_value_us / 1000LL), "keys/ms"); private_key = GNUNET_CRYPTO_rsa_private_key_create (len); public_key = GNUNET_CRYPTO_rsa_private_key_get_public (private_key); + for (i=0;i<10;i++) + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, + &bsec[i], sizeof (bsec[0])); + /* start = GNUNET_TIME_absolute_get (); for (i=0;i<10;i++) - { - bkey = GNUNET_CRYPTO_rsa_blinding_key_create (len); - GNUNET_CRYPTO_rsa_blinding_key_free (bkey); - } + rsa_blinding_key_derive(public_key, &bsec[i]); printf ("10x %u-blinding key generation took %s\n", len, GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), @@ -86,15 +87,15 @@ eval (unsigned int len) 64 * 1024 / (1 + GNUNET_TIME_absolute_get_duration (start).rel_value_us / 1000LL), "keys/ms"); - bkey = GNUNET_CRYPTO_rsa_blinding_key_create (len); + */ start = GNUNET_TIME_absolute_get (); GNUNET_CRYPTO_hash ("test", 4, &hc); for (i=0;i<10;i++) { - bbuf_len = GNUNET_CRYPTO_rsa_blind (&hc, - bkey, - public_key, - &bbuf); + GNUNET_CRYPTO_rsa_blind (&hc, + &bsec[i], + public_key, + &bbuf, &bbuf_len); GNUNET_free (bbuf); } printf ("10x %u-blinding took %s\n", @@ -110,16 +111,15 @@ eval (unsigned int len) 64 * 1024 / (1 + GNUNET_TIME_absolute_get_duration (start).rel_value_us / 1000LL), "ops/ms"); - bbuf_len = GNUNET_CRYPTO_rsa_blind (&hc, - bkey, - public_key, - &bbuf); + GNUNET_CRYPTO_rsa_blind (&hc, + &bsec[0], + public_key, + &bbuf, &bbuf_len); start = GNUNET_TIME_absolute_get (); for (i=0;i<10;i++) { - sig = GNUNET_CRYPTO_rsa_sign (private_key, - bbuf, - bbuf_len); + sig = GNUNET_CRYPTO_rsa_sign_blinded (private_key, + bbuf, bbuf_len); GNUNET_CRYPTO_rsa_signature_free (sig); } printf ("10x %u-signing took %s\n", @@ -135,14 +135,14 @@ eval (unsigned int len) 64 * 1024 / (1 + GNUNET_TIME_absolute_get_duration (start).rel_value_us / 1000LL), "ops/ms"); - sig = GNUNET_CRYPTO_rsa_sign (private_key, - bbuf, - bbuf_len); + sig = GNUNET_CRYPTO_rsa_sign_blinded (private_key, + bbuf, + bbuf_len); start = GNUNET_TIME_absolute_get (); for (i=0;i<10;i++) { rsig = GNUNET_CRYPTO_rsa_unblind (sig, - bkey, + &bsec[0], public_key); GNUNET_CRYPTO_rsa_signature_free (rsig); } @@ -160,7 +160,7 @@ eval (unsigned int len) GNUNET_TIME_absolute_get_duration (start).rel_value_us / 1000LL), "ops/ms"); rsig = GNUNET_CRYPTO_rsa_unblind (sig, - bkey, + &bsec[0], public_key); start = GNUNET_TIME_absolute_get (); for (i=0;i<10;i++) @@ -186,7 +186,6 @@ eval (unsigned int len) GNUNET_CRYPTO_rsa_signature_free (sig); GNUNET_CRYPTO_rsa_public_key_free (public_key); GNUNET_CRYPTO_rsa_private_key_free (private_key); - GNUNET_CRYPTO_rsa_blinding_key_free (bkey); GNUNET_free (bbuf); } @@ -194,8 +193,8 @@ eval (unsigned int len) int main (int argc, char *argv[]) { - eval (1024); - eval (2048); + eval (1024); + /* eval (2048); */ /* eval (4096); */ return 0; }