aboutsummaryrefslogtreecommitdiff
path: root/src/gnsrecord
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-02-03 18:12:10 +0100
committerMartin Schanzenbach <schanzen@gnunet.org>2022-02-03 18:12:10 +0100
commit3d72be07448fd435640c6d0fdc2859601319d07e (patch)
tree253ed9212019d08725166300f449645e34c463b1 /src/gnsrecord
parent3146c65c67b93ce4eb5bf27775167fde65f5e3c4 (diff)
downloadgnunet-3d72be07448fd435640c6d0fdc2859601319d07e.tar.gz
gnunet-3d72be07448fd435640c6d0fdc2859601319d07e.zip
GNS: Introduce CRITICAL flag. Fixes #7169
Diffstat (limited to 'src/gnsrecord')
-rw-r--r--src/gnsrecord/gnsrecord.c21
-rw-r--r--src/gnsrecord/plugin_gnsrecord_dns.c7
-rw-r--r--src/gnsrecord/test_gnsrecord_testvectors.c30
3 files changed, 45 insertions, 13 deletions
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
263enum GNUNET_GenericReturnValue
264GNUNET_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
776static enum GNUNET_GenericReturnValue
777dns_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
12static char *d = 12static char *d =
13"50d7b652a4efeadff37396909785e5952171a02178c8e7d450fa907925fafd98"; 13 "50d7b652a4efeadff37396909785e5952171a02178c8e7d450fa907925fafd98";
14 14
15 15
16static char *zid = 16static 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
39int parsehex(char *src, char *dst, size_t dstlen, int invert) 39int 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
106int 107int
107main() 108main ()
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,