-
Notifications
You must be signed in to change notification settings - Fork 8
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
[WIP]Re-introduce support of TLS 1.3 #290
Conversation
This patch is to confirm how to merge tls1.3 prototype branch Change-Id: I821e2fa75ffcacd03671e54faab0d19d2c8bd952 CustomizedGitHooks: yes Signed-off-by: Jerry Yu <[email protected]>
#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 |
There was a problem hiding this comment.
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.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this 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
?
Closing in favor of #293 |
This is to confirm how to introduce support of TLS 1.3