Skip to content

Commit 18597cd

Browse files
author
Hanno Becker
committed
Fix style in cipher.c
1 parent c8b699d commit 18597cd

File tree

1 file changed

+37
-24
lines changed

1 file changed

+37
-24
lines changed

library/cipher.c

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
* a non-zero value.
7272
* This is currently only used by GCM and ChaCha20+Poly1305.
7373
*/
74-
static int mbedtls_constant_time_memcmp( const void *v1, const void *v2, size_t len )
74+
static int mbedtls_constant_time_memcmp( const void *v1, const void *v2,
75+
size_t len )
7576
{
7677
const unsigned char *p1 = (const unsigned char*) v1;
7778
const unsigned char *p2 = (const unsigned char*) v2;
@@ -108,7 +109,8 @@ const int *mbedtls_cipher_list( void )
108109
return( mbedtls_cipher_supported );
109110
}
110111

111-
const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type( const mbedtls_cipher_type_t cipher_type )
112+
const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type(
113+
const mbedtls_cipher_type_t cipher_type )
112114
{
113115
const mbedtls_cipher_definition_t *def;
114116

@@ -119,7 +121,8 @@ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type( const mbedtls_cipher
119121
return( NULL );
120122
}
121123

122-
const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string( const char *cipher_name )
124+
const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string(
125+
const char *cipher_name )
123126
{
124127
const mbedtls_cipher_definition_t *def;
125128

@@ -133,9 +136,10 @@ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string( const char *cipher
133136
return( NULL );
134137
}
135138

136-
const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values( const mbedtls_cipher_id_t cipher_id,
137-
int key_bitlen,
138-
const mbedtls_cipher_mode_t mode )
139+
const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values(
140+
const mbedtls_cipher_id_t cipher_id,
141+
int key_bitlen,
142+
const mbedtls_cipher_mode_t mode )
139143
{
140144
const mbedtls_cipher_definition_t *def;
141145

@@ -173,7 +177,8 @@ void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx )
173177
mbedtls_platform_zeroize( ctx, sizeof(mbedtls_cipher_context_t) );
174178
}
175179

176-
int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info )
180+
int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx,
181+
const mbedtls_cipher_info_t *cipher_info )
177182
{
178183
if( NULL == cipher_info || NULL == ctx )
179184
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
@@ -199,8 +204,10 @@ int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_in
199204
return( 0 );
200205
}
201206

202-
int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *key,
203-
int key_bitlen, const mbedtls_operation_t operation )
207+
int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx,
208+
const unsigned char *key,
209+
int key_bitlen,
210+
const mbedtls_operation_t operation )
204211
{
205212
if( NULL == ctx || NULL == ctx->cipher_info )
206213
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
@@ -223,12 +230,13 @@ int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *k
223230
MBEDTLS_MODE_CTR == ctx->cipher_info->mode )
224231
{
225232
return ctx->cipher_info->base->setkey_enc_func( ctx->cipher_ctx, key,
226-
ctx->key_bitlen );
233+
ctx->key_bitlen );
227234
}
228235

229236
if( MBEDTLS_DECRYPT == operation )
230237
return ctx->cipher_info->base->setkey_dec_func( ctx->cipher_ctx, key,
231-
ctx->key_bitlen );
238+
ctx->key_bitlen );
239+
232240

233241
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
234242
}
@@ -830,7 +838,8 @@ int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx,
830838
}
831839

832840
#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING)
833-
int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode )
841+
int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx,
842+
mbedtls_cipher_padding_t mode )
834843
{
835844
if( NULL == ctx ||
836845
MBEDTLS_MODE_CBC != ctx->cipher_info->mode )
@@ -889,7 +898,8 @@ int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx,
889898

890899
#if defined(MBEDTLS_GCM_C)
891900
if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode )
892-
return mbedtls_gcm_finish( (mbedtls_gcm_context *) ctx->cipher_ctx, tag, tag_len );
901+
return( mbedtls_gcm_finish( (mbedtls_gcm_context *) ctx->cipher_ctx,
902+
tag, tag_len ) );
893903
#endif
894904

895905
#if defined(MBEDTLS_CHACHAPOLY_C)
@@ -899,8 +909,8 @@ int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx,
899909
if ( tag_len != 16U )
900910
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
901911

902-
return mbedtls_chachapoly_finish( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
903-
tag );
912+
return( mbedtls_chachapoly_finish(
913+
(mbedtls_chachapoly_context*) ctx->cipher_ctx, tag ) );
904914
}
905915
#endif
906916

@@ -925,8 +935,9 @@ int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx,
925935
if( tag_len > sizeof( check_tag ) )
926936
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
927937

928-
if( 0 != ( ret = mbedtls_gcm_finish( (mbedtls_gcm_context *) ctx->cipher_ctx,
929-
check_tag, tag_len ) ) )
938+
if( 0 != ( ret = mbedtls_gcm_finish(
939+
(mbedtls_gcm_context *) ctx->cipher_ctx,
940+
check_tag, tag_len ) ) )
930941
{
931942
return( ret );
932943
}
@@ -946,8 +957,8 @@ int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx,
946957
if ( tag_len != sizeof( check_tag ) )
947958
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
948959

949-
ret = mbedtls_chachapoly_finish( (mbedtls_chachapoly_context*) ctx->cipher_ctx,
950-
check_tag );
960+
ret = mbedtls_chachapoly_finish(
961+
(mbedtls_chachapoly_context*) ctx->cipher_ctx, check_tag );
951962
if ( ret != 0 )
952963
{
953964
return( ret );
@@ -982,10 +993,12 @@ int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx,
982993
if( ( ret = mbedtls_cipher_reset( ctx ) ) != 0 )
983994
return( ret );
984995

985-
if( ( ret = mbedtls_cipher_update( ctx, input, ilen, output, olen ) ) != 0 )
996+
if( ( ret = mbedtls_cipher_update( ctx, input, ilen,
997+
output, olen ) ) != 0 )
986998
return( ret );
987999

988-
if( ( ret = mbedtls_cipher_finish( ctx, output + *olen, &finish_olen ) ) != 0 )
1000+
if( ( ret = mbedtls_cipher_finish( ctx, output + *olen,
1001+
&finish_olen ) ) != 0 )
9891002
return( ret );
9901003

9911004
*olen += finish_olen;
@@ -1008,9 +1021,9 @@ int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx,
10081021
if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode )
10091022
{
10101023
*olen = ilen;
1011-
return( mbedtls_gcm_crypt_and_tag( ctx->cipher_ctx, MBEDTLS_GCM_ENCRYPT, ilen,
1012-
iv, iv_len, ad, ad_len, input, output,
1013-
tag_len, tag ) );
1024+
return( mbedtls_gcm_crypt_and_tag( ctx->cipher_ctx, MBEDTLS_GCM_ENCRYPT,
1025+
ilen, iv, iv_len, ad, ad_len,
1026+
input, output, tag_len, tag ) );
10141027
}
10151028
#endif /* MBEDTLS_GCM_C */
10161029
#if defined(MBEDTLS_CCM_C)

0 commit comments

Comments
 (0)