diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2023-06-29 20:37:34 +0200 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2023-06-29 20:37:34 +0200 |
commit | 8c34d91adf6884b1282d57760b3c22d55e807458 (patch) | |
tree | 73e0dc544c7a2c197fdd9b0d0696401898b954d6 /src | |
parent | 78f3d8739573862de8a73e47a147c8cb83d99505 (diff) | |
download | gnunet-8c34d91adf6884b1282d57760b3c22d55e807458.tar.gz gnunet-8c34d91adf6884b1282d57760b3c22d55e807458.zip |
GNS: TVs shorter expiration. Prettify revocation TV output.
Diffstat (limited to 'src')
-rw-r--r-- | src/gnsrecord/gnunet-gnsrecord-tvg.c | 8 | ||||
-rw-r--r-- | src/revocation/gnunet-revocation-tvg.c | 34 |
2 files changed, 25 insertions, 17 deletions
diff --git a/src/gnsrecord/gnunet-gnsrecord-tvg.c b/src/gnsrecord/gnunet-gnsrecord-tvg.c index 549c95e53..a4cf3f5cf 100644 --- a/src/gnsrecord/gnunet-gnsrecord-tvg.c +++ b/src/gnsrecord/gnunet-gnsrecord-tvg.c | |||
@@ -406,11 +406,11 @@ run (void *cls, | |||
406 | /* | 406 | /* |
407 | * Make different expiration times | 407 | * Make different expiration times |
408 | */ | 408 | */ |
409 | GNUNET_STRINGS_fancy_time_to_absolute ("2048-01-23 10:51:34", | 409 | GNUNET_STRINGS_fancy_time_to_absolute ("2228-01-23 10:51:34", |
410 | &exp1); | 410 | &exp1); |
411 | GNUNET_STRINGS_fancy_time_to_absolute ("3540-05-22 07:55:01", | 411 | GNUNET_STRINGS_fancy_time_to_absolute ("2540-05-22 07:55:01", |
412 | &exp2); | 412 | &exp2); |
413 | GNUNET_STRINGS_fancy_time_to_absolute ("3333-04-21 06:07:09", | 413 | GNUNET_STRINGS_fancy_time_to_absolute ("2333-04-21 06:07:09", |
414 | &exp3); | 414 | &exp3); |
415 | 415 | ||
416 | 416 | ||
@@ -441,7 +441,7 @@ run (void *cls, | |||
441 | rd[1].data_size = strlen (rd[1].data); | 441 | rd[1].data_size = strlen (rd[1].data); |
442 | rd[1].expiration_time = exp2.abs_value_us; | 442 | rd[1].expiration_time = exp2.abs_value_us; |
443 | rd[1].record_type = GNUNET_GNSRECORD_TYPE_NICK; | 443 | rd[1].record_type = GNUNET_GNSRECORD_TYPE_NICK; |
444 | rd[1].flags = GNUNET_GNSRECORD_RF_PRIVATE; | 444 | rd[1].flags = GNUNET_GNSRECORD_RF_NONE; |
445 | 445 | ||
446 | rd[2].data = "Hello World"; | 446 | rd[2].data = "Hello World"; |
447 | rd[2].data_size = strlen (rd[2].data); | 447 | rd[2].data_size = strlen (rd[2].data); |
diff --git a/src/revocation/gnunet-revocation-tvg.c b/src/revocation/gnunet-revocation-tvg.c index e1c9aa044..4dcf6e28f 100644 --- a/src/revocation/gnunet-revocation-tvg.c +++ b/src/revocation/gnunet-revocation-tvg.c | |||
@@ -34,10 +34,11 @@ | |||
34 | #define TEST_EPOCHS 2 | 34 | #define TEST_EPOCHS 2 |
35 | #define TEST_DIFFICULTY 5 | 35 | #define TEST_DIFFICULTY 5 |
36 | 36 | ||
37 | static char* d_pkey = | 37 | static char*d_pkey = |
38 | "6fea32c05af58bfa979553d188605fd57d8bf9cc263b78d5f7478c07b998ed70"; | 38 | "6fea32c05af58bfa979553d188605fd57d8bf9cc263b78d5f7478c07b998ed70"; |
39 | 39 | ||
40 | int parsehex(char *src, char *dst, size_t dstlen, int invert) | 40 | int |
41 | parsehex (char *src, char *dst, size_t dstlen, int invert) | ||
41 | { | 42 | { |
42 | char *line = src; | 43 | char *line = src; |
43 | char *data = line; | 44 | char *data = line; |
@@ -45,7 +46,8 @@ int parsehex(char *src, char *dst, size_t dstlen, int invert) | |||
45 | int read_byte; | 46 | int read_byte; |
46 | int data_len = 0; | 47 | int data_len = 0; |
47 | 48 | ||
48 | while (sscanf(data, " %02x%n", &read_byte, &off) == 1) { | 49 | while (sscanf (data, " %02x%n", &read_byte, &off) == 1) |
50 | { | ||
49 | if (invert) | 51 | if (invert) |
50 | dst[dstlen - 1 - data_len++] = read_byte; | 52 | dst[dstlen - 1 - data_len++] = read_byte; |
51 | else | 53 | else |
@@ -58,16 +60,21 @@ int parsehex(char *src, char *dst, size_t dstlen, int invert) | |||
58 | 60 | ||
59 | static void | 61 | static void |
60 | print_bytes_ (void *buf, | 62 | print_bytes_ (void *buf, |
61 | size_t buf_len, | 63 | size_t buf_len, |
62 | int fold, | 64 | int fold, |
63 | int in_be) | 65 | int in_be) |
64 | { | 66 | { |
65 | int i; | 67 | int i; |
66 | 68 | ||
67 | for (i = 0; i < buf_len; i++) | 69 | for (i = 0; i < buf_len; i++) |
68 | { | 70 | { |
69 | if ((0 != i) && (0 != fold) && (i % fold == 0)) | 71 | if (0 != i) |
70 | printf ("\n"); | 72 | { |
73 | if ((0 != fold) && (i % fold == 0)) | ||
74 | printf ("\n"); | ||
75 | else | ||
76 | printf (" "); | ||
77 | } | ||
71 | if (in_be) | 78 | if (in_be) |
72 | printf ("%02x", ((unsigned char*) buf)[buf_len - 1 - i]); | 79 | printf ("%02x", ((unsigned char*) buf)[buf_len - 1 - i]); |
73 | else | 80 | else |
@@ -76,6 +83,7 @@ print_bytes_ (void *buf, | |||
76 | printf ("\n"); | 83 | printf ("\n"); |
77 | } | 84 | } |
78 | 85 | ||
86 | |||
79 | static void | 87 | static void |
80 | print_bytes (void *buf, | 88 | print_bytes (void *buf, |
81 | size_t buf_len, | 89 | size_t buf_len, |
@@ -85,7 +93,6 @@ print_bytes (void *buf, | |||
85 | } | 93 | } |
86 | 94 | ||
87 | 95 | ||
88 | |||
89 | /** | 96 | /** |
90 | * Main function that will be run. | 97 | * Main function that will be run. |
91 | * | 98 | * |
@@ -110,15 +117,16 @@ run (void *cls, | |||
110 | 117 | ||
111 | id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA); | 118 | id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA); |
112 | GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key); | 119 | GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key); |
113 | parsehex(d_pkey,(char*)&id_priv.ecdsa_key, sizeof (id_priv.ecdsa_key), 1); | 120 | parsehex (d_pkey,(char*) &id_priv.ecdsa_key, sizeof (id_priv.ecdsa_key), 1); |
114 | GNUNET_IDENTITY_key_get_public (&id_priv, | 121 | GNUNET_IDENTITY_key_get_public (&id_priv, |
115 | &id_pub); | 122 | &id_pub); |
116 | GNUNET_STRINGS_data_to_string (&id_pub, | 123 | GNUNET_STRINGS_data_to_string (&id_pub, |
117 | GNUNET_IDENTITY_public_key_get_length (&id_pub), | 124 | GNUNET_IDENTITY_public_key_get_length ( |
125 | &id_pub), | ||
118 | ztld, | 126 | ztld, |
119 | sizeof (ztld)); | 127 | sizeof (ztld)); |
120 | fprintf (stdout, "Zone private key (d, big-endian scalar):\n"); | 128 | fprintf (stdout, "Zone private key (d, big-endian scalar):\n"); |
121 | print_bytes_ (&id_priv.ecdsa_key, sizeof(id_priv.ecdsa_key), 8, 1); | 129 | print_bytes (&id_priv.ecdsa_key, sizeof(id_priv.ecdsa_key), 8); |
122 | fprintf (stdout, "\n"); | 130 | fprintf (stdout, "\n"); |
123 | fprintf (stdout, "Zone identifier (ztype|zkey):\n"); | 131 | fprintf (stdout, "Zone identifier (ztype|zkey):\n"); |
124 | key_len = GNUNET_IDENTITY_public_key_get_length (&id_pub); | 132 | key_len = GNUNET_IDENTITY_public_key_get_length (&id_pub); |