diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-12-01 08:47:13 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-12-01 08:47:13 +0000 |
commit | 4a6d969139df04d2c5ee82c485fff88b9e990967 (patch) | |
tree | 90861b9d058f1f9ec18631af2bd537ce5fe006c6 | |
parent | d8ad247dfdea0705de2990af68026cdf6da22430 (diff) | |
download | tor-4a6d969139df04d2c5ee82c485fff88b9e990967.tar tor-4a6d969139df04d2c5ee82c485fff88b9e990967.tar.gz |
r15094@tombo: nickm | 2007-12-01 03:46:07 -0500
server-side code (for when v2 negotiation occurred) to check for renegotiation and adjust client ID info accordingly. server-side of new TLS code is now implemented, but needs testing and debugging.
svn:r12624
-rw-r--r-- | doc/TODO | 16 | ||||
-rw-r--r-- | src/or/connection_or.c | 40 |
2 files changed, 42 insertions, 14 deletions
@@ -41,10 +41,10 @@ Things we'd like to do in 0.2.0.x: that renegotiation happens according to the old rules. o Clients initiate renegotiation immediately on completing a v2 connection. - - Servers detect renegotiation, and if there is now a client + o Servers detect renegotiation, and if there is now a client cert, they adust the client ID. o Detect. - - Adjust. + o Adjust. o Add a separate handshake structure that handles version negotiation, and stores netinfo data until authentication is done. o Revise versions and netinfo to use separate structure; make @@ -68,19 +68,17 @@ Things we'd like to do in 0.2.0.x: o Code to generate o Remember certificate digests from TLS o Code to parse and check - * Revised handshake: TLS - - Server checks for new cipher types, and if it finds them, sends - only one cert and does not ask for client certs. - - Client sends certs only if server asks for them. - - Client sends new cipher list. - - Client sends correct extension list. - - Revised handshake: post-TLS. + X Revised handshake: post-TLS. o If in 'handshaking' state (since v2+ conn is in use), accept VERSIONS and NETINFO and CERT and LINK_AUTH. o After we send NETINFO, send CERT and LINK_AUTH if needed. o Once we get a good LINK_AUTH, the connection is OPEN. - Ban most cell types on a non-OPEN connection. o Close connections on handshake failure. + - New revised handshake: post-TLS: + - start by sending VERSIONS cells + - once we have a version, send a netinfo and become open + - Ban most cell types on a non-OPEN connection. o Make code work right wrt TLS context rotation. - NETINFO fallout - Don't extend a circuit over a noncanonical connection with diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 40f18584c..2f194cd60 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -19,6 +19,9 @@ static int connection_or_process_cells_from_inbuf(or_connection_t *conn); static int connection_or_send_versions(or_connection_t *conn); static int connection_init_or_handshake_state(or_connection_t *conn, int started_here); +static int connection_or_check_valid_tls_handshake(or_connection_t *conn, + int started_here, + char *digest_rcvd_out); /**************************************************************/ @@ -573,6 +576,21 @@ connection_tls_start_handshake(or_connection_t *conn, int receiving) return 0; } +/*DOCDOC*/ +static void +connection_or_tls_renegotiated_cb(tor_tls_t *tls, void *_conn) +{ + or_connection_t *conn = _conn; + char id_digest[DIGEST_LEN]; + + if (connection_or_check_valid_tls_handshake(conn, + !tor_tls_is_server(tls), + id_digest) < 0) + return; + connection_or_init_conn_from_address(conn, conn->_base.addr, + conn->_base.port, id_digest, 0); +} + /** Move forward with the tls handshake. If it finishes, hand * <b>conn</b> to connection_tls_finish_handshake(). * @@ -594,11 +612,18 @@ connection_tls_continue_handshake(or_connection_t *conn) tor_tls_err_to_string(result)); return -1; case TOR_TLS_DONE: - if (!tor_tls_is_server(conn->tls) && - !tor_tls_used_v1_handshake(conn->tls) && - conn->_base.state == OR_CONN_STATE_TLS_HANDSHAKING) { - conn->_base.state = OR_CONN_STATE_TLS_RENEGOTIATING; - goto again; + if (tor_tls_used_v1_handshake(conn->tls)) { + if (!tor_tls_is_server(conn->tls)) { + if (conn->_base.state == OR_CONN_STATE_TLS_HANDSHAKING) { + conn->_base.state = OR_CONN_STATE_TLS_RENEGOTIATING; + goto again; + } + } else { + /* improved handshake, but not a client. */ + tor_tls_set_renegotiate_callback(conn->tls, + connection_or_tls_renegotiated_cb, + conn); + } } return connection_tls_finish_handshake(conn); case TOR_TLS_WANTWRITE: @@ -812,6 +837,11 @@ connection_tls_finish_handshake(or_connection_t *conn) } return connection_or_set_state_open(conn); } else { + if (started_here) { + if (connection_or_check_valid_tls_handshake(conn, started_here, + digest_rcvd) < 0) + return -1; + } conn->_base.state = OR_CONN_STATE_OR_HANDSHAKING; if (connection_init_or_handshake_state(conn, started_here) < 0) return -1; |