diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/identity/identity.h | 27 | ||||
-rw-r--r-- | src/identity/identity_api.c | 36 |
2 files changed, 31 insertions, 32 deletions
diff --git a/src/identity/identity.h b/src/identity/identity.h index 57337c441..181f5c353 100644 --- a/src/identity/identity.h +++ b/src/identity/identity.h | |||
@@ -74,14 +74,11 @@ struct GNUNET_IDENTITY_UpdateMessage | |||
74 | uint16_t name_len GNUNET_PACKED; | 74 | uint16_t name_len GNUNET_PACKED; |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Always zero. | 77 | * Number of bytes of private key data that follow, in NBO. |
78 | */ | 78 | */ |
79 | uint16_t reserved GNUNET_PACKED; | 79 | uint16_t pk_len GNUNET_PACKED; |
80 | 80 | ||
81 | /** | 81 | /* followed by private key */ |
82 | * Public key of the identity that we provide an update about. | ||
83 | */ | ||
84 | struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded private_key_FIXME; | ||
85 | 82 | ||
86 | /* followed by 0-terminated identity name */ | 83 | /* followed by 0-terminated identity name */ |
87 | 84 | ||
@@ -133,14 +130,11 @@ struct GNUNET_IDENTITY_SetDefaultMessage | |||
133 | uint16_t name_len GNUNET_PACKED; | 130 | uint16_t name_len GNUNET_PACKED; |
134 | 131 | ||
135 | /** | 132 | /** |
136 | * Always zero. | 133 | * Number of bytes of private key data that follow, in NBO. |
137 | */ | 134 | */ |
138 | uint16_t reserved GNUNET_PACKED; | 135 | uint16_t pk_len GNUNET_PACKED; |
139 | 136 | ||
140 | /** | 137 | /* followed by private key */ |
141 | * Public key of the identity to use. | ||
142 | */ | ||
143 | struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded private_key_FIXME; | ||
144 | 138 | ||
145 | /* followed by 0-terminated service name */ | 139 | /* followed by 0-terminated service name */ |
146 | 140 | ||
@@ -164,14 +158,11 @@ struct GNUNET_IDENTITY_CreateRequestMessage | |||
164 | uint16_t name_len GNUNET_PACKED; | 158 | uint16_t name_len GNUNET_PACKED; |
165 | 159 | ||
166 | /** | 160 | /** |
167 | * Always zero. | 161 | * Number of bytes of private key data that follow, in NBO. |
168 | */ | 162 | */ |
169 | uint16_t reserved GNUNET_PACKED; | 163 | uint16_t pk_len GNUNET_PACKED; |
170 | 164 | ||
171 | /** | 165 | /* followed by private key */ |
172 | * Public key of the identity to use. | ||
173 | */ | ||
174 | struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded private_key_FIXME; | ||
175 | 166 | ||
176 | /* followed by 0-terminated identity name */ | 167 | /* followed by 0-terminated identity name */ |
177 | 168 | ||
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index 757cec76d..f03f7b449 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -239,6 +239,8 @@ message_handler (void *cls, | |||
239 | struct GNUNET_HashCode id; | 239 | struct GNUNET_HashCode id; |
240 | const char *str; | 240 | const char *str; |
241 | uint16_t size; | 241 | uint16_t size; |
242 | uint16_t pk_len; | ||
243 | uint16_t name_len; | ||
242 | 244 | ||
243 | if (NULL == msg) | 245 | if (NULL == msg) |
244 | { | 246 | { |
@@ -285,19 +287,18 @@ message_handler (void *cls, | |||
285 | return; | 287 | return; |
286 | } | 288 | } |
287 | um = (const struct GNUNET_IDENTITY_UpdateMessage *) msg; | 289 | um = (const struct GNUNET_IDENTITY_UpdateMessage *) msg; |
290 | pk_len = ntohs (um->pk_len); | ||
291 | name_len = ntohs (um->name_len); | ||
288 | str = (const char *) &um[1]; | 292 | str = (const char *) &um[1]; |
289 | if ( (size > sizeof (struct GNUNET_IDENTITY_UpdateMessage)) && | 293 | if ( (size != pk_len + name_len + sizeof (struct GNUNET_IDENTITY_UpdateMessage)) || |
290 | ('\0' != str[size - sizeof (struct GNUNET_IDENTITY_UpdateMessage) - 1]) ) | 294 | ( (0 != name_len) && |
295 | ('\0' != str[pk_len + name_len - 1])) ) | ||
291 | { | 296 | { |
292 | GNUNET_break (0); | 297 | GNUNET_break (0); |
293 | reschedule_connect (h); | 298 | reschedule_connect (h); |
294 | return; | 299 | return; |
295 | } | 300 | } |
296 | if (size == sizeof (struct GNUNET_IDENTITY_UpdateMessage)) | 301 | priv = GNUNET_CRYPTO_ecc_decode_key (str, pk_len, GNUNET_YES); |
297 | str = NULL; | ||
298 | |||
299 | // FIXME: um->pk does NOT work! | ||
300 | priv = GNUNET_CRYPTO_ecc_decode_key (NULL, 0, GNUNET_YES); // FIXME... | ||
301 | if (NULL == priv) | 302 | if (NULL == priv) |
302 | { | 303 | { |
303 | GNUNET_break (0); | 304 | GNUNET_break (0); |
@@ -307,7 +308,10 @@ message_handler (void *cls, | |||
307 | GNUNET_CRYPTO_ecc_key_get_public (priv, | 308 | GNUNET_CRYPTO_ecc_key_get_public (priv, |
308 | &pub); | 309 | &pub); |
309 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id); | 310 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id); |
310 | 311 | if (0 == name_len) | |
312 | str = NULL; | ||
313 | else | ||
314 | str = &str[pk_len]; | ||
311 | ego = GNUNET_CONTAINER_multihashmap_get (h->egos, | 315 | ego = GNUNET_CONTAINER_multihashmap_get (h->egos, |
312 | &id); | 316 | &id); |
313 | if (NULL == ego) | 317 | if (NULL == ego) |
@@ -366,18 +370,18 @@ message_handler (void *cls, | |||
366 | return; | 370 | return; |
367 | } | 371 | } |
368 | sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) msg; | 372 | sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) msg; |
373 | pk_len = ntohs (sdm->pk_len); | ||
374 | name_len = ntohs (sdm->name_len); | ||
369 | str = (const char *) &sdm[1]; | 375 | str = (const char *) &sdm[1]; |
370 | if ( (size > sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) && | 376 | if ( (size != pk_len + name_len + sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) || |
371 | ('\0' != str[size - sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) - 1]) ) | 377 | ( (0 != name_len) && |
378 | ('\0' != str[pk_len + name_len - 1]) ) ) | ||
372 | { | 379 | { |
373 | GNUNET_break (0); | 380 | GNUNET_break (0); |
374 | reschedule_connect (h); | 381 | reschedule_connect (h); |
375 | return; | 382 | return; |
376 | } | 383 | } |
377 | if (size == sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) | 384 | priv = GNUNET_CRYPTO_ecc_decode_key (str, pk_len, GNUNET_YES); |
378 | str = NULL; | ||
379 | // FIXME: sdr->pk does NOT work! | ||
380 | priv = GNUNET_CRYPTO_ecc_decode_key (NULL, 0, GNUNET_YES); // FIXME... | ||
381 | if (NULL == priv) | 385 | if (NULL == priv) |
382 | { | 386 | { |
383 | GNUNET_break (0); | 387 | GNUNET_break (0); |
@@ -388,6 +392,10 @@ message_handler (void *cls, | |||
388 | &pub); | 392 | &pub); |
389 | GNUNET_CRYPTO_ecc_key_free (priv); | 393 | GNUNET_CRYPTO_ecc_key_free (priv); |
390 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id); | 394 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id); |
395 | if (0 == name_len) | ||
396 | str = NULL; | ||
397 | else | ||
398 | str = &str[pk_len]; | ||
391 | ego = GNUNET_CONTAINER_multihashmap_get (h->egos, | 399 | ego = GNUNET_CONTAINER_multihashmap_get (h->egos, |
392 | &id); | 400 | &id); |
393 | if (NULL == ego) | 401 | if (NULL == ego) |