diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-10-14 09:30:07 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-10-14 09:30:07 +0000 |
commit | 0b10a7373e61d25aec4156ebd81123a39c0abe46 (patch) | |
tree | 41976fec0a24ecc95421d42b29e0d9fbff50c4e5 /src/util/test_crypto_ksk.c | |
parent | 84d16f7cc432df64260e932cdc785c6631f0a736 (diff) | |
download | gnunet-0b10a7373e61d25aec4156ebd81123a39c0abe46.tar.gz gnunet-0b10a7373e61d25aec4156ebd81123a39c0abe46.zip |
stuff
Diffstat (limited to 'src/util/test_crypto_ksk.c')
-rw-r--r-- | src/util/test_crypto_ksk.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/util/test_crypto_ksk.c b/src/util/test_crypto_ksk.c index d5a965d42..29c98b931 100644 --- a/src/util/test_crypto_ksk.c +++ b/src/util/test_crypto_ksk.c | |||
@@ -55,13 +55,18 @@ testCorrectKey () | |||
55 | } | 55 | } |
56 | GNUNET_CRYPTO_rsa_key_get_public (hostkey, &pkey); | 56 | GNUNET_CRYPTO_rsa_key_get_public (hostkey, &pkey); |
57 | GNUNET_CRYPTO_rsa_key_free (hostkey); | 57 | GNUNET_CRYPTO_rsa_key_free (hostkey); |
58 | #if 1 | ||
59 | for (i=0;i<sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded);i++) | ||
60 | printf(out, sizeof (out), "%02x", ((unsigned char*) &pkey)[i]); | ||
61 | printf ("\n"); | ||
62 | #endif | ||
58 | for (i=0;i<sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded);i++) | 63 | for (i=0;i<sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded);i++) |
59 | { | 64 | { |
60 | snprintf(out, sizeof (out), "%02x", ((unsigned char*) &pkey)[i]); | 65 | snprintf(out, sizeof (out), "%02x", ((unsigned char*) &pkey)[i]); |
61 | if (0 != strncmp (out, &want[i*2], 2)) | 66 | if (0 != strncmp (out, &want[i*2], 2)) |
62 | { | 67 | { |
63 | fprintf (stderr, | 68 | fprintf (stderr, |
64 | "Wanted %.2s but got %2s\n", | 69 | " Failed! Wanted %.2s but got %2s\n", |
65 | &want[i*2], | 70 | &want[i*2], |
66 | out); | 71 | out); |
67 | return GNUNET_SYSERR; | 72 | return GNUNET_SYSERR; |
@@ -230,6 +235,8 @@ main (int argc, char *argv[]) | |||
230 | struct GNUNET_CRYPTO_RsaPrivateKey *hostkey; | 235 | struct GNUNET_CRYPTO_RsaPrivateKey *hostkey; |
231 | 236 | ||
232 | GNUNET_log_setup ("test-crypto-ksk", "WARNING", NULL); | 237 | GNUNET_log_setup ("test-crypto-ksk", "WARNING", NULL); |
238 | if (GNUNET_OK != testCorrectKey ()) | ||
239 | failureCount++; | ||
233 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &in); | 240 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &in); |
234 | hostkey = GNUNET_CRYPTO_rsa_key_create_from_hash (&in); | 241 | hostkey = GNUNET_CRYPTO_rsa_key_create_from_hash (&in); |
235 | if (hostkey == NULL) | 242 | if (hostkey == NULL) |
@@ -237,9 +244,6 @@ main (int argc, char *argv[]) | |||
237 | printf ("\nGNUNET_CRYPTO_rsa_key_create_from_hash failed!\n"); | 244 | printf ("\nGNUNET_CRYPTO_rsa_key_create_from_hash failed!\n"); |
238 | return 1; | 245 | return 1; |
239 | } | 246 | } |
240 | |||
241 | if (GNUNET_OK != testCorrectKey ()) | ||
242 | failureCount++; | ||
243 | if (GNUNET_OK != testMultiKey ("foo")) | 247 | if (GNUNET_OK != testMultiKey ("foo")) |
244 | failureCount++; | 248 | failureCount++; |
245 | if (GNUNET_OK != testMultiKey ("bar")) | 249 | if (GNUNET_OK != testMultiKey ("bar")) |