Skip to content

Commit

Permalink
create functions for tls1.3
Browse files Browse the repository at this point in the history
fix redefined error

Change-Id: Ibb97cab50ca18801b7309c36c5b816890e3674c8
CustomizedGitHooks: yes
Signed-off-by: Jerry Yu <[email protected]>
  • Loading branch information
yuhaoth committed Jul 25, 2021
1 parent 24c6f7a commit ce467cd
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions library/ssl_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,11 +709,11 @@ static void ssl_calc_finished_tls_sha384( mbedtls_ssl_context *, unsigned char *
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)

#if defined(MBEDTLS_SHA256_C)
static void ssl_update_checksum_sha256( mbedtls_ssl_context *, const unsigned char *, size_t );
static void ssl_update_checksum_sha256_tls13( mbedtls_ssl_context *, const unsigned char *, size_t );
#endif

#if defined(MBEDTLS_SHA512_C)
static void ssl_update_checksum_sha384( mbedtls_ssl_context *, const unsigned char *, size_t );
static void ssl_update_checksum_sha384_tls13( mbedtls_ssl_context *, const unsigned char *, size_t );
#endif

#if defined(MBEDTLS_SHA256_C)
Expand Down Expand Up @@ -3088,12 +3088,28 @@ void mbedtls_ssl_optimize_checksum( mbedtls_ssl_context *ssl,
#if defined(MBEDTLS_SSL_PROTO_TLS1_2) || defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
#if defined(MBEDTLS_SHA512_C)
if( ciphersuite_info->mac == MBEDTLS_MD_SHA384 )
ssl->handshake->update_checksum = ssl_update_checksum_sha384;
{
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
if(ssl->minor_ver==MBEDTLS_SSL_MINOR_VERSION_4
&& ssl->major_ver == MBEDTLS_SSL_MAJOR_VERSION_3)
ssl->handshake->update_checksum = ssl_update_checksum_sha384_tls13;
else
#endif
ssl->handshake->update_checksum = ssl_update_checksum_sha384;
}
else
#endif
#if defined(MBEDTLS_SHA256_C)
if( ciphersuite_info->mac != MBEDTLS_MD_SHA384 )
ssl->handshake->update_checksum = ssl_update_checksum_sha256;
{
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
if(ssl->minor_ver==MBEDTLS_SSL_MINOR_VERSION_4
&& ssl->major_ver == MBEDTLS_SSL_MAJOR_VERSION_3)
ssl->handshake->update_checksum = ssl_update_checksum_sha256_tls13;
else
#endif
ssl->handshake->update_checksum = ssl_update_checksum_sha256;
}
else
#endif
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
Expand Down Expand Up @@ -3133,7 +3149,7 @@ void mbedtls_ssl_reset_checksum( mbedtls_ssl_context *ssl )
#endif /* defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) */

#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
static void ssl_update_checksum_start( mbedtls_ssl_context *ssl,
static void ssl_update_checksum_start_tls13( mbedtls_ssl_context *ssl,
const unsigned char *buf, size_t len )
{
#if defined(MBEDTLS_SSL_DEBUG_HANDSHAKE_HASHES)
Expand Down Expand Up @@ -3252,7 +3268,7 @@ static void ssl_update_checksum_sha384( mbedtls_ssl_context *ssl,
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)

#if defined(MBEDTLS_SHA256_C)
static void ssl_update_checksum_sha256( mbedtls_ssl_context* ssl,
static void ssl_update_checksum_sha256_tls13( mbedtls_ssl_context* ssl,
const unsigned char* buf, size_t len )
{
int ret = 0;
Expand Down Expand Up @@ -3297,7 +3313,7 @@ exit:;
#endif /* MBEDTLS_SHA256_C */

#if defined(MBEDTLS_SHA512_C)
static void ssl_update_checksum_sha384( mbedtls_ssl_context* ssl,
static void ssl_update_checksum_sha384_tls13( mbedtls_ssl_context* ssl,
const unsigned char* buf, size_t len )
{
int ret = 0;
Expand Down Expand Up @@ -3947,7 +3963,7 @@ int mbedtls_ssl_parse_finished( mbedtls_ssl_context *ssl )
}
#endif /* defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER) */

static void ssl_handshake_params_init( mbedtls_ssl_handshake_params *handshake )
static void ssl_handshake_params_init( mbedtls_ssl_handshake_params *handshake,mbedtls_ssl_context * ssl )
{
memset( handshake, 0, sizeof( mbedtls_ssl_handshake_params ) );

Expand Down Expand Up @@ -3978,8 +3994,13 @@ static void ssl_handshake_params_init( mbedtls_ssl_handshake_params *handshake )
#endif
#endif
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 || MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */

handshake->update_checksum = ssl_update_checksum_start;
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
if(ssl->minor_ver==MBEDTLS_SSL_MINOR_VERSION_4
&& ssl->major_ver == MBEDTLS_SSL_MAJOR_VERSION_3)
handshake->update_checksum = ssl_update_checksum_start_tls13;
else
#endif
handshake->update_checksum = ssl_update_checksum_start;

#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
Expand Down Expand Up @@ -4178,7 +4199,7 @@ static int ssl_handshake_init( mbedtls_ssl_context *ssl )

/* Initialize structures */
mbedtls_ssl_session_init( ssl->session_negotiate );
ssl_handshake_params_init( ssl->handshake );
ssl_handshake_params_init( ssl->handshake, ssl);

#if defined(MBEDTLS_SSL_PROTO_TLS1_2_OR_EARLIER)
mbedtls_ssl_transform_init( ssl->transform_negotiate );
Expand Down

0 comments on commit ce467cd

Please sign in to comment.