From d54d7b7ec1321bd2f6e0779aa1080f49f4bea756 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 26 Aug 2005 15:34:53 +0000 Subject: Add some documentation; move the signature generation logic into routerparse.c along with the hash generation logic; make router signing use it as well. svn:r4840 --- src/or/router.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/or/router.c') diff --git a/src/or/router.c b/src/or/router.c index 44079db608..693f32bc8e 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -857,9 +857,8 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router, { char *onion_pkey; /* Onion key, PEM-encoded. */ char *identity_pkey; /* Identity key, PEM-encoded. */ - char digest[20]; - char signature[128]; - char published[32]; + char digest[DIGEST_LEN]; + char published[ISO_TIME_LEN+1]; char fingerprint[FINGERPRINT_LEN+1]; struct in_addr in; char addrbuf[INET_NTOA_BUF_LEN]; @@ -1017,18 +1016,11 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router, if (router_get_router_hash(s, digest) < 0) return -1; - if (crypto_pk_private_sign(ident_key, signature, digest, 20) < 0) { - log_fn(LOG_WARN, "Error signing digest"); + if (router_append_dirobj_signature(s+written,maxlen-written, + digest,ident_key)<0) { + log_fn(LOG_WARN, "Couldn't sign router descriptor"); return -1; } - strlcat(s+written, "-----BEGIN SIGNATURE-----\n", maxlen-written); - written += strlen(s+written); - if (base64_encode(s+written, maxlen-written, signature, 128) < 0) { - log_fn(LOG_WARN, "Couldn't base64-encode signature"); - return -1; - } - written += strlen(s+written); - strlcat(s+written, "-----END SIGNATURE-----\n", maxlen-written); written += strlen(s+written); if (written+2 > maxlen) -- cgit v1.2.3-54-g00ecf