aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_crypto_ecdsa.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_ecdsa.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_ecdsa.c')
-rw-r--r--src/util/test_crypto_ecdsa.c21
1 files changed, 13 insertions, 8 deletions
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 @@
30 30
31#define ITER 25 31#define ITER 25
32 32
33#define PERF GNUNET_YES 33#define PERF GNUNET_NO
34 34
35 35
36static struct GNUNET_CRYPTO_EcdsaPrivateKey *key; 36static struct GNUNET_CRYPTO_EcdsaPrivateKey *key;
@@ -54,7 +54,7 @@ testSignVerify ()
54 54
55 for (i = 0; i < ITER; i++) 55 for (i = 0; i < ITER; i++)
56 { 56 {
57 FPRINTF (stderr, "%s", "."); 57 FPRINTF (stderr, "%s", "."); fflush (stderr);
58 if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign (key, &purp, &sig)) 58 if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign (key, &purp, &sig))
59 { 59 {
60 FPRINTF (stderr, 60 FPRINTF (stderr,
@@ -156,7 +156,7 @@ testSignPerformance ()
156 start = GNUNET_TIME_absolute_get (); 156 start = GNUNET_TIME_absolute_get ();
157 for (i = 0; i < ITER; i++) 157 for (i = 0; i < ITER; i++)
158 { 158 {
159 FPRINTF (stderr, "%s", "."); 159 FPRINTF (stderr, "%s", "."); fflush (stderr);
160 if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign (key, &purp, &sig)) 160 if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign (key, &purp, &sig))
161 { 161 {
162 FPRINTF (stderr, "%s", 162 FPRINTF (stderr, "%s",
@@ -180,15 +180,18 @@ perf_keygen ()
180 struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; 180 struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
181 int i; 181 int i;
182 182
183 FPRINTF (stderr, "%s", "W");
183 start = GNUNET_TIME_absolute_get (); 184 start = GNUNET_TIME_absolute_get ();
184 for (i=0;i<10;i++) 185 for (i=0;i<10;i++)
185 { 186 {
186 fprintf (stderr, "."); 187 fprintf (stderr, "."); fflush (stderr);
187 pk = GNUNET_CRYPTO_ecdsa_key_create (); 188 pk = GNUNET_CRYPTO_ecdsa_key_create ();
188 GNUNET_free (pk); 189 GNUNET_free (pk);
189 } 190 }
190 fprintf (stderr, "\n"); 191 for (;i<25;i++)
191 printf ("Creating 10 ECDSA keys took %s\n", 192 fprintf (stderr, ".");
193 fflush (stderr);
194 printf ("10 ECDSA keys created in %s\n",
192 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES)); 195 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES));
193} 196}
194 197
@@ -198,14 +201,16 @@ main (int argc, char *argv[])
198{ 201{
199 int failure_count = 0; 202 int failure_count = 0;
200 203
201 if (! gcry_check_version ("1.5.0")) 204 if (! gcry_check_version ("1.6.0"))
202 { 205 {
203 FPRINTF (stderr, 206 FPRINTF (stderr,
204 _ 207 _
205 ("libgcrypt has not the expected version (version %s is required).\n"), 208 ("libgcrypt has not the expected version (version %s is required).\n"),
206 "1.5.0"); 209 "1.6.0");
207 return 0; 210 return 0;
208 } 211 }
212 if (getenv ("GNUNET_GCRYPT_DEBUG"))
213 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
209 GNUNET_log_setup ("test-crypto-ecc", "WARNING", NULL); 214 GNUNET_log_setup ("test-crypto-ecc", "WARNING", NULL);
210 key = GNUNET_CRYPTO_ecdsa_key_create (); 215 key = GNUNET_CRYPTO_ecdsa_key_create ();
211 if (GNUNET_OK != testDeriveSignVerify ()) 216 if (GNUNET_OK != testDeriveSignVerify ())