tls: use TLS 1.3 guards in ssl_tls13 modules
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
parent
ea59c43499
commit
c9ae862225
3 changed files with 14 additions and 14 deletions
|
@ -35,7 +35,7 @@
|
||||||
#include "ssl_debug_helpers.h"
|
#include "ssl_debug_helpers.h"
|
||||||
#include "md_psa.h"
|
#include "md_psa.h"
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED)
|
#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED)
|
||||||
/* Define a local translating function to save code size by not using too many
|
/* Define a local translating function to save code size by not using too many
|
||||||
* arguments in each translating place. */
|
* arguments in each translating place. */
|
||||||
static int local_err_translation(psa_status_t status)
|
static int local_err_translation(psa_status_t status)
|
||||||
|
@ -194,7 +194,7 @@ static int ssl_tls13_reset_key_share(mbedtls_ssl_context *ssl)
|
||||||
return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
|
return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED)
|
#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED)
|
||||||
if (mbedtls_ssl_tls13_named_group_is_ecdhe(group_id) ||
|
if (mbedtls_ssl_tls13_named_group_is_ecdhe(group_id) ||
|
||||||
mbedtls_ssl_tls13_named_group_is_ffdh(group_id)) {
|
mbedtls_ssl_tls13_named_group_is_ffdh(group_id)) {
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
|
@ -211,7 +211,7 @@ static int ssl_tls13_reset_key_share(mbedtls_ssl_context *ssl)
|
||||||
ssl->handshake->xxdh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
|
ssl->handshake->xxdh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED */
|
#endif /* MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED */
|
||||||
if (0 /* other KEMs? */) {
|
if (0 /* other KEMs? */) {
|
||||||
/* Do something */
|
/* Do something */
|
||||||
}
|
}
|
||||||
|
@ -503,7 +503,7 @@ static int ssl_tls13_parse_key_share_ext(mbedtls_ssl_context *ssl,
|
||||||
return MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE;
|
return MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED)
|
#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED)
|
||||||
if (mbedtls_ssl_tls13_named_group_is_ecdhe(group) ||
|
if (mbedtls_ssl_tls13_named_group_is_ecdhe(group) ||
|
||||||
mbedtls_ssl_tls13_named_group_is_ffdh(group)) {
|
mbedtls_ssl_tls13_named_group_is_ffdh(group)) {
|
||||||
MBEDTLS_SSL_DEBUG_MSG(2,
|
MBEDTLS_SSL_DEBUG_MSG(2,
|
||||||
|
@ -513,7 +513,7 @@ static int ssl_tls13_parse_key_share_ext(mbedtls_ssl_context *ssl,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED */
|
#endif /* MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED */
|
||||||
if (0 /* other KEMs? */) {
|
if (0 /* other KEMs? */) {
|
||||||
/* Do something */
|
/* Do something */
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#include "psa/crypto.h"
|
#include "psa/crypto.h"
|
||||||
#include "mbedtls/psa_util.h"
|
#include "mbedtls/psa_util.h"
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED)
|
#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED)
|
||||||
/* Define a local translating function to save code size by not using too many
|
/* Define a local translating function to save code size by not using too many
|
||||||
* arguments in each translating place. */
|
* arguments in each translating place. */
|
||||||
static int local_err_translation(psa_status_t status)
|
static int local_err_translation(psa_status_t status)
|
||||||
|
@ -1496,7 +1496,7 @@ int mbedtls_ssl_reset_transcript_for_hrr(mbedtls_ssl_context *ssl)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED)
|
#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED)
|
||||||
|
|
||||||
int mbedtls_ssl_tls13_read_public_xxdhe_share(mbedtls_ssl_context *ssl,
|
int mbedtls_ssl_tls13_read_public_xxdhe_share(mbedtls_ssl_context *ssl,
|
||||||
const unsigned char *buf,
|
const unsigned char *buf,
|
||||||
|
@ -1625,7 +1625,7 @@ int mbedtls_ssl_tls13_generate_and_write_xxdh_key_exchange(
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED */
|
#endif /* MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED */
|
||||||
|
|
||||||
/* RFC 8446 section 4.2
|
/* RFC 8446 section 4.2
|
||||||
*
|
*
|
||||||
|
|
|
@ -837,7 +837,7 @@ static int ssl_tls13_parse_supported_groups_ext(mbedtls_ssl_context *ssl,
|
||||||
|
|
||||||
#define SSL_TLS1_3_PARSE_KEY_SHARES_EXT_NO_MATCH 1
|
#define SSL_TLS1_3_PARSE_KEY_SHARES_EXT_NO_MATCH 1
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED)
|
#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED)
|
||||||
/*
|
/*
|
||||||
* ssl_tls13_parse_key_shares_ext() verifies whether the information in the
|
* ssl_tls13_parse_key_shares_ext() verifies whether the information in the
|
||||||
* extension is correct and stores the first acceptable key share and its
|
* extension is correct and stores the first acceptable key share and its
|
||||||
|
@ -940,7 +940,7 @@ static int ssl_tls13_parse_key_shares_ext(mbedtls_ssl_context *ssl,
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED */
|
#endif /* MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED */
|
||||||
|
|
||||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||||
static int ssl_tls13_client_hello_has_exts(mbedtls_ssl_context *ssl,
|
static int ssl_tls13_client_hello_has_exts(mbedtls_ssl_context *ssl,
|
||||||
|
@ -1563,7 +1563,7 @@ static int ssl_tls13_parse_client_hello(mbedtls_ssl_context *ssl,
|
||||||
break;
|
break;
|
||||||
#endif /* PSA_WANT_ALG_ECDH || PSA_WANT_ALG_FFDH*/
|
#endif /* PSA_WANT_ALG_ECDH || PSA_WANT_ALG_FFDH*/
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED)
|
#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED)
|
||||||
case MBEDTLS_TLS_EXT_KEY_SHARE:
|
case MBEDTLS_TLS_EXT_KEY_SHARE:
|
||||||
MBEDTLS_SSL_DEBUG_MSG(3, ("found key share extension"));
|
MBEDTLS_SSL_DEBUG_MSG(3, ("found key share extension"));
|
||||||
|
|
||||||
|
@ -1588,7 +1588,7 @@ static int ssl_tls13_parse_client_hello(mbedtls_ssl_context *ssl,
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED */
|
#endif /* MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED */
|
||||||
|
|
||||||
case MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS:
|
case MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS:
|
||||||
/* Already parsed */
|
/* Already parsed */
|
||||||
|
@ -1913,7 +1913,7 @@ static int ssl_tls13_generate_and_write_key_share(mbedtls_ssl_context *ssl,
|
||||||
|
|
||||||
*out_len = 0;
|
*out_len = 0;
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED)
|
#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED)
|
||||||
if (mbedtls_ssl_tls13_named_group_is_ecdhe(named_group) ||
|
if (mbedtls_ssl_tls13_named_group_is_ecdhe(named_group) ||
|
||||||
mbedtls_ssl_tls13_named_group_is_ffdh(named_group)) {
|
mbedtls_ssl_tls13_named_group_is_ffdh(named_group)) {
|
||||||
ret = mbedtls_ssl_tls13_generate_and_write_xxdh_key_exchange(
|
ret = mbedtls_ssl_tls13_generate_and_write_xxdh_key_exchange(
|
||||||
|
@ -1925,7 +1925,7 @@ static int ssl_tls13_generate_and_write_key_share(mbedtls_ssl_context *ssl,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_XXDH_PSA_ANY_ENABLED */
|
#endif /* MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_EPHEMERAL_ENABLED */
|
||||||
if (0 /* Other kinds of KEMs */) {
|
if (0 /* Other kinds of KEMs */) {
|
||||||
} else {
|
} else {
|
||||||
((void) ssl);
|
((void) ssl);
|
||||||
|
|
Loading…
Reference in a new issue