diff options
Diffstat (limited to 'src/fs/fs_publish.c')
-rw-r--r-- | src/fs/fs_publish.c | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 1445c98d5..91ca3240a 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c | |||
@@ -360,16 +360,16 @@ compute_depth (uint64_t flen) | |||
360 | uint64_t fl; | 360 | uint64_t fl; |
361 | 361 | ||
362 | treeDepth = 1; | 362 | treeDepth = 1; |
363 | fl = GNUNET_FS_DBLOCK_SIZE; | 363 | fl = DBLOCK_SIZE; |
364 | while (fl < flen) | 364 | while (fl < flen) |
365 | { | 365 | { |
366 | treeDepth++; | 366 | treeDepth++; |
367 | if (fl * GNUNET_FS_CHK_PER_INODE < fl) | 367 | if (fl * CHK_PER_INODE < fl) |
368 | { | 368 | { |
369 | /* integer overflow, this is a HUGE file... */ | 369 | /* integer overflow, this is a HUGE file... */ |
370 | return treeDepth; | 370 | return treeDepth; |
371 | } | 371 | } |
372 | fl = fl * GNUNET_FS_CHK_PER_INODE; | 372 | fl = fl * CHK_PER_INODE; |
373 | } | 373 | } |
374 | return treeDepth; | 374 | return treeDepth; |
375 | } | 375 | } |
@@ -393,20 +393,20 @@ compute_iblock_size (unsigned int height, | |||
393 | uint64_t bds; | 393 | uint64_t bds; |
394 | 394 | ||
395 | GNUNET_assert (height > 0); | 395 | GNUNET_assert (height > 0); |
396 | bds = GNUNET_FS_DBLOCK_SIZE; /* number of bytes each CHK at level "i" | 396 | bds = DBLOCK_SIZE; /* number of bytes each CHK at level "i" |
397 | corresponds to */ | 397 | corresponds to */ |
398 | for (i=0;i<height;i++) | 398 | for (i=0;i<height;i++) |
399 | bds *= GNUNET_FS_CHK_PER_INODE; | 399 | bds *= CHK_PER_INODE; |
400 | mod = offset % bds; | 400 | mod = offset % bds; |
401 | if (0 == mod) | 401 | if (0 == mod) |
402 | { | 402 | { |
403 | /* we were triggered at the end of a full block */ | 403 | /* we were triggered at the end of a full block */ |
404 | ret = GNUNET_FS_CHK_PER_INODE; | 404 | ret = CHK_PER_INODE; |
405 | } | 405 | } |
406 | else | 406 | else |
407 | { | 407 | { |
408 | /* we were triggered at the end of the file */ | 408 | /* we were triggered at the end of the file */ |
409 | bds /= GNUNET_FS_CHK_PER_INODE; | 409 | bds /= CHK_PER_INODE; |
410 | ret = mod / bds; | 410 | ret = mod / bds; |
411 | if (0 != mod % bds) | 411 | if (0 != mod % bds) |
412 | ret++; | 412 | ret++; |
@@ -432,13 +432,13 @@ compute_chk_offset (unsigned int height, | |||
432 | unsigned int ret; | 432 | unsigned int ret; |
433 | unsigned int i; | 433 | unsigned int i; |
434 | 434 | ||
435 | bds = GNUNET_FS_DBLOCK_SIZE; /* number of bytes each CHK at level "i" | 435 | bds = DBLOCK_SIZE; /* number of bytes each CHK at level "i" |
436 | corresponds to */ | 436 | corresponds to */ |
437 | for (i=0;i<height;i++) | 437 | for (i=0;i<height;i++) |
438 | bds *= GNUNET_FS_CHK_PER_INODE; | 438 | bds *= CHK_PER_INODE; |
439 | GNUNET_assert (0 == (offset % bds)); | 439 | GNUNET_assert (0 == (offset % bds)); |
440 | ret = offset / bds; | 440 | ret = offset / bds; |
441 | return ret % GNUNET_FS_CHK_PER_INODE; | 441 | return ret % CHK_PER_INODE; |
442 | } | 442 | } |
443 | 443 | ||
444 | 444 | ||
@@ -460,8 +460,8 @@ publish_content (struct GNUNET_FS_PublishContext *sc, | |||
460 | const void *pt_block; | 460 | const void *pt_block; |
461 | uint16_t pt_size; | 461 | uint16_t pt_size; |
462 | char *emsg; | 462 | char *emsg; |
463 | char iob[GNUNET_FS_DBLOCK_SIZE]; | 463 | char iob[DBLOCK_SIZE]; |
464 | char enc[GNUNET_FS_DBLOCK_SIZE]; | 464 | char enc[DBLOCK_SIZE]; |
465 | struct GNUNET_CRYPTO_AesSessionKey sk; | 465 | struct GNUNET_CRYPTO_AesSessionKey sk; |
466 | struct GNUNET_CRYPTO_AesInitializationVector iv; | 466 | struct GNUNET_CRYPTO_AesInitializationVector iv; |
467 | uint64_t size; | 467 | uint64_t size; |
@@ -491,7 +491,7 @@ publish_content (struct GNUNET_FS_PublishContext *sc, | |||
491 | else | 491 | else |
492 | { | 492 | { |
493 | raw_data = NULL; | 493 | raw_data = NULL; |
494 | if ( (dirpos->data.file.file_size < GNUNET_FS_MAX_INLINE_SIZE) && | 494 | if ( (dirpos->data.file.file_size < MAX_INLINE_SIZE) && |
495 | (dirpos->data.file.file_size > 0) ) | 495 | (dirpos->data.file.file_size > 0) ) |
496 | { | 496 | { |
497 | raw_data = GNUNET_malloc (dirpos->data.file.file_size); | 497 | raw_data = GNUNET_malloc (dirpos->data.file.file_size); |
@@ -524,21 +524,21 @@ publish_content (struct GNUNET_FS_PublishContext *sc, | |||
524 | p->chk_tree_depth = compute_depth (size); | 524 | p->chk_tree_depth = compute_depth (size); |
525 | p->chk_tree = GNUNET_malloc (p->chk_tree_depth * | 525 | p->chk_tree = GNUNET_malloc (p->chk_tree_depth * |
526 | sizeof (struct ContentHashKey) * | 526 | sizeof (struct ContentHashKey) * |
527 | GNUNET_FS_CHK_PER_INODE); | 527 | CHK_PER_INODE); |
528 | p->current_depth = p->chk_tree_depth; | 528 | p->current_depth = p->chk_tree_depth; |
529 | } | 529 | } |
530 | if (p->current_depth == p->chk_tree_depth) | 530 | if (p->current_depth == p->chk_tree_depth) |
531 | { | 531 | { |
532 | if (p->is_directory) | 532 | if (p->is_directory) |
533 | { | 533 | { |
534 | pt_size = GNUNET_MIN(GNUNET_FS_DBLOCK_SIZE, | 534 | pt_size = GNUNET_MIN(DBLOCK_SIZE, |
535 | p->data.dir.dir_size - p->publish_offset); | 535 | p->data.dir.dir_size - p->publish_offset); |
536 | dd = p->data.dir.dir_data; | 536 | dd = p->data.dir.dir_data; |
537 | pt_block = &dd[p->publish_offset]; | 537 | pt_block = &dd[p->publish_offset]; |
538 | } | 538 | } |
539 | else | 539 | else |
540 | { | 540 | { |
541 | pt_size = GNUNET_MIN(GNUNET_FS_DBLOCK_SIZE, | 541 | pt_size = GNUNET_MIN(DBLOCK_SIZE, |
542 | p->data.file.file_size - p->publish_offset); | 542 | p->data.file.file_size - p->publish_offset); |
543 | emsg = NULL; | 543 | emsg = NULL; |
544 | if (pt_size != | 544 | if (pt_size != |
@@ -579,11 +579,11 @@ publish_content (struct GNUNET_FS_PublishContext *sc, | |||
579 | pt_size = compute_iblock_size (p->chk_tree_depth - p->current_depth, | 579 | pt_size = compute_iblock_size (p->chk_tree_depth - p->current_depth, |
580 | p->publish_offset); | 580 | p->publish_offset); |
581 | pt_block = &p->chk_tree[p->current_depth * | 581 | pt_block = &p->chk_tree[p->current_depth * |
582 | GNUNET_FS_CHK_PER_INODE]; | 582 | CHK_PER_INODE]; |
583 | } | 583 | } |
584 | off = compute_chk_offset (p->chk_tree_depth - p->current_depth, | 584 | off = compute_chk_offset (p->chk_tree_depth - p->current_depth, |
585 | p->publish_offset); | 585 | p->publish_offset); |
586 | mychk = &p->chk_tree[(p->current_depth-1)*GNUNET_FS_CHK_PER_INODE+off]; | 586 | mychk = &p->chk_tree[(p->current_depth-1)*CHK_PER_INODE+off]; |
587 | GNUNET_CRYPTO_hash (pt_block, pt_size, &mychk->key); | 587 | GNUNET_CRYPTO_hash (pt_block, pt_size, &mychk->key); |
588 | GNUNET_CRYPTO_hash_to_aes_key (&mychk->key, &sk, &iv); | 588 | GNUNET_CRYPTO_hash_to_aes_key (&mychk->key, &sk, &iv); |
589 | GNUNET_CRYPTO_aes_encrypt (pt_block, | 589 | GNUNET_CRYPTO_aes_encrypt (pt_block, |
@@ -645,12 +645,12 @@ publish_content (struct GNUNET_FS_PublishContext *sc, | |||
645 | { | 645 | { |
646 | p->publish_offset += pt_size; | 646 | p->publish_offset += pt_size; |
647 | if ( (p->publish_offset == size) || | 647 | if ( (p->publish_offset == size) || |
648 | (0 == p->publish_offset % (GNUNET_FS_CHK_PER_INODE * GNUNET_FS_DBLOCK_SIZE) ) ) | 648 | (0 == p->publish_offset % (CHK_PER_INODE * DBLOCK_SIZE) ) ) |
649 | p->current_depth--; | 649 | p->current_depth--; |
650 | } | 650 | } |
651 | else | 651 | else |
652 | { | 652 | { |
653 | if ( (off == GNUNET_FS_CHK_PER_INODE) || | 653 | if ( (off == CHK_PER_INODE) || |
654 | (p->publish_offset == size) ) | 654 | (p->publish_offset == size) ) |
655 | p->current_depth--; | 655 | p->current_depth--; |
656 | else | 656 | else |
@@ -951,13 +951,13 @@ struct PublishKskContext | |||
951 | * (in plaintext), has "mdsize+slen" more | 951 | * (in plaintext), has "mdsize+slen" more |
952 | * bytes than the struct would suggest. | 952 | * bytes than the struct would suggest. |
953 | */ | 953 | */ |
954 | struct GNUNET_FS_KBlock *kb; | 954 | struct KBlock *kb; |
955 | 955 | ||
956 | /** | 956 | /** |
957 | * Buffer of the same size as "kb" for | 957 | * Buffer of the same size as "kb" for |
958 | * the encrypted version. | 958 | * the encrypted version. |
959 | */ | 959 | */ |
960 | struct GNUNET_FS_KBlock *cpy; | 960 | struct KBlock *cpy; |
961 | 961 | ||
962 | /** | 962 | /** |
963 | * Handle to the datastore, NULL if we are just | 963 | * Handle to the datastore, NULL if we are just |
@@ -1114,7 +1114,7 @@ publish_ksk_cont (void *cls, | |||
1114 | 0, | 1114 | 0, |
1115 | &query, | 1115 | &query, |
1116 | pkc->mdsize + | 1116 | pkc->mdsize + |
1117 | sizeof (struct GNUNET_FS_KBlock) + | 1117 | sizeof (struct KBlock) + |
1118 | pkc->slen, | 1118 | pkc->slen, |
1119 | pkc->cpy, | 1119 | pkc->cpy, |
1120 | GNUNET_DATASTORE_BLOCKTYPE_KBLOCK, | 1120 | GNUNET_DATASTORE_BLOCKTYPE_KBLOCK, |
@@ -1181,11 +1181,11 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, | |||
1181 | GNUNET_assert (pkc->mdsize >= 0); | 1181 | GNUNET_assert (pkc->mdsize >= 0); |
1182 | uris = GNUNET_FS_uri_to_string (uri); | 1182 | uris = GNUNET_FS_uri_to_string (uri); |
1183 | pkc->slen = strlen (uris) + 1; | 1183 | pkc->slen = strlen (uris) + 1; |
1184 | size = pkc->mdsize + sizeof (struct GNUNET_FS_KBlock) + pkc->slen; | 1184 | size = pkc->mdsize + sizeof (struct KBlock) + pkc->slen; |
1185 | if (size > MAX_KBLOCK_SIZE) | 1185 | if (size > MAX_KBLOCK_SIZE) |
1186 | { | 1186 | { |
1187 | size = MAX_KBLOCK_SIZE; | 1187 | size = MAX_KBLOCK_SIZE; |
1188 | pkc->mdsize = size - sizeof (struct GNUNET_FS_KBlock) - pkc->slen; | 1188 | pkc->mdsize = size - sizeof (struct KBlock) - pkc->slen; |
1189 | } | 1189 | } |
1190 | pkc->kb = GNUNET_malloc (size); | 1190 | pkc->kb = GNUNET_malloc (size); |
1191 | kbe = (char *) &pkc->kb[1]; | 1191 | kbe = (char *) &pkc->kb[1]; |
@@ -1206,7 +1206,7 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, | |||
1206 | GNUNET_free (pkc); | 1206 | GNUNET_free (pkc); |
1207 | return; | 1207 | return; |
1208 | } | 1208 | } |
1209 | size = sizeof (struct GNUNET_FS_KBlock) + pkc->slen + pkc->mdsize; | 1209 | size = sizeof (struct KBlock) + pkc->slen + pkc->mdsize; |
1210 | 1210 | ||
1211 | pkc->cpy = GNUNET_malloc (size); | 1211 | pkc->cpy = GNUNET_malloc (size); |
1212 | pkc->cpy->purpose.size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + | 1212 | pkc->cpy->purpose.size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + |
@@ -1322,8 +1322,8 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, | |||
1322 | size_t nidlen; | 1322 | size_t nidlen; |
1323 | size_t idlen; | 1323 | size_t idlen; |
1324 | ssize_t mdsize; | 1324 | ssize_t mdsize; |
1325 | struct GNUNET_FS_SBlock *sb; | 1325 | struct SBlock *sb; |
1326 | struct GNUNET_FS_SBlock *sb_enc; | 1326 | struct SBlock *sb_enc; |
1327 | char *dest; | 1327 | char *dest; |
1328 | GNUNET_HashCode key; /* hash of thisId = key */ | 1328 | GNUNET_HashCode key; /* hash of thisId = key */ |
1329 | GNUNET_HashCode id; /* hash of hc = identifier */ | 1329 | GNUNET_HashCode id; /* hash of hc = identifier */ |
@@ -1337,13 +1337,13 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, | |||
1337 | mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (meta, | 1337 | mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (meta, |
1338 | GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); | 1338 | GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); |
1339 | 1339 | ||
1340 | size = sizeof (struct GNUNET_FS_SBlock) + slen + nidlen + mdsize; | 1340 | size = sizeof (struct SBlock) + slen + nidlen + mdsize; |
1341 | if (size > MAX_SBLOCK_SIZE) | 1341 | if (size > MAX_SBLOCK_SIZE) |
1342 | { | 1342 | { |
1343 | size = MAX_SBLOCK_SIZE; | 1343 | size = MAX_SBLOCK_SIZE; |
1344 | mdsize = size - (sizeof (struct GNUNET_FS_SBlock) + slen + nidlen); | 1344 | mdsize = size - (sizeof (struct SBlock) + slen + nidlen); |
1345 | } | 1345 | } |
1346 | sb = GNUNET_malloc (sizeof (struct GNUNET_FS_SBlock) + size); | 1346 | sb = GNUNET_malloc (sizeof (struct SBlock) + size); |
1347 | dest = (char *) &sb[1]; | 1347 | dest = (char *) &sb[1]; |
1348 | memcpy (dest, update, nidlen); | 1348 | memcpy (dest, update, nidlen); |
1349 | dest += nidlen; | 1349 | dest += nidlen; |
@@ -1363,8 +1363,8 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, | |||
1363 | _("Internal error.")); | 1363 | _("Internal error.")); |
1364 | return; | 1364 | return; |
1365 | } | 1365 | } |
1366 | size = sizeof (struct GNUNET_FS_SBlock) + mdsize + slen + nidlen; | 1366 | size = sizeof (struct SBlock) + mdsize + slen + nidlen; |
1367 | sb_enc = GNUNET_malloc (sizeof (struct GNUNET_FS_SBlock) + size); | 1367 | sb_enc = GNUNET_malloc (sizeof (struct SBlock) + size); |
1368 | GNUNET_CRYPTO_hash (identifier, idlen, &key); | 1368 | GNUNET_CRYPTO_hash (identifier, idlen, &key); |
1369 | GNUNET_CRYPTO_hash (&key, sizeof (GNUNET_HashCode), &id); | 1369 | GNUNET_CRYPTO_hash (&key, sizeof (GNUNET_HashCode), &id); |
1370 | sks_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 1370 | sks_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
@@ -1379,14 +1379,14 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, | |||
1379 | &sb_enc->identifier); | 1379 | &sb_enc->identifier); |
1380 | GNUNET_CRYPTO_hash_to_aes_key (&key, &sk, &iv); | 1380 | GNUNET_CRYPTO_hash_to_aes_key (&key, &sk, &iv); |
1381 | GNUNET_CRYPTO_aes_encrypt (&sb[1], | 1381 | GNUNET_CRYPTO_aes_encrypt (&sb[1], |
1382 | size - sizeof (struct GNUNET_FS_SBlock), | 1382 | size - sizeof (struct SBlock), |
1383 | &sk, | 1383 | &sk, |
1384 | &iv, | 1384 | &iv, |
1385 | &sb_enc[1]); | 1385 | &sb_enc[1]); |
1386 | GNUNET_free (sb); | 1386 | GNUNET_free (sb); |
1387 | sb_enc->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK); | 1387 | sb_enc->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK); |
1388 | sb_enc->purpose.size = htonl(slen + mdsize + nidlen | 1388 | sb_enc->purpose.size = htonl(slen + mdsize + nidlen |
1389 | + sizeof(struct GNUNET_FS_SBlock) | 1389 | + sizeof(struct SBlock) |
1390 | - sizeof(struct GNUNET_CRYPTO_RsaSignature)); | 1390 | - sizeof(struct GNUNET_CRYPTO_RsaSignature)); |
1391 | GNUNET_assert (GNUNET_OK == | 1391 | GNUNET_assert (GNUNET_OK == |
1392 | GNUNET_CRYPTO_rsa_sign (namespace->key, | 1392 | GNUNET_CRYPTO_rsa_sign (namespace->key, |