diff options
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/dirserv.c | 18 | ||||
-rw-r--r-- | src/or/test.c | 16 |
2 files changed, 25 insertions, 9 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 0ff8959ec2..a9e37c7074 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -557,7 +557,7 @@ dirserv_dump_directory_to_string(char *s, unsigned int maxlen, char signature[128]; char published[33]; time_t published_on; - int i, identity_pkeylen; + int i; eos = s+maxlen; if (!descriptor_list) @@ -565,14 +565,15 @@ dirserv_dump_directory_to_string(char *s, unsigned int maxlen, if (list_running_servers(&cp)) return -1; -#if 0 - /* PEM-encode the identity key key */ - if(crypto_pk_write_public_key_to_string(private_key, - &identity_pkey,&identity_pkeylen)<0) { + + /* ASN.1-encode the public key. This is a temporary measure; once + * everyone is running 0.0.9pre3 or later, we can shift to using a + * PEM-encoded key instead. + */ + if(crypto_pk_DER64_encode_public_key(private_key, &identity_pkey)<0) { log_fn(LOG_WARN,"write identity_pkey to string failed!"); return -1; } -#endif dirserv_remove_old_servers(ROUTER_MAX_AGE); published_on = time(NULL); format_iso_time(published, published_on); @@ -580,8 +581,9 @@ dirserv_dump_directory_to_string(char *s, unsigned int maxlen, "signed-directory\n" "published %s\n" "recommended-software %s\n" - "running-routers %s\n\n", - published, options.RecommendedVersions, cp); + "running-routers %s\n" + "opt dir-signing-key %s\n\n", + published, options.RecommendedVersions, cp, identity_pkey); tor_free(cp); tor_free(identity_pkey); diff --git a/src/or/test.c b/src/or/test.c index 800ad72cb0..48a30cec64 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -365,6 +365,20 @@ test_crypto() test_assert(! crypto_pk_write_public_key_to_string(pk1, &cp, &i)); test_assert(! crypto_pk_read_public_key_from_string(pk2, cp, i)); test_eq(0, crypto_pk_cmp_keys(pk1, pk2)); + tor_free(cp); + + /* Check DER encoding */ + i=crypto_pk_DER64_encode_public_key(pk1, &cp); + test_assert(i>0); + test_assert(cp); + test_assert(!strchr(cp, ' ')); + test_assert(!strchr(cp, '\n')); + test_eq(0, crypto_pk_cmp_keys(pk1, pk1)); + crypto_free_pk_env(pk2); + pk2 = crypto_pk_DER64_decode_public_key(cp); + test_assert(pk2); + test_eq(0, crypto_pk_cmp_keys(pk1, pk2)); + tor_free(cp); test_eq(128, crypto_pk_keysize(pk1)); test_eq(128, crypto_pk_keysize(pk2)); @@ -1095,6 +1109,7 @@ main(int c, char**v){ // puts("========================== Buffers ========================="); // test_buffers(); puts("\n========================== Crypto =========================="); + // add_stream_log(LOG_DEBUG, LOG_ERR, "<stdout>", stdout); test_crypto(); test_crypto_dh(); puts("\n========================= Util ============================"); @@ -1105,7 +1120,6 @@ main(int c, char**v){ test_onion(); test_onion_handshake(); puts("\n========================= Directory Formats ==============="); - /* add_stream_log(LOG_DEBUG, LOG_ERR, "<stdout>", stdout); */ test_dir_format(); puts("\n========================= Rendezvous functionality ========"); test_rend_fns(); |