소스 검색

r13989@Kushana: nickm | 2007-08-13 16:31:03 -0400
Actually store the v3 authority id digest of a trusteddirserver


svn:r11091

Nick Mathewson 17 년 전
부모
커밋
4e4dcb2571
4개의 변경된 파일19개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 1
      src/or/config.c
  2. 3 1
      src/or/or.h
  3. 10 1
      src/or/router.c
  4. 4 1
      src/or/routerlist.c

+ 2 - 1
src/or/config.c

@@ -3801,7 +3801,8 @@ parse_dir_server_line(const char *line, int validate_only)
     log_debug(LD_DIR, "Trusted dirserver at %s:%d (%s)", address,
               (int)dir_port,
               (char*)smartlist_get(items,0));
-    add_trusted_dir_server(nickname, address, dir_port, or_port, digest, type);
+    add_trusted_dir_server(nickname, address, dir_port, or_port, digest,
+                           v3_digest, type);
   }
 
   r = 0;

+ 3 - 1
src/or/or.h

@@ -3418,7 +3418,9 @@ int router_exit_policy_rejects_all(routerinfo_t *router);
 
 void add_trusted_dir_server(const char *nickname, const char *address,
                             uint16_t dir_port, uint16_t or_port,
-                            const char *digest, authority_type_t type);
+                            const char *digest,
+                            const char *v3_auth_digest,
+                            authority_type_t type);
 void clear_trusted_dir_servers(void);
 int any_trusted_dir_is_v1_authority(void);
 networkstatus_t *networkstatus_get_by_digest(const char *digest);

+ 10 - 1
src/or/router.c

@@ -327,6 +327,7 @@ init_keys(void)
   const char *mydesc, *datadir;
   crypto_pk_env_t *prkey;
   char digest[20];
+  char v3_digest[20];
   char *cp;
   or_options_t *options = get_options();
   or_state_t *state = get_or_state();
@@ -364,8 +365,14 @@ init_keys(void)
   }
 
   /* 1a. Read v3 directory authority key/cert information. */
-  if (authdir_mode(options) && options->V3AuthoritativeDir)
+  memset(v3_digest, 0, sizeof(v3_digest));
+  if (authdir_mode(options) && options->V3AuthoritativeDir) {
     init_v3_authority_keys(keydir);
+    if (get_my_v3_authority_cert()) {
+      crypto_pk_get_digest(get_my_v3_authority_cert()->identity_key,
+                           v3_digest);
+    }
+  }
 
   /* 1. Read identity key. Make it if none is found. */
   tor_snprintf(keydir,sizeof(keydir),
@@ -473,6 +480,7 @@ init_keys(void)
   crypto_pk_get_digest(get_identity_key(), digest);
   type = ((options->V1AuthoritativeDir ? V1_AUTHORITY : 0) |
           (options->V2AuthoritativeDir ? V2_AUTHORITY : 0) |
+          (options->V3AuthoritativeDir ? V3_AUTHORITY : 0) |
           (options->BridgeAuthoritativeDir ? BRIDGE_AUTHORITY : 0) |
           (options->HSAuthoritativeDir ? HIDSERV_AUTHORITY : 0));
 
@@ -481,6 +489,7 @@ init_keys(void)
                            (uint16_t)options->DirPort,
                            (uint16_t)options->ORPort,
                            digest,
+                           v3_digest,
                            type);
   }
   return 0; /* success */

+ 4 - 1
src/or/routerlist.c

@@ -3726,7 +3726,8 @@ router_exit_policy_rejects_all(routerinfo_t *router)
 void
 add_trusted_dir_server(const char *nickname, const char *address,
                        uint16_t dir_port, uint16_t or_port,
-                       const char *digest, authority_type_t type)
+                       const char *digest, const char *v3_auth_digest,
+                       authority_type_t type)
 {
   trusted_dir_server_t *ent;
   uint32_t a;
@@ -3761,6 +3762,8 @@ add_trusted_dir_server(const char *nickname, const char *address,
   ent->is_running = 1;
   ent->type = type;
   memcpy(ent->digest, digest, DIGEST_LEN);
+  if (v3_auth_digest)
+    memcpy(ent->v3_identity_digest, v3_auth_digest, DIGEST_LEN);
 
   dlen = 64 + strlen(hostname) + (nickname?strlen(nickname):0);
   ent->description = tor_malloc(dlen);