aboutsummaryrefslogtreecommitdiff
path: root/src/revocation/gnunet-revocation-tvg.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2023-06-29 20:37:34 +0200
committerMartin Schanzenbach <schanzen@gnunet.org>2023-06-29 20:37:34 +0200
commit8c34d91adf6884b1282d57760b3c22d55e807458 (patch)
tree73e0dc544c7a2c197fdd9b0d0696401898b954d6 /src/revocation/gnunet-revocation-tvg.c
parent78f3d8739573862de8a73e47a147c8cb83d99505 (diff)
downloadgnunet-8c34d91adf6884b1282d57760b3c22d55e807458.tar.gz
gnunet-8c34d91adf6884b1282d57760b3c22d55e807458.zip
GNS: TVs shorter expiration. Prettify revocation TV output.
Diffstat (limited to 'src/revocation/gnunet-revocation-tvg.c')
-rw-r--r--src/revocation/gnunet-revocation-tvg.c34
1 files changed, 21 insertions, 13 deletions
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
37static char* d_pkey = 37static char*d_pkey =
38"6fea32c05af58bfa979553d188605fd57d8bf9cc263b78d5f7478c07b998ed70"; 38 "6fea32c05af58bfa979553d188605fd57d8bf9cc263b78d5f7478c07b998ed70";
39 39
40int parsehex(char *src, char *dst, size_t dstlen, int invert) 40int
41parsehex (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
59static void 61static void
60print_bytes_ (void *buf, 62print_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
79static void 87static void
80print_bytes (void *buf, 88print_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);