[tor-commits] [tor/master] When we infer the master key from the certificate, save it to disk.

nickm at torproject.org nickm at torproject.org
Wed Aug 19 17:37:40 UTC 2015


commit 76ec8915721fa825e019821a4b045359156f8cc5
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Aug 7 15:22:23 2015 -0400

    When we infer the master key from the certificate, save it to disk.
---
 src/or/routerkeys.c     |   11 ++++++++++-
 src/test/test_keygen.sh |    4 ++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/or/routerkeys.c b/src/or/routerkeys.c
index 125fe75..2b967dd 100644
--- a/src/or/routerkeys.c
+++ b/src/or/routerkeys.c
@@ -697,11 +697,20 @@ load_ed_keys(const or_options_t *options, time_t now)
         FAIL("Missing identity key");
       } else {
         log_warn(LD_OR, "Master public key was absent; inferring from "
-                 "public key in signing certificate");
+                 "public key in signing certificate and saving to disk.");
         tor_assert(check_signing_cert);
         id = tor_malloc_zero(sizeof(*id));
         memcpy(&id->pubkey, &check_signing_cert->signing_key,
                sizeof(ed25519_public_key_t));
+        fname = options_get_datadir_fname2(options, "keys",
+                                           "ed25519_master_id_public_key");
+        if (ed25519_pubkey_write_to_file(&id->pubkey, fname, "type0") < 0) {
+          log_warn(LD_OR, "Error while attempting to write master public key "
+                   "to disk");
+          tor_free(fname);
+          goto err;
+        }
+        tor_free(fname);
       }
     }
     if (tor_mem_is_zero((char*)id->seckey.seckey, sizeof(id->seckey)))
diff --git a/src/test/test_keygen.sh b/src/test/test_keygen.sh
index 565e0a4..e8e3c3d 100755
--- a/src/test/test_keygen.sh
+++ b/src/test/test_keygen.sh
@@ -7,7 +7,7 @@ umask 077
 set -e
 
 if [ $# -eq 0 ] || [ ! -f ${1} ] || [ ! -x ${1} ]; then
-  if [ "$TESTING_TOR_BINARY" = ""] ; then
+  if [ "$TESTING_TOR_BINARY" = "" ] ; then
     echo "Usage: ${0} PATH_TO_TOR [case-number]"
     exit 1
   fi
@@ -329,7 +329,7 @@ cp "${SRC}/keys/ed25519_signing_secret_key" "${ME}/keys/"
 
 ${TOR} --DataDirectory "${ME}" --list-fingerprint >/dev/null || die "Failed when starting with only signing material"
 check_no_file "${ME}/keys/ed25519_master_id_secret_key"
-check_no_file "${ME}/keys/ed25519_master_id_public_key"
+check_file "${ME}/keys/ed25519_master_id_public_key"
 check_keys_eq ed25519_signing_secret_key
 check_keys_eq ed25519_signing_cert
 





More information about the tor-commits mailing list