Style fixes
1. Fix indentations.
2. Remove redundant whitespaces.
3. Keep short lines.
4. Grammar fixes.
5. Rephrase function description.
Signed-off-by: Johan Pascal <johan.pascal@belledonne-communications.com>
diff --git a/library/ssl_cli.c b/library/ssl_cli.c
index 8335f00..13547ce 100644
--- a/library/ssl_cli.c
+++ b/library/ssl_cli.c
@@ -756,9 +756,9 @@
}
#endif /* MBEDTLS_SSL_ALPN */
-#if defined (MBEDTLS_SSL_DTLS_SRTP)
+#if defined(MBEDTLS_SSL_DTLS_SRTP)
static void ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl,
- unsigned char *buf, size_t *olen )
+ unsigned char *buf, size_t *olen )
{
unsigned char *p = buf;
size_t protection_profiles_index = 0;
@@ -766,8 +766,8 @@
*olen = 0;
- if( (ssl->conf->dtls_srtp_profile_list == NULL) ||
- (ssl->conf->dtls_srtp_profile_list_len == 0) )
+ if( ( ssl->conf->dtls_srtp_profile_list == NULL ) ||
+ ( ssl->conf->dtls_srtp_profile_list_len == 0 ) )
{
return;
}
@@ -777,14 +777,13 @@
*p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_USE_SRTP >> 8 ) & 0xFF );
*p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_USE_SRTP ) & 0xFF );
- /* RFC5764 section 4.1.1
+ /* RFC 5764 section 4.1.1
* uint8 SRTPProtectionProfile[2];
*
* struct {
* SRTPProtectionProfiles SRTPProtectionProfiles;
* opaque srtp_mki<0..255>;
* } UseSRTPData;
-
* SRTPProtectionProfile SRTPProtectionProfiles<2..2^16-1>;
*/
if( ssl->conf->dtls_srtp_mki_support == MBEDTLS_SSL_DTLS_SRTP_MKI_SUPPORTED &&
@@ -811,7 +810,7 @@
protection_profiles_index < ssl->conf->dtls_srtp_profile_list_len;
protection_profiles_index++ )
{
- switch (ssl->conf->dtls_srtp_profile_list[protection_profiles_index]) {
+ switch( ssl->conf->dtls_srtp_profile_list[protection_profiles_index] ) {
case MBEDTLS_SRTP_AES128_CM_HMAC_SHA1_80:
MBEDTLS_SSL_DEBUG_MSG( 3, ( "ssl_write_use_srtp_ext, add profile: %04x",
MBEDTLS_SRTP_AES128_CM_HMAC_SHA1_80_IANA_VALUE ) );
@@ -848,7 +847,7 @@
* is checked by ssl_set_dtls_srtp_protection_profiles function
*/
MBEDTLS_SSL_DEBUG_MSG( 1, ( "client hello, ignore illegal DTLS-SRTP protection profile %d",
- ssl->conf->dtls_srtp_profile_list[protection_profiles_index]) );
+ ssl->conf->dtls_srtp_profile_list[protection_profiles_index] ) );
break;
}
}
@@ -1853,7 +1852,7 @@
ssl->conf->dtls_srtp_profile_list_len == 0 )
return( 0 );
- /* RFC5764 section 4.1.1
+ /* RFC 5764 section 4.1.1
* uint8 SRTPProtectionProfile[2];
*
* struct {
@@ -1954,11 +1953,11 @@
#if defined (MBEDTLS_DEBUG_C)
if( len > 5 )
{
- MBEDTLS_SSL_DEBUG_BUF( 3, "received mki", ssl->dtls_srtp_info.mki_value,
- ssl->dtls_srtp_info.mki_len );
+ MBEDTLS_SSL_DEBUG_BUF( 3, "received mki", ssl->dtls_srtp_info.mki_value,
+ ssl->dtls_srtp_info.mki_len );
}
#endif
- return 0;
+ return( 0 );
}
#endif /* MBEDTLS_SSL_DTLS_SRTP */
@@ -3510,7 +3509,8 @@
{
#if defined(MBEDTLS_SSL_DTLS_SRTP)
/* check if we have a chosen srtp protection profile */
- if( ssl->dtls_srtp_info.chosen_dtls_srtp_profile != MBEDTLS_SRTP_UNSET_PROFILE ) {
+ if( ssl->dtls_srtp_info.chosen_dtls_srtp_profile != MBEDTLS_SRTP_UNSET_PROFILE )
+ {
ret = MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE;
}
else
@@ -4169,7 +4169,8 @@
{
#if defined(MBEDTLS_SSL_DTLS_SRTP)
/* check if we have a chosen srtp protection profile */
- if( ssl->dtls_srtp_info.chosen_dtls_srtp_profile != MBEDTLS_SRTP_UNSET_PROFILE ) {
+ if( ssl->dtls_srtp_info.chosen_dtls_srtp_profile != MBEDTLS_SRTP_UNSET_PROFILE )
+ {
return ( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE );
}
else
diff --git a/library/ssl_srv.c b/library/ssl_srv.c
index 38908c8..fae8f60 100644
--- a/library/ssl_srv.c
+++ b/library/ssl_srv.c
@@ -847,7 +847,7 @@
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found srtp profile: %s", profile_info->name ) );
}
/* check if suggested profile is in our list */
- for( i=0; i < ssl->conf->dtls_srtp_profile_list_len; i++)
+ for( i = 0; i < ssl->conf->dtls_srtp_profile_list_len; i++)
{
if( client_protection == ssl->conf->dtls_srtp_profile_list[i] )
{
@@ -860,7 +860,7 @@
break;
}
if( ( ssl->conf->dtls_srtp_mki_support == MBEDTLS_SSL_DTLS_SRTP_MKI_SUPPORTED ) &&
- ( len > ( profile_length + 2 ) ) )
+ ( len > ( profile_length + 2 ) ) )
{
ssl->dtls_srtp_info.mki_len = buf[profile_length + 2];
if( ssl->dtls_srtp_info.mki_len > MBEDTLS_DTLS_SRTP_MAX_MKI_LENGTH )
@@ -3056,7 +3056,8 @@
* force verify mode to be at least OPTIONAL
*/
if ( ssl->dtls_srtp_info.chosen_dtls_srtp_profile != MBEDTLS_SRTP_UNSET_PROFILE &&
- ssl->conf->authmode == MBEDTLS_SSL_VERIFY_NONE ) {
+ ssl->conf->authmode == MBEDTLS_SSL_VERIFY_NONE )
+ {
authmode = MBEDTLS_SSL_VERIFY_OPTIONAL;
}
else
@@ -3067,8 +3068,9 @@
authmode == MBEDTLS_SSL_VERIFY_NONE )
{
#if defined(MBEDTLS_SSL_DTLS_SRTP)
- /* check if we have a chosen srtp protection profile */
- if ( ssl->dtls_srtp_info.chosen_dtls_srtp_profile != MBEDTLS_SRTP_UNSET_PROFILE ) {
+ /* check if we have a chosen srtp protection profile */
+ if ( ssl->dtls_srtp_info.chosen_dtls_srtp_profile != MBEDTLS_SRTP_UNSET_PROFILE )
+ {
MBEDTLS_SSL_DEBUG_MSG( 2, ( "should not happen" ) );
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 3a0fbfc..0ec2913 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -873,10 +873,11 @@
#if defined(MBEDTLS_SSL_DTLS_SRTP)
/* check if we have a chosen srtp protection profile */
- if( ssl->dtls_srtp_info.chosen_dtls_srtp_profile != MBEDTLS_SRTP_UNSET_PROFILE ) {
+ if ( ssl->dtls_srtp_info.chosen_dtls_srtp_profile != MBEDTLS_SRTP_UNSET_PROFILE )
+ {
/* derive key material for srtp session RFC5764 section 4.2
* master key and master salt are respectively 128 bits and 112 bits
- * for all currently available modes :
+ * for all currently available modes:
* SRTP_AES128_CM_HMAC_SHA1_80, SRTP_AES128_CM_HMAC_SHA1_32
* SRTP_NULL_HMAC_SHA1_80, SRTP_NULL_HMAC_SHA1_32
* So we must export 2*(128 + 112) = 480 bits
@@ -2114,7 +2115,8 @@
{
#if defined(MBEDTLS_SSL_DTLS_SRTP)
/* check if we have a chosen srtp protection profile */
- if( ssl->dtls_srtp_info.chosen_dtls_srtp_profile != MBEDTLS_SRTP_UNSET_PROFILE ) {
+ if( ssl->dtls_srtp_info.chosen_dtls_srtp_profile != MBEDTLS_SRTP_UNSET_PROFILE )
+ {
return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE );
}
else
@@ -4773,14 +4775,18 @@
size_t mki_len )
{
if ( mki_len > MBEDTLS_DTLS_SRTP_MAX_MKI_LENGTH )
+ {
return MBEDTLS_ERR_SSL_BAD_INPUT_DATA;
+ }
if( ssl->conf->dtls_srtp_mki_support == MBEDTLS_SSL_DTLS_SRTP_MKI_UNSUPPORTED )
+ {
return MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE;
+ }
memcpy( ssl->dtls_srtp_info.mki_value, mki_value, mki_len );
ssl->dtls_srtp_info.mki_len = mki_len;
- return 0;
+ return( 0 );
}
int mbedtls_ssl_conf_dtls_srtp_protection_profiles( mbedtls_ssl_config *conf,
@@ -4788,14 +4794,19 @@
size_t profiles_number )
{
size_t i;
- /* check in put validity : must be a list of profiles from enumeration */
- /* maximum length is 4 as only 4 protection profiles are defined */
- if( profiles_number > 4 ) {
- return MBEDTLS_ERR_SSL_BAD_INPUT_DATA;
+ /*
+ * Check input validity : must be a list of profiles from enumeration.
+ * Maximum length is 4 as only 4 protection profiles are defined.
+ */
+ if( profiles_number > 4 )
+ {
+ return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
}
mbedtls_free( conf->dtls_srtp_profile_list );
- conf->dtls_srtp_profile_list = (mbedtls_ssl_srtp_profile*)mbedtls_calloc(1, profiles_number * sizeof( mbedtls_ssl_srtp_profile ) );
+ conf->dtls_srtp_profile_list =
+ (mbedtls_ssl_srtp_profile*)mbedtls_calloc(1,
+ profiles_number * sizeof( mbedtls_ssl_srtp_profile ) );
for( i=0; i < profiles_number; i++ ) {
switch( profiles[i] ) {
@@ -4809,7 +4820,7 @@
mbedtls_free( conf->dtls_srtp_profile_list );
conf->dtls_srtp_profile_list = NULL;
conf->dtls_srtp_profile_list_len = 0;
- return MBEDTLS_ERR_SSL_BAD_INPUT_DATA;
+ return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
}
}
@@ -4819,25 +4830,28 @@
return( 0 );
}
-mbedtls_ssl_srtp_profile mbedtls_ssl_get_dtls_srtp_protection_profile( const mbedtls_ssl_context *ssl )
+mbedtls_ssl_srtp_profile
+ mbedtls_ssl_get_dtls_srtp_protection_profile( const mbedtls_ssl_context *ssl )
{
return( ssl->dtls_srtp_info.chosen_dtls_srtp_profile );
}
int mbedtls_ssl_get_dtls_srtp_key_material( const mbedtls_ssl_context *ssl,
unsigned char *key,
- size_t *key_len ) {
+ size_t *key_len )
+{
/* check output buffer size */
- if( *key_len < ssl->dtls_srtp_info.dtls_srtp_keys_len ) {
- return MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL;
+ if( *key_len < ssl->dtls_srtp_info.dtls_srtp_keys_len )
+ {
+ return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL );
}
memcpy( key, ssl->dtls_srtp_info.dtls_srtp_keys,
ssl->dtls_srtp_info.dtls_srtp_keys_len );
*key_len = ssl->dtls_srtp_info.dtls_srtp_keys_len;
- return 0;
+ return( 0 );
}
#endif /* MBEDTLS_SSL_DTLS_SRTP */