From 62cb95a862cb8d730b8c87930195332a54f26dca Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 5 Nov 2013 17:35:25 +0000 Subject: Werner Koch wrote: Hi, find attach the patch which makes all 3 test cases work with Ed25519. There are some minor hacks in the test cases to allow enabling of Libgcrypt debugging and also some minor output style changes. There is one FIXME in the code: /* FIXME: mpi_print creates an unsigned integer - is that intended or should we convert it to a signed integer (2-compl)? */ mpi_print (xbuf, sizeof (xbuf), result_x); X may be positive or negative but GCRYMPI_FMT_USG ignores the sign. Thus this is not what we actually want. Should we change it to 2-comp (GCRYMPI_FMT_STD) so that we have a proper value? Given that the curve is 255 bit this should alwas fit int the 256 bit buffer. Another option would be to use the EdDSA method for the sign but that is optimized to easily recover x and would be more work. Or we store the sign in the high bit. t all depends on what you want to write into the protocol specs. I would also like to revert the way we distinguish between Ed25519 with and without ECDSA: The way we do it right now is by assuming the Ed25519 is always used with EdDSA unless a flag has been set. This is a bit surprising and requiring the "(flags eddsa)" would be a less surprising interface. Salam-Shalom, Werner --- src/util/test_crypto_ecdsa.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/util/test_crypto_ecdsa.c') diff --git a/src/util/test_crypto_ecdsa.c b/src/util/test_crypto_ecdsa.c index 27c0fb137..bf5fcf571 100644 --- a/src/util/test_crypto_ecdsa.c +++ b/src/util/test_crypto_ecdsa.c @@ -30,7 +30,7 @@ #define ITER 25 -#define PERF GNUNET_YES +#define PERF GNUNET_NO static struct GNUNET_CRYPTO_EcdsaPrivateKey *key; @@ -54,7 +54,7 @@ testSignVerify () for (i = 0; i < ITER; i++) { - FPRINTF (stderr, "%s", "."); + FPRINTF (stderr, "%s", "."); fflush (stderr); if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign (key, &purp, &sig)) { FPRINTF (stderr, @@ -156,7 +156,7 @@ testSignPerformance () start = GNUNET_TIME_absolute_get (); for (i = 0; i < ITER; i++) { - FPRINTF (stderr, "%s", "."); + FPRINTF (stderr, "%s", "."); fflush (stderr); if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign (key, &purp, &sig)) { FPRINTF (stderr, "%s", @@ -180,15 +180,18 @@ perf_keygen () struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; int i; + FPRINTF (stderr, "%s", "W"); start = GNUNET_TIME_absolute_get (); for (i=0;i<10;i++) { - fprintf (stderr, "."); + fprintf (stderr, "."); fflush (stderr); pk = GNUNET_CRYPTO_ecdsa_key_create (); GNUNET_free (pk); } - fprintf (stderr, "\n"); - printf ("Creating 10 ECDSA keys took %s\n", + for (;i<25;i++) + fprintf (stderr, "."); + fflush (stderr); + printf ("10 ECDSA keys created in %s\n", GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES)); } @@ -198,14 +201,16 @@ main (int argc, char *argv[]) { int failure_count = 0; - if (! gcry_check_version ("1.5.0")) + if (! gcry_check_version ("1.6.0")) { FPRINTF (stderr, _ ("libgcrypt has not the expected version (version %s is required).\n"), - "1.5.0"); + "1.6.0"); return 0; } + if (getenv ("GNUNET_GCRYPT_DEBUG")) + gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0); GNUNET_log_setup ("test-crypto-ecc", "WARNING", NULL); key = GNUNET_CRYPTO_ecdsa_key_create (); if (GNUNET_OK != testDeriveSignVerify ()) -- cgit v1.2.3