aboutsummaryrefslogtreecommitdiff
path: root/src/gnsrecord
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnsrecord')
-rw-r--r--src/gnsrecord/.gitignore1
-rw-r--r--src/gnsrecord/Makefile.am10
-rw-r--r--src/gnsrecord/gnsrecord.c15
-rw-r--r--src/gnsrecord/gnsrecord_crypto.c29
-rw-r--r--src/gnsrecord/gnsrecord_serialization.c55
-rw-r--r--src/gnsrecord/perf_gnsrecord_crypto.c137
-rw-r--r--src/gnsrecord/test_gnsrecord_crypto.c6
7 files changed, 221 insertions, 32 deletions
diff --git a/src/gnsrecord/.gitignore b/src/gnsrecord/.gitignore
index 374abdb60..53d3bb22d 100644
--- a/src/gnsrecord/.gitignore
+++ b/src/gnsrecord/.gitignore
@@ -2,3 +2,4 @@ test_gnsrecord_block_expiration
2test_gnsrecord_crypto 2test_gnsrecord_crypto
3test_gnsrecord_serialization 3test_gnsrecord_serialization
4zonefiles 4zonefiles
5perf_gnsrecord_crypto
diff --git a/src/gnsrecord/Makefile.am b/src/gnsrecord/Makefile.am
index 2fb427c69..c83aa3307 100644
--- a/src/gnsrecord/Makefile.am
+++ b/src/gnsrecord/Makefile.am
@@ -19,7 +19,8 @@ endif
19check_PROGRAMS = \ 19check_PROGRAMS = \
20 test_gnsrecord_crypto \ 20 test_gnsrecord_crypto \
21 test_gnsrecord_serialization \ 21 test_gnsrecord_serialization \
22 test_gnsrecord_block_expiration 22 test_gnsrecord_block_expiration \
23 perf_gnsrecord_crypto
23 24
24if ENABLE_TEST_RUN 25if ENABLE_TEST_RUN
25AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; 26AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
@@ -85,3 +86,10 @@ test_gnsrecord_crypto_LDADD = \
85 libgnunetgnsrecord.la \ 86 libgnunetgnsrecord.la \
86 $(top_builddir)/src/util/libgnunetutil.la 87 $(top_builddir)/src/util/libgnunetutil.la
87 88
89
90perf_gnsrecord_crypto_SOURCES = \
91 perf_gnsrecord_crypto.c
92perf_gnsrecord_crypto_LDADD = \
93 $(top_builddir)/src/testing/libgnunettesting.la \
94 libgnunetgnsrecord.la \
95 $(top_builddir)/src/util/libgnunetutil.la
diff --git a/src/gnsrecord/gnsrecord.c b/src/gnsrecord/gnsrecord.c
index 35005b5ca..ece1665fc 100644
--- a/src/gnsrecord/gnsrecord.c
+++ b/src/gnsrecord/gnsrecord.c
@@ -114,10 +114,9 @@ init ()
114void __attribute__ ((destructor)) 114void __attribute__ ((destructor))
115GNSRECORD_fini () 115GNSRECORD_fini ()
116{ 116{
117 unsigned int i;
118 struct Plugin *plugin; 117 struct Plugin *plugin;
119 118
120 for (i = 0; i < num_plugins; i++) 119 for (unsigned int i = 0; i < num_plugins; i++)
121 { 120 {
122 plugin = gns_plugins[i]; 121 plugin = gns_plugins[i];
123 GNUNET_break (NULL == 122 GNUNET_break (NULL ==
@@ -146,12 +145,11 @@ GNUNET_GNSRECORD_value_to_string (uint32_t type,
146 const void *data, 145 const void *data,
147 size_t data_size) 146 size_t data_size)
148{ 147{
149 unsigned int i;
150 struct Plugin *plugin; 148 struct Plugin *plugin;
151 char *ret; 149 char *ret;
152 150
153 init (); 151 init ();
154 for (i = 0; i < num_plugins; i++) 152 for (unsigned int i = 0; i < num_plugins; i++)
155 { 153 {
156 plugin = gns_plugins[i]; 154 plugin = gns_plugins[i];
157 if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls, 155 if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls,
@@ -180,11 +178,10 @@ GNUNET_GNSRECORD_string_to_value (uint32_t type,
180 void **data, 178 void **data,
181 size_t *data_size) 179 size_t *data_size)
182{ 180{
183 unsigned int i;
184 struct Plugin *plugin; 181 struct Plugin *plugin;
185 182
186 init (); 183 init ();
187 for (i = 0; i < num_plugins; i++) 184 for (unsigned int i = 0; i < num_plugins; i++)
188 { 185 {
189 plugin = gns_plugins[i]; 186 plugin = gns_plugins[i];
190 if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls, 187 if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls,
@@ -207,7 +204,6 @@ GNUNET_GNSRECORD_string_to_value (uint32_t type,
207uint32_t 204uint32_t
208GNUNET_GNSRECORD_typename_to_number (const char *dns_typename) 205GNUNET_GNSRECORD_typename_to_number (const char *dns_typename)
209{ 206{
210 unsigned int i;
211 struct Plugin *plugin; 207 struct Plugin *plugin;
212 uint32_t ret; 208 uint32_t ret;
213 209
@@ -215,7 +211,7 @@ GNUNET_GNSRECORD_typename_to_number (const char *dns_typename)
215 "ANY")) 211 "ANY"))
216 return GNUNET_GNSRECORD_TYPE_ANY; 212 return GNUNET_GNSRECORD_TYPE_ANY;
217 init (); 213 init ();
218 for (i = 0; i < num_plugins; i++) 214 for (unsigned int i = 0; i < num_plugins; i++)
219 { 215 {
220 plugin = gns_plugins[i]; 216 plugin = gns_plugins[i];
221 if (UINT32_MAX != (ret = plugin->api->typename_to_number (plugin->api->cls, 217 if (UINT32_MAX != (ret = plugin->api->typename_to_number (plugin->api->cls,
@@ -235,14 +231,13 @@ GNUNET_GNSRECORD_typename_to_number (const char *dns_typename)
235const char * 231const char *
236GNUNET_GNSRECORD_number_to_typename (uint32_t type) 232GNUNET_GNSRECORD_number_to_typename (uint32_t type)
237{ 233{
238 unsigned int i;
239 struct Plugin *plugin; 234 struct Plugin *plugin;
240 const char * ret; 235 const char * ret;
241 236
242 if (GNUNET_GNSRECORD_TYPE_ANY == type) 237 if (GNUNET_GNSRECORD_TYPE_ANY == type)
243 return "ANY"; 238 return "ANY";
244 init (); 239 init ();
245 for (i = 0; i < num_plugins; i++) 240 for (unsigned int i = 0; i < num_plugins; i++)
246 { 241 {
247 plugin = gns_plugins[i]; 242 plugin = gns_plugins[i];
248 if (NULL != (ret = plugin->api->number_to_typename (plugin->api->cls, 243 if (NULL != (ret = plugin->api->number_to_typename (plugin->api->cls,
diff --git a/src/gnsrecord/gnsrecord_crypto.c b/src/gnsrecord/gnsrecord_crypto.c
index cebc842f3..6d59a545a 100644
--- a/src/gnsrecord/gnsrecord_crypto.c
+++ b/src/gnsrecord/gnsrecord_crypto.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009-2013 GNUnet e.V. 3 Copyright (C) 2009-2013, 2018 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -94,7 +94,7 @@ block_create (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
94 struct GNUNET_CRYPTO_EcdsaPrivateKey *dkey; 94 struct GNUNET_CRYPTO_EcdsaPrivateKey *dkey;
95 struct GNUNET_CRYPTO_SymmetricInitializationVector iv; 95 struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
96 struct GNUNET_CRYPTO_SymmetricSessionKey skey; 96 struct GNUNET_CRYPTO_SymmetricSessionKey skey;
97 struct GNUNET_GNSRECORD_Data rdc[rd_count]; 97 struct GNUNET_GNSRECORD_Data rdc[GNUNET_NZL(rd_count)];
98 uint32_t rd_count_nbo; 98 uint32_t rd_count_nbo;
99 struct GNUNET_TIME_Absolute now; 99 struct GNUNET_TIME_Absolute now;
100 100
@@ -246,6 +246,7 @@ GNUNET_GNSRECORD_block_create2 (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
246 GNUNET_CRYPTO_ecdsa_key_get_public (key, 246 GNUNET_CRYPTO_ecdsa_key_get_public (key,
247 &line->pkey); 247 &line->pkey);
248 } 248 }
249#undef CSIZE
249 return block_create (key, 250 return block_create (key,
250 &line->pkey, 251 &line->pkey,
251 expire, 252 expire,
@@ -304,18 +305,21 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block,
304 GNUNET_break_op (0); 305 GNUNET_break_op (0);
305 return GNUNET_SYSERR; 306 return GNUNET_SYSERR;
306 } 307 }
307 derive_block_aes_key (&iv, &skey, label, zone_key); 308 derive_block_aes_key (&iv,
309 &skey,
310 label,
311 zone_key);
308 { 312 {
309 char payload[payload_len]; 313 char payload[payload_len];
310 uint32_t rd_count; 314 uint32_t rd_count;
311 315
312 GNUNET_break (payload_len == 316 GNUNET_break (payload_len ==
313 GNUNET_CRYPTO_symmetric_decrypt (&block[1], payload_len, 317 GNUNET_CRYPTO_symmetric_decrypt (&block[1], payload_len,
314 &skey, &iv, 318 &skey, &iv,
315 payload)); 319 payload));
316 GNUNET_memcpy (&rd_count, 320 GNUNET_memcpy (&rd_count,
317 payload, 321 payload,
318 sizeof (uint32_t)); 322 sizeof (uint32_t));
319 rd_count = ntohl (rd_count); 323 rd_count = ntohl (rd_count);
320 if (rd_count > 2048) 324 if (rd_count > 2048)
321 { 325 {
@@ -324,7 +328,7 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block,
324 return GNUNET_SYSERR; 328 return GNUNET_SYSERR;
325 } 329 }
326 { 330 {
327 struct GNUNET_GNSRECORD_Data rd[rd_count]; 331 struct GNUNET_GNSRECORD_Data rd[GNUNET_NZL(rd_count)];
328 unsigned int j; 332 unsigned int j;
329 struct GNUNET_TIME_Absolute now; 333 struct GNUNET_TIME_Absolute now;
330 334
@@ -359,10 +363,13 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block,
359 continue; 363 continue;
360 if (rd[i].expiration_time < now.abs_value_us) 364 if (rd[i].expiration_time < now.abs_value_us)
361 include_record = GNUNET_NO; /* Shadow record is expired */ 365 include_record = GNUNET_NO; /* Shadow record is expired */
362 if ((rd[k].record_type == rd[i].record_type) 366 if ( (rd[k].record_type == rd[i].record_type) &&
363 && (rd[k].expiration_time >= now.abs_value_us) 367 (rd[k].expiration_time >= now.abs_value_us) &&
364 && (0 == (rd[k].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD))) 368 (0 == (rd[k].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) )
369 {
365 include_record = GNUNET_NO; /* We have a non-expired, non-shadow record of the same type */ 370 include_record = GNUNET_NO; /* We have a non-expired, non-shadow record of the same type */
371 break;
372 }
366 } 373 }
367 if (GNUNET_YES == include_record) 374 if (GNUNET_YES == include_record)
368 { 375 {
diff --git a/src/gnsrecord/gnsrecord_serialization.c b/src/gnsrecord/gnsrecord_serialization.c
index 190f62fc2..1db27464f 100644
--- a/src/gnsrecord/gnsrecord_serialization.c
+++ b/src/gnsrecord/gnsrecord_serialization.c
@@ -84,11 +84,10 @@ size_t
84GNUNET_GNSRECORD_records_get_size (unsigned int rd_count, 84GNUNET_GNSRECORD_records_get_size (unsigned int rd_count,
85 const struct GNUNET_GNSRECORD_Data *rd) 85 const struct GNUNET_GNSRECORD_Data *rd)
86{ 86{
87 unsigned int i;
88 size_t ret; 87 size_t ret;
89 88
90 ret = sizeof (struct NetworkRecord) * rd_count; 89 ret = sizeof (struct NetworkRecord) * rd_count;
91 for (i=0;i<rd_count;i++) 90 for (unsigned int i=0;i<rd_count;i++)
92 { 91 {
93 GNUNET_assert ((ret + rd[i].data_size) >= ret); 92 GNUNET_assert ((ret + rd[i].data_size) >= ret);
94 ret += rd[i].data_size; 93 ret += rd[i].data_size;
@@ -113,11 +112,10 @@ GNUNET_GNSRECORD_records_serialize (unsigned int rd_count,
113 char *dest) 112 char *dest)
114{ 113{
115 struct NetworkRecord rec; 114 struct NetworkRecord rec;
116 unsigned int i;
117 size_t off; 115 size_t off;
118 116
119 off = 0; 117 off = 0;
120 for (i=0;i<rd_count;i++) 118 for (unsigned int i=0;i<rd_count;i++)
121 { 119 {
122 LOG (GNUNET_ERROR_TYPE_DEBUG, 120 LOG (GNUNET_ERROR_TYPE_DEBUG,
123 "Serializing record %u with flags %d and expiration time %llu\n", 121 "Serializing record %u with flags %d and expiration time %llu\n",
@@ -129,17 +127,38 @@ GNUNET_GNSRECORD_records_serialize (unsigned int rd_count,
129 rec.record_type = htonl (rd[i].record_type); 127 rec.record_type = htonl (rd[i].record_type);
130 rec.flags = htonl (rd[i].flags); 128 rec.flags = htonl (rd[i].flags);
131 if (off + sizeof (rec) > dest_size) 129 if (off + sizeof (rec) > dest_size)
130 {
131 GNUNET_break (0);
132 return -1; 132 return -1;
133 }
133 GNUNET_memcpy (&dest[off], 134 GNUNET_memcpy (&dest[off],
134 &rec, 135 &rec,
135 sizeof (rec)); 136 sizeof (rec));
136 off += sizeof (rec); 137 off += sizeof (rec);
137 if (off + rd[i].data_size > dest_size) 138 if (off + rd[i].data_size > dest_size)
139 {
140 GNUNET_break (0);
138 return -1; 141 return -1;
142 }
139 GNUNET_memcpy (&dest[off], 143 GNUNET_memcpy (&dest[off],
140 rd[i].data, 144 rd[i].data,
141 rd[i].data_size); 145 rd[i].data_size);
142 off += rd[i].data_size; 146 off += rd[i].data_size;
147#if GNUNET_EXTRA_LOGGING
148 {
149 char *str;
150
151 str = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
152 rd[i].data,
153 rd[i].data_size);
154 if (NULL == str)
155 {
156 GNUNET_break_op (0);
157 return GNUNET_SYSERR;
158 }
159 GNUNET_free (str);
160 }
161#endif
143 } 162 }
144 return off; 163 return off;
145} 164}
@@ -161,24 +180,46 @@ GNUNET_GNSRECORD_records_deserialize (size_t len,
161 struct GNUNET_GNSRECORD_Data *dest) 180 struct GNUNET_GNSRECORD_Data *dest)
162{ 181{
163 struct NetworkRecord rec; 182 struct NetworkRecord rec;
164 unsigned int i;
165 size_t off; 183 size_t off;
166 184
167 off = 0; 185 off = 0;
168 for (i=0;i<rd_count;i++) 186 for (unsigned int i=0;i<rd_count;i++)
169 { 187 {
170 if (off + sizeof (rec) > len) 188 if (off + sizeof (rec) > len)
189 {
190 GNUNET_break_op (0);
171 return GNUNET_SYSERR; 191 return GNUNET_SYSERR;
172 GNUNET_memcpy (&rec, &src[off], sizeof (rec)); 192 }
193 GNUNET_memcpy (&rec,
194 &src[off],
195 sizeof (rec));
173 dest[i].expiration_time = GNUNET_ntohll (rec.expiration_time); 196 dest[i].expiration_time = GNUNET_ntohll (rec.expiration_time);
174 dest[i].data_size = ntohl ((uint32_t) rec.data_size); 197 dest[i].data_size = ntohl ((uint32_t) rec.data_size);
175 dest[i].record_type = ntohl (rec.record_type); 198 dest[i].record_type = ntohl (rec.record_type);
176 dest[i].flags = ntohl (rec.flags); 199 dest[i].flags = ntohl (rec.flags);
177 off += sizeof (rec); 200 off += sizeof (rec);
178 if (off + dest[i].data_size > len) 201 if (off + dest[i].data_size > len)
202 {
203 GNUNET_break_op (0);
179 return GNUNET_SYSERR; 204 return GNUNET_SYSERR;
205 }
180 dest[i].data = &src[off]; 206 dest[i].data = &src[off];
181 off += dest[i].data_size; 207 off += dest[i].data_size;
208#if GNUNET_EXTRA_LOGGING
209 {
210 char *str;
211
212 str = GNUNET_GNSRECORD_value_to_string (dest[i].record_type,
213 dest[i].data,
214 dest[i].data_size);
215 if (NULL == str)
216 {
217 GNUNET_break_op (0);
218 return GNUNET_SYSERR;
219 }
220 GNUNET_free (str);
221 }
222#endif
182 LOG (GNUNET_ERROR_TYPE_DEBUG, 223 LOG (GNUNET_ERROR_TYPE_DEBUG,
183 "Deserialized record %u with flags %d and expiration time %llu\n", 224 "Deserialized record %u with flags %d and expiration time %llu\n",
184 i, 225 i,
diff --git a/src/gnsrecord/perf_gnsrecord_crypto.c b/src/gnsrecord/perf_gnsrecord_crypto.c
new file mode 100644
index 000000000..ff9721006
--- /dev/null
+++ b/src/gnsrecord/perf_gnsrecord_crypto.c
@@ -0,0 +1,137 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2018 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20/**
21 * @file gnsrecord/test_gnsrecord_crypto.c
22 * @brief testcase for block creation, verification and decryption
23 */
24#include "platform.h"
25#include "gnunet_util_lib.h"
26#include "gnunet_gnsrecord_lib.h"
27
28#define ROUNDS 1000
29
30#define RECORDS 5
31
32#define TEST_RECORD_TYPE 1234
33
34#define TEST_RECORD_DATALEN 123
35
36#define TEST_RECORD_DATA 'a'
37
38#define TEST_REMOVE_RECORD_TYPE 4321
39
40#define TEST_REMOVE_RECORD_DATALEN 255
41
42#define TEST_REMOVE_RECORD_DATA 'b'
43
44
45static struct GNUNET_GNSRECORD_Data *
46create_record (int count)
47{
48 struct GNUNET_GNSRECORD_Data *rd;
49
50 rd = GNUNET_new_array (count,
51 struct GNUNET_GNSRECORD_Data);
52 for (unsigned int c = 0; c < count; c++)
53 {
54 rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value_us + 1000000000;
55 rd[c].record_type = TEST_RECORD_TYPE;
56 rd[c].data_size = TEST_RECORD_DATALEN;
57 rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
58 memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
59 }
60 return rd;
61}
62
63
64static void
65run (void *cls,
66 char *const *args,
67 const char *cfgfile,
68 const struct GNUNET_CONFIGURATION_Handle *cfg)
69{
70 struct GNUNET_GNSRECORD_Block *block;
71 struct GNUNET_HashCode query;
72 struct GNUNET_GNSRECORD_Data *s_rd;
73 const char *s_name;
74 struct GNUNET_TIME_Absolute start_time;
75 struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey;
76 struct GNUNET_TIME_Absolute expire;
77
78 (void) cls;
79 (void) args;
80 (void) cfgfile;
81 (void) cfg;
82 expire = GNUNET_TIME_absolute_get();
83 privkey = GNUNET_CRYPTO_ecdsa_key_create ();
84 GNUNET_assert (NULL != privkey);
85
86 /* test block creation */
87 s_name = "DUMMY.dummy.gnunet";
88 s_rd = create_record (RECORDS);
89 start_time = GNUNET_TIME_absolute_get ();
90 for (unsigned int i=0;i<ROUNDS;i++)
91 {
92 GNUNET_assert (NULL != (block =
93 GNUNET_GNSRECORD_block_create2 (privkey,
94 expire,
95 s_name,
96 s_rd,
97 RECORDS)));
98 GNUNET_GNSRECORD_query_from_private_key (privkey,
99 s_name,
100 &query);
101 GNUNET_free (block);
102 }
103 fprintf (stderr,
104 "Took %s to produce %u GNS blocks for the DHT\n",
105 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start_time),
106 GNUNET_YES),
107 ROUNDS);
108 for (unsigned int i=0;i<RECORDS;i++)
109 GNUNET_free ((void *) s_rd[i].data);
110 GNUNET_free (s_rd);
111 GNUNET_free (privkey);
112}
113
114
115int
116main (int argc, char *argv[])
117{
118 static char *const argvx[] = {
119 "perf-gnsrecord-crypto",
120 NULL
121 };
122 static struct GNUNET_GETOPT_CommandLineOption options[] = {
123 GNUNET_GETOPT_OPTION_END
124 };
125
126 if (GNUNET_OK !=
127 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
128 argvx,
129 "perf-gnsrecord-crypto",
130 "nohelp", options,
131 &run,
132 NULL))
133 return 1;
134 return 0;
135}
136
137/* end of test_gnsrecord_crypto.c */
diff --git a/src/gnsrecord/test_gnsrecord_crypto.c b/src/gnsrecord/test_gnsrecord_crypto.c
index 1df3f3730..9ba303e66 100644
--- a/src/gnsrecord/test_gnsrecord_crypto.c
+++ b/src/gnsrecord/test_gnsrecord_crypto.c
@@ -54,7 +54,7 @@ create_record (int count)
54{ 54{
55 struct GNUNET_GNSRECORD_Data *rd; 55 struct GNUNET_GNSRECORD_Data *rd;
56 56
57 rd = GNUNET_malloc (count * sizeof (struct GNUNET_GNSRECORD_Data)); 57 rd = GNUNET_new_array (count, struct GNUNET_GNSRECORD_Data);
58 for (unsigned int c = 0; c < count; c++) 58 for (unsigned int c = 0; c < count; c++)
59 { 59 {
60 rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value_us + 1000000000; 60 rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value_us + 1000000000;
@@ -103,11 +103,10 @@ run (void *cls,
103 struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; 103 struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
104 struct GNUNET_HashCode query_pub; 104 struct GNUNET_HashCode query_pub;
105 struct GNUNET_HashCode query_priv; 105 struct GNUNET_HashCode query_priv;
106 struct GNUNET_TIME_Absolute expire = GNUNET_TIME_absolute_get();
106 107
107 privkey = GNUNET_CRYPTO_ecdsa_key_create (); 108 privkey = GNUNET_CRYPTO_ecdsa_key_create ();
108 GNUNET_assert (NULL != privkey); 109 GNUNET_assert (NULL != privkey);
109 struct GNUNET_TIME_Absolute expire = GNUNET_TIME_absolute_get();
110
111 /* get public key */ 110 /* get public key */
112 GNUNET_CRYPTO_ecdsa_key_get_public (privkey, 111 GNUNET_CRYPTO_ecdsa_key_get_public (privkey,
113 &pubkey); 112 &pubkey);
@@ -142,6 +141,7 @@ run (void *cls,
142 &rd_decrypt_cb, 141 &rd_decrypt_cb,
143 s_name)); 142 s_name));
144 GNUNET_free (block); 143 GNUNET_free (block);
144 GNUNET_free (privkey);
145} 145}
146 146
147 147