Rename ssl_session.length to id_len

parent 797f48ac
...@@ -445,7 +445,7 @@ struct mbedtls_ssl_session ...@@ -445,7 +445,7 @@ struct mbedtls_ssl_session
#endif #endif
int ciphersuite; /*!< chosen ciphersuite */ int ciphersuite; /*!< chosen ciphersuite */
int compression; /*!< chosen compression */ int compression; /*!< chosen compression */
size_t length; /*!< session id length */ size_t id_len; /*!< session id length */
unsigned char id[32]; /*!< session identifier */ unsigned char id[32]; /*!< session identifier */
unsigned char master[48]; /*!< the master secret */ unsigned char master[48]; /*!< the master secret */
......
...@@ -86,11 +86,11 @@ int mbedtls_ssl_cache_get( void *data, mbedtls_ssl_session *session ) ...@@ -86,11 +86,11 @@ int mbedtls_ssl_cache_get( void *data, mbedtls_ssl_session *session )
if( session->ciphersuite != entry->session.ciphersuite || if( session->ciphersuite != entry->session.ciphersuite ||
session->compression != entry->session.compression || session->compression != entry->session.compression ||
session->length != entry->session.length ) session->id_len != entry->session.id_len )
continue; continue;
if( memcmp( session->id, entry->session.id, if( memcmp( session->id, entry->session.id,
entry->session.length ) != 0 ) entry->session.id_len ) != 0 )
continue; continue;
memcpy( session->master, entry->session.master, 48 ); memcpy( session->master, entry->session.master, 48 );
...@@ -167,7 +167,7 @@ int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session ) ...@@ -167,7 +167,7 @@ int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session )
} }
#endif #endif
if( memcmp( session->id, cur->session.id, cur->session.length ) == 0 ) if( memcmp( session->id, cur->session.id, cur->session.id_len ) == 0 )
break; /* client reconnected, keep timestamp for session id */ break; /* client reconnected, keep timestamp for session id */
#if defined(MBEDTLS_HAVE_TIME) #if defined(MBEDTLS_HAVE_TIME)
......
...@@ -587,7 +587,7 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) ...@@ -587,7 +587,7 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl )
* .. . .. extensions length (2 bytes) * .. . .. extensions length (2 bytes)
* .. . .. extensions * .. . .. extensions
*/ */
n = ssl->session_negotiate->length; n = ssl->session_negotiate->id_len;
if( n < 16 || n > 32 || if( n < 16 || n > 32 ||
#if defined(MBEDTLS_SSL_RENEGOTIATION) #if defined(MBEDTLS_SSL_RENEGOTIATION)
...@@ -615,7 +615,7 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) ...@@ -615,7 +615,7 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl )
if( ret != 0 ) if( ret != 0 )
return( ret ); return( ret );
ssl->session_negotiate->length = n = 32; ssl->session_negotiate->id_len = n = 32;
} }
} }
#endif /* MBEDTLS_SSL_SESSION_TICKETS */ #endif /* MBEDTLS_SSL_SESSION_TICKETS */
...@@ -1345,7 +1345,7 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl ) ...@@ -1345,7 +1345,7 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl )
#endif #endif
ssl->session_negotiate->ciphersuite != i || ssl->session_negotiate->ciphersuite != i ||
ssl->session_negotiate->compression != comp || ssl->session_negotiate->compression != comp ||
ssl->session_negotiate->length != n || ssl->session_negotiate->id_len != n ||
memcmp( ssl->session_negotiate->id, buf + 35, n ) != 0 ) memcmp( ssl->session_negotiate->id, buf + 35, n ) != 0 )
{ {
ssl->state++; ssl->state++;
...@@ -1355,7 +1355,7 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl ) ...@@ -1355,7 +1355,7 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl )
#endif #endif
ssl->session_negotiate->ciphersuite = i; ssl->session_negotiate->ciphersuite = i;
ssl->session_negotiate->compression = comp; ssl->session_negotiate->compression = comp;
ssl->session_negotiate->length = n; ssl->session_negotiate->id_len = n;
memcpy( ssl->session_negotiate->id, buf + 35, n ); memcpy( ssl->session_negotiate->id, buf + 35, n );
} }
else else
...@@ -2902,7 +2902,7 @@ static int ssl_parse_new_session_ticket( mbedtls_ssl_context *ssl ) ...@@ -2902,7 +2902,7 @@ static int ssl_parse_new_session_ticket( mbedtls_ssl_context *ssl )
* discards any Session ID that was sent in the ServerHello." * discards any Session ID that was sent in the ServerHello."
*/ */
MBEDTLS_SSL_DEBUG_MSG( 3, ( "ticket in use, discarding session id" ) ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "ticket in use, discarding session id" ) );
ssl->session_negotiate->length = 0; ssl->session_negotiate->id_len = 0;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse new session ticket" ) ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse new session ticket" ) );
......
...@@ -454,8 +454,8 @@ static int ssl_parse_session_ticket_ext( mbedtls_ssl_context *ssl, ...@@ -454,8 +454,8 @@ static int ssl_parse_session_ticket_ext( mbedtls_ssl_context *ssl,
* Keep the session ID sent by the client, since we MUST send it back to * Keep the session ID sent by the client, since we MUST send it back to
* inform them we're accepting the ticket (RFC 5077 section 3.4) * inform them we're accepting the ticket (RFC 5077 section 3.4)
*/ */
session.length = ssl->session_negotiate->length; session.id_len = ssl->session_negotiate->id_len;
memcpy( &session.id, ssl->session_negotiate->id, session.length ); memcpy( &session.id, ssl->session_negotiate->id, session.id_len );
mbedtls_ssl_session_free( ssl->session_negotiate ); mbedtls_ssl_session_free( ssl->session_negotiate );
memcpy( ssl->session_negotiate, &session, sizeof( mbedtls_ssl_session ) ); memcpy( ssl->session_negotiate, &session, sizeof( mbedtls_ssl_session ) );
...@@ -888,10 +888,10 @@ static int ssl_parse_client_hello_v2( mbedtls_ssl_context *ssl ) ...@@ -888,10 +888,10 @@ static int ssl_parse_client_hello_v2( mbedtls_ssl_context *ssl )
buf + 6 + ciph_len + sess_len, chal_len ); buf + 6 + ciph_len + sess_len, chal_len );
p = buf + 6 + ciph_len; p = buf + 6 + ciph_len;
ssl->session_negotiate->length = sess_len; ssl->session_negotiate->id_len = sess_len;
memset( ssl->session_negotiate->id, 0, memset( ssl->session_negotiate->id, 0,
sizeof( ssl->session_negotiate->id ) ); sizeof( ssl->session_negotiate->id ) );
memcpy( ssl->session_negotiate->id, p, ssl->session_negotiate->length ); memcpy( ssl->session_negotiate->id, p, ssl->session_negotiate->id_len );
p += sess_len; p += sess_len;
memset( ssl->handshake->randbytes, 0, 64 ); memset( ssl->handshake->randbytes, 0, 64 );
...@@ -1338,11 +1338,11 @@ read_record_header: ...@@ -1338,11 +1338,11 @@ read_record_header:
MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, session id", buf + 35, sess_len ); MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, session id", buf + 35, sess_len );
ssl->session_negotiate->length = sess_len; ssl->session_negotiate->id_len = sess_len;
memset( ssl->session_negotiate->id, 0, memset( ssl->session_negotiate->id, 0,
sizeof( ssl->session_negotiate->id ) ); sizeof( ssl->session_negotiate->id ) );
memcpy( ssl->session_negotiate->id, buf + 35, memcpy( ssl->session_negotiate->id, buf + 35,
ssl->session_negotiate->length ); ssl->session_negotiate->id_len );
/* /*
* Check the cookie length and content * Check the cookie length and content
...@@ -2180,7 +2180,7 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) ...@@ -2180,7 +2180,7 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl )
#if defined(MBEDTLS_SSL_RENEGOTIATION) #if defined(MBEDTLS_SSL_RENEGOTIATION)
ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE && ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE &&
#endif #endif
ssl->session_negotiate->length != 0 && ssl->session_negotiate->id_len != 0 &&
ssl->conf->f_get_cache != NULL && ssl->conf->f_get_cache != NULL &&
ssl->conf->f_get_cache( ssl->conf->p_cache, ssl->session_negotiate ) == 0 ) ssl->conf->f_get_cache( ssl->conf->p_cache, ssl->session_negotiate ) == 0 )
{ {
...@@ -2203,13 +2203,13 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) ...@@ -2203,13 +2203,13 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl )
#if defined(MBEDTLS_SSL_SESSION_TICKETS) #if defined(MBEDTLS_SSL_SESSION_TICKETS)
if( ssl->handshake->new_session_ticket != 0 ) if( ssl->handshake->new_session_ticket != 0 )
{ {
ssl->session_negotiate->length = n = 0; ssl->session_negotiate->id_len = n = 0;
memset( ssl->session_negotiate->id, 0, 32 ); memset( ssl->session_negotiate->id, 0, 32 );
} }
else else
#endif /* MBEDTLS_SSL_SESSION_TICKETS */ #endif /* MBEDTLS_SSL_SESSION_TICKETS */
{ {
ssl->session_negotiate->length = n = 32; ssl->session_negotiate->id_len = n = 32;
if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->session_negotiate->id, if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->session_negotiate->id,
n ) ) != 0 ) n ) ) != 0 )
return( ret ); return( ret );
...@@ -2220,7 +2220,7 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) ...@@ -2220,7 +2220,7 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl )
/* /*
* Resuming a session * Resuming a session
*/ */
n = ssl->session_negotiate->length; n = ssl->session_negotiate->id_len;
ssl->state = MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC; ssl->state = MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC;
if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 ) if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 )
...@@ -2238,9 +2238,9 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) ...@@ -2238,9 +2238,9 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl )
* 42+n . 43+n extensions length * 42+n . 43+n extensions length
* 44+n . 43+n+m extensions * 44+n . 43+n+m extensions
*/ */
*p++ = (unsigned char) ssl->session_negotiate->length; *p++ = (unsigned char) ssl->session_negotiate->id_len;
memcpy( p, ssl->session_negotiate->id, ssl->session_negotiate->length ); memcpy( p, ssl->session_negotiate->id, ssl->session_negotiate->id_len );
p += ssl->session_negotiate->length; p += ssl->session_negotiate->id_len;
MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, session id len.: %d", n ) ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, session id len.: %d", n ) );
MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, session id", buf + 39, n ); MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, session id", buf + 39, n );
......
...@@ -4610,7 +4610,7 @@ void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ) ...@@ -4610,7 +4610,7 @@ void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl )
* Add cache entry * Add cache entry
*/ */
if( ssl->conf->f_set_cache != NULL && if( ssl->conf->f_set_cache != NULL &&
ssl->session->length != 0 && ssl->session->id_len != 0 &&
resume == 0 ) resume == 0 )
{ {
if( ssl->conf->f_set_cache( ssl->conf->p_cache, ssl->session ) != 0 ) if( ssl->conf->f_set_cache( ssl->conf->p_cache, ssl->session ) != 0 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment