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
This commit is contained in:
Nick Mathewson 2007-12-01 08:47:13 +00:00
parent d8ad247dfd
commit 4a6d969139
2 changed files with 42 additions and 14 deletions

View File

@ -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

View File

@ -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;