Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move client_auth to handshake #5472

Merged
merged 5 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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. */
ronald-cron-arm marked this conversation as resolved.
Show resolved Hide resolved

/*
* 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 @@ -768,6 +768,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 @@ -1701,7 +1701,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