diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-09 21:08:16 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-09 21:08:16 +0000 |
commit | 01e6bbb6ccd7337c7a9286016418d03d3d365d90 (patch) | |
tree | 817c8a18aa395b06b67195055dab608f8affb6e9 /src/fs/fs_unindex.c | |
parent | b0ee2cbddcdf5a2361ff168b8aeef5fb28d37014 (diff) | |
download | gnunet-01e6bbb6ccd7337c7a9286016418d03d3d365d90.tar.gz gnunet-01e6bbb6ccd7337c7a9286016418d03d3d365d90.zip |
-unindex needs to decrypt KBlock
Diffstat (limited to 'src/fs/fs_unindex.c')
-rw-r--r-- | src/fs/fs_unindex.c | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index 07b9cccd3..9e477c111 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c | |||
@@ -446,7 +446,6 @@ process_kblock_for_unindex (void *cls, | |||
446 | { | 446 | { |
447 | struct GNUNET_FS_UnindexContext *uc = cls; | 447 | struct GNUNET_FS_UnindexContext *uc = cls; |
448 | const struct KBlock *kb; | 448 | const struct KBlock *kb; |
449 | const char *uris; | ||
450 | struct GNUNET_FS_Uri *chk_uri; | 449 | struct GNUNET_FS_Uri *chk_uri; |
451 | 450 | ||
452 | uc->dqe = NULL; | 451 | uc->dqe = NULL; |
@@ -476,17 +475,33 @@ process_kblock_for_unindex (void *cls, | |||
476 | goto get_next; | 475 | goto get_next; |
477 | } | 476 | } |
478 | kb = data; | 477 | kb = data; |
479 | uris = (const char*) &kb[1]; | ||
480 | if (NULL == memchr (uris, 0, size - sizeof (struct KBlock))) | ||
481 | { | 478 | { |
482 | GNUNET_break (0); | 479 | char pt[size - sizeof (struct KBlock)]; |
483 | goto get_next; | 480 | struct GNUNET_CRYPTO_AesSessionKey skey; |
484 | } | 481 | struct GNUNET_CRYPTO_AesInitializationVector iv; |
485 | chk_uri = GNUNET_FS_uri_parse (uris, NULL); | 482 | |
486 | if (NULL == chk_uri) | 483 | GNUNET_CRYPTO_hash_to_aes_key (&uc->key, &skey, &iv); |
487 | { | 484 | if (-1 == |
488 | GNUNET_break (0); | 485 | GNUNET_CRYPTO_aes_decrypt (&kb[1], size - sizeof (struct KBlock), &skey, |
489 | goto get_next; | 486 | &iv, pt)) |
487 | { | ||
488 | GNUNET_break (0); | ||
489 | goto get_next; | ||
490 | } | ||
491 | if (NULL == memchr (pt, 0, sizeof (pt))) | ||
492 | { | ||
493 | GNUNET_break (0); | ||
494 | goto get_next; | ||
495 | } | ||
496 | chk_uri = GNUNET_FS_uri_parse (pt, NULL); | ||
497 | if (NULL == chk_uri) | ||
498 | { | ||
499 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
500 | _("Failed to parse URI `%s' from KBlock!\n"), | ||
501 | pt); | ||
502 | GNUNET_break (0); | ||
503 | goto get_next; | ||
504 | } | ||
490 | } | 505 | } |
491 | if (0 != memcmp (&uc->chk, | 506 | if (0 != memcmp (&uc->chk, |
492 | &chk_uri->data.chk.chk, | 507 | &chk_uri->data.chk.chk, |
@@ -507,7 +522,7 @@ process_kblock_for_unindex (void *cls, | |||
507 | get_next: | 522 | get_next: |
508 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, | 523 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, |
509 | uc->roff++, | 524 | uc->roff++, |
510 | &uc->key, | 525 | &uc->query, |
511 | GNUNET_BLOCK_TYPE_FS_KBLOCK, | 526 | GNUNET_BLOCK_TYPE_FS_KBLOCK, |
512 | 0 /* priority */, 1 /* queue size */, | 527 | 0 /* priority */, 1 /* queue size */, |
513 | GNUNET_TIME_UNIT_FOREVER_REL, | 528 | GNUNET_TIME_UNIT_FOREVER_REL, |
@@ -525,7 +540,6 @@ void | |||
525 | GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc) | 540 | GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc) |
526 | { | 541 | { |
527 | const char *keyword; | 542 | const char *keyword; |
528 | GNUNET_HashCode hc; | ||
529 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub; | 543 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub; |
530 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; | 544 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; |
531 | 545 | ||
@@ -547,19 +561,19 @@ GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc) | |||
547 | } | 561 | } |
548 | /* FIXME: code duplication with fs_search.c here... */ | 562 | /* FIXME: code duplication with fs_search.c here... */ |
549 | keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1]; | 563 | keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1]; |
550 | GNUNET_CRYPTO_hash (keyword, strlen (keyword), &hc); | 564 | GNUNET_CRYPTO_hash (keyword, strlen (keyword), &uc->key); |
551 | pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&hc); | 565 | pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&uc->key); |
552 | GNUNET_assert (pk != NULL); | 566 | GNUNET_assert (pk != NULL); |
553 | GNUNET_CRYPTO_rsa_key_get_public (pk, &pub); | 567 | GNUNET_CRYPTO_rsa_key_get_public (pk, &pub); |
554 | GNUNET_CRYPTO_rsa_key_free (pk); | 568 | GNUNET_CRYPTO_rsa_key_free (pk); |
555 | GNUNET_CRYPTO_hash (&pub, | 569 | GNUNET_CRYPTO_hash (&pub, |
556 | sizeof (struct | 570 | sizeof (struct |
557 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 571 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
558 | &uc->key); | 572 | &uc->query); |
559 | uc->first_uid = 0; | 573 | uc->first_uid = 0; |
560 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, | 574 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, |
561 | uc->roff++, | 575 | uc->roff++, |
562 | &uc->key, | 576 | &uc->query, |
563 | GNUNET_BLOCK_TYPE_FS_KBLOCK, | 577 | GNUNET_BLOCK_TYPE_FS_KBLOCK, |
564 | 0 /* priority */, 1 /* queue size */, | 578 | 0 /* priority */, 1 /* queue size */, |
565 | GNUNET_TIME_UNIT_FOREVER_REL, | 579 | GNUNET_TIME_UNIT_FOREVER_REL, |