fix format issues

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
Jerry Yu 2021-08-30 18:32:07 +08:00
parent 995ecd396f
commit eecfbf001c
3 changed files with 53 additions and 48 deletions

View file

@ -1405,8 +1405,8 @@ static inline int mbedtls_ssl_conf_is_hybrid_tls12_tls13( const mbedtls_ssl_conf
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context* ssl, static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context *ssl,
mbedtls_ssl_states state ) mbedtls_ssl_states state )
{ {
ssl->state = state; ssl->state = state;
} }
@ -1415,29 +1415,30 @@ static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context* ssl,
* Write tls13 handshake message header * Write tls13 handshake message header
*/ */
int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl,
unsigned hs_type, unsigned hs_type,
unsigned char **buf, unsigned char **buf,
size_t *buflen ); size_t *buflen );
/* /*
* Write tls13 handshake message tail * Write tls13 handshake message tail
*/ */
int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl, int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl,
size_t buf_len, size_t buf_len,
size_t msg_len ); size_t msg_len );
/* /*
* Update checksum with handshake header * Update checksum with handshake header
*/ */
void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl,
unsigned hs_type, unsigned hs_type,
size_t total_hs_len ); size_t total_hs_len );
#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
/* /*
* Write TLS1.3 Signature Algorithm extesion * Write TLS1.3 Signature Algorithm extesion
*/ */
int mbedtls_ssl_tls13_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, int mbedtls_ssl_tls13_write_signature_algorithms_ext( mbedtls_ssl_context *ssl,
unsigned char *buf, unsigned char *end, unsigned char *buf,
size_t *olen); unsigned char *end,
size_t *olen);
#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */
#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */

View file

@ -43,9 +43,9 @@
* } SupportedVersions; * } SupportedVersions;
*/ */
static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl, static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl,
unsigned char *buf, unsigned char *buf,
unsigned char *end, unsigned char *end,
size_t *olen ) size_t *olen )
{ {
unsigned char *p = buf; unsigned char *p = buf;
@ -55,11 +55,11 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl,
MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 ); MBEDTLS_SSL_CHK_BUF_PTR( p, end, 7 );
MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0); MBEDTLS_PUT_UINT16_BE( MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS, p, 0 );
/* total length */ /* total length */
MBEDTLS_PUT_UINT16_BE( 3, p, 2); MBEDTLS_PUT_UINT16_BE( 3, p, 2);
p+=4; p += 4;
/* length of next field */ /* length of next field */
*p++ = 0x2; *p++ = 0x2;
@ -67,11 +67,13 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl,
/* This implementation only supports a single TLS version, and only /* This implementation only supports a single TLS version, and only
* advertises a single value. * advertises a single value.
*/ */
mbedtls_ssl_write_version( ssl->conf->max_major_ver, ssl->conf->max_minor_ver, mbedtls_ssl_write_version( ssl->conf->max_major_ver,
ssl->conf->transport, p ); ssl->conf->max_minor_ver,
ssl->conf->transport, p );
MBEDTLS_SSL_DEBUG_MSG( 3, ( "supported version: [%d:%d]", MBEDTLS_SSL_DEBUG_MSG( 3, ( "supported version: [%d:%d]",
ssl->conf->max_major_ver, ssl->conf->max_minor_ver ) ); ssl->conf->max_major_ver,
ssl->conf->max_minor_ver ) );
*olen = 7; *olen = 7;
@ -81,9 +83,9 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl,
#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl, static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl,
unsigned char *buf, unsigned char *buf,
unsigned char *end, unsigned char *end,
size_t *olen ) size_t *olen )
{ {
((void) ssl); ((void) ssl);
((void) buf); ((void) buf);
@ -93,9 +95,9 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl,
} }
static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl, static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl,
unsigned char *buf, unsigned char *buf,
unsigned char *end, unsigned char *end,
size_t *olen ) size_t *olen )
{ {
((void) ssl); ((void) ssl);
((void) buf); ((void) buf);
@ -109,8 +111,9 @@ static int ssl_tls13_write_key_shares_ext( mbedtls_ssl_context *ssl,
/* Functions for ClientHello */ /* Functions for ClientHello */
static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl, static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl,
unsigned char *buf, size_t buflen, unsigned char *buf,
size_t *len_with_binders ) size_t buflen,
size_t *len_with_binders )
{ {
/* Extensions */ /* Extensions */
@ -121,20 +124,20 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl,
* the total extension list size in the end. * the total extension list size in the end.
*/ */
int ret; int ret;
unsigned char* extension_start; unsigned char *extension_start;
size_t cur_ext_len; /* Size of the current extension */ size_t cur_ext_len; /* Size of the current extension */
size_t total_ext_len; /* Size of list of extensions */ size_t total_ext_len; /* Size of list of extensions */
/* Buffer management */ /* Buffer management */
unsigned char* start = buf; unsigned char *start = buf;
unsigned char* end = buf + buflen; unsigned char *end = buf + buflen;
/* Ciphersuite-related variables */ /* Ciphersuite-related variables */
const int* ciphersuites; const int *ciphersuites;
const mbedtls_ssl_ciphersuite_t* ciphersuite_info; const mbedtls_ssl_ciphersuite_t *ciphersuite_info;
/* ciphersuite_start points to the start of /* ciphersuite_start points to the start of
the ciphersuite list, i.e. to the length field*/ the ciphersuite list, i.e. to the length field*/
unsigned char* ciphersuite_start; unsigned char *ciphersuite_start;
size_t ciphersuite_count; size_t ciphersuite_count;
/* Keeping track of the included extensions */ /* Keeping track of the included extensions */
@ -167,13 +170,13 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl,
* *
* In cTLS the version number is elided. * In cTLS the version number is elided.
*/ */
MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_VERSION_LEN); MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_VERSION_LEN );
MBEDTLS_PUT_UINT16_BE( 0x0303, buf, 0); MBEDTLS_PUT_UINT16_BE( 0x0303, buf, 0);
buf += 2; buf += 2;
buflen -= CLIENT_HELLO_VERSION_LEN; buflen -= CLIENT_HELLO_VERSION_LEN;
/* Write random bytes */ /* Write random bytes */
MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_RAND_BYTES_LEN); MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_RAND_BYTES_LEN );
memcpy( buf, ssl->handshake->randbytes, CLIENT_HELLO_RAND_BYTES_LEN ); memcpy( buf, ssl->handshake->randbytes, CLIENT_HELLO_RAND_BYTES_LEN );
MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes",
buf, CLIENT_HELLO_RAND_BYTES_LEN ); buf, CLIENT_HELLO_RAND_BYTES_LEN );
@ -255,7 +258,7 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl,
} }
/* write ciphersuite length now */ /* write ciphersuite length now */
MBEDTLS_PUT_UINT16_BE( ciphersuite_count*2, ciphersuite_start, 0); MBEDTLS_PUT_UINT16_BE( ciphersuite_count*2, ciphersuite_start, 0 );
ciphersuite_start += 2; ciphersuite_start += 2;
MBEDTLS_SSL_DEBUG_MSG( 3, MBEDTLS_SSL_DEBUG_MSG( 3,
@ -340,7 +343,7 @@ static int ssl_tls13_write_exts_client_hello( mbedtls_ssl_context *ssl,
MBEDTLS_SSL_DEBUG_BUF( 3, "client hello extensions", extension_start, total_ext_len ); MBEDTLS_SSL_DEBUG_BUF( 3, "client hello extensions", extension_start, total_ext_len );
/* Write extension length */ /* Write extension length */
MBEDTLS_PUT_UINT16_BE( total_ext_len, extension_start, 0); MBEDTLS_PUT_UINT16_BE( total_ext_len, extension_start, 0 );
extension_start += 2; extension_start += 2;
*len_with_binders = ( extension_start + total_ext_len ) - start; *len_with_binders = ( extension_start + total_ext_len ) - start;

View file

@ -28,9 +28,9 @@
#include "ssl_misc.h" #include "ssl_misc.h"
int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl, int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl,
unsigned hs_type, unsigned hs_type,
unsigned char **buf, unsigned char **buf,
size_t *buflen ) size_t *buflen )
{ {
*buf = ssl->out_msg + 4; *buf = ssl->out_msg + 4;
*buflen = MBEDTLS_SSL_OUT_CONTENT_LEN - 4; *buflen = MBEDTLS_SSL_OUT_CONTENT_LEN - 4;
@ -42,8 +42,8 @@ int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl,
} }
int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl, int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl,
size_t buf_len, size_t buf_len,
size_t msg_len ) size_t msg_len )
{ {
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
((void) buf_len); ((void) buf_len);
@ -56,8 +56,8 @@ cleanup:
} }
void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl, void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl,
unsigned hs_type, unsigned hs_type,
size_t total_hs_len ) size_t total_hs_len )
{ {
unsigned char hs_hdr[4]; unsigned char hs_hdr[4];
@ -90,10 +90,11 @@ void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl,
* Only if we handle at least one key exchange that needs signatures. * Only if we handle at least one key exchange that needs signatures.
*/ */
int mbedtls_ssl_tls13_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, int mbedtls_ssl_tls13_write_signature_algorithms_ext(
unsigned char* buf, mbedtls_ssl_context *ssl,
unsigned char* end, unsigned char *buf,
size_t* olen ) unsigned char *end,
size_t *olen )
{ {
((void) ssl); ((void) ssl);
((void) buf); ((void) buf);