forked from Mbed-TLS/mbedtls
-
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]fix compile error for re-introducing exists options. #293
Draft
yuhaoth
wants to merge
10
commits into
hannestschofenig:tls13-prototype
Choose a base branch
from
yuhaoth:pr/fix-compile-error
base: tls13-prototype
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d855fa9
Add different options test script
yuhaoth a11a793
fix unused-function warning
yuhaoth df0e31f
fix local variables undefined error
yuhaoth 34d751d
fix mbedtls_ssl_check_cert_usage compile fail
yuhaoth 81c88ff
fix functions undeclared warnings
yuhaoth bd8e483
fix sig_hashes config error
yuhaoth 17e162b
Add conditional compilation for mbedtls_ssl_conf_dtls_cookies
yuhaoth c494232
Merge remote-tracking branches 'origin/pr/add-options-test-script', '…
yuhaoth 8917997
disable EXPORT_KEYS
yuhaoth 2306e50
Enable MBEDTLS_SSL_PROTO_*
yuhaoth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2795,7 +2795,7 @@ static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl, | |
#endif /* MBEDTLS_ECP_C */ | ||
|
||
if( mbedtls_ssl_check_cert_usage( chain, | ||
ciphersuite_info, | ||
ciphersuite_info->key_exchange, | ||
! ssl->conf->endpoint, | ||
&ssl->session_negotiate->verify_result ) != 0 ) | ||
{ | ||
|
@@ -4380,7 +4380,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) | ||
{ | ||
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; | ||
} | ||
#endif | ||
/* | ||
* Setup an SSL context | ||
*/ | ||
|
@@ -4390,6 +4401,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 ); | ||
#endif | ||
|
||
#if !defined(MBEDTLS_SSL_USE_MPS) | ||
size_t in_buf_len = MBEDTLS_SSL_IN_BUFFER_LEN; | ||
size_t out_buf_len = MBEDTLS_SSL_OUT_BUFFER_LEN; | ||
|
@@ -6407,7 +6423,8 @@ static int ssl_session_load( mbedtls_ssl_session *session, | |
const unsigned char *p = buf; | ||
const unsigned char * const end = buf + len; | ||
int minor_ver = 0; | ||
#if defined(MBEDTLS_HAVE_TIME) && defined(MBEDTLS_SSL_SESSION_TICKETS) | ||
#if defined(MBEDTLS_HAVE_TIME) \ | ||
&& defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) | ||
uint64_t start; | ||
#endif /* MBEDTLS_HAVE_TIME && MBEDTLS_SSL_SESSION_TICKETS */ | ||
|
||
|
@@ -6795,12 +6812,37 @@ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl ) | |
|
||
#if defined(MBEDTLS_SSL_CLI_C) | ||
if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) | ||
{ | ||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style |
||
|
||
if(ssl->conf->max_major_ver==MBEDTLS_SSL_MAJOR_VERSION_3 | ||
&& ssl->conf->min_major_ver==MBEDTLS_SSL_MAJOR_VERSION_3 | ||
&& ssl->conf->max_minor_ver==MBEDTLS_SSL_MINOR_VERSION_4 | ||
&& ssl->conf->min_minor_ver==MBEDTLS_SSL_MINOR_VERSION_4) | ||
ret = mbedtls_ssl_handshake_client_step_tls1_3( ssl ); | ||
else | ||
ret = mbedtls_ssl_handshake_client_step( ssl ); | ||
#else | ||
ret = mbedtls_ssl_handshake_client_step( ssl ); | ||
#endif | ||
} | ||
#endif | ||
#if defined(MBEDTLS_SSL_SRV_C) | ||
if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER ) | ||
{ | ||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) | ||
if(ssl->conf->max_major_ver==MBEDTLS_SSL_MAJOR_VERSION_3 | ||
&& ssl->conf->min_major_ver==MBEDTLS_SSL_MAJOR_VERSION_3 | ||
&& ssl->conf->max_minor_ver==MBEDTLS_SSL_MINOR_VERSION_4 | ||
&& ssl->conf->min_minor_ver==MBEDTLS_SSL_MINOR_VERSION_4) | ||
ret = mbedtls_ssl_handshake_server_step_tls1_3( ssl ); | ||
else | ||
ret = mbedtls_ssl_handshake_server_step( ssl ); | ||
#else | ||
ret = mbedtls_ssl_handshake_server_step( ssl ); | ||
#endif | ||
} | ||
#endif | ||
|
||
if( ret != 0 ) | ||
{ | ||
|
@@ -8217,14 +8259,23 @@ int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf, | |
#endif | ||
|
||
#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) | ||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) | ||
/* TLS 1.3 re-interprets the signature algorithms | ||
* and therefore we cannot include both. | ||
*/ | ||
|
||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) && defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) | ||
if(conf->max_minor_ver==MBEDTLS_SSL_MINOR_VERSION_4 | ||
&& conf->min_minor_ver == MBEDTLS_SSL_MINOR_VERSION_4) | ||
/* TLS 1.3 re-interprets the signature algorithms | ||
* and therefore we cannot include both. | ||
*/ | ||
conf->sig_hashes = ssl_preset_suiteb_signature_algorithms_tls13; | ||
else | ||
conf->sig_hashes = ssl_preset_suiteb_hashes; | ||
#else /* defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) */ | ||
conf->sig_hashes = ssl_preset_suiteb_signature_algorithms_tls13; | ||
|
||
#elif defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) | ||
conf->sig_hashes = ssl_preset_suiteb_signature_algorithms_tls13; | ||
#elif defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) | ||
conf->sig_hashes = ssl_preset_suiteb_hashes; | ||
#endif /* !defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) */ | ||
|
||
#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ | ||
|
||
#if defined(MBEDTLS_ECP_C) | ||
|
@@ -8274,13 +8325,21 @@ int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf, | |
#endif | ||
|
||
#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) | ||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) | ||
conf->sig_hashes = ssl_preset_default_hashes; | ||
#else /* defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) */ | ||
|
||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) && defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) | ||
if(conf->max_minor_ver==MBEDTLS_SSL_MINOR_VERSION_4 | ||
&& conf->min_minor_ver == MBEDTLS_SSL_MINOR_VERSION_4) | ||
conf->sig_hashes = ssl_preset_suiteb_signature_algorithms_tls13; | ||
else | ||
conf->sig_hashes = ssl_preset_default_hashes; | ||
#elif defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) | ||
conf->sig_hashes = ssl_preset_suiteb_signature_algorithms_tls13; | ||
#endif /* !defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) */ | ||
#elif defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) | ||
conf->sig_hashes = ssl_preset_default_hashes; | ||
#endif /* defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) */ | ||
|
||
#endif | ||
|
||
#if defined(MBEDTLS_ECP_C) | ||
conf->curve_list = mbedtls_ecp_grp_id_list(); | ||
#endif | ||
|
@@ -8538,17 +8597,10 @@ int mbedtls_ssl_check_sig_hash( const mbedtls_ssl_context *ssl, | |
#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ | ||
|
||
#if defined(MBEDTLS_X509_CRT_PARSE_C) | ||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) | ||
int mbedtls_ssl_check_cert_usage( const mbedtls_x509_crt* cert, | ||
const mbedtls_key_exchange_type_t key_exchange, | ||
int cert_endpoint, | ||
uint32_t* flags ) | ||
#else | ||
int mbedtls_ssl_check_cert_usage( const mbedtls_x509_crt* cert, | ||
const mbedtls_ssl_ciphersuite_t* ciphersuite, | ||
int cert_endpoint, | ||
uint32_t* flags ) | ||
#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ | ||
{ | ||
int ret = 0; | ||
#if defined(MBEDTLS_X509_CHECK_KEY_USAGE) | ||
|
@@ -8570,11 +8622,7 @@ int mbedtls_ssl_check_cert_usage( const mbedtls_x509_crt* cert, | |
if( cert_endpoint == MBEDTLS_SSL_IS_SERVER ) | ||
{ | ||
/* Server part of the key exchange */ | ||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) | ||
switch( ciphersuite->key_exchange ) | ||
#else /* defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) */ | ||
switch( key_exchange ) | ||
#endif /* !defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) */ | ||
{ | ||
case MBEDTLS_KEY_EXCHANGE_RSA: | ||
case MBEDTLS_KEY_EXCHANGE_RSA_PSK: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2151,7 +2151,10 @@ int main( int argc, char *argv[] ) | |
mbedtls_printf( "Warning: event-driven IO mandates nbio=1 - overwrite\n" ); | ||
opt.nbio = 1; | ||
} | ||
|
||
#if defined(MBEDTLS_DISABLE_NONBLOCK_IO) | ||
// TODO: if #238 is fixed , This should be removed | ||
opt.nbio = 0; | ||
#endif | ||
#if defined(MBEDTLS_DEBUG_C) | ||
mbedtls_debug_set_threshold( opt.debug_level ); | ||
#endif | ||
|
@@ -3017,10 +3020,12 @@ int main( int argc, char *argv[] ) | |
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */ | ||
|
||
if( opt.min_version != DFL_MIN_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 commentThe reason will be displayed to describe this comment to others. Learn more. Can this comment be removed? |
||
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 | ||
mbedtls_ssl_conf_max_version( &conf, MBEDTLS_SSL_MAJOR_VERSION_3, | ||
opt.max_version ); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Same comment as in #290 - style adherence and more descriptive name needed.