Skip to content

Commit

Permalink
Merge pull request Mbed-TLS#5472 from yuhaoth/pr/move-client-auth
Browse files Browse the repository at this point in the history
Move client_auth to handshake
  • Loading branch information
mpg authored Feb 9, 2022
2 parents 9193f7d + 5c7d1cc commit 62b49cd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
5 changes: 0 additions & 5 deletions include/mbedtls/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1612,11 +1612,6 @@ struct mbedtls_ssl_context
uint16_t MBEDTLS_PRIVATE(mtu); /*!< path mtu, used to fragment outgoing messages */
#endif /* MBEDTLS_SSL_PROTO_DTLS */

/*
* PKI layer
*/
int MBEDTLS_PRIVATE(client_auth); /*!< flag for client auth. */

/*
* User settings
*/
Expand Down
10 changes: 6 additions & 4 deletions library/ssl_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -3137,12 +3137,13 @@ static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl )
}

ssl->state++;
ssl->client_auth = ( ssl->in_msg[0] == MBEDTLS_SSL_HS_CERTIFICATE_REQUEST );
ssl->handshake->client_auth =
( ssl->in_msg[0] == MBEDTLS_SSL_HS_CERTIFICATE_REQUEST );

MBEDTLS_SSL_DEBUG_MSG( 3, ( "got %s certificate request",
ssl->client_auth ? "a" : "no" ) );
ssl->handshake->client_auth ? "a" : "no" ) );

if( ssl->client_auth == 0 )
if( ssl->handshake->client_auth == 0 )
{
/* Current message is probably the ServerHelloDone */
ssl->keep_current_message = 1;
Expand Down Expand Up @@ -3794,7 +3795,8 @@ static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl )
return( 0 );
}

if( ssl->client_auth == 0 || mbedtls_ssl_own_cert( ssl ) == NULL )
if( ssl->handshake->client_auth == 0 ||
mbedtls_ssl_own_cert( ssl ) == NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write certificate verify" ) );
ssl->state++;
Expand Down
6 changes: 6 additions & 0 deletions library/ssl_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,12 @@ struct mbedtls_ssl_handshake_params
* but can be overwritten by the HRR. */
#endif /* MBEDTLS_SSL_PROTO_TLS1_3 */

#if defined(MBEDTLS_SSL_CLI_C)
uint8_t client_auth; /*!< used to check if CertificateRequest has been
received from server side. If CertificateRequest
has been received, Certificate and CertificateVerify
should be sent to server */
#endif /* MBEDTLS_SSL_CLI_C */
/*
* State-local variables used during the processing
* of a specific handshake state.
Expand Down
2 changes: 1 addition & 1 deletion library/ssl_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@ int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl )
#if defined(MBEDTLS_SSL_CLI_C)
if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT )
{
if( ssl->client_auth == 0 )
if( ssl->handshake->client_auth == 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write certificate" ) );
ssl->state++;
Expand Down

0 comments on commit 62b49cd

Please sign in to comment.