[or-cvs] r11370: fixed two bugs dealing with (1) client-side computation of v (tor/branches/114-dist-storage/src/or)
kloesing at seul.org
kloesing at seul.org
Tue Sep 4 10:45:12 UTC 2007
Author: kloesing
Date: 2007-09-04 06:45:12 -0400 (Tue, 04 Sep 2007)
New Revision: 11370
Modified:
tor/branches/114-dist-storage/src/or/rendcommon.c
tor/branches/114-dist-storage/src/or/rendservice.c
tor/branches/114-dist-storage/src/or/test.c
Log:
fixed two bugs dealing with (1) client-side computation of v2 desc-ids and (2) server-side descriptor re-publication intervals; added test for (1)
Modified: tor/branches/114-dist-storage/src/or/rendcommon.c
===================================================================
--- tor/branches/114-dist-storage/src/or/rendcommon.c 2007-09-04 08:54:55 UTC (rev 11369)
+++ tor/branches/114-dist-storage/src/or/rendcommon.c 2007-09-04 10:45:12 UTC (rev 11370)
@@ -97,9 +97,10 @@
return result;
}
-/* Compute the <b>desc_id</b> for a given base32-encoded <b>service_id</b> and
- * base32-encoded <b>secret_cookie</b> at time <b>now</b> for replica number
- * <b>replica</b>. Return 0 for success, -1 otherwise. */
+/* Compute the binary <b>desc_id</b> for a given base32-encoded
+ * <b>service_id</b> and base32-encoded <b>secret_cookie</b> at time
+ * <b>now</b> for replica number <b>replica</b>. Return 0 for success,
+ * -1 otherwise. */
int
rend_compute_v2_desc_id(char *desc_id, const char *service_id_base32,
const char *secret_cookie_base32, time_t now,
@@ -121,7 +122,7 @@
"Illegal secret cookie.");
return -1;
}
- if (replica < NUMBER_OF_NON_CONSECUTIVE_REPLICAS) {
+ if (replica >= NUMBER_OF_NON_CONSECUTIVE_REPLICAS) {
log_warn(LD_REND, "Could not compute v2 descriptor ID: "
"Replica number out of range: %d", replica);
return -1;
Modified: tor/branches/114-dist-storage/src/or/rendservice.c
===================================================================
--- tor/branches/114-dist-storage/src/or/rendservice.c 2007-09-04 08:54:55 UTC (rev 11369)
+++ tor/branches/114-dist-storage/src/or/rendservice.c 2007-09-04 10:45:12 UTC (rev 11370)
@@ -1052,11 +1052,13 @@
smartlist_free(desc_strs);
smartlist_free(desc_ids);
/* Update next upload time. */
- if (seconds_valid - TIME_PERIOD_TWO_V2_DESCS < rendpostperiod)
+ if (seconds_valid - TIME_PERIOD_TWO_V2_DESCS > rendpostperiod)
+ service->next_upload_time = now + rendpostperiod;
+ else if (seconds_valid < TIME_PERIOD_TWO_V2_DESCS)
+ service->next_upload_time = now + seconds_valid + 1;
+ else
service->next_upload_time = now + seconds_valid -
TIME_PERIOD_TWO_V2_DESCS + 1;
- else
- service->next_upload_time = now + rendpostperiod;
/* Post also the next descriptors, if necessary. */
if (seconds_valid < TIME_PERIOD_TWO_V2_DESCS) {
desc_strs = smartlist_create();
Modified: tor/branches/114-dist-storage/src/or/test.c
===================================================================
--- tor/branches/114-dist-storage/src/or/test.c 2007-09-04 08:54:55 UTC (rev 11369)
+++ tor/branches/114-dist-storage/src/or/test.c 2007-09-04 10:45:12 UTC (rev 11370)
@@ -3182,9 +3182,12 @@
test_v2_rend_desc(void)
{
rend_service_descriptor_t *generated, *parsed;
+ char service_id[DIGEST_LEN];
+ char service_id_base32[REND_SERVICE_ID_LEN+1];
const char *next_desc;
smartlist_t *desc_strs = smartlist_create();
smartlist_t *desc_ids = smartlist_create();
+ char computed_desc_id[DIGEST_LEN];
char parsed_desc_id[DIGEST_LEN];
crypto_pk_env_t *pk1;
time_t now;
@@ -3198,6 +3201,8 @@
base32_encode(secret_cookie_base32, 24 + 1, secret_cookie_bin, 15);
generated = tor_malloc_zero(sizeof(rend_service_descriptor_t));
generated->pk = crypto_pk_dup_key(pk1);
+ crypto_pk_get_digest(generated->pk, service_id);
+ base32_encode(service_id_base32, REND_SERVICE_ID_LEN+1, service_id, 10);
now = time(NULL);
generated->timestamp = now;
generated->n_intro_points = 3;
@@ -3224,12 +3229,16 @@
}
test_assert(rend_encode_v2_descriptors(desc_strs, desc_ids, generated, now,
secret_cookie_base32, 0) > 0);
+ test_assert(rend_compute_v2_desc_id(computed_desc_id, service_id_base32,
+ secret_cookie_base32, now, 0) == 0);
+ test_assert(smartlist_digest_isin(desc_ids, computed_desc_id));
test_assert(rend_parse_v2_service_descriptor(&parsed, parsed_desc_id,
&intro_points_encrypted,
&intro_points_size,
&next_desc,
desc_strs->list[0]) == 0);
test_assert(parsed);
+ test_assert(smartlist_digest_isin(desc_ids, parsed_desc_id));
test_assert(rend_decrypt_introduction_points(parsed, secret_cookie_base32,
intro_points_encrypted,
intro_points_size) == 3);
More information about the tor-commits
mailing list