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

[WIP]Re-introduce support of TLS 1.3 #290

Conversation

yuhaoth
Copy link
Collaborator

@yuhaoth yuhaoth commented Jul 9, 2021

This is to confirm how to introduce support of TLS 1.3

This patch is to confirm how to merge tls1.3 prototype branch

Change-Id: I821e2fa75ffcacd03671e54faab0d19d2c8bd952
CustomizedGitHooks: yes
Signed-off-by: Jerry Yu <[email protected]>
@yuhaoth yuhaoth marked this pull request as draft July 20, 2021 04:25
@hanno-becker hanno-becker changed the base branch from tls13-prototype to tls13-prototype-backup180520 July 20, 2021 04:28
@hanno-becker hanno-becker changed the base branch from tls13-prototype-backup180520 to tls13-prototype July 20, 2021 04:28
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
static inline int check_version_config(const mbedtls_ssl_config *conf)
{
if(conf->max_minor_ver==MBEDTLS_SSL_MINOR_VERSION_4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Please make sure to adhere to the Mbed TLS coding style.

Comment on lines +4422 to +4428
if(conf->max_minor_ver==MBEDTLS_SSL_MINOR_VERSION_4
&& conf->min_minor_ver == MBEDTLS_SSL_MINOR_VERSION_4)
return 0;
if(conf->max_minor_ver!=MBEDTLS_SSL_MINOR_VERSION_4
&& conf->min_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4)
return 0;
return 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(conf->max_minor_ver==MBEDTLS_SSL_MINOR_VERSION_4
&& conf->min_minor_ver == MBEDTLS_SSL_MINOR_VERSION_4)
return 0;
if(conf->max_minor_ver!=MBEDTLS_SSL_MINOR_VERSION_4
&& conf->min_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4)
return 0;
return 1;
if( conf->max_minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 &&
conf->min_minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 )
{
return( 0 );
}
if( conf->max_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4 &&
conf->min_minor_ver != MBEDTLS_SSL_MINOR_VERSION_4 )
{
return( 0 );
}
return( 1 );

@@ -4416,7 +4416,18 @@ static void ssl_mps_free( mbedtls_ssl_context *ssl )
mps_alloc_free( &ssl->mps.alloc );
}
#endif /* MEDTLS_SSL_USE_MPS */

#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
static inline int check_version_config(const mbedtls_ssl_config *conf)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give this function a more descriptive name?

@@ -4426,6 +4437,11 @@ int mbedtls_ssl_setup( mbedtls_ssl_context *ssl,
{
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;

#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
if(check_version_config(conf))
return( MBEDTLS_ERR_SSL_BAD_CONFIG );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE seems more appropriate I think.

@@ -4426,6 +4437,11 @@ int mbedtls_ssl_setup( mbedtls_ssl_context *ssl,
{
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;

#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
if(check_version_config(conf))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a short comment on what we're checking here and how it is going to change in the future?

{
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)

if(ssl->conf->max_major_ver==MBEDTLS_SSL_MAJOR_VERSION_3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivia: Coding style

mbedtls_ssl_conf_min_version( &conf, MBEDTLS_SSL_MAJOR_VERSION_3,
opt.min_version );

if( opt.max_version != DFL_MAX_VERSION )
// TAG for Jerry Yu, This is important for TLS1.3 now
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this comment be removed?

Copy link
Collaborator

@hanno-becker hanno-becker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach looks good to me, thank you @yuhaoth

If I understand correctly, the PR still needs to rename the handshake state machine functions in ssl_tls13_{client,server}.c?

@hanno-becker
Copy link
Collaborator

Closing in favor of #293

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants