|
@@ -985,94 +985,6 @@ router_is_active(const routerinfo_t *ri, const node_t *node, time_t now)
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- * Point *<b>dir_out</b> to the allocated string. Sign the
|
|
|
- * directory with <b>private_key</b>. Return 0 on success, -1 on
|
|
|
- * failure. If <b>complete</b> is set, give us all the descriptors;
|
|
|
- * otherwise leave out non-running and non-valid ones.
|
|
|
- */
|
|
|
-int
|
|
|
-dirserv_dump_directory_to_string(char **dir_out,
|
|
|
- crypto_pk_t *private_key)
|
|
|
-{
|
|
|
-
|
|
|
- * fetching these any longer */
|
|
|
- char *cp;
|
|
|
- char *identity_pkey;
|
|
|
- char *recommended_versions;
|
|
|
- char digest[DIGEST_LEN];
|
|
|
- char published[ISO_TIME_LEN+1];
|
|
|
- char *buf = NULL;
|
|
|
- size_t buf_len;
|
|
|
- size_t identity_pkey_len;
|
|
|
- time_t now = time(NULL);
|
|
|
-
|
|
|
- tor_assert(dir_out);
|
|
|
- *dir_out = NULL;
|
|
|
-
|
|
|
- if (crypto_pk_write_public_key_to_string(private_key,&identity_pkey,
|
|
|
- &identity_pkey_len)<0) {
|
|
|
- log_warn(LD_BUG,"write identity_pkey to string failed!");
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- recommended_versions =
|
|
|
- format_versions_list(get_options()->RecommendedVersions);
|
|
|
-
|
|
|
- format_iso_time(published, now);
|
|
|
-
|
|
|
- buf_len = 2048+strlen(recommended_versions);
|
|
|
-
|
|
|
- buf = tor_malloc(buf_len);
|
|
|
-
|
|
|
- function, though strictly speaking we shouldn't be able to exceed
|
|
|
- it. This is C, after all, so we may as well check for buffer
|
|
|
- overruns.*/
|
|
|
-
|
|
|
- tor_snprintf(buf, buf_len,
|
|
|
- "signed-directory\n"
|
|
|
- "published %s\n"
|
|
|
- "recommended-software %s\n"
|
|
|
- "router-status %s\n"
|
|
|
- "dir-signing-key\n%s\n",
|
|
|
- published, recommended_versions, "",
|
|
|
- identity_pkey);
|
|
|
-
|
|
|
- tor_free(recommended_versions);
|
|
|
- tor_free(identity_pkey);
|
|
|
-
|
|
|
- cp = buf + strlen(buf);
|
|
|
- *cp = '\0';
|
|
|
-
|
|
|
-
|
|
|
- signature. */
|
|
|
- if (strlcat(buf, "directory-signature ", buf_len) >= buf_len)
|
|
|
- goto truncated;
|
|
|
- if (strlcat(buf, get_options()->Nickname, buf_len) >= buf_len)
|
|
|
- goto truncated;
|
|
|
- if (strlcat(buf, "\n", buf_len) >= buf_len)
|
|
|
- goto truncated;
|
|
|
-
|
|
|
- if (router_get_dir_hash(buf,digest)) {
|
|
|
- log_warn(LD_BUG,"couldn't compute digest");
|
|
|
- tor_free(buf);
|
|
|
- return -1;
|
|
|
- }
|
|
|
- note_crypto_pk_op(SIGN_DIR);
|
|
|
- if (router_append_dirobj_signature(buf,buf_len,digest,DIGEST_LEN,
|
|
|
- private_key)<0) {
|
|
|
- tor_free(buf);
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- *dir_out = buf;
|
|
|
- return 0;
|
|
|
- truncated:
|
|
|
- log_warn(LD_BUG,"tried to exceed string length.");
|
|
|
- tor_free(buf);
|
|
|
- return -1;
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
|
|
|
|