Extract signed_descriptor_t into its own header.

This commit is contained in:
Nick Mathewson 2018-06-15 14:53:07 -04:00
parent ed0731c7de
commit 03fc83ab6d
6 changed files with 67 additions and 47 deletions

View File

@ -7,6 +7,8 @@
#ifndef AUTHORITY_CERT_ST_H #ifndef AUTHORITY_CERT_ST_H
#define AUTHORITY_CERT_ST_H #define AUTHORITY_CERT_ST_H
#include "signed_descriptor_st.h"
/** Certificate for v3 directory protocol: binds long-term authority identity /** Certificate for v3 directory protocol: binds long-term authority identity
* keys to medium-term authority signing keys. */ * keys to medium-term authority signing keys. */
struct authority_cert_t { struct authority_cert_t {

View File

@ -7,6 +7,8 @@
#ifndef EXTRAINFO_ST_H #ifndef EXTRAINFO_ST_H
#define EXTRAINFO_ST_H #define EXTRAINFO_ST_H
#include "signed_descriptor_st.h"
/** Information needed to keep and cache a signed extra-info document. */ /** Information needed to keep and cache a signed extra-info document. */
struct extrainfo_t { struct extrainfo_t {
signed_descriptor_t cache_info; signed_descriptor_t cache_info;

View File

@ -307,6 +307,7 @@ ORHEADERS = \
src/or/scheduler.h \ src/or/scheduler.h \
src/or/server_port_cfg_st.h \ src/or/server_port_cfg_st.h \
src/or/shared_random_client.h \ src/or/shared_random_client.h \
src/or/signed_descriptor_st.h \
src/or/socks_request_st.h \ src/or/socks_request_st.h \
src/or/statefile.h \ src/or/statefile.h \
src/or/status.h \ src/or/status.h \

View File

@ -1511,53 +1511,7 @@ typedef struct download_status_t {
* create any that are larger than this. */ * create any that are larger than this. */
#define ROUTER_ANNOTATION_BUF_LEN 256 #define ROUTER_ANNOTATION_BUF_LEN 256
/** Information need to cache an onion router's descriptor. */ typedef struct signed_descriptor_t signed_descriptor_t;
typedef struct signed_descriptor_t {
/** Pointer to the raw server descriptor, preceded by annotations. Not
* necessarily NUL-terminated. If saved_location is SAVED_IN_CACHE, this
* pointer is null. */
char *signed_descriptor_body;
/** Length of the annotations preceding the server descriptor. */
size_t annotations_len;
/** Length of the server descriptor. */
size_t signed_descriptor_len;
/** Digest of the server descriptor, computed as specified in
* dir-spec.txt. */
char signed_descriptor_digest[DIGEST_LEN];
/** Identity digest of the router. */
char identity_digest[DIGEST_LEN];
/** Declared publication time of the descriptor. */
time_t published_on;
/** For routerdescs only: digest of the corresponding extrainfo. */
char extra_info_digest[DIGEST_LEN];
/** For routerdescs only: A SHA256-digest of the extrainfo (if any) */
char extra_info_digest256[DIGEST256_LEN];
/** Certificate for ed25519 signing key. */
struct tor_cert_st *signing_key_cert;
/** For routerdescs only: Status of downloading the corresponding
* extrainfo. */
download_status_t ei_dl_status;
/** Where is the descriptor saved? */
saved_location_t saved_location;
/** If saved_location is SAVED_IN_CACHE or SAVED_IN_JOURNAL, the offset of
* this descriptor in the corresponding file. */
off_t saved_offset;
/** What position is this descriptor within routerlist->routers or
* routerlist->old_routers? -1 for none. */
int routerlist_index;
/** The valid-until time of the most recent consensus that listed this
* descriptor. 0 for "never listed in a consensus, so far as we know." */
time_t last_listed_as_valid_until;
/* If true, we do not ever try to save this object in the cache. */
unsigned int do_not_cache : 1;
/* If true, this item is meant to represent an extrainfo. */
unsigned int is_extrainfo : 1;
/* If true, we got an extrainfo for this item, and the digest was right,
* but it was incompatible. */
unsigned int extrainfo_is_bogus : 1;
/* If true, we are willing to transmit this item unencrypted. */
unsigned int send_unencrypted : 1;
} signed_descriptor_t;
/** A signed integer representing a country code. */ /** A signed integer representing a country code. */
typedef int16_t country_t; typedef int16_t country_t;

View File

@ -7,6 +7,8 @@
#ifndef ROUTERINFO_ST_H #ifndef ROUTERINFO_ST_H
#define ROUTERINFO_ST_H #define ROUTERINFO_ST_H
#include "signed_descriptor_st.h"
/** Information about another onion router in the network. */ /** Information about another onion router in the network. */
struct routerinfo_t { struct routerinfo_t {
signed_descriptor_t cache_info; signed_descriptor_t cache_info;

View File

@ -0,0 +1,59 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2017, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef SIGNED_DESCRIPTOR_ST_H
#define SIGNED_DESCRIPTOR_ST_H
/** Information need to cache an onion router's descriptor. */
struct signed_descriptor_t {
/** Pointer to the raw server descriptor, preceded by annotations. Not
* necessarily NUL-terminated. If saved_location is SAVED_IN_CACHE, this
* pointer is null. */
char *signed_descriptor_body;
/** Length of the annotations preceding the server descriptor. */
size_t annotations_len;
/** Length of the server descriptor. */
size_t signed_descriptor_len;
/** Digest of the server descriptor, computed as specified in
* dir-spec.txt. */
char signed_descriptor_digest[DIGEST_LEN];
/** Identity digest of the router. */
char identity_digest[DIGEST_LEN];
/** Declared publication time of the descriptor. */
time_t published_on;
/** For routerdescs only: digest of the corresponding extrainfo. */
char extra_info_digest[DIGEST_LEN];
/** For routerdescs only: A SHA256-digest of the extrainfo (if any) */
char extra_info_digest256[DIGEST256_LEN];
/** Certificate for ed25519 signing key. */
struct tor_cert_st *signing_key_cert;
/** For routerdescs only: Status of downloading the corresponding
* extrainfo. */
download_status_t ei_dl_status;
/** Where is the descriptor saved? */
saved_location_t saved_location;
/** If saved_location is SAVED_IN_CACHE or SAVED_IN_JOURNAL, the offset of
* this descriptor in the corresponding file. */
off_t saved_offset;
/** What position is this descriptor within routerlist->routers or
* routerlist->old_routers? -1 for none. */
int routerlist_index;
/** The valid-until time of the most recent consensus that listed this
* descriptor. 0 for "never listed in a consensus, so far as we know." */
time_t last_listed_as_valid_until;
/* If true, we do not ever try to save this object in the cache. */
unsigned int do_not_cache : 1;
/* If true, this item is meant to represent an extrainfo. */
unsigned int is_extrainfo : 1;
/* If true, we got an extrainfo for this item, and the digest was right,
* but it was incompatible. */
unsigned int extrainfo_is_bogus : 1;
/* If true, we are willing to transmit this item unencrypted. */
unsigned int send_unencrypted : 1;
};
#endif