aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-09-20 10:10:04 +0000
committerChristian Grothoff <christian@grothoff.org>2012-09-20 10:10:04 +0000
commit1aa42a97fb4310dd72a31aad114b6ebe26aebd8a (patch)
treeed076a8a4dd413efa4cbd67ec6482834b7ebc581
parent37c4704049df39026b5fb043bcebcd7a15ecf1a2 (diff)
downloadgnunet-1aa42a97fb4310dd72a31aad114b6ebe26aebd8a.tar.gz
gnunet-1aa42a97fb4310dd72a31aad114b6ebe26aebd8a.zip
-core review
-rw-r--r--src/gns/Makefile.am290
-rw-r--r--src/gns/gns_common.c79
-rw-r--r--src/gns/gns_common.h58
-rw-r--r--src/gns/gnunet-gns.c211
-rw-r--r--src/gns/gnunet-service-gns.c289
-rw-r--r--src/gns/gnunet-service-gns_resolver.c59
-rw-r--r--src/gns/plugin_block_gns.c57
-rw-r--r--src/namestore/plugin_namestore_sqlite.c1
8 files changed, 519 insertions, 525 deletions
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index 12d50481a..9f732257b 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -6,6 +6,14 @@ endif
6 6
7SUBDIRS = . $(NSS_SUBDIR) 7SUBDIRS = . $(NSS_SUBDIR)
8 8
9EXTRA_DIST = \
10 test_gns_defaults.conf \
11 test_gns_simple_lookup.conf \
12 test_gns_dht_default.conf \
13 zonefiles/188JSUMKEF25GVU8TTV0PBNNN8JVCPUEDFV1UHJJU884JD25V0T0.zkey \
14 zonefiles/OEFL7A4VEF1B40QLEMTG5D8G1CN6EN16QUSG5R2DT71GRJN34LSG.zkey \
15 zonefiles/test_zonekey
16
9if MINGW 17if MINGW
10 WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols 18 WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
11 DO_W32_HELPER = gnunet-gns-helper-service-w32 19 DO_W32_HELPER = gnunet-gns-helper-service-w32
@@ -18,7 +26,7 @@ if USE_COVERAGE
18 AM_CFLAGS = --coverage -O0 26 AM_CFLAGS = --coverage -O0
19endif 27endif
20 28
21pkgcfgdir= $(pkgdatadir)/config.d/ 29pkgcfgdir = $(pkgdatadir)/config.d/
22 30
23plugindir = $(libdir)/gnunet 31plugindir = $(libdir)/gnunet
24 32
@@ -28,7 +36,9 @@ pkgcfg_DATA = \
28 36
29lib_LTLIBRARIES = \ 37lib_LTLIBRARIES = \
30 $(DO_W32_NSP) \ 38 $(DO_W32_NSP) \
31 libgnunetgns.la 39 libgnunetgns.la \
40 libgnunetgns_common.la
41
32 42
33if HAVE_MHD 43if HAVE_MHD
34 DO_FCFSD=gnunet-gns-fcfsd 44 DO_FCFSD=gnunet-gns-fcfsd
@@ -46,7 +56,143 @@ bin_PROGRAMS = \
46 gnunet-gns \ 56 gnunet-gns \
47 gnunet-dns2gns 57 gnunet-dns2gns
48 58
49bin_SCRIPTS=gnunet-gns-proxy-setup-ca 59bin_SCRIPTS = gnunet-gns-proxy-setup-ca
60
61plugin_LTLIBRARIES = \
62 libgnunet_plugin_block_gns.la
63
64gnunet_gns_SOURCES = \
65 gnunet-gns.c
66gnunet_gns_LDADD = \
67 $(top_builddir)/src/gns/libgnunetgns.la \
68 $(top_builddir)/src/util/libgnunetutil.la \
69 $(top_builddir)/src/namestore/libgnunetnamestore.la \
70 $(GN_LIBINTL)
71gnunet_gns_DEPENDENCIES = \
72 libgnunetgns.la
73
74gnunet_dns2gns_SOURCES = \
75 gnunet-dns2gns.c
76gnunet_dns2gns_LDADD = \
77 $(top_builddir)/src/gns/libgnunetgns.la \
78 $(top_builddir)/src/util/libgnunetutil.la \
79 $(top_builddir)/src/namestore/libgnunetnamestore.la \
80 $(top_builddir)/src/dns/libgnunetdnsparser.la \
81 $(top_builddir)/src/dns/libgnunetdnsstub.la \
82 $(GN_LIBINTL)
83gnunet_dns2gns_DEPENDENCIES = \
84 libgnunetgns.la
85
86gnunet_gns_proxy_SOURCES = \
87 gnunet-gns-proxy.c gns_proxy_proto.h
88gnunet_gns_proxy_LDADD = -lmicrohttpd -lcurl -lgnutls \
89 $(top_builddir)/src/gns/libgnunetgns.la \
90 $(top_builddir)/src/util/libgnunetutil.la \
91 $(GN_LIBINTL)
92gnunet_gns_proxy_DEPENDENCIES = \
93 libgnunetgns.la
94
95gnunet_gns_helper_service_w32_SOURCES = \
96 gnunet-gns-helper-service-w32.c
97gnunet_gns_helper_service_w32_LDADD = \
98 $(top_builddir)/src/gns/libgnunetgns.la \
99 $(top_builddir)/src/util/libgnunetutil.la \
100 $(GN_LIBINTL)
101gnunet_gns_helper_service_w32_DEPENDENCIES = \
102 libgnunetgns.la
103
104w32nsp_install_SOURCES = \
105 w32nsp-install.c
106w32nsp_install_LDADD = -lws2_32
107
108w32nsp_uninstall_SOURCES = \
109 w32nsp-uninstall.c
110w32nsp_uninstall_LDADD = -lws2_32
111
112w32nsp_resolve_SOURCES = \
113 w32nsp-resolve.c
114w32nsp_resolve_LDADD = -lws2_32
115
116gnunet_service_gns_SOURCES = \
117 gnunet-service-gns.c \
118 gnunet-service-gns_resolver.c gnunet-service-gns_resolver.h \
119 gnunet-service-gns_interceptor.c gnunet-service-gns_interceptor.h
120gnunet_service_gns_LDADD = \
121 -lm \
122 $(top_builddir)/src/statistics/libgnunetstatistics.la \
123 $(top_builddir)/src/util/libgnunetutil.la \
124 $(top_builddir)/src/gns/libgnunetgns_common.la \
125 $(top_builddir)/src/dns/libgnunetdns.la \
126 $(top_builddir)/src/dns/libgnunetdnsparser.la \
127 $(top_builddir)/src/dht/libgnunetdht.la \
128 $(top_builddir)/src/namestore/libgnunetnamestore.la \
129 $(top_builddir)/src/vpn/libgnunetvpn.la \
130 $(GN_LIBINTL)
131gnunet_service_gns_DEPENDENCIES = \
132 $(top_builddir)/src/statistics/libgnunetstatistics.la \
133 $(top_builddir)/src/util/libgnunetutil.la \
134 $(top_builddir)/src/gns/libgnunetgns_common.la \
135 $(top_builddir)/src/dns/libgnunetdns.la \
136 $(top_builddir)/src/dns/libgnunetdnsparser.la \
137 $(top_builddir)/src/dht/libgnunetdht.la \
138 $(top_builddir)/src/namestore/libgnunetnamestore.la \
139 $(top_builddir)/src/vpn/libgnunetvpn.la
140
141
142
143gnunet_gns_fcfsd_SOURCES = \
144 gnunet-gns-fcfsd.c
145gnunet_gns_fcfsd_LDADD = -lmicrohttpd \
146 $(top_builddir)/src/util/libgnunetutil.la \
147 $(top_builddir)/src/namestore/libgnunetnamestore.la \
148 $(GN_LIBINTL)
149gnunet_gns_fcfsd_DEPENDENCIES = \
150 $(top_builddir)/src/util/libgnunetutil.la \
151 $(top_builddir)/src/namestore/libgnunetnamestore.la
152
153libw32nsp_la_SOURCES = \
154 w32nsp.c
155libw32nsp_la_LIBADD = \
156 -lole32 -lws2_32
157libw32nsp_la_LDFLAGS = \
158 -export-symbols $(top_srcdir)/src/gns/w32nsp.def \
159 $(GN_LIB_LDFLAGS)
160
161libgnunetgns_la_SOURCES = \
162 gns_api.c gns.h
163libgnunetgns_la_LIBADD = \
164 $(top_builddir)/src/util/libgnunetutil.la $(XLIB) \
165 $(top_builddir)/src/namestore/libgnunetnamestore.la
166libgnunetgns_la_LDFLAGS = \
167 $(GN_LIB_LDFLAGS)
168libgnunetgns_la_DEPENDENCIES = \
169 $(top_builddir)/src/util/libgnunetutil.la \
170 $(top_builddir)/src/namestore/libgnunetnamestore.la
171
172
173libgnunetgns_common_la_SOURCES = \
174 gns_common.c gns_common.h
175libgnunetgns_common_la_LIBADD = \
176 $(top_builddir)/src/util/libgnunetutil.la
177libgnunetgns_common_la_DEPENDENCIES = \
178 $(top_builddir)/src/util/libgnunetutil.la
179
180
181libgnunet_plugin_block_gns_la_SOURCES = \
182 plugin_block_gns.c
183libgnunet_plugin_block_gns_la_LIBADD = \
184 $(top_builddir)/src/util/libgnunetutil.la \
185 $(top_builddir)/src/block/libgnunetblock.la \
186 $(top_builddir)/src/gns/libgnunetgns_common.la \
187 $(top_builddir)/src/namestore/libgnunetnamestore.la
188libgnunet_plugin_block_gns_la_LDFLAGS = \
189 $(GN_PLUGIN_LDFLAGS)
190libgnunet_plugin_block_gns_la_DEPENDENCIES = \
191 $(top_builddir)/src/util/libgnunetutil.la \
192 $(top_builddir)/src/gns/libgnunetgns_common.la \
193 $(top_builddir)/src/block/libgnunetblock.la \
194 $(top_builddir)/src/namestore/libgnunetnamestore.la
195
50 196
51check_PROGRAMS = \ 197check_PROGRAMS = \
52 test_gns_simple_shorten \ 198 test_gns_simple_shorten \
@@ -65,7 +211,11 @@ check_PROGRAMS = \
65 test_gns_dht_three_peers 211 test_gns_dht_three_peers
66 #test_gns_proxy 212 #test_gns_proxy
67 213
68 214if ENABLE_TEST_RUN
215if LINUX
216TESTS = $(check_PROGRAMS)
217endif
218endif
69 219
70 220
71# test_gns_simple_lookup 221# test_gns_simple_lookup
@@ -73,9 +223,6 @@ check_PROGRAMS = \
73# test_gns_dht_delegated_lookup 223# test_gns_dht_delegated_lookup
74 224
75 225
76plugin_LTLIBRARIES = \
77 libgnunet_plugin_block_gns.la
78
79#test_gns_proxy_SOURCES = \ 226#test_gns_proxy_SOURCES = \
80# test_gns_proxy.c 227# test_gns_proxy.c
81#test_gns_proxy_LDADD = -lmicrohttpd @LIBCURL@ \ 228#test_gns_proxy_LDADD = -lmicrohttpd @LIBCURL@ \
@@ -282,123 +429,6 @@ test_gns_revocation_DEPENDENCIES = \
282 $(top_builddir)/src/testing/libgnunettesting.la 429 $(top_builddir)/src/testing/libgnunettesting.la
283 430
284 431
285gnunet_gns_SOURCES = \
286 gnunet-gns.c
287gnunet_gns_LDADD = \
288 $(top_builddir)/src/gns/libgnunetgns.la \
289 $(top_builddir)/src/util/libgnunetutil.la \
290 $(top_builddir)/src/namestore/libgnunetnamestore.la \
291 $(GN_LIBINTL)
292gnunet_gns_DEPENDENCIES = \
293 libgnunetgns.la
294
295gnunet_dns2gns_SOURCES = \
296 gnunet-dns2gns.c
297gnunet_dns2gns_LDADD = \
298 $(top_builddir)/src/gns/libgnunetgns.la \
299 $(top_builddir)/src/util/libgnunetutil.la \
300 $(top_builddir)/src/namestore/libgnunetnamestore.la \
301 $(top_builddir)/src/dns/libgnunetdnsparser.la \
302 $(top_builddir)/src/dns/libgnunetdnsstub.la \
303 $(GN_LIBINTL)
304gnunet_dns2gns_DEPENDENCIES = \
305 libgnunetgns.la
306
307gnunet_gns_proxy_SOURCES = \
308 gnunet-gns-proxy.c gns_proxy_proto.h
309gnunet_gns_proxy_LDADD = -lmicrohttpd -lcurl -lgnutls \
310 $(top_builddir)/src/gns/libgnunetgns.la \
311 $(top_builddir)/src/util/libgnunetutil.la \
312 $(GN_LIBINTL)
313gnunet_gns_proxy_DEPENDENCIES = \
314 libgnunetgns.la
315
316gnunet_gns_helper_service_w32_SOURCES = \
317 gnunet-gns-helper-service-w32.c
318gnunet_gns_helper_service_w32_LDADD = \
319 $(top_builddir)/src/gns/libgnunetgns.la \
320 $(top_builddir)/src/util/libgnunetutil.la \
321 $(GN_LIBINTL)
322gnunet_gns_helper_service_w32_DEPENDENCIES = \
323 libgnunetgns.la
324
325w32nsp_install_SOURCES = \
326 w32nsp-install.c
327w32nsp_install_LDADD = -lws2_32
328
329w32nsp_uninstall_SOURCES = \
330 w32nsp-uninstall.c
331w32nsp_uninstall_LDADD = -lws2_32
332
333w32nsp_resolve_SOURCES = \
334 w32nsp-resolve.c
335w32nsp_resolve_LDADD = -lws2_32
336
337gnunet_service_gns_SOURCES = \
338 gnunet-service-gns.c \
339 gnunet-service-gns_resolver.c gnunet-service-gns_resolver.h \
340 gnunet-service-gns_interceptor.c gnunet-service-gns_interceptor.h
341gnunet_service_gns_LDADD = \
342 -lm \
343 $(top_builddir)/src/statistics/libgnunetstatistics.la \
344 $(top_builddir)/src/util/libgnunetutil.la \
345 $(top_builddir)/src/dns/libgnunetdns.la \
346 $(top_builddir)/src/dns/libgnunetdnsparser.la \
347 $(top_builddir)/src/dht/libgnunetdht.la \
348 $(top_builddir)/src/namestore/libgnunetnamestore.la \
349 $(top_builddir)/src/vpn/libgnunetvpn.la \
350 $(GN_LIBINTL)
351gnunet_service_gns_DEPENDENCIES = \
352 $(top_builddir)/src/statistics/libgnunetstatistics.la \
353 $(top_builddir)/src/util/libgnunetutil.la \
354 $(top_builddir)/src/dns/libgnunetdns.la \
355 $(top_builddir)/src/dns/libgnunetdnsparser.la \
356 $(top_builddir)/src/dht/libgnunetdht.la \
357 $(top_builddir)/src/namestore/libgnunetnamestore.la \
358 $(top_builddir)/src/vpn/libgnunetvpn.la
359
360
361gnunet_gns_fcfsd_SOURCES = \
362 gnunet-gns-fcfsd.c
363gnunet_gns_fcfsd_LDADD = -lmicrohttpd \
364 $(top_builddir)/src/util/libgnunetutil.la \
365 $(top_builddir)/src/namestore/libgnunetnamestore.la \
366 $(GN_LIBINTL)
367gnunet_gns_fcfsd_DEPENDENCIES = \
368 $(top_builddir)/src/util/libgnunetutil.la \
369 $(top_builddir)/src/namestore/libgnunetnamestore.la
370
371libw32nsp_la_SOURCES = \
372 w32nsp.c
373libw32nsp_la_LIBADD = \
374 -lole32 -lws2_32
375libw32nsp_la_LDFLAGS = \
376 -export-symbols $(top_srcdir)/src/gns/w32nsp.def \
377 $(GN_LIB_LDFLAGS)
378
379libgnunetgns_la_SOURCES = \
380 gns_api.c gns.h
381libgnunetgns_la_LIBADD = \
382 $(top_builddir)/src/util/libgnunetutil.la $(XLIB) \
383 $(top_builddir)/src/namestore/libgnunetnamestore.la
384libgnunetgns_la_LDFLAGS = \
385 $(GN_LIB_LDFLAGS)
386libgnunetgns_la_DEPENDENCIES = \
387 $(top_builddir)/src/util/libgnunetutil.la \
388 $(top_builddir)/src/namestore/libgnunetnamestore.la
389
390libgnunet_plugin_block_gns_la_SOURCES = \
391 plugin_block_gns.c
392libgnunet_plugin_block_gns_la_LIBADD = \
393 $(top_builddir)/src/util/libgnunetutil.la \
394 $(top_builddir)/src/block/libgnunetblock.la \
395 $(top_builddir)/src/namestore/libgnunetnamestore.la
396libgnunet_plugin_block_gns_la_LDFLAGS = \
397 $(GN_PLUGIN_LDFLAGS)
398libgnunet_plugin_block_gns_la_DEPENDENCIES = \
399 $(top_builddir)/src/util/libgnunetutil.la \
400 $(top_builddir)/src/block/libgnunetblock.la \
401 $(top_builddir)/src/namestore/libgnunetnamestore.la
402 432
403#Build stub api 433#Build stub api
404#libgnunetnamestore_la_SOURCES = \ 434#libgnunetnamestore_la_SOURCES = \
@@ -410,17 +440,5 @@ libgnunet_plugin_block_gns_la_DEPENDENCIES = \
410#libgnunetnamestore_la_DEPENDENCIES = \ 440#libgnunetnamestore_la_DEPENDENCIES = \
411# $(top_builddir)/src/util/libgnunetutil.la 441# $(top_builddir)/src/util/libgnunetutil.la
412 442
413if ENABLE_TEST_RUN
414if LINUX
415TESTS = $(check_PROGRAMS)
416endif
417endif
418 443
419EXTRA_DIST = \
420 test_gns_defaults.conf \
421 test_gns_simple_lookup.conf \
422 test_gns_dht_default.conf \
423 zonefiles/188JSUMKEF25GVU8TTV0PBNNN8JVCPUEDFV1UHJJU884JD25V0T0.zkey \
424 zonefiles/OEFL7A4VEF1B40QLEMTG5D8G1CN6EN16QUSG5R2DT71GRJN34LSG.zkey \
425 zonefiles/test_zonekey
426 444
diff --git a/src/gns/gns_common.c b/src/gns/gns_common.c
new file mode 100644
index 000000000..88b365da5
--- /dev/null
+++ b/src/gns/gns_common.c
@@ -0,0 +1,79 @@
1/*
2 This file is part of GNUnet.
3 (C) 2012 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20/**
21 *
22 * @file gns/gns_common.c
23 * @brief helper functions shared between GNS service and block plugin
24 * @author Martin Schanzenbach
25 */
26#include "platform.h"
27#include "gns_common.h"
28
29
30/**
31 * Compute the DHT key for a name in a zone.
32 * DHT key is H(name) xor H(pubkey).
33 *
34 * @param name name of the record
35 * @param zone GADS zone
36 * @param key where to store the DHT key for records under this name in the given zone
37 */
38void
39GNUNET_GNS_get_key_for_record (const char *name,
40 const struct GNUNET_CRYPTO_ShortHashCode *zone,
41 struct GNUNET_HashCode *key)
42{
43 struct GNUNET_CRYPTO_ShortHashCode name_hash;
44 struct GNUNET_HashCode name_hash_double;
45 struct GNUNET_HashCode zone_hash_double;
46
47 GNUNET_CRYPTO_short_hash (name,
48 strlen (name),
49 &name_hash);
50 GNUNET_CRYPTO_short_hash_double (&name_hash, &name_hash_double);
51 GNUNET_CRYPTO_short_hash_double (zone, &zone_hash_double);
52 GNUNET_CRYPTO_hash_xor(&name_hash_double, &zone_hash_double, key);
53}
54
55
56/**
57 * Compute the zone identifier from a given DHT key and record name.
58 *
59 * @param name name of the record
60 * @param key DHT key of the record
61 * @param zone set to the corresponding zone hash
62 */
63void
64GNUNET_GNS_get_zone_from_key (const char *name,
65 const struct GNUNET_HashCode *key,
66 struct GNUNET_CRYPTO_ShortHashCode *zone)
67{
68 struct GNUNET_CRYPTO_ShortHashCode name_hash;
69 struct GNUNET_HashCode name_hash_double;
70 struct GNUNET_HashCode zone_hash_double;
71
72 GNUNET_CRYPTO_short_hash(name, strlen(name), &name_hash);
73 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
74 GNUNET_CRYPTO_hash_xor(key, &name_hash_double, &zone_hash_double);
75 GNUNET_CRYPTO_short_hash_from_truncation (&zone_hash_double, zone);
76}
77
78
79/* end of gns_common.c */
diff --git a/src/gns/gns_common.h b/src/gns/gns_common.h
new file mode 100644
index 000000000..5b4a11658
--- /dev/null
+++ b/src/gns/gns_common.h
@@ -0,0 +1,58 @@
1/*
2 This file is part of GNUnet.
3 (C) 2012 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20/**
21 *
22 * @file gns/gns_common.h
23 * @brief helper functions shared between GNS service and block plugin
24 * @author Martin Schanzenbach
25 */
26#ifndef GNS_COMMON_H
27#define GNS_COMMON_H
28
29#include "gnunet_util_lib.h"
30
31/**
32 * Compute the DHT key for a name in a zone.
33 *
34 * @param name name of the record
35 * @param zone GADS zone
36 * @param key where to store the DHT key for records under this name in the given zone
37 */
38void
39GNUNET_GNS_get_key_for_record (const char *name,
40 const struct GNUNET_CRYPTO_ShortHashCode *zone,
41 struct GNUNET_HashCode *key);
42
43
44/**
45 * Compute the zone identifier from a given DHT key and record name.
46 *
47 * @param name name of the record
48 * @param key DHT key of the record
49 * @param zone set to the corresponding zone hash
50 */
51void
52GNUNET_GNS_get_zone_from_key (const char *name,
53 const struct GNUNET_HashCode *key,
54 struct GNUNET_CRYPTO_ShortHashCode *zone);
55
56
57
58#endif
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index 0524b3def..f06bf0d7b 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -58,7 +58,7 @@ static char *auth_name;
58/** 58/**
59 * raw output 59 * raw output
60 */ 60 */
61static int raw = 0; 61static int raw;
62 62
63static enum GNUNET_GNS_RecordType rtype; 63static enum GNUNET_GNS_RecordType rtype;
64 64
@@ -71,8 +71,6 @@ static struct GNUNET_GNS_ShortenRequest *shorten_request;
71/* Handle to get authority request */ 71/* Handle to get authority request */
72static struct GNUNET_GNS_GetAuthRequest *getauth_request; 72static struct GNUNET_GNS_GetAuthRequest *getauth_request;
73 73
74/* shutdown task */
75static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
76 74
77/** 75/**
78 * Task run on shutdown. Cleans up everything. 76 * Task run on shutdown. Cleans up everything.
@@ -99,61 +97,61 @@ do_shutdown (void *cls,
99 97
100 98
101static void 99static void
102process_shorten_result(void* cls, const char* nshort) 100process_shorten_result (void* cls, const char* nshort)
103{ 101{
102 const char *original_name = cls;
103
104 shorten_request = NULL; 104 shorten_request = NULL;
105 if (raw) 105 if (raw)
106 printf("%s", nshort); 106 printf("%s", nshort);
107 else 107 else
108 printf("%s shortened to %s\n", (char*) cls, nshort); 108 printf("%s shortened to %s\n", original_name, nshort);
109 GNUNET_SCHEDULER_cancel (shutdown_task); 109 GNUNET_SCHEDULER_shutdown ();
110 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
111} 110}
112 111
112
113static void 113static void
114process_lookup_result(void* cls, uint32_t rd_count, 114process_lookup_result (void* cls, uint32_t rd_count,
115 const struct GNUNET_NAMESTORE_RecordData *rd) 115 const struct GNUNET_NAMESTORE_RecordData *rd)
116{ 116{
117 int i; 117 const char* name = cls;
118 char* name = (char*) cls; 118 uint32_t i;
119 const char* typename; 119 const char* typename;
120 char* string_val; 120 char* string_val;
121 lookup_request = NULL; 121
122 122 lookup_request = NULL;
123 if (!raw) { 123 if (!raw)
124 {
124 if (rd_count == 0) 125 if (rd_count == 0)
125 printf("No results.\n"); 126 printf("No results.\n");
126 else 127 else
127 printf("%s:\n", name); 128 printf("%s:\n", name);
128 } 129 }
129
130
131
132 for (i=0; i<rd_count; i++) 130 for (i=0; i<rd_count; i++)
133 { 131 {
134 typename = GNUNET_NAMESTORE_number_to_typename (rd[i].record_type); 132 typename = GNUNET_NAMESTORE_number_to_typename (rd[i].record_type);
135 string_val = GNUNET_NAMESTORE_value_to_string(rd[i].record_type, 133 string_val = GNUNET_NAMESTORE_value_to_string (rd[i].record_type,
136 rd[i].data, 134 rd[i].data,
137 rd[i].data_size); 135 rd[i].data_size);
138 if (raw) 136 if (raw)
139 printf("%s\n", string_val); 137 printf ("%s\n", string_val);
140 else 138 else
141 printf("Got %s record: %s\n", typename, string_val); 139 printf ("Got `%s' record: %s\n", typename, string_val);
142 140 GNUNET_free_non_null (string_val);
143 } 141 }
144 GNUNET_SCHEDULER_cancel (shutdown_task); 142 GNUNET_SCHEDULER_shutdown ();
145 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
146} 143}
147 144
145
148static void 146static void
149process_auth_result(void* cls, const char* auth) 147process_auth_result (void* cls, const char* auth)
150{ 148{
151 getauth_request = NULL; 149 getauth_request = NULL;
152 printf ("%s\n", auth); 150 printf ("%s\n", auth);
153 GNUNET_SCHEDULER_cancel (shutdown_task); 151 GNUNET_SCHEDULER_shutdown ();
154 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
155} 152}
156 153
154
157/** 155/**
158 * Main function that will be run. 156 * Main function that will be run.
159 * 157 *
@@ -177,124 +175,84 @@ run (void *cls, char *const *args, const char *cfgfile,
177 struct GNUNET_CRYPTO_ShortHashCode *private_zone = NULL; 175 struct GNUNET_CRYPTO_ShortHashCode *private_zone = NULL;
178 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone = NULL; 176 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone = NULL;
179 177
180 shorten_request = NULL; 178 gns = GNUNET_GNS_connect (cfg);
181 lookup_request = NULL; 179 if (NULL == gns)
182 getauth_request = NULL; 180 {
183 181 fprintf (stderr,
182 _("Failed to connect to GNS\n"));
183 return;
184 }
184 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 185 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
185 "ZONEKEY", &keyfile)) 186 "ZONEKEY", &keyfile))
186 { 187 {
187 if (!raw) 188 if (! raw)
188 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 189 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
189 "No private key for root zone found, using default!\n"); 190 "No private key for root zone found, using default!\n");
190 zone = NULL;
191 } 191 }
192 else 192 else
193 { 193 {
194 if (GNUNET_YES == GNUNET_DISK_file_test (keyfile)) 194 key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
195 { 195 GNUNET_CRYPTO_rsa_key_get_public (key, &pkey);
196 key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); 196 GNUNET_CRYPTO_short_hash (&pkey,
197 GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); 197 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
198 GNUNET_CRYPTO_short_hash(&pkey, 198 &user_zone);
199 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 199 zone = &user_zone;
200 &user_zone); 200 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename);
201 zone = &user_zone; 201 if (!raw)
202 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); 202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
203 if (!raw) 203 "Using zone: %s!\n", &zonename);
204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 204 GNUNET_CRYPTO_rsa_key_free (key);
205 "Using zone: %s!\n", &zonename);
206 GNUNET_CRYPTO_rsa_key_free(key);
207 }
208 GNUNET_free(keyfile); 205 GNUNET_free(keyfile);
209 } 206 }
210 207
211 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 208 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
212 "SHORTEN_ZONEKEY", &keyfile)) 209 "SHORTEN_ZONEKEY", &keyfile))
213 { 210 {
214 if (!raw) 211 if (! raw)
215 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 212 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
216 "No shorten key found!\n"); 213 "No shorten key found!\n");
217 shorten_key = NULL;
218 } 214 }
219 else 215 else
220 { 216 {
221 if (GNUNET_YES == GNUNET_DISK_file_test (keyfile)) 217 shorten_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
222 { 218 GNUNET_CRYPTO_rsa_key_get_public (shorten_key, &pkey);
223 shorten_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); 219 shorten_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode));
224 GNUNET_CRYPTO_rsa_key_get_public (shorten_key, &pkey); 220 GNUNET_CRYPTO_short_hash(&pkey,
225 shorten_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode)); 221 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
226 GNUNET_CRYPTO_short_hash(&pkey, 222 shorten_zone);
227 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 223 GNUNET_CRYPTO_short_hash_to_enc (shorten_zone, &zonename);
228 shorten_zone); 224 if (! raw)
229 GNUNET_CRYPTO_short_hash_to_enc (shorten_zone, &zonename); 225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
230 if (!raw) 226 "Using shorten zone: %s!\n", &zonename);
231 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 227 GNUNET_free (keyfile);
232 "Using shorten zone: %s!\n", &zonename);
233
234 }
235 GNUNET_free(keyfile);
236 } 228 }
237 229
238
239 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 230 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
240 "PRIVATE_ZONEKEY", &keyfile)) 231 "PRIVATE_ZONEKEY", &keyfile))
241 { 232 {
242 if (!raw) 233 if (! raw)
243 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 234 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
244 "No private zone key file name specified in configuration!\n"); 235 "No private zone key file name specified in configuration!\n");
245 private_key = NULL;
246 } 236 }
247 else 237 else
248 { 238 {
249 if (GNUNET_YES == GNUNET_DISK_file_test (keyfile)) 239 private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
250 { 240 GNUNET_CRYPTO_rsa_key_get_public (private_key, &pkey);
251 private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); 241 private_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode));
252 GNUNET_CRYPTO_rsa_key_get_public (private_key, &pkey); 242 GNUNET_CRYPTO_short_hash(&pkey,
253 private_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode)); 243 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
254 GNUNET_CRYPTO_short_hash(&pkey, 244 private_zone);
255 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 245 GNUNET_CRYPTO_short_hash_to_enc (private_zone, &zonename);
256 private_zone); 246 if (! raw)
257 GNUNET_CRYPTO_short_hash_to_enc (private_zone, &zonename); 247 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
258 if (!raw) 248 "Using private zone: %s!\n", &zonename);
259 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
260 "Using private zone: %s!\n", &zonename);
261 }
262 else
263 {
264 /* FIXME: shouldn't we just create the private key in this case? */
265 if (!raw)
266 fprintf (stderr,
267 _("Key file `%s' for private zone does not exist!\n"),
268 keyfile);
269
270 }
271 GNUNET_free(keyfile);
272 if (NULL != private_key)
273 {
274 GNUNET_CRYPTO_rsa_key_free (private_key);
275 private_key = NULL;
276 }
277 } 249 }
278 250
279
280 gns = GNUNET_GNS_connect (cfg);
281 if (NULL != lookup_type) 251 if (NULL != lookup_type)
282 rtype = GNUNET_NAMESTORE_typename_to_number (lookup_type); 252 rtype = GNUNET_NAMESTORE_typename_to_number (lookup_type);
283 else 253 else
284 rtype = GNUNET_GNS_RECORD_A; 254 rtype = GNUNET_GNS_RECORD_A;
285 255
286 if (NULL == gns)
287 {
288 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
289 _("Failed to connect to GNS\n"));
290 if (NULL != shorten_key)
291 {
292 GNUNET_CRYPTO_rsa_key_free (shorten_key);
293 shorten_key = NULL;
294 }
295 return;
296 }
297
298 if ((NULL != shorten_name) && (NULL != shorten_zone) && (NULL != private_zone)) 256 if ((NULL != shorten_name) && (NULL != shorten_zone) && (NULL != private_zone))
299 { 257 {
300 shorten_request = GNUNET_GNS_shorten_zone (gns, shorten_name, 258 shorten_request = GNUNET_GNS_shorten_zone (gns, shorten_name,
@@ -304,31 +262,25 @@ run (void *cls, char *const *args, const char *cfgfile,
304 &process_shorten_result, 262 &process_shorten_result,
305 shorten_name); 263 shorten_name);
306 } 264 }
307
308 if (NULL != lookup_name) 265 if (NULL != lookup_name)
309 { 266 {
310 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
311 "Lookup\n");
312 lookup_request = GNUNET_GNS_lookup_zone (gns, lookup_name, 267 lookup_request = GNUNET_GNS_lookup_zone (gns, lookup_name,
313 zone, 268 zone,
314 rtype, 269 rtype,
315 GNUNET_NO, //Use DHT 270 GNUNET_NO, /* Use DHT */
316 shorten_key, 271 shorten_key,
317 &process_lookup_result, lookup_name); 272 &process_lookup_result, lookup_name);
318 } 273 }
319
320 if (NULL != auth_name) 274 if (NULL != auth_name)
321 { 275 {
322 getauth_request = GNUNET_GNS_get_authority(gns, auth_name, 276 getauth_request = GNUNET_GNS_get_authority (gns, auth_name,
323 &process_auth_result, auth_name); 277 &process_auth_result, auth_name);
324 } 278 }
325 279
326 if (NULL != shorten_key) 280 if (NULL != shorten_key)
327 GNUNET_CRYPTO_rsa_key_free (shorten_key); 281 GNUNET_CRYPTO_rsa_key_free (shorten_key);
328
329 if (NULL != shorten_zone) 282 if (NULL != shorten_zone)
330 GNUNET_free (shorten_zone); 283 GNUNET_free (shorten_zone);
331
332 if (NULL != private_zone) 284 if (NULL != private_zone)
333 GNUNET_free (private_zone); 285 GNUNET_free (private_zone);
334 286
@@ -336,15 +288,14 @@ run (void *cls, char *const *args, const char *cfgfile,
336 (NULL == shorten_name) && 288 (NULL == shorten_name) &&
337 (NULL == lookup_name)) 289 (NULL == lookup_name))
338 { 290 {
339 if (!raw) 291 fprintf (stderr,
340 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 292 _("Please specify lookup, shorten or authority operation!\n"));
341 "Please specify lookup, shorten or authority operation!\n");
342 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 293 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
343 return; 294 return;
344 } 295 }
345 296
346 shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 297 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
347 &do_shutdown, NULL); 298 &do_shutdown, NULL);
348} 299}
349 300
350 301
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 18bb26fe8..1a3485982 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors) 3 (C) 2009, 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
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
@@ -35,6 +35,7 @@
35#include "gnunet_statistics_service.h" 35#include "gnunet_statistics_service.h"
36#include "block_gns.h" 36#include "block_gns.h"
37#include "gns.h" 37#include "gns.h"
38#include "gns_common.h"
38#include "gnunet-service-gns_resolver.h" 39#include "gnunet-service-gns_resolver.h"
39#include "gnunet-service-gns_interceptor.h" 40#include "gnunet-service-gns_interceptor.h"
40#include "gnunet_protocols.h" 41#include "gnunet_protocols.h"
@@ -102,7 +103,7 @@ struct ClientGetAuthHandle
102 uint64_t unique_id; 103 uint64_t unique_id;
103 104
104 /* name to lookup authority */ 105 /* name to lookup authority */
105 char* name; 106 char *name;
106 107
107}; 108};
108 109
@@ -132,9 +133,10 @@ struct ClientLookupHandle
132 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key; 133 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key;
133 134
134 /* the name to look up */ 135 /* the name to look up */
135 char* name; //Needed? 136 char *name;
136}; 137};
137 138
139
138/** 140/**
139 * Our handle to the DHT 141 * Our handle to the DHT
140 */ 142 */
@@ -143,23 +145,18 @@ static struct GNUNET_DHT_Handle *dht_handle;
143/** 145/**
144 * Our zone's private key 146 * Our zone's private key
145 */ 147 */
146struct GNUNET_CRYPTO_RsaPrivateKey *zone_key; 148static struct GNUNET_CRYPTO_RsaPrivateKey *zone_key;
147 149
148/** 150/**
149 * Our handle to the namestore service 151 * Our handle to the namestore service
150 * FIXME maybe need a second handle for iteration 152 * FIXME maybe need a second handle for iteration
151 */ 153 */
152struct GNUNET_NAMESTORE_Handle *namestore_handle; 154static struct GNUNET_NAMESTORE_Handle *namestore_handle;
153 155
154/** 156/**
155 * Handle to iterate over our authoritative zone in namestore 157 * Handle to iterate over our authoritative zone in namestore
156 */ 158 */
157struct GNUNET_NAMESTORE_ZoneIterator *namestore_iter; 159static struct GNUNET_NAMESTORE_ZoneIterator *namestore_iter;
158
159/**
160 * The configuration the GNS service is running with
161 */
162const struct GNUNET_CONFIGURATION_Handle *GNS_cfg;
163 160
164/** 161/**
165 * Our notification context. 162 * Our notification context.
@@ -169,7 +166,7 @@ static struct GNUNET_SERVER_NotificationContext *nc;
169/** 166/**
170 * Our zone hash 167 * Our zone hash
171 */ 168 */
172struct GNUNET_CRYPTO_ShortHashCode zone_hash; 169static struct GNUNET_CRYPTO_ShortHashCode zone_hash;
173 170
174/** 171/**
175 * Useful for zone update for DHT put 172 * Useful for zone update for DHT put
@@ -190,7 +187,7 @@ static struct GNUNET_TIME_Relative zone_iteration_interval;
190static struct GNUNET_TIME_Relative record_put_interval; 187static struct GNUNET_TIME_Relative record_put_interval;
191 188
192/* zone update task */ 189/* zone update task */
193GNUNET_SCHEDULER_TaskIdentifier zone_update_taskid = GNUNET_SCHEDULER_NO_TASK; 190static GNUNET_SCHEDULER_TaskIdentifier zone_update_taskid;
194 191
195/* automatic pkey import for name shortening */ 192/* automatic pkey import for name shortening */
196static int auto_import_pkey; 193static int auto_import_pkey;
@@ -256,7 +253,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
256 * @param tc task context 253 * @param tc task context
257 */ 254 */
258static void 255static void
259update_zone_dht_next(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 256update_zone_dht_next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
260{ 257{
261 zone_update_taskid = GNUNET_SCHEDULER_NO_TASK; 258 zone_update_taskid = GNUNET_SCHEDULER_NO_TASK;
262 GNUNET_NAMESTORE_zone_iterator_next (namestore_iter); 259 GNUNET_NAMESTORE_zone_iterator_next (namestore_iter);
@@ -284,6 +281,7 @@ record_dht_put(void *cls, int success)
284static void 281static void
285update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 282update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
286 283
284
287/** 285/**
288 * Function used to put all records successively into the DHT. 286 * Function used to put all records successively into the DHT.
289 * 287 *
@@ -305,19 +303,18 @@ put_gns_record(void *cls,
305 const struct GNUNET_CRYPTO_RsaSignature *signature) 303 const struct GNUNET_CRYPTO_RsaSignature *signature)
306{ 304{
307 struct GNSNameRecordBlock *nrb; 305 struct GNSNameRecordBlock *nrb;
308 struct GNUNET_CRYPTO_ShortHashCode name_hash;
309 struct GNUNET_CRYPTO_ShortHashCode zhash; 306 struct GNUNET_CRYPTO_ShortHashCode zhash;
310 struct GNUNET_HashCode xor_hash; 307 struct GNUNET_HashCode dht_key;
311 struct GNUNET_HashCode name_hash_double;
312 struct GNUNET_HashCode zone_hash_double;
313 uint32_t rd_payload_length; 308 uint32_t rd_payload_length;
314 char* nrb_data = NULL; 309 char* nrb_data = NULL;
315 size_t namelen; 310 size_t namelen;
316 struct GNUNET_TIME_Relative next_put_interval; 311 struct GNUNET_TIME_Relative next_put_interval;
317 312
318 /* we're done */
319 if (NULL == name) 313 if (NULL == name)
320 { 314 {
315 /* we're done */
316 namestore_iter = NULL;
317 last_num_public_records = num_public_records;
321 first_zone_iteration = GNUNET_NO; 318 first_zone_iteration = GNUNET_NO;
322 if (0 == num_public_records) 319 if (0 == num_public_records)
323 { 320 {
@@ -329,49 +326,41 @@ put_gns_record(void *cls,
329 zone_iteration_interval = GNUNET_TIME_relative_divide (record_put_interval, 326 zone_iteration_interval = GNUNET_TIME_relative_divide (record_put_interval,
330 1); 327 1);
331 328
332 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 329 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
333 "No records in db.\n"); 330 "No records in db.\n");
334 } 331 }
335 else 332 else
336 { 333 {
337 zone_iteration_interval = GNUNET_TIME_relative_divide (record_put_interval, 334 zone_iteration_interval = GNUNET_TIME_relative_divide (record_put_interval,
338 num_public_records); 335 num_public_records);
339 } 336 }
340
341 zone_iteration_interval = GNUNET_TIME_relative_max (MINIMUM_ZONE_ITERATION_INTERVAL, 337 zone_iteration_interval = GNUNET_TIME_relative_max (MINIMUM_ZONE_ITERATION_INTERVAL,
342 zone_iteration_interval); 338 zone_iteration_interval);
343 339
344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 340 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
345 "Adjusted zone iteration interval to %s\n", 341 "Zone iteration finished. Adjusted zone iteration interval to %s\n",
346 GNUNET_STRINGS_relative_time_to_string (zone_iteration_interval, GNUNET_YES)); 342 GNUNET_STRINGS_relative_time_to_string (zone_iteration_interval, GNUNET_YES));
347 GNUNET_STATISTICS_set (statistics, 343 GNUNET_STATISTICS_set (statistics,
348 "Current zone iteration interval [msec]", 344 "Current zone iteration interval (in ms)",
349 zone_iteration_interval.rel_value, 345 zone_iteration_interval.rel_value,
350 GNUNET_NO); 346 GNUNET_NO);
351
352 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
353 "Zone iteration finished. Rescheduling zone iteration\n");
354
355 namestore_iter = NULL;
356 if (num_public_records == 0)
357 zone_update_taskid = GNUNET_SCHEDULER_add_delayed (zone_iteration_interval,
358 &update_zone_dht_start,
359 NULL);
360 else
361 zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_start, NULL);
362 GNUNET_STATISTICS_update (statistics, 347 GNUNET_STATISTICS_update (statistics,
363 "Number of zone iterations", 1, GNUNET_NO); 348 "Number of zone iterations", 1, GNUNET_NO);
364
365 last_num_public_records = num_public_records;
366 GNUNET_STATISTICS_set (statistics, 349 GNUNET_STATISTICS_set (statistics,
367 "Number of public records in DHT", 350 "Number of public records in DHT",
368 last_num_public_records, 351 last_num_public_records,
369 GNUNET_NO); 352 GNUNET_NO);
353 if (0 == num_public_records)
354 zone_update_taskid = GNUNET_SCHEDULER_add_delayed (zone_iteration_interval,
355 &update_zone_dht_start,
356 NULL);
357 else
358 zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_start, NULL);
370 return; 359 return;
371 } 360 }
372 361
373 namelen = strlen(name) + 1; 362 namelen = strlen (name) + 1;
374 if (rd_count == 0) 363 if (0 == rd_count)
375 { 364 {
376 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 365 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
377 "No records for name `%s'! Skipping.\n", 366 "No records for name `%s'! Skipping.\n",
@@ -380,7 +369,7 @@ put_gns_record(void *cls,
380 NULL); 369 NULL);
381 return; 370 return;
382 } 371 }
383 if (signature == NULL) 372 if (NULL == signature)
384 { 373 {
385 GNUNET_break (0); 374 GNUNET_break (0);
386 zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_next, 375 zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_next,
@@ -389,15 +378,14 @@ put_gns_record(void *cls,
389 } 378 }
390 379
391 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 380 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
392 "Putting records for `%s' into the DHT\n", name); 381 "Putting records for `%s' into the DHT\n", name);
393
394 rd_payload_length = GNUNET_NAMESTORE_records_get_size (rd_count, rd); 382 rd_payload_length = GNUNET_NAMESTORE_records_get_size (rd_count, rd);
395 nrb = GNUNET_malloc(rd_payload_length + namelen 383 nrb = GNUNET_malloc (rd_payload_length + namelen
396 + sizeof(struct GNSNameRecordBlock)); 384 + sizeof (struct GNSNameRecordBlock));
397 nrb->signature = *signature; 385 nrb->signature = *signature;
398 nrb->public_key = *key; 386 nrb->public_key = *key;
399 nrb->rd_count = htonl(rd_count); 387 nrb->rd_count = htonl (rd_count);
400 memcpy(&nrb[1], name, namelen); 388 memcpy (&nrb[1], name, namelen);
401 nrb_data = (char *) &nrb[1]; 389 nrb_data = (char *) &nrb[1];
402 nrb_data += namelen; 390 nrb_data += namelen;
403 rd_payload_length += sizeof(struct GNSNameRecordBlock) + namelen; 391 rd_payload_length += sizeof(struct GNSNameRecordBlock) + namelen;
@@ -419,27 +407,20 @@ put_gns_record(void *cls,
419 return; 407 return;
420 } 408 }
421 409
422 /* 410 GNUNET_GNS_get_key_for_record (name, &zhash, &dht_key);
423 * calculate DHT key: H(name) xor H(pubkey)
424 */
425 GNUNET_CRYPTO_short_hash(name, strlen(name), &name_hash);
426 GNUNET_CRYPTO_short_hash_double (&name_hash, &name_hash_double);
427 GNUNET_CRYPTO_short_hash_double (&zhash, &zone_hash_double);
428 GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash);
429
430 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 411 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
431 "putting %u records from zone %s for `%s' under key: %s with size %u and timeout %s\n", 412 "putting %u records from zone %s for `%s' under key: %s with size %u and timeout %s\n",
432 rd_count, 413 rd_count,
433 GNUNET_h2s (&zone_hash_double) /* FIXME: write converter for short hash... */, 414 GNUNET_short_h2s (&zhash),
434 name, 415 name,
435 GNUNET_h2s (&xor_hash), 416 GNUNET_h2s (&dht_key),
436 (unsigned int) rd_payload_length, 417 (unsigned int) rd_payload_length,
437 GNUNET_STRINGS_relative_time_to_string (DHT_OPERATION_TIMEOUT, GNUNET_YES)); 418 GNUNET_STRINGS_relative_time_to_string (DHT_OPERATION_TIMEOUT, GNUNET_YES));
438 419
439 GNUNET_STATISTICS_update (statistics, 420 GNUNET_STATISTICS_update (statistics,
440 "Record bytes put into DHT", rd_payload_length, GNUNET_NO); 421 "Record bytes put into DHT", rd_payload_length, GNUNET_NO);
441 422
442 (void) GNUNET_DHT_put (dht_handle, &xor_hash, 423 (void) GNUNET_DHT_put (dht_handle, &dht_key,
443 DHT_GNS_REPLICATION_LEVEL, 424 DHT_GNS_REPLICATION_LEVEL,
444 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, 425 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
445 GNUNET_BLOCK_TYPE_GNS_NAMERECORD, 426 GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
@@ -449,36 +430,29 @@ put_gns_record(void *cls,
449 DHT_OPERATION_TIMEOUT, 430 DHT_OPERATION_TIMEOUT,
450 &record_dht_put, 431 &record_dht_put,
451 NULL); 432 NULL);
452 433 GNUNET_free (nrb);
453 num_public_records++; 434
454 435 num_public_records++;
455 if ((num_public_records > last_num_public_records) 436 if ( (num_public_records > last_num_public_records)
456 && (first_zone_iteration == GNUNET_NO)) 437 && (GNUNET_NO == first_zone_iteration) )
457 { 438 {
439 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
440 "Last record count was lower than current record count. Reducing interval.\n");
458 zone_iteration_interval = GNUNET_TIME_relative_divide (record_put_interval, 441 zone_iteration_interval = GNUNET_TIME_relative_divide (record_put_interval,
459 num_public_records); 442 num_public_records);
460 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
461 "Last record count was lower than current record count... increasing.\n");
462 next_put_interval = GNUNET_TIME_relative_divide (zone_iteration_interval, 443 next_put_interval = GNUNET_TIME_relative_divide (zone_iteration_interval,
463 LATE_ITERATION_SPEEDUP_FACTOR); 444 LATE_ITERATION_SPEEDUP_FACTOR);
464
465 } 445 }
466 else 446 else
467 next_put_interval = zone_iteration_interval; 447 next_put_interval = zone_iteration_interval;
468 448
469 GNUNET_STATISTICS_set (statistics, 449 GNUNET_STATISTICS_set (statistics,
470 "Current zone iteration interval [msec]", 450 "Current zone iteration interval (ms)",
471 next_put_interval.rel_value, 451 next_put_interval.rel_value,
472 GNUNET_NO); 452 GNUNET_NO);
473
474 /**
475 * Reschedule periodic put
476 */
477 zone_update_taskid = GNUNET_SCHEDULER_add_delayed (next_put_interval, 453 zone_update_taskid = GNUNET_SCHEDULER_add_delayed (next_put_interval,
478 &update_zone_dht_next, 454 &update_zone_dht_next,
479 NULL); 455 NULL);
480
481 GNUNET_free(nrb);
482} 456}
483 457
484 458
@@ -493,20 +467,21 @@ update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
493{ 467{
494 zone_update_taskid = GNUNET_SCHEDULER_NO_TASK; 468 zone_update_taskid = GNUNET_SCHEDULER_NO_TASK;
495 469
496 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Scheduling DHT zone update!\n"); 470 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Scheduling DHT zone update!\n");
497
498 /* start counting again */ 471 /* start counting again */
499 num_public_records = 0; 472 num_public_records = 0;
500 namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle, 473 namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle,
501 NULL, //All zones 474 NULL, /* All zones */
502 GNUNET_NAMESTORE_RF_AUTHORITY, 475 GNUNET_NAMESTORE_RF_AUTHORITY,
503 GNUNET_NAMESTORE_RF_PRIVATE, 476 GNUNET_NAMESTORE_RF_PRIVATE,
504 &put_gns_record, 477 &put_gns_record,
505 NULL); 478 NULL);
506} 479}
507 480
481
508/* END DHT ZONE PROPAGATION */ 482/* END DHT ZONE PROPAGATION */
509 483
484
510/** 485/**
511 * Send shorten response back to client 486 * Send shorten response back to client
512 * 487 *
@@ -514,7 +489,7 @@ update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
514 * @param name the shortened name result or NULL if cannot be shortened 489 * @param name the shortened name result or NULL if cannot be shortened
515 */ 490 */
516static void 491static void
517send_shorten_response(void* cls, const char* name) 492send_shorten_response (void* cls, const char* name)
518{ 493{
519 struct ClientShortenHandle *csh = cls; 494 struct ClientShortenHandle *csh = cls;
520 struct GNUNET_GNS_ClientShortenResultMessage *rmsg; 495 struct GNUNET_GNS_ClientShortenResultMessage *rmsg;
@@ -529,8 +504,8 @@ send_shorten_response(void* cls, const char* name)
529 GNUNET_STATISTICS_update (statistics, 504 GNUNET_STATISTICS_update (statistics,
530 "Name shorten results", 1, GNUNET_NO); 505 "Name shorten results", 1, GNUNET_NO);
531 506
532 rmsg = GNUNET_malloc(sizeof(struct GNUNET_GNS_ClientShortenResultMessage) + 507 rmsg = GNUNET_malloc (sizeof (struct GNUNET_GNS_ClientShortenResultMessage) +
533 name_len); 508 name_len);
534 509
535 rmsg->id = csh->unique_id; 510 rmsg->id = csh->unique_id;
536 rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT); 511 rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT);
@@ -538,11 +513,9 @@ send_shorten_response(void* cls, const char* name)
538 htons(sizeof(struct GNUNET_GNS_ClientShortenResultMessage) + 513 htons(sizeof(struct GNUNET_GNS_ClientShortenResultMessage) +
539 name_len); 514 name_len);
540 memcpy (&rmsg[1], name, name_len); 515 memcpy (&rmsg[1], name, name_len);
541
542 GNUNET_SERVER_notification_context_unicast (nc, csh->client, 516 GNUNET_SERVER_notification_context_unicast (nc, csh->client,
543 &rmsg->header, 517 &rmsg->header,
544 GNUNET_NO); 518 GNUNET_NO);
545 GNUNET_SERVER_receive_done (csh->client, GNUNET_OK);
546 if (NULL != csh->namestore_task) 519 if (NULL != csh->namestore_task)
547 GNUNET_NAMESTORE_cancel (csh->namestore_task); 520 GNUNET_NAMESTORE_cancel (csh->namestore_task);
548 GNUNET_free (rmsg); 521 GNUNET_free (rmsg);
@@ -564,18 +537,18 @@ send_shorten_response(void* cls, const char* name)
564 */ 537 */
565static void 538static void
566process_shorten_in_private_zone_lookup (void *cls, 539process_shorten_in_private_zone_lookup (void *cls,
567 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, 540 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key,
568 struct GNUNET_TIME_Absolute expiration, 541 struct GNUNET_TIME_Absolute expiration,
569 const char *name, 542 const char *name,
570 unsigned int rd_count, 543 unsigned int rd_count,
571 const struct GNUNET_NAMESTORE_RecordData *rd, 544 const struct GNUNET_NAMESTORE_RecordData *rd,
572 const struct GNUNET_CRYPTO_RsaSignature *signature) 545 const struct GNUNET_CRYPTO_RsaSignature *signature)
573{ 546{
574 struct ClientShortenHandle *csh = cls; 547 struct ClientShortenHandle *csh = cls;
575 csh->namestore_task = NULL;
576 struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone; 548 struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone;
577 struct GNUNET_CRYPTO_ShortHashCode *pzone = &csh->private_zone; 549 struct GNUNET_CRYPTO_ShortHashCode *pzone = &csh->private_zone;
578 550
551 csh->namestore_task = NULL;
579 if (0 == strcmp (csh->private_zone_id, "")) 552 if (0 == strcmp (csh->private_zone_id, ""))
580 pzone = NULL; 553 pzone = NULL;
581 554
@@ -583,14 +556,11 @@ process_shorten_in_private_zone_lookup (void *cls,
583 { 556 {
584 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 557 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
585 "No shorten zone in private zone!\n"); 558 "No shorten zone in private zone!\n");
586
587 strcpy (csh->shorten_zone_id, ""); 559 strcpy (csh->shorten_zone_id, "");
588 szone = NULL; 560 szone = NULL;
589
590 } 561 }
591 else 562 else
592 { 563 {
593
594 GNUNET_assert (rd_count == 1); 564 GNUNET_assert (rd_count == 1);
595 565
596 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 566 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -635,10 +605,10 @@ process_shorten_in_root_zone_lookup (void *cls,
635 const struct GNUNET_CRYPTO_RsaSignature *signature) 605 const struct GNUNET_CRYPTO_RsaSignature *signature)
636{ 606{
637 struct ClientShortenHandle *csh = cls; 607 struct ClientShortenHandle *csh = cls;
638 csh->namestore_task = NULL;
639 struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone; 608 struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone;
640 struct GNUNET_CRYPTO_ShortHashCode *pzone = &csh->private_zone; 609 struct GNUNET_CRYPTO_ShortHashCode *pzone = &csh->private_zone;
641 610
611 csh->namestore_task = NULL;
642 if (0 == strcmp (csh->private_zone_id, "")) 612 if (0 == strcmp (csh->private_zone_id, ""))
643 pzone = NULL; 613 pzone = NULL;
644 614
@@ -762,33 +732,24 @@ handle_shorten (void *cls,
762 struct GNUNET_SERVER_Client * client, 732 struct GNUNET_SERVER_Client * client,
763 const struct GNUNET_MessageHeader * message) 733 const struct GNUNET_MessageHeader * message)
764{ 734{
765 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "SHORTEN");
766
767 size_t msg_size = 0; 735 size_t msg_size = 0;
768 struct ClientShortenHandle *csh; 736 struct ClientShortenHandle *csh;
769 char name[MAX_DNS_NAME_LENGTH]; 737 char name[MAX_DNS_NAME_LENGTH];
770 char* nameptr = name; 738 char* nameptr = name;
771 739
740 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "SHORTEN");
772 if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientShortenMessage)) 741 if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientShortenMessage))
773 { 742 {
774 GNUNET_break_op (0); 743 GNUNET_break (0);
775 GNUNET_SERVER_receive_done (client, GNUNET_OK); 744 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
776 return; 745 return;
777 } 746 }
778 747
779 748
780 struct GNUNET_GNS_ClientShortenMessage *sh_msg = 749 const struct GNUNET_GNS_ClientShortenMessage *sh_msg =
781 (struct GNUNET_GNS_ClientShortenMessage *) message; 750 (const struct GNUNET_GNS_ClientShortenMessage *) message;
782 751
783 msg_size = ntohs(message->size); 752 msg_size = ntohs (message->size);
784
785 if (msg_size > GNUNET_SERVER_MAX_MESSAGE_SIZE)
786 {
787 GNUNET_break_op (0);
788 GNUNET_SERVER_receive_done (client, GNUNET_OK);
789 return;
790 }
791
792 csh = GNUNET_malloc(sizeof (struct ClientShortenHandle)); 753 csh = GNUNET_malloc(sizeof (struct ClientShortenHandle));
793 csh->client = client; 754 csh->client = client;
794 csh->unique_id = sh_msg->id; 755 csh->unique_id = sh_msg->id;
@@ -805,6 +766,7 @@ handle_shorten (void *cls,
805 "SHORTEN: %s is too short\n", name); 766 "SHORTEN: %s is too short\n", name);
806 GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh); 767 GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh);
807 send_shorten_response(csh, name); 768 send_shorten_response(csh, name);
769 GNUNET_SERVER_receive_done (client, GNUNET_OK);
808 return; 770 return;
809 } 771 }
810 772
@@ -813,6 +775,7 @@ handle_shorten (void *cls,
813 "SHORTEN: %s is too long\n", name); 775 "SHORTEN: %s is too long\n", name);
814 GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh); 776 GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh);
815 send_shorten_response(csh, name); 777 send_shorten_response(csh, name);
778 GNUNET_SERVER_receive_done (client, GNUNET_OK);
816 return; 779 return;
817 } 780 }
818 781
@@ -822,6 +785,7 @@ handle_shorten (void *cls,
822 "%s is not our domain. Returning\n", name); 785 "%s is not our domain. Returning\n", name);
823 GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh); 786 GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh);
824 send_shorten_response(csh, name); 787 send_shorten_response(csh, name);
788 GNUNET_SERVER_receive_done (client, GNUNET_OK);
825 return; 789 return;
826 } 790 }
827 791
@@ -840,7 +804,7 @@ handle_shorten (void *cls,
840 804
841 GNUNET_STATISTICS_update (statistics, 805 GNUNET_STATISTICS_update (statistics,
842 "Name shorten attempts", 1, GNUNET_NO); 806 "Name shorten attempts", 1, GNUNET_NO);
843 807 GNUNET_SERVER_receive_done (client, GNUNET_OK);
844} 808}
845 809
846 810
@@ -850,24 +814,21 @@ handle_shorten (void *cls,
850 * @param cls the closure containing a client get auth handle 814 * @param cls the closure containing a client get auth handle
851 * @param name the shortened name result or NULL if cannot be shortened 815 * @param name the shortened name result or NULL if cannot be shortened
852 */ 816 */
853static void 817static void
854send_get_auth_response(void *cls, const char* name) 818send_get_auth_response(void *cls, const char* name)
855{ 819{
856 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message with %s\n", 820 struct ClientGetAuthHandle *cah = cls;
857 "GET_AUTH_RESULT", name);
858 struct GNUNET_GNS_ClientGetAuthResultMessage *rmsg; 821 struct GNUNET_GNS_ClientGetAuthResultMessage *rmsg;
859 struct ClientGetAuthHandle *cah = (struct ClientGetAuthHandle *)cls;
860 822
823 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message with %s\n",
824 "GET_AUTH_RESULT", name);
861 if (name != NULL) 825 if (name != NULL)
862 { 826 {
863 GNUNET_STATISTICS_update (statistics, 827 GNUNET_STATISTICS_update (statistics,
864 "Authorities resolved", 1, GNUNET_NO); 828 "Authorities resolved", 1, GNUNET_NO);
865 } 829 }
866 830 if (name == NULL)
867 if (name == NULL) 831 name = "";
868 {
869 name = "";
870 }
871 832
872 rmsg = GNUNET_malloc(sizeof(struct GNUNET_GNS_ClientGetAuthResultMessage) 833 rmsg = GNUNET_malloc(sizeof(struct GNUNET_GNS_ClientGetAuthResultMessage)
873 + strlen(name) + 1); 834 + strlen(name) + 1);
@@ -877,8 +838,7 @@ send_get_auth_response(void *cls, const char* name)
877 rmsg->header.size = 838 rmsg->header.size =
878 htons(sizeof(struct GNUNET_GNS_ClientGetAuthResultMessage) + 839 htons(sizeof(struct GNUNET_GNS_ClientGetAuthResultMessage) +
879 strlen(name) + 1); 840 strlen(name) + 1);
880 841 strcpy ((char*)&rmsg[1], name);
881 strcpy((char*)&rmsg[1], name);
882 842
883 GNUNET_SERVER_notification_context_unicast (nc, cah->client, 843 GNUNET_SERVER_notification_context_unicast (nc, cah->client,
884 &rmsg->header, 844 &rmsg->header,
@@ -887,10 +847,7 @@ send_get_auth_response(void *cls, const char* name)
887 847
888 GNUNET_free(rmsg); 848 GNUNET_free(rmsg);
889 GNUNET_free_non_null(cah->name); 849 GNUNET_free_non_null(cah->name);
890 GNUNET_free(cah); 850 GNUNET_free(cah);
891
892
893
894} 851}
895 852
896 853
@@ -901,21 +858,20 @@ send_get_auth_response(void *cls, const char* name)
901 * @param client the client 858 * @param client the client
902 * @param message the message 859 * @param message the message
903 */ 860 */
904static void handle_get_authority(void *cls, 861static void
905 struct GNUNET_SERVER_Client * client, 862handle_get_authority (void *cls,
906 const struct GNUNET_MessageHeader * message) 863 struct GNUNET_SERVER_Client * client,
864 const struct GNUNET_MessageHeader * message)
907{ 865{
908 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "GET_AUTH");
909
910 size_t msg_size = 0; 866 size_t msg_size = 0;
911 struct ClientGetAuthHandle *cah; 867 struct ClientGetAuthHandle *cah;
912 char name[MAX_DNS_NAME_LENGTH]; 868 char name[MAX_DNS_NAME_LENGTH];
913 char* nameptr = name; 869 char* nameptr = name;
914 870
915 871 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "GET_AUTH");
916 if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientGetAuthMessage)) 872 if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientGetAuthMessage))
917 { 873 {
918 GNUNET_break_op (0); 874 GNUNET_break (0);
919 GNUNET_SERVER_receive_done (client, GNUNET_OK); 875 GNUNET_SERVER_receive_done (client, GNUNET_OK);
920 return; 876 return;
921 } 877 }
@@ -926,15 +882,7 @@ static void handle_get_authority(void *cls,
926 (struct GNUNET_GNS_ClientGetAuthMessage *) message; 882 (struct GNUNET_GNS_ClientGetAuthMessage *) message;
927 883
928 msg_size = ntohs(message->size); 884 msg_size = ntohs(message->size);
929 885 GNUNET_STRINGS_utf8_tolower((const char*)&sh_msg[1], &nameptr);
930 if (msg_size > GNUNET_SERVER_MAX_MESSAGE_SIZE)
931 {
932 GNUNET_break_op (0);
933 GNUNET_SERVER_receive_done (client, GNUNET_OK);
934 return;
935 }
936
937 GNUNET_STRINGS_utf8_tolower((char*)&sh_msg[1], &nameptr);
938 886
939 887
940 cah = GNUNET_malloc(sizeof(struct ClientGetAuthHandle)); 888 cah = GNUNET_malloc(sizeof(struct ClientGetAuthHandle));
@@ -950,7 +898,8 @@ static void handle_get_authority(void *cls,
950 return; 898 return;
951 } 899 }
952 900
953 if (strlen (name) > MAX_DNS_NAME_LENGTH) { 901 if (strlen (name) > MAX_DNS_NAME_LENGTH)
902 {
954 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 903 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
955 "GET_AUTH: %s is too long", name); 904 "GET_AUTH: %s is too long", name);
956 cah->name = NULL; 905 cah->name = NULL;
@@ -1074,7 +1023,7 @@ handle_lookup(void *cls,
1074 1023
1075 if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientLookupMessage)) 1024 if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientLookupMessage))
1076 { 1025 {
1077 GNUNET_break_op (0); 1026 GNUNET_break (0);
1078 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1027 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1079 return; 1028 return;
1080 } 1029 }
@@ -1085,15 +1034,7 @@ handle_lookup(void *cls,
1085 (struct GNUNET_GNS_ClientLookupMessage *) message; 1034 (struct GNUNET_GNS_ClientLookupMessage *) message;
1086 1035
1087 msg_size = ntohs(message->size); 1036 msg_size = ntohs(message->size);
1088 1037 if (GNUNET_YES == ntohl(sh_msg->have_key))
1089 if (msg_size > GNUNET_SERVER_MAX_MESSAGE_SIZE)
1090 {
1091 GNUNET_break_op (0);
1092 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1093 return;
1094 }
1095
1096 if (1 == ntohl(sh_msg->have_key))
1097 { 1038 {
1098 pkey = (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *)&sh_msg[1]; 1039 pkey = (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *)&sh_msg[1];
1099 tmp_pkey = (char*)&sh_msg[1]; 1040 tmp_pkey = (char*)&sh_msg[1];
@@ -1172,6 +1113,7 @@ handle_lookup(void *cls,
1172 "Record lookup attempts", 1, GNUNET_NO); 1113 "Record lookup attempts", 1, GNUNET_NO);
1173} 1114}
1174 1115
1116
1175/** 1117/**
1176 * Test if the given AF is supported by this system. 1118 * Test if the given AF is supported by this system.
1177 * 1119 *
@@ -1199,6 +1141,7 @@ test_af (int af)
1199 return GNUNET_OK; 1141 return GNUNET_OK;
1200} 1142}
1201 1143
1144
1202/** 1145/**
1203 * Process GNS requests. 1146 * Process GNS requests.
1204 * 1147 *
@@ -1210,9 +1153,6 @@ static void
1210run (void *cls, struct GNUNET_SERVER_Handle *server, 1153run (void *cls, struct GNUNET_SERVER_Handle *server,
1211 const struct GNUNET_CONFIGURATION_Handle *c) 1154 const struct GNUNET_CONFIGURATION_Handle *c)
1212{ 1155{
1213
1214 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Initializing GNS\n");
1215
1216 char* keyfile; 1156 char* keyfile;
1217 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; 1157 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
1218 unsigned long long max_parallel_bg_queries = 0; 1158 unsigned long long max_parallel_bg_queries = 0;
@@ -1225,8 +1165,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1225 {&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0} 1165 {&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0}
1226 }; 1166 };
1227 1167
1228 GNS_cfg = c;
1229
1230 v6_enabled = test_af (AF_INET6); 1168 v6_enabled = test_af (AF_INET6);
1231 v4_enabled = test_af (AF_INET); 1169 v4_enabled = test_af (AF_INET);
1232 1170
@@ -1249,25 +1187,16 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1249 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 1187 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
1250 &zone_hash); 1188 &zone_hash);
1251 GNUNET_free(keyfile); 1189 GNUNET_free(keyfile);
1252 1190 namestore_handle = GNUNET_NAMESTORE_connect (c);
1253 /**
1254 * handle to our local namestore
1255 */
1256 namestore_handle = GNUNET_NAMESTORE_connect(c);
1257
1258 if (NULL == namestore_handle) 1191 if (NULL == namestore_handle)
1259 { 1192 {
1260 //FIXME do error handling; 1193 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1261 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1194 _("Failed to connect to the namestore!\n"));
1262 "Failed to connect to the namestore!\n");
1263 GNUNET_SCHEDULER_shutdown (); 1195 GNUNET_SCHEDULER_shutdown ();
1264 return; 1196 return;
1265 } 1197 }
1266 1198
1267
1268
1269 auto_import_pkey = GNUNET_NO; 1199 auto_import_pkey = GNUNET_NO;
1270
1271 if (GNUNET_YES == 1200 if (GNUNET_YES ==
1272 GNUNET_CONFIGURATION_get_value_yesno (c, "gns", 1201 GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
1273 "AUTO_IMPORT_PKEY")) 1202 "AUTO_IMPORT_PKEY"))
@@ -1287,9 +1216,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1287 "RECORD_PUT_INTERVAL", 1216 "RECORD_PUT_INTERVAL",
1288 &record_put_interval)) 1217 &record_put_interval))
1289 { 1218 {
1290 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 1219 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1291 "Record put interval: %llu\n", 1220 "Record put interval: %s\n",
1292 record_put_interval); 1221 GNUNET_STRINGS_relative_time_to_string (record_put_interval, GNUNET_YES));
1293 } 1222 }
1294 1223
1295 if (GNUNET_OK == 1224 if (GNUNET_OK ==
@@ -1332,7 +1261,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1332 1261
1333 if (NULL == dht_handle) 1262 if (NULL == dht_handle)
1334 { 1263 {
1335 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not connect to DHT!\n"); 1264 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to DHT!\n");
1336 } 1265 }
1337 1266
1338 if (gns_resolver_init(namestore_handle, dht_handle, zone_hash, c, 1267 if (gns_resolver_init(namestore_handle, dht_handle, zone_hash, c,
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index f51b5393e..3c6d019f2 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -35,6 +35,7 @@
35#include "gnunet_dnsparser_lib.h" 35#include "gnunet_dnsparser_lib.h"
36#include "gns_protocol.h" 36#include "gns_protocol.h"
37#include "gnunet_gns_service.h" 37#include "gnunet_gns_service.h"
38#include "gns_common.h"
38#include "block_gns.h" 39#include "block_gns.h"
39#include "gns.h" 40#include "gns.h"
40#include "gnunet-service-gns_resolver.h" 41#include "gnunet-service-gns_resolver.h"
@@ -459,30 +460,19 @@ process_auth_discovery_ns_result (void* cls,
459 const struct GNUNET_CRYPTO_RsaSignature *signature) 460 const struct GNUNET_CRYPTO_RsaSignature *signature)
460{ 461{
461 struct GetPseuAuthorityHandle* gph = cls; 462 struct GetPseuAuthorityHandle* gph = cls;
462 struct GNUNET_CRYPTO_ShortHashCode name_hash;
463 struct GNUNET_HashCode lookup_key; 463 struct GNUNET_HashCode lookup_key;
464 struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string; 464 unsigned int i;
465 struct GNUNET_HashCode name_hash_double;
466 struct GNUNET_HashCode zone_hash_double;
467 int i;
468 uint32_t xquery; 465 uint32_t xquery;
469 466
470 gph->namestore_task = NULL; 467 gph->namestore_task = NULL;
471 /* no pseu found */ 468 /* no pseu found */
472 if (0 == rd_count) 469 if (0 == rd_count)
473 { 470 {
474 /** 471 GNUNET_GNS_get_key_for_record (GNUNET_GNS_TLD_PLUS, &gph->auth->zone, &lookup_key);
475 * check dht
476 */
477 GNUNET_CRYPTO_short_hash ("+", strlen ("+"), &name_hash);
478 GNUNET_CRYPTO_short_hash_double (&name_hash, &name_hash_double);
479 GNUNET_CRYPTO_short_hash_double (&gph->auth->zone, &zone_hash_double);
480 GNUNET_CRYPTO_hash_xor (&name_hash_double, &zone_hash_double, &lookup_key);
481 GNUNET_CRYPTO_hash_to_enc (&lookup_key, &lookup_key_string);
482
483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 472 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
484 "GNS_AUTO_PSEU: starting dht lookup for %s with key: %s\n", 473 "GNS_AUTO_PSEU: starting dht lookup for %s with key: %s\n",
485 "+", (char*)&lookup_key_string); 474 GNUNET_GNS_TLD_PLUS,
475 GNUNET_h2s (&lookup_key));
486 476
487 gph->timeout = GNUNET_SCHEDULER_add_delayed (DHT_LOOKUP_TIMEOUT, 477 gph->timeout = GNUNET_SCHEDULER_add_delayed (DHT_LOOKUP_TIMEOUT,
488 &handle_auth_discovery_timeout, gph); 478 &handle_auth_discovery_timeout, gph);
@@ -505,7 +495,7 @@ process_auth_discovery_ns_result (void* cls,
505 495
506 for (i=0; i < rd_count; i++) 496 for (i=0; i < rd_count; i++)
507 { 497 {
508 if (0 != (strcmp (name, "+"))) 498 if (0 != (strcmp (name, GNUNET_GNS_TLD_PLUS)))
509 continue; 499 continue;
510 500
511 if (rd[i].record_type != GNUNET_GNS_RECORD_PSEU) 501 if (rd[i].record_type != GNUNET_GNS_RECORD_PSEU)
@@ -1127,23 +1117,14 @@ static void
1127resolve_record_dht (struct ResolverHandle *rh) 1117resolve_record_dht (struct ResolverHandle *rh)
1128{ 1118{
1129 uint32_t xquery; 1119 uint32_t xquery;
1130 struct GNUNET_CRYPTO_ShortHashCode name_hash;
1131 struct GNUNET_HashCode lookup_key; 1120 struct GNUNET_HashCode lookup_key;
1132 struct GNUNET_HashCode name_hash_double;
1133 struct GNUNET_HashCode zone_hash_double;
1134 struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string;
1135 struct RecordLookupHandle *rlh = rh->proc_cls; 1121 struct RecordLookupHandle *rlh = rh->proc_cls;
1136 struct ResolverHandle *rh_heap_root; 1122 struct ResolverHandle *rh_heap_root;
1137 1123
1138 GNUNET_CRYPTO_short_hash (rh->name, strlen (rh->name), &name_hash); 1124 GNUNET_GNS_get_key_for_record (rh->name, &rh->authority, &lookup_key);
1139 GNUNET_CRYPTO_short_hash_double (&name_hash, &name_hash_double);
1140 GNUNET_CRYPTO_short_hash_double (&rh->authority, &zone_hash_double);
1141 GNUNET_CRYPTO_hash_xor (&name_hash_double, &zone_hash_double, &lookup_key);
1142 GNUNET_CRYPTO_hash_to_enc (&lookup_key, &lookup_key_string);
1143
1144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1125 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1145 "GNS_PHASE_REC-%llu: starting dht lookup for %s with key: %s\n", 1126 "GNS_PHASE_REC-%llu: starting dht lookup for %s with key: %s\n",
1146 rh->id, rh->name, (char*)&lookup_key_string); 1127 rh->id, rh->name, GNUNET_h2s (&lookup_key));
1147 1128
1148 //rh->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1129 //rh->timeout_task = GNUNET_SCHEDULER_NO_TASK;
1149 rh->dht_heap_node = NULL; 1130 rh->dht_heap_node = NULL;
@@ -2191,10 +2172,9 @@ process_delegation_result_dht(void* cls,
2191 uint32_t num_records; 2172 uint32_t num_records;
2192 char* name = NULL; 2173 char* name = NULL;
2193 char* rd_data = (char*) data; 2174 char* rd_data = (char*) data;
2194 int i; 2175 uint32_t i;
2195 int rd_size; 2176 int rd_size;
2196 struct GNUNET_CRYPTO_ShortHashCode zone, name_hash; 2177 struct GNUNET_CRYPTO_ShortHashCode zone;
2197 struct GNUNET_HashCode zone_hash_double, name_hash_double;
2198 2178
2199 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2179 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2200 "GNS_PHASE_DELEGATE_DHT-%llu: Got DHT result\n", rh->id); 2180 "GNS_PHASE_DELEGATE_DHT-%llu: Got DHT result\n", rh->id);
@@ -2301,13 +2281,9 @@ process_delegation_result_dht(void* cls,
2301 } 2281 }
2302 2282
2303 } 2283 }
2284 GNUNET_GNS_get_zone_from_key (name, key, &zone);
2304 2285
2305 2286
2306 GNUNET_CRYPTO_short_hash(name, strlen(name), &name_hash);
2307 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
2308 GNUNET_CRYPTO_hash_xor(key, &name_hash_double, &zone_hash_double);
2309 GNUNET_CRYPTO_short_hash_from_truncation (&zone_hash_double, &zone);
2310
2311 /* Save to namestore 2287 /* Save to namestore
2312 if (0 != GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, 2288 if (0 != GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone,
2313 &zone)) 2289 &zone))
@@ -2802,21 +2778,12 @@ static void
2802resolve_delegation_dht(struct ResolverHandle *rh) 2778resolve_delegation_dht(struct ResolverHandle *rh)
2803{ 2779{
2804 uint32_t xquery; 2780 uint32_t xquery;
2805 struct GNUNET_CRYPTO_ShortHashCode name_hash;
2806 struct GNUNET_HashCode name_hash_double;
2807 struct GNUNET_HashCode zone_hash_double;
2808 struct GNUNET_HashCode lookup_key; 2781 struct GNUNET_HashCode lookup_key;
2809 struct ResolverHandle *rh_heap_root; 2782 struct ResolverHandle *rh_heap_root;
2810 2783
2811 pop_tld(rh->name, rh->authority_name); 2784 pop_tld(rh->name, rh->authority_name);
2812 2785
2813 //FIXME handle return values here 2786 GNUNET_GNS_get_key_for_record (rh->authority_name, &rh->authority, &lookup_key);
2814 GNUNET_CRYPTO_short_hash(rh->authority_name,
2815 strlen(rh->authority_name),
2816 &name_hash);
2817 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
2818 GNUNET_CRYPTO_short_hash_double(&rh->authority, &zone_hash_double);
2819 GNUNET_CRYPTO_hash_xor(&name_hash_double, &zone_hash_double, &lookup_key);
2820 2787
2821 rh->dht_heap_node = NULL; 2788 rh->dht_heap_node = NULL;
2822 2789
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c
index 637467a5c..a2faecf2d 100644
--- a/src/gns/plugin_block_gns.c
+++ b/src/gns/plugin_block_gns.c
@@ -29,6 +29,7 @@
29#include "gnunet_namestore_service.h" 29#include "gnunet_namestore_service.h"
30#include "block_gns.h" 30#include "block_gns.h"
31#include "gnunet_signatures.h" 31#include "gnunet_signatures.h"
32#include "gns_common.h"
32 33
33/** 34/**
34 * Number of bits we set per entry in the bloomfilter. 35 * Number of bits we set per entry in the bloomfilter.
@@ -62,15 +63,14 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
62 size_t xquery_size, const void *reply_block, 63 size_t xquery_size, const void *reply_block,
63 size_t reply_block_size) 64 size_t reply_block_size)
64{ 65{
65 char* name; 66 const char* name;
66 struct GNUNET_HashCode pkey_hash_double;
67 struct GNUNET_HashCode query_key; 67 struct GNUNET_HashCode query_key;
68 struct GNUNET_HashCode name_hash_double;
69 struct GNUNET_HashCode mhash; 68 struct GNUNET_HashCode mhash;
70 struct GNUNET_HashCode chash; 69 struct GNUNET_HashCode chash;
71 struct GNUNET_CRYPTO_ShortHashCode pkey_hash; 70 struct GNUNET_CRYPTO_ShortHashCode pkey_hash;
72 struct GNUNET_CRYPTO_ShortHashCode name_hash;
73 struct GNSNameRecordBlock *nrb; 71 struct GNSNameRecordBlock *nrb;
72 struct GNUNET_CRYPTO_HashAsciiEncoded xor_exp;
73 struct GNUNET_CRYPTO_HashAsciiEncoded xor_got;
74 uint32_t rd_count; 74 uint32_t rd_count;
75 char* rd_data = NULL; 75 char* rd_data = NULL;
76 int rd_len; 76 int rd_len;
@@ -98,20 +98,13 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
98 /* this is a reply */ 98 /* this is a reply */
99 99
100 nrb = (struct GNSNameRecordBlock *)reply_block; 100 nrb = (struct GNSNameRecordBlock *)reply_block;
101 name = (char*)&nrb[1]; 101 name = (const char*)&nrb[1];
102 GNUNET_CRYPTO_short_hash(&nrb->public_key,
103 sizeof(nrb->public_key),
104 &pkey_hash);
105
106 GNUNET_CRYPTO_short_hash(name, strlen(name), &name_hash);
107 102
108 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double); 103 GNUNET_CRYPTO_short_hash (&nrb->public_key,
109 GNUNET_CRYPTO_short_hash_double(&pkey_hash, &pkey_hash_double); 104 sizeof(nrb->public_key),
110 105 &pkey_hash);
111 GNUNET_CRYPTO_hash_xor(&pkey_hash_double, &name_hash_double, &query_key); 106 GNUNET_GNS_get_key_for_record (name, &pkey_hash, &query_key);
112 107
113 struct GNUNET_CRYPTO_HashAsciiEncoded xor_exp;
114 struct GNUNET_CRYPTO_HashAsciiEncoded xor_got;
115 GNUNET_CRYPTO_hash_to_enc (&query_key, &xor_exp); 108 GNUNET_CRYPTO_hash_to_enc (&query_key, &xor_exp);
116 GNUNET_CRYPTO_hash_to_enc (query, &xor_got); 109 GNUNET_CRYPTO_hash_to_enc (query, &xor_got);
117 110
@@ -220,25 +213,23 @@ block_plugin_gns_get_key (void *cls, enum GNUNET_BLOCK_Type type,
220 const void *block, size_t block_size, 213 const void *block, size_t block_size,
221 struct GNUNET_HashCode * key) 214 struct GNUNET_HashCode * key)
222{ 215{
223 if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
224 return GNUNET_SYSERR;
225 struct GNUNET_CRYPTO_ShortHashCode name_hash;
226 struct GNUNET_CRYPTO_ShortHashCode pkey_hash; 216 struct GNUNET_CRYPTO_ShortHashCode pkey_hash;
227 struct GNUNET_HashCode name_hash_double; 217 const struct GNSNameRecordBlock *nrb = (const struct GNSNameRecordBlock *)block;
228 struct GNUNET_HashCode pkey_hash_double; 218 const char *name;
229
230 struct GNSNameRecordBlock *nrb = (struct GNSNameRecordBlock *)block;
231 219
232 GNUNET_CRYPTO_short_hash(&nrb[1], strlen((char*)&nrb[1]), &name_hash); 220 if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
233 GNUNET_CRYPTO_short_hash(&nrb->public_key, 221 return GNUNET_SYSERR;
234 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 222 name = (const char *) &nrb[1];
235 &pkey_hash); 223 if (NULL == memchr (name, '\0', block_size - sizeof (struct GNSNameRecordBlock)))
236 224 {
237 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double); 225 /* malformed, no 0-termination in name */
238 GNUNET_CRYPTO_short_hash_double(&pkey_hash, &pkey_hash_double); 226 GNUNET_break_op (0);
239 227 return GNUNET_SYSERR;
240 GNUNET_CRYPTO_hash_xor(&name_hash_double, &pkey_hash_double, key); 228 }
241 229 GNUNET_CRYPTO_short_hash (&nrb->public_key,
230 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
231 &pkey_hash);
232 GNUNET_GNS_get_key_for_record (name, &pkey_hash, key);
242 return GNUNET_OK; 233 return GNUNET_OK;
243} 234}
244 235
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c
index 8b35fb84c..ef1f9b8e3 100644
--- a/src/namestore/plugin_namestore_sqlite.c
+++ b/src/namestore/plugin_namestore_sqlite.c
@@ -405,6 +405,7 @@ namestore_sqlite_remove_records (void *cls,
405 struct GNUNET_CRYPTO_ShortHashCode nh; 405 struct GNUNET_CRYPTO_ShortHashCode nh;
406 size_t name_len; 406 size_t name_len;
407 int n; 407 int n;
408
408 name_len = strlen (name); 409 name_len = strlen (name);
409 GNUNET_CRYPTO_short_hash (name, name_len, &nh); 410 GNUNET_CRYPTO_short_hash (name, name_len, &nh);
410 411