diff options
Diffstat (limited to 'src/gnsrecord/gnunet-gnsrecord-tvg.c')
-rw-r--r-- | src/gnsrecord/gnunet-gnsrecord-tvg.c | 223 |
1 files changed, 171 insertions, 52 deletions
diff --git a/src/gnsrecord/gnunet-gnsrecord-tvg.c b/src/gnsrecord/gnunet-gnsrecord-tvg.c index 16a360bdc..f9b83e48b 100644 --- a/src/gnsrecord/gnunet-gnsrecord-tvg.c +++ b/src/gnsrecord/gnunet-gnsrecord-tvg.c | |||
@@ -31,15 +31,43 @@ | |||
31 | #include "gnunet_dnsparser_lib.h" | 31 | #include "gnunet_dnsparser_lib.h" |
32 | #include "gnunet_testing_lib.h" | 32 | #include "gnunet_testing_lib.h" |
33 | #include <inttypes.h> | 33 | #include <inttypes.h> |
34 | #include "gnsrecord_crypto.h" | ||
34 | 35 | ||
35 | #define TEST_RECORD_LABEL "test" | 36 | #define TEST_RECORD_LABEL "test" |
36 | #define TEST_RECORD_A "1.2.3.4" | 37 | #define TEST_RECORD_A "1.2.3.4" |
37 | #define TEST_RRCOUNT 2 | 38 | #define TEST_RRCOUNT 2 |
38 | 39 | ||
40 | static char *d_pkey = | ||
41 | "50d7b652a4efeadff37396909785e5952171a02178c8e7d450fa907925fafd98"; | ||
42 | |||
43 | static char *d_edkey = | ||
44 | "5af7020ee19160328832352bbc6a68a8d71a7cbe1b929969a7c66d415a0d8f65"; | ||
45 | |||
46 | int parsehex (char *src, char *dst, size_t dstlen, int invert) | ||
47 | { | ||
48 | char *line = src; | ||
49 | char *data = line; | ||
50 | int off; | ||
51 | int read_byte; | ||
52 | int data_len = 0; | ||
53 | |||
54 | while (sscanf (data, " %02x%n", &read_byte, &off) == 1) | ||
55 | { | ||
56 | if (invert) | ||
57 | dst[dstlen - 1 - data_len++] = read_byte; | ||
58 | else | ||
59 | dst[data_len++] = read_byte; | ||
60 | data += off; | ||
61 | } | ||
62 | return data_len; | ||
63 | } | ||
64 | |||
65 | |||
39 | static void | 66 | static void |
40 | print_bytes (void *buf, | 67 | print_bytes_ (void *buf, |
41 | size_t buf_len, | 68 | size_t buf_len, |
42 | int fold) | 69 | int fold, |
70 | int in_be) | ||
43 | { | 71 | { |
44 | int i; | 72 | int i; |
45 | 73 | ||
@@ -47,11 +75,22 @@ print_bytes (void *buf, | |||
47 | { | 75 | { |
48 | if ((0 != i) && (0 != fold) && (i % fold == 0)) | 76 | if ((0 != i) && (0 != fold) && (i % fold == 0)) |
49 | printf ("\n"); | 77 | printf ("\n"); |
50 | printf ("%02x", ((unsigned char*) buf)[i]); | 78 | if (in_be) |
79 | printf ("%02x", ((unsigned char*) buf)[buf_len - 1 - i]); | ||
80 | else | ||
81 | printf ("%02x", ((unsigned char*) buf)[i]); | ||
51 | } | 82 | } |
52 | printf ("\n"); | 83 | printf ("\n"); |
53 | } | 84 | } |
54 | 85 | ||
86 | static void | ||
87 | print_bytes (void *buf, | ||
88 | size_t buf_len, | ||
89 | int fold) | ||
90 | { | ||
91 | print_bytes_ (buf, buf_len, fold, 0); | ||
92 | } | ||
93 | |||
55 | 94 | ||
56 | static void | 95 | static void |
57 | print_record (const struct GNUNET_GNSRECORD_Data *rd) | 96 | print_record (const struct GNUNET_GNSRECORD_Data *rd) |
@@ -84,28 +123,51 @@ static void | |||
84 | run_pkey (void) | 123 | run_pkey (void) |
85 | { | 124 | { |
86 | struct GNUNET_GNSRECORD_Data rd[2]; | 125 | struct GNUNET_GNSRECORD_Data rd[2]; |
87 | struct GNUNET_TIME_Absolute exp_abs = GNUNET_TIME_absolute_get (); | 126 | struct GNUNET_TIME_Absolute expire; |
127 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | ||
128 | struct GNUNET_TIME_Absolute exp1; | ||
129 | struct GNUNET_TIME_Absolute exp2; | ||
130 | struct GNUNET_TIME_Relative delta1; | ||
131 | struct GNUNET_TIME_Relative delta2; | ||
88 | struct GNUNET_GNSRECORD_Block *rrblock; | 132 | struct GNUNET_GNSRECORD_Block *rrblock; |
89 | char *bdata; | 133 | char *bdata; |
90 | struct GNUNET_IDENTITY_PrivateKey id_priv; | 134 | struct GNUNET_IDENTITY_PrivateKey id_priv; |
91 | struct GNUNET_IDENTITY_PublicKey id_pub; | 135 | struct GNUNET_IDENTITY_PublicKey id_pub; |
92 | struct GNUNET_IDENTITY_PrivateKey pkey_data_p; | 136 | struct GNUNET_IDENTITY_PrivateKey pkey_data_p; |
93 | struct GNUNET_IDENTITY_PublicKey pkey_data; | 137 | struct GNUNET_IDENTITY_PublicKey pkey_data; |
138 | struct GNUNET_HashCode query; | ||
94 | void *data; | 139 | void *data; |
95 | size_t data_size; | 140 | size_t data_size; |
96 | char *rdata; | 141 | char *rdata; |
97 | size_t rdata_size; | 142 | size_t rdata_size; |
143 | uint32_t rd_count_nbo; | ||
98 | char ztld[128]; | 144 | char ztld[128]; |
145 | unsigned char ctr[GNUNET_CRYPTO_AES_KEY_LENGTH / 2]; | ||
146 | unsigned char skey[GNUNET_CRYPTO_AES_KEY_LENGTH]; | ||
147 | |||
148 | /* | ||
149 | * Make two different expiration times | ||
150 | */ | ||
151 | GNUNET_STRINGS_fancy_time_to_absolute ("2048-01-23 10:51:34", | ||
152 | &exp1); | ||
153 | GNUNET_STRINGS_fancy_time_to_absolute ("3540-05-22 07:55:01", | ||
154 | &exp2); | ||
155 | |||
99 | 156 | ||
100 | id_priv.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); | 157 | id_priv.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); |
101 | GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key); | 158 | GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key); |
159 | parsehex (d_pkey, | ||
160 | (char*) &id_priv.ecdsa_key, | ||
161 | sizeof (id_priv.ecdsa_key), 1); | ||
162 | |||
102 | GNUNET_IDENTITY_key_get_public (&id_priv, | 163 | GNUNET_IDENTITY_key_get_public (&id_priv, |
103 | &id_pub); | 164 | &id_pub); |
104 | fprintf (stdout, | 165 | fprintf (stdout, |
105 | "Zone private key (d, little-endian, with ztype prepended):\n"); | 166 | "Zone private key (d, big-endian):\n"); |
106 | print_bytes (&id_priv, GNUNET_IDENTITY_key_get_length (&id_pub), 8); // FIXME length for privkey? | 167 | print_bytes_ (&id_priv.ecdsa_key, |
168 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey), 8, 1); | ||
107 | fprintf (stdout, "\n"); | 169 | fprintf (stdout, "\n"); |
108 | fprintf (stdout, "Zone identifier (zid):\n"); | 170 | fprintf (stdout, "Zone identifier (ztype|zkey):\n"); |
109 | print_bytes (&id_pub, GNUNET_IDENTITY_key_get_length (&id_pub), 8); | 171 | print_bytes (&id_pub, GNUNET_IDENTITY_key_get_length (&id_pub), 8); |
110 | GNUNET_STRINGS_data_to_string (&id_pub, | 172 | GNUNET_STRINGS_data_to_string (&id_pub, |
111 | GNUNET_IDENTITY_key_get_length (&id_pub), | 173 | GNUNET_IDENTITY_key_get_length (&id_pub), |
@@ -127,20 +189,20 @@ run_pkey (void) | |||
127 | GNUNET_DNSPARSER_TYPE_A, TEST_RECORD_A, &data, &data_size)); | 189 | GNUNET_DNSPARSER_TYPE_A, TEST_RECORD_A, &data, &data_size)); |
128 | rd[0].data = data; | 190 | rd[0].data = data; |
129 | rd[0].data_size = data_size; | 191 | rd[0].data_size = data_size; |
130 | rd[0].expiration_time = exp_abs.abs_value_us; | 192 | rd[0].expiration_time = exp1.abs_value_us; |
131 | rd[0].record_type = GNUNET_DNSPARSER_TYPE_A; | 193 | rd[0].record_type = GNUNET_DNSPARSER_TYPE_A; |
132 | fprintf (stdout, "Record #0\n"); | 194 | fprintf (stdout, "Record #0\n"); |
133 | print_record (&rd[0]); | 195 | print_record (&rd[0]); |
134 | 196 | ||
135 | rd[1].data = &pkey_data; | 197 | rd[1].data = "Some nick"; |
136 | rd[1].data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); | 198 | rd[1].data_size = sizeof (struct GNUNET_IDENTITY_PublicKey); |
137 | rd[1].expiration_time = exp_abs.abs_value_us; | 199 | rd[1].expiration_time = exp2.abs_value_us; |
138 | rd[1].record_type = GNUNET_GNSRECORD_TYPE_PKEY; | 200 | rd[1].record_type = GNUNET_GNSRECORD_TYPE_NICK; |
139 | rd[1].flags = GNUNET_GNSRECORD_RF_PRIVATE; | 201 | rd[1].flags = GNUNET_GNSRECORD_RF_PRIVATE; |
140 | fprintf (stdout, "Record #1\n"); | 202 | fprintf (stdout, "Record #1\n"); |
141 | print_record (&rd[1]); | 203 | print_record (&rd[1]); |
142 | 204 | ||
143 | rdata_size = GNUNET_GNSRECORD_records_get_size (2, | 205 | rdata_size = GNUNET_GNSRECORD_records_get_size (TEST_RRCOUNT, |
144 | rd); | 206 | rd); |
145 | rdata = GNUNET_malloc (rdata_size); | 207 | rdata = GNUNET_malloc (rdata_size); |
146 | GNUNET_GNSRECORD_records_serialize (2, | 208 | GNUNET_GNSRECORD_records_serialize (2, |
@@ -150,25 +212,40 @@ run_pkey (void) | |||
150 | fprintf (stdout, "RDATA:\n"); | 212 | fprintf (stdout, "RDATA:\n"); |
151 | print_bytes (rdata, rdata_size, 8); | 213 | print_bytes (rdata, rdata_size, 8); |
152 | fprintf (stdout, "\n"); | 214 | fprintf (stdout, "\n"); |
153 | rrblock = GNUNET_GNSRECORD_block_create (&id_priv, | 215 | expire = GNUNET_GNSRECORD_record_get_expiration_time (TEST_RRCOUNT, rd); |
154 | exp_abs, | 216 | GNR_derive_block_aes_key (ctr, |
155 | TEST_RECORD_LABEL, | 217 | skey, |
156 | rd, | 218 | TEST_RECORD_LABEL, |
157 | TEST_RRCOUNT); | 219 | GNUNET_TIME_absolute_hton ( |
158 | size_t bdata_size = ntohl (rrblock->ecdsa_block.purpose.size) | 220 | expire).abs_value_us__, |
159 | - sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) | 221 | &id_pub.ecdsa_key); |
160 | - sizeof(struct GNUNET_TIME_AbsoluteNBO); | 222 | |
161 | size_t ecblock_size = ntohl (rrblock->ecdsa_block.purpose.size) | 223 | fprintf (stdout, "Encryption NONCE|EXPIRATION|BLOCK COUNTER:\n"); |
162 | + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) | 224 | print_bytes (ctr, sizeof (ctr), 8); |
163 | + sizeof(struct GNUNET_CRYPTO_EcdsaSignature); | 225 | fprintf (stdout, "\n"); |
164 | size_t block_size = ecblock_size + sizeof (uint32_t); | 226 | fprintf (stdout, "Encryption key (K):\n"); |
227 | print_bytes (skey, sizeof (skey), 8); | ||
228 | fprintf (stdout, "\n"); | ||
229 | GNUNET_GNSRECORD_query_from_public_key (&id_pub, | ||
230 | TEST_RECORD_LABEL, | ||
231 | &query); | ||
232 | fprintf (stdout, "Storage key (q):\n"); | ||
233 | print_bytes (&query, sizeof (query), 8); | ||
234 | fprintf (stdout, "\n"); | ||
235 | GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_block_create (&id_priv, | ||
236 | expire, | ||
237 | TEST_RECORD_LABEL, | ||
238 | rd, | ||
239 | TEST_RRCOUNT, | ||
240 | &rrblock)); | ||
241 | size_t bdata_size = ntohl(rrblock->size) - sizeof (struct GNUNET_GNSRECORD_Block); | ||
165 | 242 | ||
166 | bdata = (char*) &(&rrblock->ecdsa_block)[1]; | 243 | bdata = (char*) &(&rrblock->ecdsa_block)[1]; |
167 | fprintf (stdout, "BDATA:\n"); | 244 | fprintf (stdout, "BDATA:\n"); |
168 | print_bytes (bdata, bdata_size, 8); | 245 | print_bytes (bdata, bdata_size, 8); |
169 | fprintf (stdout, "\n"); | 246 | fprintf (stdout, "\n"); |
170 | fprintf (stdout, "RRBLOCK:\n"); | 247 | fprintf (stdout, "RRBLOCK:\n"); |
171 | print_bytes (rrblock, block_size, 8); | 248 | print_bytes (rrblock, ntohl(rrblock->size), 8); |
172 | fprintf (stdout, "\n"); | 249 | fprintf (stdout, "\n"); |
173 | GNUNET_free (rdata); | 250 | GNUNET_free (rdata); |
174 | } | 251 | } |
@@ -186,28 +263,54 @@ static void | |||
186 | run_edkey (void) | 263 | run_edkey (void) |
187 | { | 264 | { |
188 | struct GNUNET_GNSRECORD_Data rd[2]; | 265 | struct GNUNET_GNSRECORD_Data rd[2]; |
189 | struct GNUNET_TIME_Absolute exp_abs = GNUNET_TIME_absolute_get (); | 266 | struct GNUNET_TIME_Absolute expire; |
267 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | ||
268 | struct GNUNET_TIME_Absolute exp1; | ||
269 | struct GNUNET_TIME_Absolute exp2; | ||
270 | struct GNUNET_TIME_Relative delta1; | ||
271 | struct GNUNET_TIME_Relative delta2; | ||
190 | struct GNUNET_GNSRECORD_Block *rrblock; | 272 | struct GNUNET_GNSRECORD_Block *rrblock; |
191 | char *bdata; | 273 | char *bdata; |
192 | struct GNUNET_IDENTITY_PrivateKey id_priv; | 274 | struct GNUNET_IDENTITY_PrivateKey id_priv; |
193 | struct GNUNET_IDENTITY_PublicKey id_pub; | 275 | struct GNUNET_IDENTITY_PublicKey id_pub; |
194 | struct GNUNET_IDENTITY_PrivateKey pkey_data_p; | 276 | struct GNUNET_IDENTITY_PrivateKey pkey_data_p; |
195 | struct GNUNET_IDENTITY_PublicKey pkey_data; | 277 | struct GNUNET_IDENTITY_PublicKey pkey_data; |
278 | struct GNUNET_HashCode query; | ||
196 | void *data; | 279 | void *data; |
197 | size_t data_size; | 280 | size_t data_size; |
198 | char *rdata; | 281 | char *rdata; |
199 | size_t rdata_size; | 282 | size_t rdata_size; |
283 | uint32_t rd_count_nbo; | ||
200 | char ztld[128]; | 284 | char ztld[128]; |
285 | unsigned char nonce[crypto_secretbox_NONCEBYTES]; | ||
286 | unsigned char skey[crypto_secretbox_KEYBYTES]; | ||
287 | |||
288 | /* | ||
289 | * Make two different expiration times | ||
290 | */ | ||
291 | GNUNET_STRINGS_fancy_time_to_absolute ("%2048-01-23 10:51:34", | ||
292 | &exp1); | ||
293 | GNUNET_STRINGS_fancy_time_to_absolute ("3540-05-22 07:55:01", | ||
294 | &exp2); | ||
295 | |||
296 | id_priv.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); | ||
297 | GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key); | ||
298 | GNUNET_IDENTITY_key_get_public (&id_priv, | ||
299 | &id_pub); | ||
201 | 300 | ||
202 | id_priv.type = htonl (GNUNET_IDENTITY_TYPE_EDDSA); | 301 | id_priv.type = htonl (GNUNET_IDENTITY_TYPE_EDDSA); |
203 | GNUNET_CRYPTO_eddsa_key_create (&id_priv.eddsa_key); | 302 | GNUNET_CRYPTO_eddsa_key_create (&id_priv.eddsa_key); |
303 | parsehex (d_edkey, | ||
304 | (char*) &id_priv.eddsa_key, | ||
305 | sizeof (id_priv.eddsa_key), 0); | ||
204 | GNUNET_IDENTITY_key_get_public (&id_priv, | 306 | GNUNET_IDENTITY_key_get_public (&id_priv, |
205 | &id_pub); | 307 | &id_pub); |
206 | fprintf (stdout, | 308 | fprintf (stdout, |
207 | "Zone private key (d, little-endian, with ztype prepended):\n"); | 309 | "Zone private key (d):\n"); |
208 | print_bytes (&id_priv, GNUNET_IDENTITY_key_get_length (&id_pub), 8); // FIXME length for privkey? | 310 | print_bytes (&id_priv.eddsa_key, sizeof (struct |
311 | GNUNET_CRYPTO_EddsaPrivateKey), 8); | ||
209 | fprintf (stdout, "\n"); | 312 | fprintf (stdout, "\n"); |
210 | fprintf (stdout, "Zone identifier (zid):\n"); | 313 | fprintf (stdout, "Zone identifier (ztype|zkey):\n"); |
211 | print_bytes (&id_pub, GNUNET_IDENTITY_key_get_length (&id_pub), 8); | 314 | print_bytes (&id_pub, GNUNET_IDENTITY_key_get_length (&id_pub), 8); |
212 | GNUNET_STRINGS_data_to_string (&id_pub, | 315 | GNUNET_STRINGS_data_to_string (&id_pub, |
213 | GNUNET_IDENTITY_key_get_length (&id_pub), | 316 | GNUNET_IDENTITY_key_get_length (&id_pub), |
@@ -229,21 +332,23 @@ run_edkey (void) | |||
229 | GNUNET_DNSPARSER_TYPE_A, TEST_RECORD_A, &data, &data_size)); | 332 | GNUNET_DNSPARSER_TYPE_A, TEST_RECORD_A, &data, &data_size)); |
230 | rd[0].data = data; | 333 | rd[0].data = data; |
231 | rd[0].data_size = data_size; | 334 | rd[0].data_size = data_size; |
232 | rd[0].expiration_time = exp_abs.abs_value_us; | 335 | rd[0].expiration_time = exp1.abs_value_us; |
233 | rd[0].record_type = GNUNET_DNSPARSER_TYPE_A; | 336 | rd[0].record_type = GNUNET_DNSPARSER_TYPE_A; |
234 | fprintf (stdout, "Record #0\n"); | 337 | fprintf (stdout, "Record #0\n"); |
235 | print_record (&rd[0]); | 338 | print_record (&rd[0]); |
236 | 339 | ||
237 | rd[1].data = &pkey_data; | 340 | rd[1].data = "My Nick"; |
238 | rd[1].data_size = sizeof (struct GNUNET_CRYPTO_EddsaPublicKey); | 341 | rd[1].data_size = sizeof (struct GNUNET_IDENTITY_PublicKey); |
239 | rd[1].expiration_time = exp_abs.abs_value_us; | 342 | rd[1].expiration_time = exp2.abs_value_us; |
240 | rd[1].record_type = GNUNET_GNSRECORD_TYPE_EDKEY; | 343 | rd[1].record_type = GNUNET_GNSRECORD_TYPE_NICK; |
241 | rd[1].flags = GNUNET_GNSRECORD_RF_PRIVATE; | 344 | rd[1].flags = GNUNET_GNSRECORD_RF_PRIVATE; |
242 | fprintf (stdout, "Record #1\n"); | 345 | fprintf (stdout, "Record #1\n"); |
243 | print_record (&rd[1]); | 346 | print_record (&rd[1]); |
244 | 347 | ||
245 | rdata_size = GNUNET_GNSRECORD_records_get_size (2, | 348 | rdata_size = GNUNET_GNSRECORD_records_get_size (TEST_RRCOUNT, |
246 | rd); | 349 | rd); |
350 | expire = GNUNET_GNSRECORD_record_get_expiration_time (TEST_RRCOUNT, | ||
351 | rd); | ||
247 | rdata = GNUNET_malloc (rdata_size); | 352 | rdata = GNUNET_malloc (rdata_size); |
248 | GNUNET_GNSRECORD_records_serialize (2, | 353 | GNUNET_GNSRECORD_records_serialize (2, |
249 | rd, | 354 | rd, |
@@ -252,25 +357,39 @@ run_edkey (void) | |||
252 | fprintf (stdout, "RDATA:\n"); | 357 | fprintf (stdout, "RDATA:\n"); |
253 | print_bytes (rdata, rdata_size, 8); | 358 | print_bytes (rdata, rdata_size, 8); |
254 | fprintf (stdout, "\n"); | 359 | fprintf (stdout, "\n"); |
255 | rrblock = GNUNET_GNSRECORD_block_create (&id_priv, | 360 | GNR_derive_block_xsalsa_key (nonce, |
256 | exp_abs, | 361 | skey, |
257 | TEST_RECORD_LABEL, | 362 | TEST_RECORD_LABEL, |
258 | rd, | 363 | GNUNET_TIME_absolute_hton ( |
259 | TEST_RRCOUNT); | 364 | expire).abs_value_us__, |
260 | size_t bdata_size = ntohl (rrblock->eddsa_block.purpose.size) | 365 | &id_pub.eddsa_key); |
261 | - sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) | 366 | fprintf (stdout, "Encryption NONCE|EXPIRATION:\n"); |
262 | - sizeof(struct GNUNET_TIME_AbsoluteNBO); | 367 | print_bytes (nonce, sizeof (nonce), 8); |
263 | size_t ecblock_size = ntohl (rrblock->eddsa_block.purpose.size) | 368 | fprintf (stdout, "\n"); |
264 | + sizeof(struct GNUNET_CRYPTO_EddsaPublicKey) | 369 | fprintf (stdout, "Encryption key (K):\n"); |
265 | + sizeof(struct GNUNET_CRYPTO_EddsaSignature); | 370 | print_bytes (skey, sizeof (skey), 8); |
266 | size_t block_size = ecblock_size + sizeof (uint32_t); | 371 | fprintf (stdout, "\n"); |
372 | GNUNET_GNSRECORD_query_from_public_key (&id_pub, | ||
373 | TEST_RECORD_LABEL, | ||
374 | &query); | ||
375 | fprintf (stdout, "Storage key (q):\n"); | ||
376 | print_bytes (&query, sizeof (query), 8); | ||
377 | fprintf (stdout, "\n"); | ||
378 | |||
379 | GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_block_create (&id_priv, | ||
380 | expire, | ||
381 | TEST_RECORD_LABEL, | ||
382 | rd, | ||
383 | TEST_RRCOUNT, | ||
384 | &rrblock)); | ||
385 | size_t bdata_size = ntohl(rrblock->size) - sizeof (struct GNUNET_GNSRECORD_Block); | ||
267 | 386 | ||
268 | bdata = (char*) &(&rrblock->eddsa_block)[1]; | 387 | bdata = (char*) &(&rrblock->eddsa_block)[1]; |
269 | fprintf (stdout, "BDATA:\n"); | 388 | fprintf (stdout, "BDATA:\n"); |
270 | print_bytes (bdata, bdata_size, 8); | 389 | print_bytes (bdata, bdata_size, 8); |
271 | fprintf (stdout, "\n"); | 390 | fprintf (stdout, "\n"); |
272 | fprintf (stdout, "RRBLOCK:\n"); | 391 | fprintf (stdout, "RRBLOCK:\n"); |
273 | print_bytes (rrblock, block_size, 8); | 392 | print_bytes (rrblock, ntohl(rrblock->size), 8); |
274 | fprintf (stdout, "\n"); | 393 | fprintf (stdout, "\n"); |
275 | GNUNET_free (rdata); | 394 | GNUNET_free (rdata); |
276 | } | 395 | } |
@@ -290,8 +409,8 @@ run (void *cls, | |||
290 | const char *cfgfile, | 409 | const char *cfgfile, |
291 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 410 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
292 | { | 411 | { |
293 | run_pkey(); | 412 | run_pkey (); |
294 | run_edkey(); | 413 | run_edkey (); |
295 | } | 414 | } |
296 | 415 | ||
297 | 416 | ||