aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_crypto_ksk.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-10-14 08:06:57 +0000
committerChristian Grothoff <christian@grothoff.org>2010-10-14 08:06:57 +0000
commit84d16f7cc432df64260e932cdc785c6631f0a736 (patch)
tree878d4f3f8e1d6842c0ea4dbb78d2caddc6b395d8 /src/util/test_crypto_ksk.c
parentf09d601b5b22e39c1e6cc5b04d6278e53847949e (diff)
downloadgnunet-84d16f7cc432df64260e932cdc785c6631f0a736.tar.gz
gnunet-84d16f7cc432df64260e932cdc785c6631f0a736.zip
fix as suggested by amatus:
Diffstat (limited to 'src/util/test_crypto_ksk.c')
-rw-r--r--src/util/test_crypto_ksk.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/util/test_crypto_ksk.c b/src/util/test_crypto_ksk.c
index 952b1dcac..d5a965d42 100644
--- a/src/util/test_crypto_ksk.c
+++ b/src/util/test_crypto_ksk.c
@@ -36,6 +36,43 @@
36 36
37 37
38static int 38static int
39testCorrectKey ()
40{
41 const char *want = "010601000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b73c215f7a5e6b09bec55713c901786c09324a150980e014bdb0d04426934929c3b4971a9711af5455536cd6eeb8bfa004ee904972a737455f53c752987d8e5e1396e5e5a4ed694fb1d45e15ae68d8756e525cbaf6ab6ed0269ac402f2a6b8a73627e3797496b43a851271cb7d7b60b6acf4324ba72be5cafcef98dca8d71d1b01010000";
42 GNUNET_HashCode in;
43 struct GNUNET_CRYPTO_RsaPrivateKey *hostkey;
44 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
45 int i;
46 char out[3];
47
48 fprintf (stderr, "Testing KBlock key correctness");
49 GNUNET_CRYPTO_hash ("X", strlen ("X"), &in);
50 hostkey = GNUNET_CRYPTO_rsa_key_create_from_hash (&in);
51 if (hostkey == NULL)
52 {
53 GNUNET_break (0);
54 return GNUNET_SYSERR;
55 }
56 GNUNET_CRYPTO_rsa_key_get_public (hostkey, &pkey);
57 GNUNET_CRYPTO_rsa_key_free (hostkey);
58 for (i=0;i<sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded);i++)
59 {
60 snprintf(out, sizeof (out), "%02x", ((unsigned char*) &pkey)[i]);
61 if (0 != strncmp (out, &want[i*2], 2))
62 {
63 fprintf (stderr,
64 "Wanted %.2s but got %2s\n",
65 &want[i*2],
66 out);
67 return GNUNET_SYSERR;
68 }
69 }
70 fprintf (stderr, " OK\n");
71 return GNUNET_OK;
72}
73
74
75static int
39testMultiKey (const char *word) 76testMultiKey (const char *word)
40{ 77{
41 GNUNET_HashCode in; 78 GNUNET_HashCode in;
@@ -201,6 +238,8 @@ main (int argc, char *argv[])
201 return 1; 238 return 1;
202 } 239 }
203 240
241 if (GNUNET_OK != testCorrectKey ())
242 failureCount++;
204 if (GNUNET_OK != testMultiKey ("foo")) 243 if (GNUNET_OK != testMultiKey ("foo"))
205 failureCount++; 244 failureCount++;
206 if (GNUNET_OK != testMultiKey ("bar")) 245 if (GNUNET_OK != testMultiKey ("bar"))