diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-07-14 20:37:08 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-07-14 20:37:08 +0000 |
commit | d0e0b8256a32f05dee2bc79494e4fba7830e63d2 (patch) | |
tree | 981157ca4715e43cdfa35c91b3f511acf60046e3 /src/identity/identity_api.c | |
parent | a7349d7a85cc142fa2416671da346d368819775d (diff) | |
download | gnunet-d0e0b8256a32f05dee2bc79494e4fba7830e63d2.tar.gz gnunet-d0e0b8256a32f05dee2bc79494e4fba7830e63d2.zip |
-addressing variable-size ECC private key len in IPC
Diffstat (limited to 'src/identity/identity_api.c')
-rw-r--r-- | src/identity/identity_api.c | 36 |
1 files changed, 22 insertions, 14 deletions
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) |