Fix code styling for return statements

This commit is contained in:
Paul Bakker 2014-06-17 14:06:49 +02:00
parent 3c38f29a61
commit d8bb82665e
27 changed files with 256 additions and 256 deletions

View File

@ -211,7 +211,7 @@ int asn1_get_bitstring( unsigned char **p, const unsigned char *end,
if( *p != end )
return( POLARSSL_ERR_ASN1_LENGTH_MISMATCH );
return 0;
return( 0 );
}
/*

View File

@ -304,7 +304,7 @@ int mpi_get_bit( const mpi *X, size_t pos )
if( X->n * biL <= pos )
return( 0 );
return ( X->p[pos / biL] >> ( pos % biL ) ) & 0x01;
return( ( X->p[pos / biL] >> ( pos % biL ) ) & 0x01 );
}
/*
@ -317,12 +317,12 @@ int mpi_set_bit( mpi *X, size_t pos, unsigned char val )
size_t idx = pos % biL;
if( val != 0 && val != 1 )
return POLARSSL_ERR_MPI_BAD_INPUT_DATA;
return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
if( X->n * biL <= pos )
{
if( val == 0 )
return ( 0 );
return( 0 );
MPI_CHK( mpi_grow( X, off + 1 ) );
}
@ -1382,7 +1382,7 @@ int mpi_mod_mpi( mpi *R, const mpi *A, const mpi *B )
int ret;
if( mpi_cmp_int( B, 0 ) < 0 )
return POLARSSL_ERR_MPI_NEGATIVE_VALUE;
return( POLARSSL_ERR_MPI_NEGATIVE_VALUE );
MPI_CHK( mpi_div_mpi( NULL, R, A, B ) );
@ -1409,7 +1409,7 @@ int mpi_mod_int( t_uint *r, const mpi *A, t_sint b )
return( POLARSSL_ERR_MPI_DIVISION_BY_ZERO );
if( b < 0 )
return POLARSSL_ERR_MPI_NEGATIVE_VALUE;
return( POLARSSL_ERR_MPI_NEGATIVE_VALUE );
/*
* handle trivial cases

View File

@ -91,7 +91,7 @@ static uint32_t F(blowfish_context *ctx, uint32_t x)
y = y ^ ctx->S[2][c];
y = y + ctx->S[3][d];
return y;
return( y );
}
static void blowfish_enc(blowfish_context *ctx, uint32_t *xl, uint32_t *xr)
@ -164,7 +164,7 @@ int blowfish_setkey( blowfish_context *ctx, const unsigned char *key,
if( keysize < BLOWFISH_MIN_KEY || keysize > BLOWFISH_MAX_KEY ||
( keysize % 8 ) )
{
return POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH;
return( POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH );
}
keysize >>= 3;

View File

@ -1050,7 +1050,7 @@ int camellia_self_test( int verbose )
polarssl_printf( "\n" );
#endif /* POLARSSL_CIPHER_MODE_CTR */
return ( 0 );
return( 0 );
}
#endif /* POLARSSL_SELF_TEST */

View File

@ -82,7 +82,7 @@ const int *cipher_list( void )
supported_init = 1;
}
return supported_ciphers;
return( supported_ciphers );
}
const cipher_info_t *cipher_info_from_type( const cipher_type_t cipher_type )
@ -93,7 +93,7 @@ const cipher_info_t *cipher_info_from_type( const cipher_type_t cipher_type )
if( def->type == cipher_type )
return( def->info );
return NULL;
return( NULL );
}
const cipher_info_t *cipher_info_from_string( const char *cipher_name )
@ -101,13 +101,13 @@ const cipher_info_t *cipher_info_from_string( const char *cipher_name )
const cipher_definition_t *def;
if( NULL == cipher_name )
return NULL;
return( NULL );
for( def = cipher_definitions; def->info != NULL; def++ )
if( ! strcasecmp( def->info->name, cipher_name ) )
return( def->info );
return NULL;
return( NULL );
}
const cipher_info_t *cipher_info_from_values( const cipher_id_t cipher_id,
@ -122,18 +122,18 @@ const cipher_info_t *cipher_info_from_values( const cipher_id_t cipher_id,
def->info->mode == mode )
return( def->info );
return NULL;
return( NULL );
}
int cipher_init_ctx( cipher_context_t *ctx, const cipher_info_t *cipher_info )
{
if( NULL == cipher_info || NULL == ctx )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
memset( ctx, 0, sizeof( cipher_context_t ) );
if( NULL == ( ctx->cipher_ctx = cipher_info->base->ctx_alloc_func() ) )
return POLARSSL_ERR_CIPHER_ALLOC_FAILED;
return( POLARSSL_ERR_CIPHER_ALLOC_FAILED );
ctx->cipher_info = cipher_info;
@ -148,28 +148,28 @@ int cipher_init_ctx( cipher_context_t *ctx, const cipher_info_t *cipher_info )
#endif
#endif /* POLARSSL_CIPHER_MODE_WITH_PADDING */
return 0;
return( 0 );
}
int cipher_free_ctx( cipher_context_t *ctx )
{
if( ctx == NULL || ctx->cipher_info == NULL )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
ctx->cipher_info->base->ctx_free_func( ctx->cipher_ctx );
polarssl_zeroize( ctx, sizeof(cipher_context_t) );
return 0;
return( 0 );
}
int cipher_setkey( cipher_context_t *ctx, const unsigned char *key,
int key_length, const operation_t operation )
{
if( NULL == ctx || NULL == ctx->cipher_info )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
if( (int) ctx->cipher_info->key_length != key_length )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
ctx->key_length = key_length;
ctx->operation = operation;
@ -189,7 +189,7 @@ int cipher_setkey( cipher_context_t *ctx, const unsigned char *key,
return ctx->cipher_info->base->setkey_dec_func( ctx->cipher_ctx, key,
ctx->key_length );
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
}
int cipher_set_iv( cipher_context_t *ctx,
@ -198,11 +198,11 @@ int cipher_set_iv( cipher_context_t *ctx,
size_t actual_iv_size;
if( NULL == ctx || NULL == ctx->cipher_info || NULL == iv )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
/* avoid buffer overflow in ctx->iv */
if( iv_len > POLARSSL_MAX_IV_LENGTH )
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
if( ctx->cipher_info->accepts_variable_iv_size )
actual_iv_size = iv_len;
@ -212,23 +212,23 @@ int cipher_set_iv( cipher_context_t *ctx,
/* avoid reading past the end of input buffer */
if( actual_iv_size > iv_len )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
}
memcpy( ctx->iv, iv, actual_iv_size );
ctx->iv_size = actual_iv_size;
return 0;
return( 0 );
}
int cipher_reset( cipher_context_t *ctx )
{
if( NULL == ctx || NULL == ctx->cipher_info )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
ctx->unprocessed_len = 0;
return 0;
return( 0 );
}
#if defined(POLARSSL_CIPHER_MODE_AEAD)
@ -236,7 +236,7 @@ int cipher_update_ad( cipher_context_t *ctx,
const unsigned char *ad, size_t ad_len )
{
if( NULL == ctx || NULL == ctx->cipher_info )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
#if defined(POLARSSL_GCM_C)
if( POLARSSL_MODE_GCM == ctx->cipher_info->mode )
@ -246,7 +246,7 @@ int cipher_update_ad( cipher_context_t *ctx,
}
#endif
return 0;
return( 0 );
}
#endif /* POLARSSL_CIPHER_MODE_AEAD */
@ -257,7 +257,7 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input,
if( NULL == ctx || NULL == ctx->cipher_info || NULL == olen )
{
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
}
*olen = 0;
@ -265,17 +265,17 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input,
if( ctx->cipher_info->mode == POLARSSL_MODE_ECB )
{
if( ilen != cipher_get_block_size( ctx ) )
return POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED;
return( POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED );
*olen = ilen;
if( 0 != ( ret = ctx->cipher_info->base->ecb_func( ctx->cipher_ctx,
ctx->operation, input, output ) ) )
{
return ret;
return( ret );
}
return 0;
return( 0 );
}
#if defined(POLARSSL_GCM_C)
@ -290,7 +290,7 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input,
if( input == output &&
( ctx->unprocessed_len != 0 || ilen % cipher_get_block_size( ctx ) ) )
{
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
}
#if defined(POLARSSL_CIPHER_MODE_CBC)
@ -310,7 +310,7 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input,
ilen );
ctx->unprocessed_len += ilen;
return 0;
return( 0 );
}
/*
@ -327,7 +327,7 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input,
ctx->operation, cipher_get_block_size( ctx ), ctx->iv,
ctx->unprocessed_data, output ) ) )
{
return ret;
return( ret );
}
*olen += cipher_get_block_size( ctx );
@ -362,13 +362,13 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input,
if( 0 != ( ret = ctx->cipher_info->base->cbc_func( ctx->cipher_ctx,
ctx->operation, ilen, ctx->iv, input, output ) ) )
{
return ret;
return( ret );
}
*olen += ilen;
}
return 0;
return( 0 );
}
#endif /* POLARSSL_CIPHER_MODE_CBC */
@ -379,12 +379,12 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input,
ctx->operation, ilen, &ctx->unprocessed_len, ctx->iv,
input, output ) ) )
{
return ret;
return( ret );
}
*olen = ilen;
return 0;
return( 0 );
}
#endif /* POLARSSL_CIPHER_MODE_CFB */
@ -395,12 +395,12 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input,
ilen, &ctx->unprocessed_len, ctx->iv,
ctx->unprocessed_data, input, output ) ) )
{
return ret;
return( ret );
}
*olen = ilen;
return 0;
return( 0 );
}
#endif /* POLARSSL_CIPHER_MODE_CTR */
@ -410,16 +410,16 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input,
if( 0 != ( ret = ctx->cipher_info->base->stream_func( ctx->cipher_ctx,
ilen, input, output ) ) )
{
return ret;
return( ret );
}
*olen = ilen;
return 0;
return( 0 );
}
#endif /* POLARSSL_CIPHER_MODE_STREAM */
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
}
#if defined(POLARSSL_CIPHER_MODE_WITH_PADDING)
@ -444,7 +444,7 @@ static int get_pkcs_padding( unsigned char *input, size_t input_len,
unsigned char padding_len, bad = 0;
if( NULL == input || NULL == data_len )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
padding_len = input[input_len - 1];
*data_len = input_len - padding_len;
@ -459,7 +459,7 @@ static int get_pkcs_padding( unsigned char *input, size_t input_len,
for( i = 0; i < input_len; i++ )
bad |= ( input[i] ^ padding_len ) * ( i >= pad_idx );
return POLARSSL_ERR_CIPHER_INVALID_PADDING * (bad != 0);
return( POLARSSL_ERR_CIPHER_INVALID_PADDING * (bad != 0) );
}
#endif /* POLARSSL_CIPHER_PADDING_PKCS7 */
@ -485,7 +485,7 @@ static int get_one_and_zeros_padding( unsigned char *input, size_t input_len,
unsigned char done = 0, prev_done, bad;
if( NULL == input || NULL == data_len )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
bad = 0xFF;
*data_len = 0;
@ -497,7 +497,7 @@ static int get_one_and_zeros_padding( unsigned char *input, size_t input_len,
bad &= ( input[i-1] ^ 0x80 ) | ( done == prev_done );
}
return POLARSSL_ERR_CIPHER_INVALID_PADDING * (bad != 0);
return( POLARSSL_ERR_CIPHER_INVALID_PADDING * (bad != 0) );
}
#endif /* POLARSSL_CIPHER_PADDING_ONE_AND_ZEROS */
@ -524,7 +524,7 @@ static int get_zeros_and_len_padding( unsigned char *input, size_t input_len,
unsigned char padding_len, bad = 0;
if( NULL == input || NULL == data_len )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
padding_len = input[input_len - 1];
*data_len = input_len - padding_len;
@ -538,7 +538,7 @@ static int get_zeros_and_len_padding( unsigned char *input, size_t input_len,
for( i = 0; i < input_len - 1; i++ )
bad |= input[i] * ( i >= pad_idx );
return POLARSSL_ERR_CIPHER_INVALID_PADDING * (bad != 0);
return( POLARSSL_ERR_CIPHER_INVALID_PADDING * (bad != 0) );
}
#endif /* POLARSSL_CIPHER_PADDING_ZEROS_AND_LEN */
@ -562,7 +562,7 @@ static int get_zeros_padding( unsigned char *input, size_t input_len,
unsigned char done = 0, prev_done;
if( NULL == input || NULL == data_len )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
*data_len = 0;
for( i = input_len; i > 0; i-- )
@ -572,7 +572,7 @@ static int get_zeros_padding( unsigned char *input, size_t input_len,
*data_len |= i * ( done != prev_done );
}
return 0;
return( 0 );
}
#endif /* POLARSSL_CIPHER_PADDING_ZEROS */
@ -586,11 +586,11 @@ static int get_no_padding( unsigned char *input, size_t input_len,
size_t *data_len )
{
if( NULL == input || NULL == data_len )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
*data_len = input_len;
return 0;
return( 0 );
}
#endif /* POLARSSL_CIPHER_MODE_WITH_PADDING */
@ -598,7 +598,7 @@ int cipher_finish( cipher_context_t *ctx,
unsigned char *output, size_t *olen )
{
if( NULL == ctx || NULL == ctx->cipher_info || NULL == olen )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
*olen = 0;
@ -607,15 +607,15 @@ int cipher_finish( cipher_context_t *ctx,
POLARSSL_MODE_GCM == ctx->cipher_info->mode ||
POLARSSL_MODE_STREAM == ctx->cipher_info->mode )
{
return 0;
return( 0 );
}
if( POLARSSL_MODE_ECB == ctx->cipher_info->mode )
{
if( ctx->unprocessed_len != 0 )
return POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED;
return( POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED );
return 0;
return( 0 );
}
#if defined(POLARSSL_CIPHER_MODE_CBC)
@ -629,9 +629,9 @@ int cipher_finish( cipher_context_t *ctx,
if( NULL == ctx->add_padding )
{
if( 0 != ctx->unprocessed_len )
return POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED;
return( POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED );
return 0;
return( 0 );
}
ctx->add_padding( ctx->unprocessed_data, cipher_get_iv_size( ctx ),
@ -644,9 +644,9 @@ int cipher_finish( cipher_context_t *ctx,
* or an empty block if no padding
*/
if( NULL == ctx->add_padding && 0 == ctx->unprocessed_len )
return 0;
return( 0 );
return POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED;
return( POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED );
}
/* cipher block */
@ -654,7 +654,7 @@ int cipher_finish( cipher_context_t *ctx,
ctx->operation, cipher_get_block_size( ctx ), ctx->iv,
ctx->unprocessed_data, output ) ) )
{
return ret;
return( ret );
}
/* Set output size for decryption */
@ -664,13 +664,13 @@ int cipher_finish( cipher_context_t *ctx,
/* Set output size for encryption */
*olen = cipher_get_block_size( ctx );
return 0;
return( 0 );
}
#else
((void) output);
#endif /* POLARSSL_CIPHER_MODE_CBC */
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
}
#if defined(POLARSSL_CIPHER_MODE_WITH_PADDING)
@ -679,7 +679,7 @@ int cipher_set_padding_mode( cipher_context_t *ctx, cipher_padding_t mode )
if( NULL == ctx ||
POLARSSL_MODE_CBC != ctx->cipher_info->mode )
{
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
}
switch( mode )
@ -714,10 +714,10 @@ int cipher_set_padding_mode( cipher_context_t *ctx, cipher_padding_t mode )
break;
default:
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
}
return 0;
return( 0 );
}
#endif /* POLARSSL_CIPHER_MODE_WITH_PADDING */
@ -726,17 +726,17 @@ int cipher_write_tag( cipher_context_t *ctx,
unsigned char *tag, size_t tag_len )
{
if( NULL == ctx || NULL == ctx->cipher_info || NULL == tag )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
if( POLARSSL_ENCRYPT != ctx->operation )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
#if defined(POLARSSL_GCM_C)
if( POLARSSL_MODE_GCM == ctx->cipher_info->mode )
return gcm_finish( (gcm_context *) ctx->cipher_ctx, tag, tag_len );
#endif
return 0;
return( 0 );
}
int cipher_check_tag( cipher_context_t *ctx,
@ -747,7 +747,7 @@ int cipher_check_tag( cipher_context_t *ctx,
if( NULL == ctx || NULL == ctx->cipher_info ||
POLARSSL_DECRYPT != ctx->operation )
{
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
}
#if defined(POLARSSL_GCM_C)
@ -758,7 +758,7 @@ int cipher_check_tag( cipher_context_t *ctx,
int diff;
if( tag_len > sizeof( check_tag ) )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
if( 0 != ( ret = gcm_finish( (gcm_context *) ctx->cipher_ctx,
check_tag, tag_len ) ) )

View File

@ -129,7 +129,7 @@ static int aes_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
#endif /* POLARSSL_CIPHER_MODE_CBC */
}
@ -149,7 +149,7 @@ static int aes_crypt_cfb128_wrap( void *ctx, operation_t operation,
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
#endif /* POLARSSL_CIPHER_MODE_CFB */
}
@ -169,7 +169,7 @@ static int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
#endif /* POLARSSL_CIPHER_MODE_CTR */
}
@ -483,7 +483,7 @@ static int camellia_crypt_cbc_wrap( void *ctx, operation_t operation,
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
#endif /* POLARSSL_CIPHER_MODE_CBC */
}
@ -503,7 +503,7 @@ static int camellia_crypt_cfb128_wrap( void *ctx, operation_t operation,
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
#endif /* POLARSSL_CIPHER_MODE_CFB */
}
@ -523,7 +523,7 @@ static int camellia_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
#endif /* POLARSSL_CIPHER_MODE_CTR */
}
@ -843,7 +843,7 @@ static int des_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
#endif /* POLARSSL_CIPHER_MODE_CBC */
}
@ -861,7 +861,7 @@ static int des3_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
#endif /* POLARSSL_CIPHER_MODE_CBC */
}
@ -877,7 +877,7 @@ static int des_crypt_cfb128_wrap( void *ctx, operation_t operation,
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
}
static int des_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
@ -892,7 +892,7 @@ static int des_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
}
static int des_setkey_dec_wrap( void *ctx, const unsigned char *key,
@ -1100,7 +1100,7 @@ static int blowfish_crypt_cbc_wrap( void *ctx, operation_t operation,
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
#endif /* POLARSSL_CIPHER_MODE_CBC */
}
@ -1120,7 +1120,7 @@ static int blowfish_crypt_cfb64_wrap( void *ctx, operation_t operation,
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
#endif /* POLARSSL_CIPHER_MODE_CFB */
}
@ -1140,7 +1140,7 @@ static int blowfish_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
((void) input);
((void) output);
return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
#endif /* POLARSSL_CIPHER_MODE_CTR */
}
@ -1302,7 +1302,7 @@ static int null_setkey( void *ctx, const unsigned char *key,
static void * null_ctx_alloc( void )
{
return (void *) 1;
return( (void *) 1 )
}
static void null_ctx_free( void *ctx )

View File

@ -144,7 +144,7 @@ int ecdh_make_params( ecdh_context *ctx, size_t *olen,
return( ret );
*olen = grp_len + pt_len;
return 0;
return( 0 );
}
/*
@ -166,7 +166,7 @@ int ecdh_read_params( ecdh_context *ctx,
!= 0 )
return( ret );
return 0;
return( 0 );
}
/*

View File

@ -176,7 +176,7 @@ static ecp_group_id ecp_supported_grp_id[POLARSSL_ECP_DP_MAX];
*/
const ecp_curve_info *ecp_curve_list( void )
{
return ecp_supported_curves;
return( ecp_supported_curves );
}
/*
@ -202,7 +202,7 @@ const ecp_group_id *ecp_grp_id_list( void )
init_done = 1;
}
return ecp_supported_grp_id;
return( ecp_supported_grp_id );
}
/*
@ -575,7 +575,7 @@ int ecp_tls_write_point( const ecp_group *grp, const ecp_point *pt,
buf[0] = (unsigned char) *olen;
++*olen;
return 0;
return( 0 );
}
/*
@ -664,7 +664,7 @@ int ecp_tls_write_group( const ecp_group *grp, size_t *olen,
buf[0] = curve_info->tls_id >> 8;
buf[1] = curve_info->tls_id & 0xFF;
return 0;
return( 0 );
}
/*

View File

@ -175,7 +175,7 @@ int entropy_update_manual( entropy_context *ctx,
return( POLARSSL_ERR_THREADING_MUTEX_ERROR );
#endif
return ( ret );
return( ret );
}
/*

View File

@ -60,11 +60,11 @@ int platform_entropy_poll( void *data, unsigned char *output, size_t len,
if( CryptAcquireContext( &provider, NULL, NULL,
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT ) == FALSE )
{
return POLARSSL_ERR_ENTROPY_SOURCE_FAILED;
return( POLARSSL_ERR_ENTROPY_SOURCE_FAILED );
}
if( CryptGenRandom( provider, (DWORD) len, output ) == FALSE )
return POLARSSL_ERR_ENTROPY_SOURCE_FAILED;
return( POLARSSL_ERR_ENTROPY_SOURCE_FAILED );
CryptReleaseContext( provider, 0 );
*olen = len;
@ -86,13 +86,13 @@ int platform_entropy_poll( void *data,
file = fopen( "/dev/urandom", "rb" );
if( file == NULL )
return POLARSSL_ERR_ENTROPY_SOURCE_FAILED;
return( POLARSSL_ERR_ENTROPY_SOURCE_FAILED );
ret = fread( output, 1, len, file );
if( ret != len )
{
fclose( file );
return POLARSSL_ERR_ENTROPY_SOURCE_FAILED;
return( POLARSSL_ERR_ENTROPY_SOURCE_FAILED );
}
fclose( file );
@ -129,7 +129,7 @@ int havege_poll( void *data,
*olen = 0;
if( havege_random( hs, output, len ) != 0 )
return POLARSSL_ERR_ENTROPY_SOURCE_FAILED;
return( POLARSSL_ERR_ENTROPY_SOURCE_FAILED );
*olen = len;

View File

@ -87,13 +87,13 @@ static const int supported_digests[] = {
const int *md_list( void )
{
return supported_digests;
return( supported_digests );
}
const md_info_t *md_info_from_string( const char *md_name )
{
if( NULL == md_name )
return NULL;
return( NULL );
/* Get the appropriate digest information */
#if defined(POLARSSL_MD2_C)
@ -128,7 +128,7 @@ const md_info_t *md_info_from_string( const char *md_name )
if( !strcasecmp( "SHA512", md_name ) )
return md_info_from_type( POLARSSL_MD_SHA512 );
#endif
return NULL;
return( NULL );
}
const md_info_t *md_info_from_type( md_type_t md_type )
@ -137,109 +137,109 @@ const md_info_t *md_info_from_type( md_type_t md_type )
{
#if defined(POLARSSL_MD2_C)
case POLARSSL_MD_MD2:
return &md2_info;
return( &md2_info );
#endif
#if defined(POLARSSL_MD4_C)
case POLARSSL_MD_MD4:
return &md4_info;
return( &md4_info );
#endif
#if defined(POLARSSL_MD5_C)
case POLARSSL_MD_MD5:
return &md5_info;
return( &md5_info );
#endif
#if defined(POLARSSL_RIPEMD160_C)
case POLARSSL_MD_RIPEMD160:
return &ripemd160_info;
return( &ripemd160_info );
#endif
#if defined(POLARSSL_SHA1_C)
case POLARSSL_MD_SHA1:
return &sha1_info;
return( &sha1_info );
#endif
#if defined(POLARSSL_SHA256_C)
case POLARSSL_MD_SHA224:
return &sha224_info;
return( &sha224_info );
case POLARSSL_MD_SHA256:
return &sha256_info;
return( &sha256_info );
#endif
#if defined(POLARSSL_SHA512_C)
case POLARSSL_MD_SHA384:
return &sha384_info;
return( &sha384_info );
case POLARSSL_MD_SHA512:
return &sha512_info;
return( &sha512_info );
#endif
default:
return NULL;
return( NULL );
}
}
int md_init_ctx( md_context_t *ctx, const md_info_t *md_info )
{
if( md_info == NULL || ctx == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
memset( ctx, 0, sizeof( md_context_t ) );
if( ( ctx->md_ctx = md_info->ctx_alloc_func() ) == NULL )
return POLARSSL_ERR_MD_ALLOC_FAILED;
return( POLARSSL_ERR_MD_ALLOC_FAILED );
ctx->md_info = md_info;
md_info->starts_func( ctx->md_ctx );
return 0;
return( 0 );
}
int md_free_ctx( md_context_t *ctx )
{
if( ctx == NULL || ctx->md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
ctx->md_info->ctx_free_func( ctx->md_ctx );
polarssl_zeroize( ctx, sizeof( md_context_t ) );
return 0;
return( 0 );
}
int md_starts( md_context_t *ctx )
{
if( ctx == NULL || ctx->md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
ctx->md_info->starts_func( ctx->md_ctx );
return 0;
return( 0 );
}
int md_update( md_context_t *ctx, const unsigned char *input, size_t ilen )
{
if( ctx == NULL || ctx->md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
ctx->md_info->update_func( ctx->md_ctx, input, ilen );
return 0;
return( 0 );
}
int md_finish( md_context_t *ctx, unsigned char *output )
{
if( ctx == NULL || ctx->md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
ctx->md_info->finish_func( ctx->md_ctx, output );
return 0;
return( 0 );
}
int md( const md_info_t *md_info, const unsigned char *input, size_t ilen,
unsigned char *output )
{
if ( md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
md_info->digest_func( input, ilen, output );
return 0;
return( 0 );
}
int md_file( const md_info_t *md_info, const char *path, unsigned char *output )
@ -249,7 +249,7 @@ int md_file( const md_info_t *md_info, const char *path, unsigned char *output )
#endif
if( md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
#if defined(POLARSSL_FS_IO)
ret = md_info->file_func( path, output );
@ -261,48 +261,48 @@ int md_file( const md_info_t *md_info, const char *path, unsigned char *output )
((void) path);
((void) output);
return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
#endif /* POLARSSL_FS_IO */
}
int md_hmac_starts( md_context_t *ctx, const unsigned char *key, size_t keylen )
{
if( ctx == NULL || ctx->md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
ctx->md_info->hmac_starts_func( ctx->md_ctx, key, keylen);
return 0;
return( 0 );
}
int md_hmac_update( md_context_t *ctx, const unsigned char *input, size_t ilen )
{
if( ctx == NULL || ctx->md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
ctx->md_info->hmac_update_func( ctx->md_ctx, input, ilen );
return 0;
return( 0 );
}
int md_hmac_finish( md_context_t *ctx, unsigned char *output)
{
if( ctx == NULL || ctx->md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
ctx->md_info->hmac_finish_func( ctx->md_ctx, output);
return 0;
return( 0 );
}
int md_hmac_reset( md_context_t *ctx )
{
if( ctx == NULL || ctx->md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
ctx->md_info->hmac_reset_func( ctx->md_ctx);
return 0;
return( 0 );
}
int md_hmac( const md_info_t *md_info, const unsigned char *key, size_t keylen,
@ -310,21 +310,21 @@ int md_hmac( const md_info_t *md_info, const unsigned char *key, size_t keylen,
unsigned char *output )
{
if( md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
md_info->hmac_func( key, keylen, input, ilen, output );
return 0;
return( 0 );
}
int md_process( md_context_t *ctx, const unsigned char *data )
{
if( ctx == NULL || ctx->md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
ctx->md_info->process_func( ctx->md_ctx, data );
return 0;
return( 0 );
}
#endif /* POLARSSL_MD_C */

View File

@ -104,7 +104,7 @@ static int md2_file_wrap( const char *path, unsigned char *output )
#else
((void) path);
((void) output);
return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
#endif
}
@ -194,7 +194,7 @@ static int md4_file_wrap( const char *path, unsigned char *output )
#else
((void) path);
((void) output);
return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
#endif
}
@ -282,7 +282,7 @@ static int md5_file_wrap( const char *path, unsigned char *output )
#else
((void) path);
((void) output);
return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
#endif
}
@ -370,7 +370,7 @@ static int ripemd160_file_wrap( const char *path, unsigned char *output )
#else
((void) path);
((void) output);
return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
#endif
}
@ -458,7 +458,7 @@ static int sha1_file_wrap( const char *path, unsigned char *output )
#else
((void) path);
((void) output);
return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
#endif
}
@ -555,7 +555,7 @@ static int sha224_file_wrap( const char *path, unsigned char *output )
#else
((void) path);
((void) output);
return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
#endif
}
@ -652,7 +652,7 @@ static int sha256_file_wrap( const char *path, unsigned char *output )
#else
((void) path);
((void) output);
return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
#endif
}
@ -753,7 +753,7 @@ static int sha384_file_wrap( const char *path, unsigned char *output )
#else
((void) path);
((void) output);
return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
#endif
}
@ -850,7 +850,7 @@ static int sha512_file_wrap( const char *path, unsigned char *output )
#else
((void) path);
((void) output);
return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE;
return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
#endif
}

View File

@ -318,7 +318,7 @@ static void *buffer_alloc_malloc( size_t len )
if( ( heap.verify & MEMORY_VERIFY_ALLOC ) && verify_chain() != 0 )
exit( 1 );
return ( (unsigned char *) cur ) + sizeof(memory_header);
return( ( (unsigned char *) cur ) + sizeof(memory_header) );
}
p = ( (unsigned char *) cur ) + sizeof(memory_header) + len;
@ -373,7 +373,7 @@ static void *buffer_alloc_malloc( size_t len )
if( ( heap.verify & MEMORY_VERIFY_ALLOC ) && verify_chain() != 0 )
exit( 1 );
return ( (unsigned char *) cur ) + sizeof(memory_header);
return( ( (unsigned char *) cur ) + sizeof(memory_header) );
}
static void buffer_alloc_free( void *ptr )

View File

@ -624,24 +624,24 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
if ( res < 0 )
return( (int) size + 20 );
return res;
return( res );
}
#define snprintf compat_snprintf
#endif /* _MSC_VER && !snprintf && !EFIX64 && !EFI32 */
#define SAFE_SNPRINTF() \
{ \
if( ret == -1 ) \
return POLARSSL_ERR_OID_BUF_TOO_SMALL; \
\
if ( (unsigned int) ret >= n ) { \
p[n - 1] = '\0'; \
return POLARSSL_ERR_OID_BUF_TOO_SMALL; \
} \
\
n -= (unsigned int) ret; \
p += (unsigned int) ret; \
#define SAFE_SNPRINTF() \
{ \
if( ret == -1 ) \
return( POLARSSL_ERR_OID_BUF_TOO_SMALL ); \
\
if ( (unsigned int) ret >= n ) { \
p[n - 1] = '\0'; \
return( POLARSSL_ERR_OID_BUF_TOO_SMALL ); \
} \
\
n -= (unsigned int) ret; \
p += (unsigned int) ret; \
}
/* Return the x.y.z.... style numeric string for the given OID */

View File

@ -82,21 +82,21 @@ const pk_info_t * pk_info_from_type( pk_type_t pk_type )
switch( pk_type ) {
#if defined(POLARSSL_RSA_C)
case POLARSSL_PK_RSA:
return &rsa_info;
return( &rsa_info );
#endif
#if defined(POLARSSL_ECP_C)
case POLARSSL_PK_ECKEY:
return &eckey_info;
return( &eckey_info );
case POLARSSL_PK_ECKEY_DH:
return &eckeydh_info;
return( &eckeydh_info );
#endif
#if defined(POLARSSL_ECDSA_C)
case POLARSSL_PK_ECDSA:
return &ecdsa_info;
return( &ecdsa_info );
#endif
/* POLARSSL_PK_RSA_ALT omitted on purpose */
default:
return NULL;
return( NULL );
}
}

View File

@ -132,7 +132,7 @@ static void *rsa_alloc_wrap( void )
if( ctx != NULL )
rsa_init( (rsa_context *) ctx, 0, 0 );
return ctx;
return( ctx );
}
static void rsa_free_wrap( void *ctx )
@ -426,7 +426,7 @@ static void *rsa_alt_alloc_wrap( void )
if( ctx != NULL )
memset( ctx, 0, sizeof( rsa_alt_context ) );
return ctx;
return( ctx );
}
static void rsa_alt_free_wrap( void *ctx )

View File

@ -87,7 +87,7 @@ cleanup:
if( NULL != cert_blob )
polarssl_free( cert_blob );
return ret;
return( ret );
}
@ -113,7 +113,7 @@ int pkcs11_priv_key_init( pkcs11_context *priv_key,
cleanup:
x509_crt_free( &cert );
return ret;
return( ret );
}
void pkcs11_priv_key_free( pkcs11_context *priv_key )
@ -172,10 +172,10 @@ int pkcs11_sign( pkcs11_context *ctx,
const char *oid;
if( NULL == ctx )
return POLARSSL_ERR_RSA_BAD_INPUT_DATA;
return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
if( RSA_PRIVATE != mode )
return POLARSSL_ERR_RSA_BAD_INPUT_DATA;
return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
if( md_alg != POLARSSL_MD_NONE )
{

View File

@ -830,7 +830,7 @@ static int pk_parse_key_sec1_der( ecp_keypair *eck,
return( ret );
}
return 0;
return( 0 );
}
#endif /* POLARSSL_ECP_C */
@ -919,7 +919,7 @@ static int pk_parse_key_pkcs8_unencrypted_der(
#endif /* POLARSSL_ECP_C */
return( POLARSSL_ERR_PK_UNKNOWN_PK_ALG );
return 0;
return( 0 );
}
/*

View File

@ -604,7 +604,7 @@ int rsa_rsaes_pkcs1_v15_encrypt( rsa_context *ctx,
// Check if RNG failed to generate data
//
if( rng_dl == 0 || ret != 0)
return POLARSSL_ERR_RSA_RNG_FAILED + ret;
return( POLARSSL_ERR_RSA_RNG_FAILED + ret );
p++;
}

View File

@ -1702,7 +1702,7 @@ const int *ssl_list_ciphersuites( void )
supported_init = 1;
}
return supported_ciphersuites;
return( supported_ciphersuites );
};
const ssl_ciphersuite_t *ssl_ciphersuite_from_string(

View File

@ -650,7 +650,7 @@ int ssl_derive_keys( ssl_context *ssl )
transform->maclen ) ) != 0 )
{
SSL_DEBUG_RET( 1, "ssl_hw_record_init", ret );
return POLARSSL_ERR_SSL_HW_ACCEL_FAILED;
return( POLARSSL_ERR_SSL_HW_ACCEL_FAILED );
}
}
#endif /* POLARSSL_SSL_HW_RECORD_ACCEL */
@ -1887,7 +1887,7 @@ int ssl_write_record( ssl_context *ssl )
if( ret != 0 && ret != POLARSSL_ERR_SSL_HW_ACCEL_FALLTHROUGH )
{
SSL_DEBUG_RET( 1, "ssl_hw_record_write", ret );
return POLARSSL_ERR_SSL_HW_ACCEL_FAILED;
return( POLARSSL_ERR_SSL_HW_ACCEL_FAILED );
}
if( ret == 0 )
@ -2085,7 +2085,7 @@ int ssl_read_record( ssl_context *ssl )
if( ret != 0 && ret != POLARSSL_ERR_SSL_HW_ACCEL_FALLTHROUGH )
{
SSL_DEBUG_RET( 1, "ssl_hw_record_read", ret );
return POLARSSL_ERR_SSL_HW_ACCEL_FAILED;
return( POLARSSL_ERR_SSL_HW_ACCEL_FAILED );
}
if( ret == 0 )
@ -3622,7 +3622,7 @@ static ssl_key_cert *ssl_add_key_cert( ssl_context *ssl )
last->next = key_cert;
}
return key_cert;
return( key_cert );
}
void ssl_set_ca_chain( ssl_context *ssl, x509_crt *ca_chain,
@ -3864,7 +3864,7 @@ int ssl_set_alpn_protocols( ssl_context *ssl, const char **protos )
const char *ssl_get_alpn_protocol( const ssl_context *ssl )
{
return ssl->alpn_chosen;
return( ssl->alpn_chosen );
}
#endif /* POLARSSL_SSL_ALPN */
@ -3961,7 +3961,7 @@ int ssl_get_verify_result( const ssl_context *ssl )
const char *ssl_get_ciphersuite( const ssl_context *ssl )
{
if( ssl == NULL || ssl->session == NULL )
return NULL;
return( NULL );
return ssl_get_ciphersuite_name( ssl->session->ciphersuite );
}
@ -3992,9 +3992,9 @@ const char *ssl_get_version( const ssl_context *ssl )
const x509_crt *ssl_get_peer_cert( const ssl_context *ssl )
{
if( ssl == NULL || ssl->session == NULL )
return NULL;
return( NULL );
return ssl->session->peer_cert;
return( ssl->session->peer_cert );
}
#endif /* POLARSSL_X509_CRT_PARSE_C */

View File

@ -202,7 +202,7 @@ unsigned long hardclock( void )
QueryPerformanceCounter( &offset );
return (unsigned long)( offset.QuadPart );
return( (unsigned long)( offset.QuadPart ) );
}
#endif /* !POLARSSL_HAVE_HARDCLOCK && _MSC_VER && !EFIX64 && !EFI32 */

View File

@ -38,7 +38,7 @@ const char version[] = POLARSSL_VERSION_STRING;
unsigned int version_get_number()
{
return POLARSSL_VERSION_NUMBER;
return( POLARSSL_VERSION_NUMBER );
}
void version_get_string( char *string )

View File

@ -718,7 +718,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
if ( res < 0 )
return( (int) size + 20 );
return res;
return( res );
}
#define snprintf compat_snprintf
@ -726,18 +726,18 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
#define POLARSSL_ERR_DEBUG_BUF_TOO_SMALL -2
#define SAFE_SNPRINTF() \
{ \
if( ret == -1 ) \
return( -1 ); \
\
if ( (unsigned int) ret > n ) { \
p[n - 1] = '\0'; \
return POLARSSL_ERR_DEBUG_BUF_TOO_SMALL;\
} \
\
n -= (unsigned int) ret; \
p += (unsigned int) ret; \
#define SAFE_SNPRINTF() \
{ \
if( ret == -1 ) \
return( -1 ); \
\
if ( (unsigned int) ret > n ) { \
p[n - 1] = '\0'; \
return( POLARSSL_ERR_DEBUG_BUF_TOO_SMALL ); \
} \
\
n -= (unsigned int) ret; \
p += (unsigned int) ret; \
}
/*
@ -890,7 +890,7 @@ int x509_key_size_helper( char *buf, size_t size, const char *name )
int ret;
if( strlen( name ) + sizeof( " key size" ) > size )
return POLARSSL_ERR_DEBUG_BUF_TOO_SMALL;
return( POLARSSL_ERR_DEBUG_BUF_TOO_SMALL );
ret = snprintf( p, n, "%s key size", name );
SAFE_SNPRINTF();

View File

@ -594,7 +594,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
if ( res < 0 )
return( (int) size + 20 );
return res;
return( res );
}
#define snprintf compat_snprintf
@ -602,18 +602,18 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
#define POLARSSL_ERR_DEBUG_BUF_TOO_SMALL -2
#define SAFE_SNPRINTF() \
{ \
if( ret == -1 ) \
return( -1 ); \
\
if ( (unsigned int) ret > n ) { \
p[n - 1] = '\0'; \
return POLARSSL_ERR_DEBUG_BUF_TOO_SMALL;\
} \
\
n -= (unsigned int) ret; \
p += (unsigned int) ret; \
#define SAFE_SNPRINTF() \
{ \
if( ret == -1 ) \
return( -1 ); \
\
if ( (unsigned int) ret > n ) { \
p[n - 1] = '\0'; \
return( POLARSSL_ERR_DEBUG_BUF_TOO_SMALL ); \
} \
\
n -= (unsigned int) ret; \
p += (unsigned int) ret; \
}
/*

View File

@ -201,7 +201,7 @@ static int x509_get_basic_constraints( unsigned char **p,
return( POLARSSL_ERR_X509_INVALID_EXTENSIONS + ret );
if( *p == end )
return 0;
return( 0 );
if( ( ret = asn1_get_bool( p, end, ca_istrue ) ) != 0 )
{
@ -216,7 +216,7 @@ static int x509_get_basic_constraints( unsigned char **p,
}
if( *p == end )
return 0;
return( 0 );
if( ( ret = asn1_get_int( p, end, max_pathlen ) ) != 0 )
return( POLARSSL_ERR_X509_INVALID_EXTENSIONS + ret );
@ -227,7 +227,7 @@ static int x509_get_basic_constraints( unsigned char **p,
(*max_pathlen)++;
return 0;
return( 0 );
}
static int x509_get_ns_cert_type( unsigned char **p,
@ -246,7 +246,7 @@ static int x509_get_ns_cert_type( unsigned char **p,
/* Get actual bitstring */
*ns_cert_type = *bs.p;
return 0;
return( 0 );
}
static int x509_get_key_usage( unsigned char **p,
@ -265,7 +265,7 @@ static int x509_get_key_usage( unsigned char **p,
/* Get actual bitstring */
*key_usage = *bs.p;
return 0;
return( 0 );
}
/*
@ -287,7 +287,7 @@ static int x509_get_ext_key_usage( unsigned char **p,
return( POLARSSL_ERR_X509_INVALID_EXTENSIONS +
POLARSSL_ERR_ASN1_INVALID_LENGTH );
return 0;
return( 0 );
}
/*
@ -472,7 +472,7 @@ static int x509_get_crt_ext( unsigned char **p,
if( is_critical )
{
/* Data is marked as critical: fail */
return ( POLARSSL_ERR_X509_INVALID_EXTENSIONS +
return( POLARSSL_ERR_X509_INVALID_EXTENSIONS +
POLARSSL_ERR_ASN1_UNEXPECTED_TAG );
}
#endif
@ -487,35 +487,35 @@ static int x509_get_crt_ext( unsigned char **p,
/* Parse basic constraints */
if( ( ret = x509_get_basic_constraints( p, end_ext_octet,
&crt->ca_istrue, &crt->max_pathlen ) ) != 0 )
return ( ret );
return( ret );
break;
case EXT_KEY_USAGE:
/* Parse key usage */
if( ( ret = x509_get_key_usage( p, end_ext_octet,
&crt->key_usage ) ) != 0 )
return ( ret );
return( ret );
break;
case EXT_EXTENDED_KEY_USAGE:
/* Parse extended key usage */
if( ( ret = x509_get_ext_key_usage( p, end_ext_octet,
&crt->ext_key_usage ) ) != 0 )
return ( ret );
return( ret );
break;
case EXT_SUBJECT_ALT_NAME:
/* Parse subject alt name */
if( ( ret = x509_get_subject_alt_name( p, end_ext_octet,
&crt->subject_alt_names ) ) != 0 )
return ( ret );
return( ret );
break;
case EXT_NS_CERT_TYPE:
/* Parse netscape certificate type */
if( ( ret = x509_get_ns_cert_type( p, end_ext_octet,
&crt->ns_cert_type ) ) != 0 )
return ( ret );
return( ret );
break;
default:
@ -1097,7 +1097,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
if ( res < 0 )
return( (int) size + 20 );
return res;
return( res );
}
#define snprintf compat_snprintf
@ -1105,18 +1105,18 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
#define POLARSSL_ERR_DEBUG_BUF_TOO_SMALL -2
#define SAFE_SNPRINTF() \
{ \
if( ret == -1 ) \
return( -1 ); \
\
if ( (unsigned int) ret > n ) { \
p[n - 1] = '\0'; \
return POLARSSL_ERR_DEBUG_BUF_TOO_SMALL;\
} \
\
n -= (unsigned int) ret; \
p += (unsigned int) ret; \
#define SAFE_SNPRINTF() \
{ \
if( ret == -1 ) \
return( -1 ); \
\
if ( (unsigned int) ret > n ) { \
p[n - 1] = '\0'; \
return( POLARSSL_ERR_DEBUG_BUF_TOO_SMALL ); \
} \
\
n -= (unsigned int) ret; \
p += (unsigned int) ret; \
}
static int x509_info_subject_alt_name( char **buf, size_t *size,
@ -1525,7 +1525,7 @@ static int x509_crt_verifycrl( x509_crt *crt, x509_crt *ca,
crl_list = crl_list->next;
}
return flags;
return( flags );
}
#endif /* POLARSSL_X509_CRL_PARSE_C */

View File

@ -337,7 +337,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
if ( res < 0 )
return( (int) size + 20 );
return res;
return( res );
}
#define snprintf compat_snprintf
@ -345,18 +345,18 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
#define POLARSSL_ERR_DEBUG_BUF_TOO_SMALL -2
#define SAFE_SNPRINTF() \
{ \
if( ret == -1 ) \
return( -1 ); \
\
if ( (unsigned int) ret > n ) { \
p[n - 1] = '\0'; \
return POLARSSL_ERR_DEBUG_BUF_TOO_SMALL;\
} \
\
n -= (unsigned int) ret; \
p += (unsigned int) ret; \
#define SAFE_SNPRINTF() \
{ \
if( ret == -1 ) \
return( -1 ); \
\
if ( (unsigned int) ret > n ) { \
p[n - 1] = '\0'; \
return( POLARSSL_ERR_DEBUG_BUF_TOO_SMALL ); \
} \
\
n -= (unsigned int) ret; \
p += (unsigned int) ret; \
}
#define BEFORE_COLON 14