aboutsummaryrefslogtreecommitdiff
path: root/src/gnsrecord/test_gnsrecord_crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnsrecord/test_gnsrecord_crypto.c')
-rw-r--r--src/gnsrecord/test_gnsrecord_crypto.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/gnsrecord/test_gnsrecord_crypto.c b/src/gnsrecord/test_gnsrecord_crypto.c
index b9b2b5ba5..9e5a1aa7e 100644
--- a/src/gnsrecord/test_gnsrecord_crypto.c
+++ b/src/gnsrecord/test_gnsrecord_crypto.c
@@ -92,6 +92,7 @@ rd_decrypt_cb (void *cls,
92 res = 0; 92 res = 0;
93} 93}
94 94
95
95static void 96static void
96test_with_type (struct GNUNET_IDENTITY_PrivateKey *privkey) 97test_with_type (struct GNUNET_IDENTITY_PrivateKey *privkey)
97{ 98{
@@ -99,6 +100,7 @@ test_with_type (struct GNUNET_IDENTITY_PrivateKey *privkey)
99 struct GNUNET_IDENTITY_PublicKey pubkey; 100 struct GNUNET_IDENTITY_PublicKey pubkey;
100 struct GNUNET_HashCode query_pub; 101 struct GNUNET_HashCode query_pub;
101 struct GNUNET_HashCode query_priv; 102 struct GNUNET_HashCode query_priv;
103 struct GNUNET_HashCode query_block;
102 struct GNUNET_TIME_Absolute expire = GNUNET_TIME_absolute_get (); 104 struct GNUNET_TIME_Absolute expire = GNUNET_TIME_absolute_get ();
103 105
104 106
@@ -117,7 +119,7 @@ test_with_type (struct GNUNET_IDENTITY_PrivateKey *privkey)
117 &query_pub, 119 &query_pub,
118 sizeof(struct GNUNET_HashCode))); 120 sizeof(struct GNUNET_HashCode)));
119 /* create record */ 121 /* create record */
120 s_name = "DUMMY.dummy.gnunet"; 122 s_name = "testlabel";
121 s_rd = create_record (RECORDS); 123 s_rd = create_record (RECORDS);
122 124
123 /* Create block */ 125 /* Create block */
@@ -128,6 +130,13 @@ test_with_type (struct GNUNET_IDENTITY_PrivateKey *privkey)
128 s_rd, 130 s_rd,
129 RECORDS))); 131 RECORDS)));
130 GNUNET_assert (GNUNET_OK == 132 GNUNET_assert (GNUNET_OK ==
133 GNUNET_GNSRECORD_query_from_block (block,
134 &query_block));
135 GNUNET_assert (0 == memcmp (&query_pub,
136 &query_block,
137 sizeof(struct GNUNET_HashCode)));
138
139 GNUNET_assert (GNUNET_OK ==
131 GNUNET_GNSRECORD_block_verify (block)); 140 GNUNET_GNSRECORD_block_verify (block));
132 GNUNET_assert (GNUNET_OK == 141 GNUNET_assert (GNUNET_OK ==
133 GNUNET_GNSRECORD_block_decrypt (block, 142 GNUNET_GNSRECORD_block_decrypt (block,
@@ -139,7 +148,6 @@ test_with_type (struct GNUNET_IDENTITY_PrivateKey *privkey)
139} 148}
140 149
141 150
142
143static void 151static void
144run (void *cls, 152run (void *cls,
145 char *const *args, 153 char *const *args,
@@ -158,17 +166,17 @@ run (void *cls,
158 test_with_type (&privkey); 166 test_with_type (&privkey);
159 end = GNUNET_TIME_absolute_get (); 167 end = GNUNET_TIME_absolute_get ();
160 printf ("Time: %llu ms\n", (unsigned long long) 168 printf ("Time: %llu ms\n", (unsigned long long)
161 GNUNET_TIME_absolute_get_difference (start, 169 GNUNET_TIME_absolute_get_difference (start,
162 end).rel_value_us); 170 end).rel_value_us);
163 171
164 privkey_ed.type = htonl (GNUNET_GNSRECORD_TYPE_EDKEY); 172 privkey_ed.type = htonl (GNUNET_GNSRECORD_TYPE_EDKEY);
165 GNUNET_CRYPTO_eddsa_key_create (&privkey_ed.eddsa_key); 173 GNUNET_CRYPTO_eddsa_key_create (&privkey_ed.eddsa_key);
166 start = GNUNET_TIME_absolute_get (); 174 start = GNUNET_TIME_absolute_get ();
167 test_with_type(&privkey_ed); 175 test_with_type (&privkey_ed);
168 end = GNUNET_TIME_absolute_get (); 176 end = GNUNET_TIME_absolute_get ();
169 printf ("Time: %llu ms\n", (unsigned long long) 177 printf ("Time: %llu ms\n", (unsigned long long)
170 GNUNET_TIME_absolute_get_difference (start, 178 GNUNET_TIME_absolute_get_difference (start,
171 end).rel_value_us); 179 end).rel_value_us);
172 180
173 181
174} 182}