diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-11-22 18:37:35 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-11-22 18:37:35 +0100 |
commit | 67935982582a31e4a75dc431feceee9664bca839 (patch) | |
tree | 902431f5318c6a704ff5036b85391dcbb8792054 /src/hello/hello-ng.c | |
parent | ca90313490f4233ce9d209abbdcc2d78d16b8326 (diff) | |
download | gnunet-67935982582a31e4a75dc431feceee9664bca839.tar.gz gnunet-67935982582a31e4a75dc431feceee9664bca839.zip |
more work on TNG
Diffstat (limited to 'src/hello/hello-ng.c')
-rw-r--r-- | src/hello/hello-ng.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/hello/hello-ng.c b/src/hello/hello-ng.c index 425095f9c..46c83a7eb 100644 --- a/src/hello/hello-ng.c +++ b/src/hello/hello-ng.c | |||
@@ -53,6 +53,7 @@ struct SignedAddress | |||
53 | * Build address record by signing raw information with private key. | 53 | * Build address record by signing raw information with private key. |
54 | * | 54 | * |
55 | * @param address text address at @a communicator to sign | 55 | * @param address text address at @a communicator to sign |
56 | * @param nt network type of @a address | ||
56 | * @param expiration how long is @a address valid | 57 | * @param expiration how long is @a address valid |
57 | * @param private_key signing key to use | 58 | * @param private_key signing key to use |
58 | * @param result[out] where to write address record (allocated) | 59 | * @param result[out] where to write address record (allocated) |
@@ -60,6 +61,7 @@ struct SignedAddress | |||
60 | */ | 61 | */ |
61 | void | 62 | void |
62 | GNUNET_HELLO_sign_address (const char *address, | 63 | GNUNET_HELLO_sign_address (const char *address, |
64 | enum GNUNET_ATS_Network_Type nt, | ||
63 | struct GNUNET_TIME_Absolute expiration, | 65 | struct GNUNET_TIME_Absolute expiration, |
64 | const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, | 66 | const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, |
65 | void **result, | 67 | void **result, |
@@ -84,9 +86,10 @@ GNUNET_HELLO_sign_address (const char *address, | |||
84 | sizeof (sig), | 86 | sizeof (sig), |
85 | &sig_str); | 87 | &sig_str); |
86 | *result_size = 1 + GNUNET_asprintf ((char **) result, | 88 | *result_size = 1 + GNUNET_asprintf ((char **) result, |
87 | "%s;%llu;%s", | 89 | "%s;%llu;%u;%s", |
88 | sig_str, | 90 | sig_str, |
89 | (unsigned long long) expiration.abs_value_us, | 91 | (unsigned long long) expiration.abs_value_us, |
92 | (unsigned int) nt, | ||
90 | address); | 93 | address); |
91 | GNUNET_free (sig_str); | 94 | GNUNET_free (sig_str); |
92 | } | 95 | } |
@@ -98,6 +101,7 @@ GNUNET_HELLO_sign_address (const char *address, | |||
98 | * @param raw raw signed address | 101 | * @param raw raw signed address |
99 | * @param raw_size size of @a raw | 102 | * @param raw_size size of @a raw |
100 | * @param public_key public key to use for signature verification | 103 | * @param public_key public key to use for signature verification |
104 | * @param nt[out] set to network type | ||
101 | * @param expiration[out] how long is the address valid | 105 | * @param expiration[out] how long is the address valid |
102 | * @return NULL on error, otherwise the address | 106 | * @return NULL on error, otherwise the address |
103 | */ | 107 | */ |
@@ -105,12 +109,15 @@ char * | |||
105 | GNUNET_HELLO_extract_address (const void *raw, | 109 | GNUNET_HELLO_extract_address (const void *raw, |
106 | size_t raw_size, | 110 | size_t raw_size, |
107 | const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, | 111 | const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, |
112 | enum GNUNET_ATS_Network_Type *nt, | ||
108 | struct GNUNET_TIME_Absolute *expiration) | 113 | struct GNUNET_TIME_Absolute *expiration) |
109 | { | 114 | { |
110 | const char *raws = raw; | 115 | const char *raws = raw; |
111 | unsigned long long raw_us; | 116 | unsigned long long raw_us; |
117 | unsigned int raw_nt; | ||
112 | const char *sc; | 118 | const char *sc; |
113 | const char *sc2; | 119 | const char *sc2; |
120 | const char *sc3; | ||
114 | const char *raw_addr; | 121 | const char *raw_addr; |
115 | struct GNUNET_TIME_Absolute raw_expiration; | 122 | struct GNUNET_TIME_Absolute raw_expiration; |
116 | struct SignedAddress sa; | 123 | struct SignedAddress sa; |
@@ -133,9 +140,16 @@ GNUNET_HELLO_extract_address (const void *raw, | |||
133 | GNUNET_break_op (0); | 140 | GNUNET_break_op (0); |
134 | return NULL; | 141 | return NULL; |
135 | } | 142 | } |
143 | if (NULL == (sc3 = strchr (sc2 + 1, | ||
144 | ';'))) | ||
145 | { | ||
146 | GNUNET_break_op (0); | ||
147 | return NULL; | ||
148 | } | ||
136 | if (1 != sscanf (sc + 1, | 149 | if (1 != sscanf (sc + 1, |
137 | "%llu;", | 150 | "%llu;%u;", |
138 | &raw_us)) | 151 | &raw_us, |
152 | &raw_nt)) | ||
139 | { | 153 | { |
140 | GNUNET_break_op (0); | 154 | GNUNET_break_op (0); |
141 | return NULL; | 155 | return NULL; |
@@ -153,7 +167,7 @@ GNUNET_HELLO_extract_address (const void *raw, | |||
153 | GNUNET_free_non_null (sig); | 167 | GNUNET_free_non_null (sig); |
154 | return NULL; | 168 | return NULL; |
155 | } | 169 | } |
156 | raw_addr = sc2 + 1; | 170 | raw_addr = sc3 + 1; |
157 | 171 | ||
158 | sa.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS); | 172 | sa.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS); |
159 | sa.purpose.size = htonl (sizeof (sa)); | 173 | sa.purpose.size = htonl (sizeof (sa)); |
@@ -172,6 +186,8 @@ GNUNET_HELLO_extract_address (const void *raw, | |||
172 | return NULL; | 186 | return NULL; |
173 | } | 187 | } |
174 | GNUNET_free (sig); | 188 | GNUNET_free (sig); |
189 | *expiration = raw_expiration; | ||
190 | *nt = (enum GNUNET_ATS_Network_Type) raw_nt; | ||
175 | return GNUNET_strdup (raw_addr); | 191 | return GNUNET_strdup (raw_addr); |
176 | } | 192 | } |
177 | 193 | ||