diff options
m--------- | contrib/gana | 0 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 7 | ||||
-rw-r--r-- | src/gns/plugin_gnsrecord_gns.c | 15 | ||||
-rw-r--r-- | src/gnsrecord/gnsrecord.c | 21 | ||||
-rw-r--r-- | src/gnsrecord/plugin_gnsrecord_dns.c | 7 | ||||
-rw-r--r-- | src/gnsrecord/test_gnsrecord_testvectors.c | 30 | ||||
-rw-r--r-- | src/include/gnunet_gnsrecord_lib.h | 9 | ||||
-rw-r--r-- | src/include/gnunet_gnsrecord_plugin.h | 17 | ||||
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 2 | ||||
-rw-r--r-- | src/zonemaster/gnunet-service-zonemaster.c | 6 |
10 files changed, 99 insertions, 15 deletions
diff --git a/contrib/gana b/contrib/gana | |||
Subproject 3a71278a2aab67f9a1888af172b507d6e08364c | Subproject 8bdb180732314481667944cb90c1f3b148bd008 | ||
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 51e650b4f..f232fb272 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -2393,12 +2393,17 @@ handle_gns_resolution_result (void *cls, | |||
2393 | &rd[0]); | 2393 | &rd[0]); |
2394 | return; | 2394 | return; |
2395 | 2395 | ||
2396 | default: | 2396 | case GNUNET_GNSRECORD_TYPE_GNS2DNS: |
2397 | if (GNUNET_OK == | 2397 | if (GNUNET_OK == |
2398 | recursive_gns2dns_resolution (rh, | 2398 | recursive_gns2dns_resolution (rh, |
2399 | rd_count, | 2399 | rd_count, |
2400 | rd)) | 2400 | rd)) |
2401 | return; | 2401 | return; |
2402 | default: | ||
2403 | if (GNUNET_YES != GNUNET_GNSRECORD_is_critical (rd[0].record_type)) | ||
2404 | return; | ||
2405 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2406 | _ ("Unable to process critical delegation record\n")); | ||
2402 | break; | 2407 | break; |
2403 | } | 2408 | } |
2404 | fail: | 2409 | fail: |
diff --git a/src/gns/plugin_gnsrecord_gns.c b/src/gns/plugin_gnsrecord_gns.c index b37e84ea3..f270e4473 100644 --- a/src/gns/plugin_gnsrecord_gns.c +++ b/src/gns/plugin_gnsrecord_gns.c | |||
@@ -323,6 +323,7 @@ static struct | |||
323 | { "VPN", GNUNET_GNSRECORD_TYPE_VPN }, | 323 | { "VPN", GNUNET_GNSRECORD_TYPE_VPN }, |
324 | { "GNS2DNS", GNUNET_GNSRECORD_TYPE_GNS2DNS }, | 324 | { "GNS2DNS", GNUNET_GNSRECORD_TYPE_GNS2DNS }, |
325 | { "BOX", GNUNET_GNSRECORD_TYPE_BOX }, | 325 | { "BOX", GNUNET_GNSRECORD_TYPE_BOX }, |
326 | { "REDIRECT", GNUNET_GNSRECORD_TYPE_REDIRECT }, | ||
326 | { NULL, UINT32_MAX } }; | 327 | { NULL, UINT32_MAX } }; |
327 | 328 | ||
328 | 329 | ||
@@ -365,6 +366,19 @@ gns_number_to_typename (void *cls, uint32_t type) | |||
365 | } | 366 | } |
366 | 367 | ||
367 | 368 | ||
369 | static enum GNUNET_GenericReturnValue | ||
370 | gns_is_critical (void *cls, uint32_t type) | ||
371 | { | ||
372 | return ((type == GNUNET_GNSRECORD_TYPE_PKEY) || | ||
373 | (type == GNUNET_GNSRECORD_TYPE_EDKEY) || | ||
374 | (type == GNUNET_GNSRECORD_TYPE_GNS2DNS) || | ||
375 | (type == GNUNET_GNSRECORD_TYPE_REDIRECT) ? | ||
376 | GNUNET_YES : GNUNET_NO); | ||
377 | } | ||
378 | |||
379 | |||
380 | |||
381 | |||
368 | /** | 382 | /** |
369 | * Entry point for the plugin. | 383 | * Entry point for the plugin. |
370 | * | 384 | * |
@@ -381,6 +395,7 @@ libgnunet_plugin_gnsrecord_gns_init (void *cls) | |||
381 | api->string_to_value = &gns_string_to_value; | 395 | api->string_to_value = &gns_string_to_value; |
382 | api->typename_to_number = &gns_typename_to_number; | 396 | api->typename_to_number = &gns_typename_to_number; |
383 | api->number_to_typename = &gns_number_to_typename; | 397 | api->number_to_typename = &gns_number_to_typename; |
398 | api->is_critical = &gns_is_critical; | ||
384 | return api; | 399 | return api; |
385 | } | 400 | } |
386 | 401 | ||
diff --git a/src/gnsrecord/gnsrecord.c b/src/gnsrecord/gnsrecord.c index e9994a868..52c480ef6 100644 --- a/src/gnsrecord/gnsrecord.c +++ b/src/gnsrecord/gnsrecord.c | |||
@@ -260,4 +260,25 @@ GNUNET_GNSRECORD_number_to_typename (uint32_t type) | |||
260 | } | 260 | } |
261 | 261 | ||
262 | 262 | ||
263 | enum GNUNET_GenericReturnValue | ||
264 | GNUNET_GNSRECORD_is_critical (uint32_t type) | ||
265 | { | ||
266 | struct Plugin *plugin; | ||
267 | |||
268 | if (GNUNET_GNSRECORD_TYPE_ANY == type) | ||
269 | return GNUNET_NO; | ||
270 | init (); | ||
271 | for (unsigned int i = 0; i < num_plugins; i++) | ||
272 | { | ||
273 | plugin = gns_plugins[i]; | ||
274 | if (NULL == plugin->api->is_critical) | ||
275 | continue; | ||
276 | if (GNUNET_NO == plugin->api->is_critical (plugin->api->cls, type)) | ||
277 | continue; | ||
278 | return GNUNET_YES; | ||
279 | } | ||
280 | return GNUNET_NO; | ||
281 | } | ||
282 | |||
283 | |||
263 | /* end of gnsrecord.c */ | 284 | /* end of gnsrecord.c */ |
diff --git a/src/gnsrecord/plugin_gnsrecord_dns.c b/src/gnsrecord/plugin_gnsrecord_dns.c index 123c59905..649133cd1 100644 --- a/src/gnsrecord/plugin_gnsrecord_dns.c +++ b/src/gnsrecord/plugin_gnsrecord_dns.c | |||
@@ -773,6 +773,12 @@ dns_number_to_typename (void *cls, uint32_t type) | |||
773 | } | 773 | } |
774 | 774 | ||
775 | 775 | ||
776 | static enum GNUNET_GenericReturnValue | ||
777 | dns_is_critical (void *cls, uint32_t type) | ||
778 | { | ||
779 | return GNUNET_NO; | ||
780 | } | ||
781 | |||
776 | /** | 782 | /** |
777 | * Entry point for the plugin. | 783 | * Entry point for the plugin. |
778 | * | 784 | * |
@@ -789,6 +795,7 @@ libgnunet_plugin_gnsrecord_dns_init (void *cls) | |||
789 | api->string_to_value = &dns_string_to_value; | 795 | api->string_to_value = &dns_string_to_value; |
790 | api->typename_to_number = &dns_typename_to_number; | 796 | api->typename_to_number = &dns_typename_to_number; |
791 | api->number_to_typename = &dns_number_to_typename; | 797 | api->number_to_typename = &dns_number_to_typename; |
798 | api->is_critical = &dns_is_critical; | ||
792 | return api; | 799 | return api; |
793 | } | 800 | } |
794 | 801 | ||
diff --git a/src/gnsrecord/test_gnsrecord_testvectors.c b/src/gnsrecord/test_gnsrecord_testvectors.c index 153c56261..6419f9c94 100644 --- a/src/gnsrecord/test_gnsrecord_testvectors.c +++ b/src/gnsrecord/test_gnsrecord_testvectors.c | |||
@@ -10,11 +10,11 @@ | |||
10 | 10 | ||
11 | 11 | ||
12 | static char *d = | 12 | static char *d = |
13 | "50d7b652a4efeadff37396909785e5952171a02178c8e7d450fa907925fafd98"; | 13 | "50d7b652a4efeadff37396909785e5952171a02178c8e7d450fa907925fafd98"; |
14 | 14 | ||
15 | 15 | ||
16 | static char *zid = | 16 | static char *zid = |
17 | "00010000677c477d2d93097c85b195c6f96d84ff61f5982c2c4fe02d5a11fedfb0c2901f"; | 17 | "00010000677c477d2d93097c85b195c6f96d84ff61f5982c2c4fe02d5a11fedfb0c2901f"; |
18 | 18 | ||
19 | #define RRCOUNT 2 | 19 | #define RRCOUNT 2 |
20 | #define LABEL "test" | 20 | #define LABEL "test" |
@@ -31,12 +31,12 @@ static char *zid = | |||
31 | #define R1_TYPE 65536 | 31 | #define R1_TYPE 65536 |
32 | #define R1_FLAGS 2 | 32 | #define R1_FLAGS 2 |
33 | #define R1_DATA \ | 33 | #define R1_DATA \ |
34 | "000100000e601be42eb57fb4697610cf3a3b18347b65a33f025b5b174abefb30807bfecf" | 34 | "000100000e601be42eb57fb4697610cf3a3b18347b65a33f025b5b174abefb30807bfecf" |
35 | 35 | ||
36 | #define R1_RRBLOCK \ | 36 | #define R1_RRBLOCK \ |
37 | "000100008e16da87203b5159c5538e9b765742e968c54af9afbc0890dc80205ad14c84e107b0c115fc0089aa38b9c7ab9cbe1d77040d282a51a2ad493f61f3495f02d8170fe473a55ec6bdf9a509ab1701ffc37ea3bb4cac4a672520986df96e67cc1a73000000940000000f0034e53be193799100e4837eb5d04f92903de4b5234e8ccac5736c9793379a59c33375fc8951aca2eb7aad067bf9af60bf26758646a17f5e5c3b6215f94079545b1c4d4f1b2ebb22c2b4dad44126817b6f001530d476401dd67ac0148554e806353da9e4298079f3e1b16942c48d90c4360c61238c40d9d52911aea52cc0037ac7160bb3cf5b2f4a722fd96b" | 37 | "000100008e16da87203b5159c5538e9b765742e968c54af9afbc0890dc80205ad14c84e107b0c115fc0089aa38b9c7ab9cbe1d77040d282a51a2ad493f61f3495f02d8170fe473a55ec6bdf9a509ab1701ffc37ea3bb4cac4a672520986df96e67cc1a73000000940000000f0034e53be193799100e4837eb5d04f92903de4b5234e8ccac5736c9793379a59c33375fc8951aca2eb7aad067bf9af60bf26758646a17f5e5c3b6215f94079545b1c4d4f1b2ebb22c2b4dad44126817b6f001530d476401dd67ac0148554e806353da9e4298079f3e1b16942c48d90c4360c61238c40d9d52911aea52cc0037ac7160bb3cf5b2f4a722fd96b" |
38 | 38 | ||
39 | int parsehex(char *src, char *dst, size_t dstlen, int invert) | 39 | int parsehex (char *src, char *dst, size_t dstlen, int invert) |
40 | { | 40 | { |
41 | char *line = src; | 41 | char *line = src; |
42 | char *data = line; | 42 | char *data = line; |
@@ -44,7 +44,8 @@ int parsehex(char *src, char *dst, size_t dstlen, int invert) | |||
44 | int read_byte; | 44 | int read_byte; |
45 | int data_len = 0; | 45 | int data_len = 0; |
46 | 46 | ||
47 | while (sscanf(data, " %02x%n", &read_byte, &off) == 1) { | 47 | while (sscanf (data, " %02x%n", &read_byte, &off) == 1) |
48 | { | ||
48 | if (invert) | 49 | if (invert) |
49 | dst[dstlen - 1 - data_len++] = read_byte; | 50 | dst[dstlen - 1 - data_len++] = read_byte; |
50 | else | 51 | else |
@@ -62,8 +63,8 @@ res_checker (void *cls, | |||
62 | int r1_found = 0; | 63 | int r1_found = 0; |
63 | char r0_data[R0_DATA_SIZE]; | 64 | char r0_data[R0_DATA_SIZE]; |
64 | char r1_data[R1_DATA_SIZE]; | 65 | char r1_data[R1_DATA_SIZE]; |
65 | parsehex(R0_DATA, (char*)r0_data, 0, 0); | 66 | parsehex (R0_DATA, (char*) r0_data, 0, 0); |
66 | parsehex(R1_DATA, (char*)r1_data, 0, 0); | 67 | parsehex (R1_DATA, (char*) r1_data, 0, 0); |
67 | GNUNET_assert (rd_count == RRCOUNT); | 68 | GNUNET_assert (rd_count == RRCOUNT); |
68 | for (int i = 0; i < RRCOUNT; i++) | 69 | for (int i = 0; i < RRCOUNT; i++) |
69 | { | 70 | { |
@@ -104,7 +105,7 @@ res_checker (void *cls, | |||
104 | 105 | ||
105 | 106 | ||
106 | int | 107 | int |
107 | main() | 108 | main () |
108 | { | 109 | { |
109 | struct GNUNET_IDENTITY_PrivateKey priv; | 110 | struct GNUNET_IDENTITY_PrivateKey priv; |
110 | struct GNUNET_IDENTITY_PublicKey pub; | 111 | struct GNUNET_IDENTITY_PublicKey pub; |
@@ -112,13 +113,16 @@ main() | |||
112 | struct GNUNET_GNSRECORD_Block *rrblock; | 113 | struct GNUNET_GNSRECORD_Block *rrblock; |
113 | char *bdata; | 114 | char *bdata; |
114 | 115 | ||
115 | parsehex(d,(char*)&priv.ecdsa_key, sizeof (priv.ecdsa_key), 1); | 116 | parsehex (d,(char*) &priv.ecdsa_key, sizeof (priv.ecdsa_key), 1); |
116 | priv.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); | 117 | priv.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); |
117 | parsehex(zid,(char*)&pub_parsed, 0, 0); | 118 | parsehex (zid,(char*) &pub_parsed, 0, 0); |
118 | GNUNET_IDENTITY_key_get_public(&priv, &pub); | 119 | GNUNET_IDENTITY_key_get_public (&priv, &pub); |
119 | GNUNET_assert (0 == memcmp (&pub, &pub_parsed, sizeof (pub))); | 120 | GNUNET_assert (0 == memcmp (&pub, &pub_parsed, sizeof (pub))); |
120 | rrblock = GNUNET_malloc (strlen (R1_RRBLOCK) / 2); | 121 | rrblock = GNUNET_malloc (strlen (R1_RRBLOCK) / 2); |
121 | parsehex(R1_RRBLOCK, (char*)rrblock, 0, 0); | 122 | parsehex (R1_RRBLOCK, (char*) rrblock, 0, 0); |
123 | GNUNET_assert (GNUNET_YES | ||
124 | == GNUNET_GNSRECORD_is_critical_record_type ( | ||
125 | GNUNET_GNSRECORD_TYPE_PKEY)); | ||
122 | GNUNET_GNSRECORD_block_decrypt (rrblock, | 126 | GNUNET_GNSRECORD_block_decrypt (rrblock, |
123 | &pub_parsed, | 127 | &pub_parsed, |
124 | LABEL, | 128 | LABEL, |
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h index fdbac3cf5..2b2bd4952 100644 --- a/src/include/gnunet_gnsrecord_lib.h +++ b/src/include/gnunet_gnsrecord_lib.h | |||
@@ -700,6 +700,15 @@ GNUNET_GNSRECORD_data_from_identity (const struct | |||
700 | enum GNUNET_GenericReturnValue | 700 | enum GNUNET_GenericReturnValue |
701 | GNUNET_GNSRECORD_is_zonekey_type (uint32_t type); | 701 | GNUNET_GNSRECORD_is_zonekey_type (uint32_t type); |
702 | 702 | ||
703 | /** | ||
704 | * Check if this type is a critical record. | ||
705 | * | ||
706 | * @param type the type to check | ||
707 | * @return GNUNET_YES if it is critical. | ||
708 | */ | ||
709 | enum GNUNET_GenericReturnValue | ||
710 | GNUNET_GNSRECORD_is_critical (uint32_t type); | ||
711 | |||
703 | 712 | ||
704 | #if 0 /* keep Emacsens' auto-indent happy */ | 713 | #if 0 /* keep Emacsens' auto-indent happy */ |
705 | { | 714 | { |
diff --git a/src/include/gnunet_gnsrecord_plugin.h b/src/include/gnunet_gnsrecord_plugin.h index aec22c3af..84b7c3c23 100644 --- a/src/include/gnunet_gnsrecord_plugin.h +++ b/src/include/gnunet_gnsrecord_plugin.h | |||
@@ -105,6 +105,18 @@ typedef const char * | |||
105 | (*GNUNET_GNSRECORD_NumberToTypenameFunction) (void *cls, | 105 | (*GNUNET_GNSRECORD_NumberToTypenameFunction) (void *cls, |
106 | uint32_t type); | 106 | uint32_t type); |
107 | 107 | ||
108 | /** | ||
109 | * Function called to check for critical records. | ||
110 | * | ||
111 | * @param cls closure | ||
112 | * @param type number of a type to check | ||
113 | * @return GNUNET_YES if critical, otherwise GNUNET_NO | ||
114 | */ | ||
115 | typedef enum GNUNET_GenericReturnValue | ||
116 | (*GNUNET_GNSRECORD_IsCriticalFunction) (void *cls, | ||
117 | uint32_t type); | ||
118 | |||
119 | |||
108 | 120 | ||
109 | /** | 121 | /** |
110 | * Each plugin is required to return a pointer to a struct of this | 122 | * Each plugin is required to return a pointer to a struct of this |
@@ -136,6 +148,11 @@ struct GNUNET_GNSRECORD_PluginFunctions | |||
136 | * Number to typename. | 148 | * Number to typename. |
137 | */ | 149 | */ |
138 | GNUNET_GNSRECORD_NumberToTypenameFunction number_to_typename; | 150 | GNUNET_GNSRECORD_NumberToTypenameFunction number_to_typename; |
151 | |||
152 | /** | ||
153 | * Is critical. | ||
154 | */ | ||
155 | GNUNET_GNSRECORD_IsCriticalFunction is_critical; | ||
139 | }; | 156 | }; |
140 | 157 | ||
141 | /** @} */ /* end of group */ | 158 | /** @} */ /* end of group */ |
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 9b2d9b6f3..3842621ae 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -1545,6 +1545,8 @@ handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg) | |||
1545 | cache_nick (&rp_msg->private_key, &rd[i]); | 1545 | cache_nick (&rp_msg->private_key, &rd[i]); |
1546 | have_nick = GNUNET_YES; | 1546 | have_nick = GNUNET_YES; |
1547 | } | 1547 | } |
1548 | if (GNUNET_YES == GNUNET_GNSRECORD_is_critical (rd[i].record_type)) | ||
1549 | rd_clean[i].flags |= GNUNET_GNSRECORD_RF_CRITICAL; | ||
1548 | } | 1550 | } |
1549 | if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) && | 1551 | if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) && |
1550 | (GNUNET_NO == have_nick)) | 1552 | (GNUNET_NO == have_nick)) |
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c index bacafb97c..9ff1a97b8 100644 --- a/src/zonemaster/gnunet-service-zonemaster.c +++ b/src/zonemaster/gnunet-service-zonemaster.c | |||
@@ -562,7 +562,11 @@ convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd, | |||
562 | GNUNET_MIN (rd[i].expiration_time, | 562 | GNUNET_MIN (rd[i].expiration_time, |
563 | min_relative_record_time.rel_value_us); | 563 | min_relative_record_time.rel_value_us); |
564 | } | 564 | } |
565 | rd_public[rd_public_count++] = rd[i]; | 565 | rd_public[rd_public_count] = rd[i]; |
566 | /* Make sure critical record types are published as such */ | ||
567 | if (GNUNET_YES == GNUNET_GNSRECORD_is_critical (rd[i].record_type)) | ||
568 | rd_public[rd_public_count].flags |= GNUNET_GNSRECORD_RF_CRITICAL; | ||
569 | rd_public_count++; | ||
566 | } | 570 | } |
567 | return rd_public_count; | 571 | return rd_public_count; |
568 | } | 572 | } |