or_handshake_state_st.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2019, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef OR_HANDSHAKE_STATE_ST
  7. #define OR_HANDSHAKE_STATE_ST
  8. /** Stores flags and information related to the portion of a v2/v3 Tor OR
  9. * connection handshake that happens after the TLS handshake is finished.
  10. */
  11. struct or_handshake_state_t {
  12. /** When was the VERSIONS cell sent on this connection? Used to get
  13. * an estimate of the skew in the returning NETINFO reply. */
  14. time_t sent_versions_at;
  15. /** True iff we originated this connection */
  16. unsigned int started_here : 1;
  17. /** True iff we have received and processed a VERSIONS cell. */
  18. unsigned int received_versions : 1;
  19. /** True iff we have received and processed an AUTH_CHALLENGE cell */
  20. unsigned int received_auth_challenge : 1;
  21. /** True iff we have received and processed a CERTS cell. */
  22. unsigned int received_certs_cell : 1;
  23. /** True iff we have received and processed an AUTHENTICATE cell */
  24. unsigned int received_authenticate : 1;
  25. /* True iff we've received valid authentication to some identity. */
  26. unsigned int authenticated : 1;
  27. unsigned int authenticated_rsa : 1;
  28. unsigned int authenticated_ed25519 : 1;
  29. /* True iff we have sent a netinfo cell */
  30. unsigned int sent_netinfo : 1;
  31. /** The signing->ed25519 link certificate corresponding to the x509
  32. * certificate we used on the TLS connection (if this is a server-side
  33. * connection). We make a copy of this here to prevent a race condition
  34. * caused by TLS context rotation. */
  35. struct tor_cert_st *own_link_cert;
  36. /** True iff we should feed outgoing cells into digest_sent and
  37. * digest_received respectively.
  38. *
  39. * From the server's side of the v3 handshake, we want to capture everything
  40. * from the VERSIONS cell through and including the AUTH_CHALLENGE cell.
  41. * From the client's, we want to capture everything from the VERSIONS cell
  42. * through but *not* including the AUTHENTICATE cell.
  43. *
  44. * @{ */
  45. unsigned int digest_sent_data : 1;
  46. unsigned int digest_received_data : 1;
  47. /**@}*/
  48. /** Identity RSA digest that we have received and authenticated for our peer
  49. * on this connection. */
  50. uint8_t authenticated_rsa_peer_id[DIGEST_LEN];
  51. /** Identity Ed25519 public key that we have received and authenticated for
  52. * our peer on this connection. */
  53. ed25519_public_key_t authenticated_ed25519_peer_id;
  54. /** Digests of the cells that we have sent or received as part of a V3
  55. * handshake. Used for making and checking AUTHENTICATE cells.
  56. *
  57. * @{
  58. */
  59. crypto_digest_t *digest_sent;
  60. crypto_digest_t *digest_received;
  61. /** @} */
  62. /** Certificates that a connection initiator sent us in a CERTS cell; we're
  63. * holding on to them until we get an AUTHENTICATE cell.
  64. */
  65. or_handshake_certs_t *certs;
  66. };
  67. #endif