[tor-commits] [tor/master] Split or_handshake_{certs, state}_t into their own headers.

nickm at torproject.org nickm at torproject.org
Mon Jun 18 18:18:42 UTC 2018


commit bcc283bcc90ed5ef6f8da22b63df01aea1794b2a
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Jun 15 10:56:15 2018 -0400

    Split or_handshake_{certs,state}_t into their own headers.
---
 src/or/channeltls.c            |  2 +
 src/or/connection_or.c         |  2 +
 src/or/include.am              |  2 +
 src/or/or.h                    | 96 +-----------------------------------------
 src/or/or_handshake_certs_st.h | 39 +++++++++++++++++
 src/or/or_handshake_state_st.h | 78 ++++++++++++++++++++++++++++++++++
 src/or/torcert.c               |  2 +
 src/test/test_link_handshake.c |  2 +
 8 files changed, 129 insertions(+), 94 deletions(-)

diff --git a/src/or/channeltls.c b/src/or/channeltls.c
index 20a4d37b4..4d5677821 100644
--- a/src/or/channeltls.c
+++ b/src/or/channeltls.c
@@ -61,6 +61,8 @@
 #include "channelpadding.h"
 
 #include "or_connection_st.h"
+#include "or_handshake_certs_st.h"
+#include "or_handshake_state_st.h"
 
 /** How many CELL_PADDING cells have we received, ever? */
 uint64_t stats_n_padding_cells_processed = 0;
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index c2dd36416..070253dce 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -62,6 +62,8 @@
 #include "channelpadding.h"
 
 #include "or_connection_st.h"
+#include "or_handshake_certs_st.h"
+#include "or_handshake_state_st.h"
 
 static int connection_tls_finish_handshake(or_connection_t *conn);
 static int connection_or_launch_v3_or_handshake(or_connection_t *conn);
diff --git a/src/or/include.am b/src/or/include.am
index 673e43ece..f3bbaa11c 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -250,6 +250,8 @@ ORHEADERS = \
 	src/or/onion_tap.h				\
 	src/or/or.h					\
 	src/or/or_connection_st.h			\
+	src/or/or_handshake_certs_st.h			\
+	src/or/or_handshake_state_st.h			\
 	src/or/transports.h				\
 	src/or/parsecommon.h			\
 	src/or/periodic.h				\
diff --git a/src/or/or.h b/src/or/or.h
index 2a69415e1..990f7f94e 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1440,100 +1440,8 @@ typedef struct connection_t {
  * signs. */
 #define V3_AUTH_BODY_LEN (V3_AUTH_FIXED_PART_LEN + 8 + 16)
 
-/** Structure to hold all the certificates we've received on an OR connection
- */
-typedef struct or_handshake_certs_t {
-  /** True iff we originated this connection. */
-  int started_here;
-  /** The cert for the 'auth' RSA key that's supposed to sign the AUTHENTICATE
-   * cell. Signed with the RSA identity key. */
-  tor_x509_cert_t *auth_cert;
-  /** The cert for the 'link' RSA key that was used to negotiate the TLS
-   *  connection.  Signed with the RSA identity key. */
-  tor_x509_cert_t *link_cert;
-  /** A self-signed identity certificate: the RSA identity key signed
-   * with itself.  */
-  tor_x509_cert_t *id_cert;
-  /** The Ed25519 signing key, signed with the Ed25519 identity key. */
-  struct tor_cert_st *ed_id_sign;
-  /** A digest of the X509 link certificate for the TLS connection, signed
-   * with the Ed25519 siging key. */
-  struct tor_cert_st *ed_sign_link;
-  /** The Ed25519 authentication key (that's supposed to sign an AUTHENTICATE
-   * cell) , signed with the Ed25519 siging key. */
-  struct tor_cert_st *ed_sign_auth;
-  /** The Ed25519 identity key, crosssigned with the RSA identity key. */
-  uint8_t *ed_rsa_crosscert;
-  /** The length of <b>ed_rsa_crosscert</b> in bytes */
-  size_t ed_rsa_crosscert_len;
-} or_handshake_certs_t;
-
-/** Stores flags and information related to the portion of a v2/v3 Tor OR
- * connection handshake that happens after the TLS handshake is finished.
- */
-typedef struct or_handshake_state_t {
-  /** When was the VERSIONS cell sent on this connection?  Used to get
-   * an estimate of the skew in the returning NETINFO reply. */
-  time_t sent_versions_at;
-  /** True iff we originated this connection */
-  unsigned int started_here : 1;
-  /** True iff we have received and processed a VERSIONS cell. */
-  unsigned int received_versions : 1;
-  /** True iff we have received and processed an AUTH_CHALLENGE cell */
-  unsigned int received_auth_challenge : 1;
-  /** True iff we have received and processed a CERTS cell. */
-  unsigned int received_certs_cell : 1;
-  /** True iff we have received and processed an AUTHENTICATE cell */
-  unsigned int received_authenticate : 1;
-
-  /* True iff we've received valid authentication to some identity. */
-  unsigned int authenticated : 1;
-  unsigned int authenticated_rsa : 1;
-  unsigned int authenticated_ed25519 : 1;
-
-  /* True iff we have sent a netinfo cell */
-  unsigned int sent_netinfo : 1;
-
-  /** The signing->ed25519 link certificate corresponding to the x509
-   * certificate we used on the TLS connection (if this is a server-side
-   * connection). We make a copy of this here to prevent a race condition
-   * caused by TLS context rotation. */
-  struct tor_cert_st *own_link_cert;
-
-  /** True iff we should feed outgoing cells into digest_sent and
-   * digest_received respectively.
-   *
-   * From the server's side of the v3 handshake, we want to capture everything
-   * from the VERSIONS cell through and including the AUTH_CHALLENGE cell.
-   * From the client's, we want to capture everything from the VERSIONS cell
-   * through but *not* including the AUTHENTICATE cell.
-   *
-   * @{ */
-  unsigned int digest_sent_data : 1;
-  unsigned int digest_received_data : 1;
-  /**@}*/
-
-  /** Identity RSA digest that we have received and authenticated for our peer
-   * on this connection. */
-  uint8_t authenticated_rsa_peer_id[DIGEST_LEN];
-  /** Identity Ed25519 public key that we have received and authenticated for
-   * our peer on this connection. */
-  ed25519_public_key_t authenticated_ed25519_peer_id;
-
-  /** Digests of the cells that we have sent or received as part of a V3
-   * handshake.  Used for making and checking AUTHENTICATE cells.
-   *
-   * @{
-   */
-  crypto_digest_t *digest_sent;
-  crypto_digest_t *digest_received;
-  /** @} */
-
-  /** Certificates that a connection initiator sent us in a CERTS cell; we're
-   * holding on to them until we get an AUTHENTICATE cell.
-   */
-  or_handshake_certs_t *certs;
-} or_handshake_state_t;
+typedef struct or_handshake_certs_t or_handshake_certs_t;
+typedef struct or_handshake_state_t or_handshake_state_t;
 
 /** Length of Extended ORPort connection identifier. */
 #define EXT_OR_CONN_ID_LEN DIGEST_LEN /* 20 */
diff --git a/src/or/or_handshake_certs_st.h b/src/or/or_handshake_certs_st.h
new file mode 100644
index 000000000..515866af7
--- /dev/null
+++ b/src/or/or_handshake_certs_st.h
@@ -0,0 +1,39 @@
+/* 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 OR_HANDSHAKE_CERTS_ST
+#define OR_HANDSHAKE_CERTS_ST
+
+/** Structure to hold all the certificates we've received on an OR connection
+ */
+struct or_handshake_certs_t {
+  /** True iff we originated this connection. */
+  int started_here;
+  /** The cert for the 'auth' RSA key that's supposed to sign the AUTHENTICATE
+   * cell. Signed with the RSA identity key. */
+  tor_x509_cert_t *auth_cert;
+  /** The cert for the 'link' RSA key that was used to negotiate the TLS
+   *  connection.  Signed with the RSA identity key. */
+  tor_x509_cert_t *link_cert;
+  /** A self-signed identity certificate: the RSA identity key signed
+   * with itself.  */
+  tor_x509_cert_t *id_cert;
+  /** The Ed25519 signing key, signed with the Ed25519 identity key. */
+  struct tor_cert_st *ed_id_sign;
+  /** A digest of the X509 link certificate for the TLS connection, signed
+   * with the Ed25519 siging key. */
+  struct tor_cert_st *ed_sign_link;
+  /** The Ed25519 authentication key (that's supposed to sign an AUTHENTICATE
+   * cell) , signed with the Ed25519 siging key. */
+  struct tor_cert_st *ed_sign_auth;
+  /** The Ed25519 identity key, crosssigned with the RSA identity key. */
+  uint8_t *ed_rsa_crosscert;
+  /** The length of <b>ed_rsa_crosscert</b> in bytes */
+  size_t ed_rsa_crosscert_len;
+};
+
+#endif
+
diff --git a/src/or/or_handshake_state_st.h b/src/or/or_handshake_state_st.h
new file mode 100644
index 000000000..d0e3adaef
--- /dev/null
+++ b/src/or/or_handshake_state_st.h
@@ -0,0 +1,78 @@
+/* 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 OR_HANDSHAKE_STATE_ST
+#define OR_HANDSHAKE_STATE_ST
+
+/** Stores flags and information related to the portion of a v2/v3 Tor OR
+ * connection handshake that happens after the TLS handshake is finished.
+ */
+struct or_handshake_state_t {
+  /** When was the VERSIONS cell sent on this connection?  Used to get
+   * an estimate of the skew in the returning NETINFO reply. */
+  time_t sent_versions_at;
+  /** True iff we originated this connection */
+  unsigned int started_here : 1;
+  /** True iff we have received and processed a VERSIONS cell. */
+  unsigned int received_versions : 1;
+  /** True iff we have received and processed an AUTH_CHALLENGE cell */
+  unsigned int received_auth_challenge : 1;
+  /** True iff we have received and processed a CERTS cell. */
+  unsigned int received_certs_cell : 1;
+  /** True iff we have received and processed an AUTHENTICATE cell */
+  unsigned int received_authenticate : 1;
+
+  /* True iff we've received valid authentication to some identity. */
+  unsigned int authenticated : 1;
+  unsigned int authenticated_rsa : 1;
+  unsigned int authenticated_ed25519 : 1;
+
+  /* True iff we have sent a netinfo cell */
+  unsigned int sent_netinfo : 1;
+
+  /** The signing->ed25519 link certificate corresponding to the x509
+   * certificate we used on the TLS connection (if this is a server-side
+   * connection). We make a copy of this here to prevent a race condition
+   * caused by TLS context rotation. */
+  struct tor_cert_st *own_link_cert;
+
+  /** True iff we should feed outgoing cells into digest_sent and
+   * digest_received respectively.
+   *
+   * From the server's side of the v3 handshake, we want to capture everything
+   * from the VERSIONS cell through and including the AUTH_CHALLENGE cell.
+   * From the client's, we want to capture everything from the VERSIONS cell
+   * through but *not* including the AUTHENTICATE cell.
+   *
+   * @{ */
+  unsigned int digest_sent_data : 1;
+  unsigned int digest_received_data : 1;
+  /**@}*/
+
+  /** Identity RSA digest that we have received and authenticated for our peer
+   * on this connection. */
+  uint8_t authenticated_rsa_peer_id[DIGEST_LEN];
+  /** Identity Ed25519 public key that we have received and authenticated for
+   * our peer on this connection. */
+  ed25519_public_key_t authenticated_ed25519_peer_id;
+
+  /** Digests of the cells that we have sent or received as part of a V3
+   * handshake.  Used for making and checking AUTHENTICATE cells.
+   *
+   * @{
+   */
+  crypto_digest_t *digest_sent;
+  crypto_digest_t *digest_received;
+  /** @} */
+
+  /** Certificates that a connection initiator sent us in a CERTS cell; we're
+   * holding on to them until we get an AUTHENTICATE cell.
+   */
+  or_handshake_certs_t *certs;
+};
+
+#endif
+
diff --git a/src/or/torcert.c b/src/or/torcert.c
index 1c5afd965..5a156f18d 100644
--- a/src/or/torcert.c
+++ b/src/or/torcert.c
@@ -35,6 +35,8 @@
 #include "compat.h"
 #include "link_handshake.h"
 
+#include "or_handshake_certs_st.h"
+
 /** Helper for tor_cert_create(): signs any 32 bytes, not just an ed25519
  * key.
  */
diff --git a/src/test/test_link_handshake.c b/src/test/test_link_handshake.c
index 94e784cdc..1c2e91b83 100644
--- a/src/test/test_link_handshake.c
+++ b/src/test/test_link_handshake.c
@@ -22,6 +22,8 @@
 #include "torcert.h"
 
 #include "or_connection_st.h"
+#include "or_handshake_certs_st.h"
+#include "or_handshake_state_st.h"
 
 #include "test.h"
 #include "log_test_helpers.h"





More information about the tor-commits mailing list