aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_crypto_eddsa.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-11-05 17:35:25 +0000
committerChristian Grothoff <christian@grothoff.org>2013-11-05 17:35:25 +0000
commit62cb95a862cb8d730b8c87930195332a54f26dca (patch)
treeae4673a67e3a4bbb01665dadb88b506256bc4090 /src/util/test_crypto_eddsa.c
parent5ff9d6c06021db8efad154660843ed4f3617fd98 (diff)
downloadgnunet-62cb95a862cb8d730b8c87930195332a54f26dca.tar.gz
gnunet-62cb95a862cb8d730b8c87930195332a54f26dca.zip
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
Diffstat (limited to 'src/util/test_crypto_eddsa.c')
-rw-r--r--src/util/test_crypto_eddsa.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/util/test_crypto_eddsa.c b/src/util/test_crypto_eddsa.c
index 209eea5c6..eda285af8 100644
--- a/src/util/test_crypto_eddsa.c
+++ b/src/util/test_crypto_eddsa.c
@@ -56,7 +56,7 @@ testSignVerify ()
56 56
57 for (i = 0; i < ITER; i++) 57 for (i = 0; i < ITER; i++)
58 { 58 {
59 FPRINTF (stderr, "%s", "."); 59 FPRINTF (stderr, "%s", "."); fflush (stderr);
60 if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_sign (key, &purp, &sig)) 60 if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_sign (key, &purp, &sig))
61 { 61 {
62 FPRINTF (stderr, "%s", "GNUNET_CRYPTO_eddsa_sign returned SYSERR\n"); 62 FPRINTF (stderr, "%s", "GNUNET_CRYPTO_eddsa_sign returned SYSERR\n");
@@ -80,7 +80,7 @@ testSignVerify ()
80 continue; 80 continue;
81 } 81 }
82 } 82 }
83 printf ("%d ECC sign/verify operations %s\n", ITER, 83 printf ("%d EdDSA sign/verify operations %s\n", ITER,
84 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES)); 84 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES));
85 return ok; 85 return ok;
86} 86}
@@ -104,7 +104,7 @@ testSignPerformance ()
104 start = GNUNET_TIME_absolute_get (); 104 start = GNUNET_TIME_absolute_get ();
105 for (i = 0; i < ITER; i++) 105 for (i = 0; i < ITER; i++)
106 { 106 {
107 FPRINTF (stderr, "%s", "."); 107 FPRINTF (stderr, "%s", "."); fflush (stderr);
108 if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_sign (key, &purp, &sig)) 108 if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_sign (key, &purp, &sig))
109 { 109 {
110 FPRINTF (stderr, "%s", "GNUNET_CRYPTO_eddsa_sign returned SYSERR\n"); 110 FPRINTF (stderr, "%s", "GNUNET_CRYPTO_eddsa_sign returned SYSERR\n");
@@ -152,15 +152,18 @@ perf_keygen ()
152 struct GNUNET_CRYPTO_EddsaPrivateKey *pk; 152 struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
153 int i; 153 int i;
154 154
155 FPRINTF (stderr, "%s", "W");
155 start = GNUNET_TIME_absolute_get (); 156 start = GNUNET_TIME_absolute_get ();
156 for (i=0;i<10;i++) 157 for (i=0;i<10;i++)
157 { 158 {
158 fprintf (stderr, "."); 159 fprintf (stderr, "."); fflush (stderr);
159 pk = GNUNET_CRYPTO_eddsa_key_create (); 160 pk = GNUNET_CRYPTO_eddsa_key_create ();
160 GNUNET_free (pk); 161 GNUNET_free (pk);
161 } 162 }
162 fprintf (stderr, "\n"); 163 for (;i<25;i++)
163 printf ("Creating 10 EdDSA keys took %s\n", 164 fprintf (stderr, ".");
165 fflush (stderr);
166 printf ("10 EdDSA keys created in %s\n",
164 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES)); 167 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES));
165} 168}
166 169
@@ -170,13 +173,15 @@ main (int argc, char *argv[])
170{ 173{
171 int failure_count = 0; 174 int failure_count = 0;
172 175
173 if (! gcry_check_version ("1.5.0")) 176 if (! gcry_check_version ("1.6.0"))
174 { 177 {
175 FPRINTF (stderr, 178 FPRINTF (stderr,
176 _("libgcrypt has not the expected version (version %s is required).\n"), 179 _("libgcrypt has not the expected version (version %s is required).\n"),
177 "1.5.0"); 180 "1.6.0");
178 return 0; 181 return 0;
179 } 182 }
183 if (getenv ("GNUNET_GCRYPT_DEBUG"))
184 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
180 GNUNET_log_setup ("test-crypto-eddsa", "WARNING", NULL); 185 GNUNET_log_setup ("test-crypto-eddsa", "WARNING", NULL);
181 key = GNUNET_CRYPTO_eddsa_key_create (); 186 key = GNUNET_CRYPTO_eddsa_key_create ();
182#if PERF 187#if PERF