Commit 66d5d076 authored by Paul Bakker's avatar Paul Bakker

Fix formatting in various code to match spacing from coding style

parent db20c104
......@@ -420,10 +420,10 @@ static void aes_gen_tables( void )
{
x = pow[255 - log[i]];
y = x; y = ( (y << 1) | (y >> 7) ) & 0xFF;
x ^= y; y = ( (y << 1) | (y >> 7) ) & 0xFF;
x ^= y; y = ( (y << 1) | (y >> 7) ) & 0xFF;
x ^= y; y = ( (y << 1) | (y >> 7) ) & 0xFF;
y = x; y = ( ( y << 1 ) | ( y >> 7 ) ) & 0xFF;
x ^= y; y = ( ( y << 1 ) | ( y >> 7 ) ) & 0xFF;
x ^= y; y = ( ( y << 1 ) | ( y >> 7 ) ) & 0xFF;
x ^= y; y = ( ( y << 1 ) | ( y >> 7 ) ) & 0xFF;
x ^= y ^ 0x63;
FSb[i] = (unsigned char) x;
......@@ -504,7 +504,7 @@ int aes_setkey_enc( aes_context *ctx, const unsigned char *key,
return( aesni_setkey_enc( (unsigned char *) ctx->rk, key, keysize ) );
#endif
for( i = 0; i < (keysize >> 5); i++ )
for( i = 0; i < ( keysize >> 5 ); i++ )
{
GET_UINT32_LE( RK[i], key, i << 2 );
}
......@@ -726,7 +726,7 @@ int aes_crypt_ecb( aes_context *ctx,
if( mode == AES_DECRYPT )
{
for( i = (ctx->nr >> 1) - 1; i > 0; i-- )
for( i = ( ctx->nr >> 1 ) - 1; i > 0; i-- )
{
AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 );
AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 );
......@@ -760,7 +760,7 @@ int aes_crypt_ecb( aes_context *ctx,
}
else /* AES_ENCRYPT */
{
for( i = (ctx->nr >> 1) - 1; i > 0; i-- )
for( i = ( ctx->nr >> 1 ) - 1; i > 0; i-- )
{
AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 );
AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 );
......@@ -893,7 +893,7 @@ int aes_crypt_cfb128( aes_context *ctx,
*output++ = (unsigned char)( c ^ iv[n] );
iv[n] = (unsigned char) c;
n = (n + 1) & 0x0F;
n = ( n + 1 ) & 0x0F;
}
}
else
......@@ -905,7 +905,7 @@ int aes_crypt_cfb128( aes_context *ctx,
iv[n] = *output++ = (unsigned char)( iv[n] ^ *input++ );
n = (n + 1) & 0x0F;
n = ( n + 1 ) & 0x0F;
}
}
......@@ -930,7 +930,7 @@ int aes_crypt_cfb8( aes_context *ctx,
while( length-- )
{
memcpy(ov, iv, 16);
memcpy( ov, iv, 16 );
aes_crypt_ecb( ctx, AES_ENCRYPT, iv, iv );
if( mode == AES_DECRYPT )
......@@ -941,7 +941,7 @@ int aes_crypt_cfb8( aes_context *ctx,
if( mode == AES_ENCRYPT )
ov[16] = c;
memcpy(iv, ov + 1, 16);
memcpy( iv, ov + 1, 16 );
}
return( 0 );
......@@ -975,7 +975,7 @@ int aes_crypt_ctr( aes_context *ctx,
c = *input++;
*output++ = (unsigned char)( c ^ stream_block[n] );
n = (n + 1) & 0x0F;
n = ( n + 1 ) & 0x0F;
}
*nc_off = n;
......
/*
* AES-NI support functions
*
* Copyright (C) 2013, Brainspark B.V.
* Copyright (C) 2006-2014, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......
......@@ -194,7 +194,7 @@ int asn1_get_bitstring( unsigned char **p, const unsigned char *end,
return( ret );
/* Check length, subtract one for actual bit string length */
if ( bs->len < 1 )
if( bs->len < 1 )
return( POLARSSL_ERR_ASN1_OUT_OF_DATA );
bs->len -= 1;
......@@ -265,7 +265,7 @@ int asn1_get_sequence_of( unsigned char **p,
*p += buf->len;
/* Allocate and assign next pointer */
if (*p < end)
if( *p < end )
{
cur->next = (asn1_sequence *) polarssl_malloc(
sizeof( asn1_sequence ) );
......
......@@ -118,7 +118,7 @@ int asn1_write_mpi( unsigned char **p, unsigned char *start, mpi *X )
// DER format assumes 2s complement for numbers, so the leftmost bit
// should be 0 for positive numbers and 1 for negative numbers.
//
if ( X->s ==1 && **p & 0x80 )
if( X->s ==1 && **p & 0x80 )
{
if( *p - start < 1 )
return( POLARSSL_ERR_ASN1_BUF_TOO_SMALL );
......@@ -217,7 +217,7 @@ int asn1_write_int( unsigned char **p, unsigned char *start, int val )
len += 1;
*--(*p) = val;
if ( val > 0 && **p & 0x80 )
if( val > 0 && **p & 0x80 )
{
if( *p - start < 1 )
return( POLARSSL_ERR_ASN1_BUF_TOO_SMALL );
......
......@@ -87,9 +87,9 @@ int base64_encode( unsigned char *dst, size_t *dlen,
if( slen == 0 )
return( 0 );
n = (slen << 3) / 6;
n = ( slen << 3 ) / 6;
switch( (slen << 3) - (n * 6) )
switch( ( slen << 3 ) - ( n * 6 ) )
{
case 2: n += 3; break;
case 4: n += 2; break;
......@@ -102,7 +102,7 @@ int base64_encode( unsigned char *dst, size_t *dlen,
return( POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL );
}
n = (slen / 3) * 3;
n = ( slen / 3 ) * 3;
for( i = 0, p = dst; i < n; i += 3 )
{
......@@ -119,12 +119,12 @@ int base64_encode( unsigned char *dst, size_t *dlen,
if( i < slen )
{
C1 = *src++;
C2 = ((i + 1) < slen) ? *src++ : 0;
C2 = ( ( i + 1 ) < slen ) ? *src++ : 0;
*p++ = base64_enc_map[(C1 >> 2) & 0x3F];
*p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F];
if( (i + 1) < slen )
if( ( i + 1 ) < slen )
*p++ = base64_enc_map[((C2 & 15) << 2) & 0x3F];
else *p++ = '=';
......@@ -171,7 +171,7 @@ int base64_decode( unsigned char *dst, size_t *dlen,
if( n == 0 )
return( 0 );
n = ((n * 6) + 7) >> 3;
n = ( ( n * 6 ) + 7 ) >> 3;
if( dst == NULL || *dlen < n )
{
......@@ -185,7 +185,7 @@ int base64_decode( unsigned char *dst, size_t *dlen,
continue;
j -= ( base64_dec_map[*src] == 64 );
x = (x << 6) | ( base64_dec_map[*src] & 0x3F );
x = ( x << 6 ) | ( base64_dec_map[*src] & 0x3F );
if( ++n == 4 )
{
......
......@@ -229,13 +229,13 @@ int mpi_safe_cond_assign( mpi *X, const mpi *Y, unsigned char assign )
MPI_CHK( mpi_grow( X, Y->n ) );
X->s = X->s * (1 - assign) + Y->s * assign;
X->s = X->s * ( 1 - assign ) + Y->s * assign;
for( i = 0; i < Y->n; i++ )
X->p[i] = X->p[i] * (1 - assign) + Y->p[i] * assign;
X->p[i] = X->p[i] * ( 1 - assign ) + Y->p[i] * assign;
for( ; i < X->n; i++ )
X->p[i] *= (1 - assign);
X->p[i] *= ( 1 - assign );
cleanup:
return( ret );
......@@ -263,15 +263,15 @@ int mpi_safe_cond_swap( mpi *X, mpi *Y, unsigned char swap )
MPI_CHK( mpi_grow( Y, X->n ) );
s = X->s;
X->s = X->s * (1 - swap) + Y->s * swap;
Y->s = Y->s * (1 - swap) + s * swap;
X->s = X->s * ( 1 - swap ) + Y->s * swap;
Y->s = Y->s * ( 1 - swap ) + s * swap;
for( i = 0; i < X->n; i++ )
{
tmp = X->p[i];
X->p[i] = X->p[i] * (1 - swap) + Y->p[i] * swap;
Y->p[i] = Y->p[i] * (1 - swap) + tmp * swap;
X->p[i] = X->p[i] * ( 1 - swap ) + Y->p[i] * swap;
Y->p[i] = Y->p[i] * ( 1 - swap ) + tmp * swap;
}
cleanup:
......@@ -426,7 +426,7 @@ int mpi_read_string( mpi *X, int radix, const char *s )
}
MPI_CHK( mpi_get_digit( &d, radix, s[i - 1] ) );
X->p[j / (2 * ciL)] |= d << ( (j % (2 * ciL)) << 2 );
X->p[j / ( 2 * ciL )] |= d << ( ( j % ( 2 * ciL ) ) << 2 );
}
}
else
......@@ -1226,14 +1226,14 @@ int mpi_div_mpi( mpi *Q, mpi *R, const mpi *A, const mpi *B )
n = X.n - 1;
t = Y.n - 1;
MPI_CHK( mpi_shift_l( &Y, biL * (n - t) ) );
MPI_CHK( mpi_shift_l( &Y, biL * ( n - t ) ) );
while( mpi_cmp_mpi( &X, &Y ) >= 0 )
{
Z.p[n - t]++;
MPI_CHK( mpi_sub_mpi( &X, &X, &Y ) );
}
MPI_CHK( mpi_shift_r( &Y, biL * (n - t) ) );
MPI_CHK( mpi_shift_r( &Y, biL * ( n - t ) ) );
for( i = n; i > t ; i-- )
{
......@@ -1257,8 +1257,8 @@ int mpi_div_mpi( mpi *Q, mpi *R, const mpi *A, const mpi *B )
r = (t_udbl) X.p[i] << biL;
r |= (t_udbl) X.p[i - 1];
r /= Y.p[t];
if( r > ((t_udbl) 1 << biL) - 1)
r = ((t_udbl) 1 << biL) - 1;
if( r > ( (t_udbl) 1 << biL ) - 1 )
r = ( (t_udbl) 1 << biL ) - 1;
Z.p[i - t - 1] = (t_uint) r;
#else
......@@ -1310,25 +1310,25 @@ int mpi_div_mpi( mpi *Q, mpi *R, const mpi *A, const mpi *B )
Z.p[i - t - 1]--;
MPI_CHK( mpi_lset( &T1, 0 ) );
T1.p[0] = (t < 1) ? 0 : Y.p[t - 1];
T1.p[0] = ( t < 1 ) ? 0 : Y.p[t - 1];
T1.p[1] = Y.p[t];
MPI_CHK( mpi_mul_int( &T1, &T1, Z.p[i - t - 1] ) );
MPI_CHK( mpi_lset( &T2, 0 ) );
T2.p[0] = (i < 2) ? 0 : X.p[i - 2];
T2.p[1] = (i < 1) ? 0 : X.p[i - 1];
T2.p[0] = ( i < 2 ) ? 0 : X.p[i - 2];
T2.p[1] = ( i < 1 ) ? 0 : X.p[i - 1];
T2.p[2] = X.p[i];
}
while( mpi_cmp_mpi( &T1, &T2 ) > 0 );
MPI_CHK( mpi_mul_int( &T1, &Y, Z.p[i - t - 1] ) );
MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) );
MPI_CHK( mpi_shift_l( &T1, biL * ( i - t - 1 ) ) );
MPI_CHK( mpi_sub_mpi( &X, &X, &T1 ) );
if( mpi_cmp_int( &X, 0 ) < 0 )
{
MPI_CHK( mpi_copy( &T1, &Y ) );
MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) );
MPI_CHK( mpi_shift_l( &T1, biL * ( i - t - 1 ) ) );
MPI_CHK( mpi_add_mpi( &X, &X, &T1 ) );
Z.p[i - t - 1]--;
}
......@@ -1500,7 +1500,7 @@ static void mpi_montmul( mpi *A, const mpi *B, const mpi *N, t_uint mm,
*d++ = u0; d[n + 1] = 0;
}
memcpy( A->p, d, (n + 1) * ciL );
memcpy( A->p, d, ( n + 1 ) * ciL );
if( mpi_cmp_abs( A, N ) >= 0 )
mpi_sub_hlp( n, N->p, A->p );
......@@ -1610,7 +1610,7 @@ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR )
/*
* W[1 << (wsize - 1)] = W[1] ^ (wsize - 1)
*/
j = one << (wsize - 1);
j = one << ( wsize - 1 );
MPI_CHK( mpi_grow( &W[j], N->n + 1 ) );
MPI_CHK( mpi_copy( &W[j], &W[1] ) );
......@@ -1621,7 +1621,7 @@ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR )
/*
* W[i] = W[i - 1] * W[1]
*/
for( i = j + 1; i < (one << wsize); i++ )
for( i = j + 1; i < ( one << wsize ); i++ )
{
MPI_CHK( mpi_grow( &W[i], N->n + 1 ) );
MPI_CHK( mpi_copy( &W[i], &W[i - 1] ) );
......@@ -1673,7 +1673,7 @@ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR )
state = 2;
nbits++;
wbits |= (ei << (wsize - nbits));
wbits |= ( ei << ( wsize - nbits ) );
if( nbits == wsize )
{
......@@ -1703,7 +1703,7 @@ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR )
wbits <<= 1;
if( (wbits & (one << wsize)) != 0 )
if( ( wbits & ( one << wsize ) ) != 0 )
mpi_montmul( X, &W[1], N, mm, &T );
}
......@@ -1720,7 +1720,7 @@ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR )
cleanup:
for( i = (one << (wsize - 1)); i < (one << wsize); i++ )
for( i = ( one << ( wsize - 1 ) ); i < ( one << wsize ); i++ )
mpi_free( &W[i] );
mpi_free( &W[1] ); mpi_free( &T ); mpi_free( &Apos );
......@@ -1748,7 +1748,7 @@ int mpi_gcd( mpi *G, const mpi *A, const mpi *B )
lz = mpi_lsb( &TA );
lzt = mpi_lsb( &TB );
if ( lzt < lz )
if( lzt < lz )
lz = lzt;
MPI_CHK( mpi_shift_r( &TA, lz ) );
......@@ -2305,7 +2305,7 @@ int mpi_self_test( int verbose )
if( verbose != 0 )
polarssl_printf( " MPI test #5 (simple gcd): " );
for ( i = 0; i < GCD_PAIR_COUNT; i++)
for( i = 0; i < GCD_PAIR_COUNT; i++ )
{
MPI_CHK( mpi_lset( &X, gcd_pairs[i][0] ) );
MPI_CHK( mpi_lset( &Y, gcd_pairs[i][1] ) );
......
......@@ -75,7 +75,7 @@ static const uint32_t P[BLOWFISH_ROUNDS + 2] = {
/* declarations of data at the end of this file */
static const uint32_t S[4][256];
static uint32_t F(blowfish_context *ctx, uint32_t x)
static uint32_t F( blowfish_context *ctx, uint32_t x )
{
unsigned short a, b, c, d;
uint32_t y;
......@@ -94,7 +94,7 @@ static uint32_t F(blowfish_context *ctx, uint32_t x)
return( y );
}
static void blowfish_enc(blowfish_context *ctx, uint32_t *xl, uint32_t *xr)
static void blowfish_enc( blowfish_context *ctx, uint32_t *xl, uint32_t *xr )
{
uint32_t Xl, Xr, temp;
short i;
......@@ -102,10 +102,10 @@ static void blowfish_enc(blowfish_context *ctx, uint32_t *xl, uint32_t *xr)
Xl = *xl;
Xr = *xr;
for (i = 0; i < BLOWFISH_ROUNDS; ++i)
for( i = 0; i < BLOWFISH_ROUNDS; ++i )
{
Xl = Xl ^ ctx->P[i];
Xr = F(ctx, Xl) ^ Xr;
Xr = F( ctx, Xl ) ^ Xr;
temp = Xl;
Xl = Xr;
......@@ -123,7 +123,7 @@ static void blowfish_enc(blowfish_context *ctx, uint32_t *xl, uint32_t *xr)
*xr = Xr;
}
static void blowfish_dec(blowfish_context *ctx, uint32_t *xl, uint32_t *xr)
static void blowfish_dec( blowfish_context *ctx, uint32_t *xl, uint32_t *xr )
{
uint32_t Xl, Xr, temp;
short i;
......@@ -131,10 +131,10 @@ static void blowfish_dec(blowfish_context *ctx, uint32_t *xl, uint32_t *xr)
Xl = *xl;
Xr = *xr;
for (i = BLOWFISH_ROUNDS + 1; i > 1; --i)
for( i = BLOWFISH_ROUNDS + 1; i > 1; --i )
{
Xl = Xl ^ ctx->P[i];
Xr = F(ctx, Xl) ^ Xr;
Xr = F( ctx, Xl ) ^ Xr;
temp = Xl;
Xl = Xr;
......@@ -225,11 +225,11 @@ int blowfish_crypt_ecb( blowfish_context *ctx,
if( mode == BLOWFISH_DECRYPT )
{
blowfish_dec(ctx, &X0, &X1);
blowfish_dec( ctx, &X0, &X1 );
}
else /* BLOWFISH_ENCRYPT */
{
blowfish_enc(ctx, &X0, &X1);
blowfish_enc( ctx, &X0, &X1 );
}
PUT_UINT32_BE( X0, output, 0 );
......@@ -318,7 +318,7 @@ int blowfish_crypt_cfb64( blowfish_context *ctx,
*output++ = (unsigned char)( c ^ iv[n] );
iv[n] = (unsigned char) c;
n = (n + 1) % BLOWFISH_BLOCKSIZE;
n = ( n + 1 ) % BLOWFISH_BLOCKSIZE;
}
}
else
......@@ -330,7 +330,7 @@ int blowfish_crypt_cfb64( blowfish_context *ctx,
iv[n] = *output++ = (unsigned char)( iv[n] ^ *input++ );
n = (n + 1) % BLOWFISH_BLOCKSIZE;
n = ( n + 1 ) % BLOWFISH_BLOCKSIZE;
}
}
......@@ -368,7 +368,7 @@ int blowfish_crypt_ctr( blowfish_context *ctx,
c = *input++;
*output++ = (unsigned char)( c ^ stream_block[n] );
n = (n + 1) % BLOWFISH_BLOCKSIZE;
n = ( n + 1 ) % BLOWFISH_BLOCKSIZE;
}
*nc_off = n;
......
This diff is collapsed.
......@@ -345,7 +345,7 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input,
{
copy_len = ilen % cipher_get_block_size( ctx );
if( copy_len == 0 && ctx->operation == POLARSSL_DECRYPT )
copy_len = cipher_get_block_size(ctx);
copy_len = cipher_get_block_size( ctx );
memcpy( ctx->unprocessed_data, &( input[ilen - copy_len] ),
copy_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 */
......@@ -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 */
......@@ -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 */
......@@ -637,7 +637,7 @@ int cipher_finish( cipher_context_t *ctx,
ctx->add_padding( ctx->unprocessed_data, cipher_get_iv_size( ctx ),
ctx->unprocessed_len );
}
else if ( cipher_get_block_size( ctx ) != ctx->unprocessed_len )
else if( cipher_get_block_size( ctx ) != ctx->unprocessed_len )
{
/*
* For decrypt operations, expect a full block,
......
......@@ -1237,7 +1237,7 @@ static int arc4_setkey_wrap( void *ctx, const unsigned char *key,
unsigned int key_length )
{
/* we get key_length in bits, arc4 expects it in bytes */
if( key_length % 8 != 0)
if( key_length % 8 != 0 )
return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
arc4_setup( (arc4_context *) ctx, key, key_length / 8 );
......
......@@ -336,7 +336,7 @@ int ctr_drbg_random_with_add( void *p_rng,
*/
aes_crypt_ecb( &ctx->aes_ctx, AES_ENCRYPT, ctx->counter, tmp );
use_len = (output_len > CTR_DRBG_BLOCKSIZE ) ? CTR_DRBG_BLOCKSIZE :
use_len = ( output_len > CTR_DRBG_BLOCKSIZE ) ? CTR_DRBG_BLOCKSIZE :
output_len;
/*
* Copy random block to destination
......
/*
* Debugging routines
*
* Copyright (C) 2006-2010, Brainspark B.V.
* Copyright (C) 2006-2014, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
......@@ -229,7 +229,7 @@ void debug_print_mpi( const ssl_context *ssl, int level,
for( k = sizeof( t_uint ) - 1; k >= 0; k-- )
{
if( zeros && ( ( X->p[i - 1] >> (k << 3) ) & 0xFF ) == 0 )
if( zeros && ( ( X->p[i - 1] >> ( k << 3 ) ) & 0xFF ) == 0 )
continue;
else
zeros = 0;
......@@ -248,7 +248,7 @@ void debug_print_mpi( const ssl_context *ssl, int level,
}
idx += snprintf( str + idx, maxlen - idx, " %02x", (unsigned int)
( X->p[i - 1] >> (k << 3) ) & 0xFF );
( X->p[i - 1] >> ( k << 3 ) ) & 0xFF );
j++;
}
......
......@@ -332,7 +332,7 @@ int des_key_check_key_parity( const unsigned char key[DES_KEY_SIZE] )
int i;
for( i = 0; i < DES_KEY_SIZE; i++ )
if ( key[i] != odd_parity_table[key[i] / 2] )
if( key[i] != odd_parity_table[key[i] / 2] )
return( 1 );
return( 0 );
......@@ -387,7 +387,7 @@ int des_key_check_weak( const unsigned char key[DES_KEY_SIZE] )
int i;
for( i = 0; i < WEAK_KEY_COUNT; i++ )
if( memcmp( weak_key_table[i], key, DES_KEY_SIZE) == 0)
if( memcmp( weak_key_table[i], key, DES_KEY_SIZE) == 0 )
return( 1 );
return( 0 );
......
......@@ -535,7 +535,7 @@ int dhm_parse_dhmfile( dhm_context *dhm, const char *path )
size_t n;
unsigned char *buf;
if ( ( ret = load_file( path, &buf, &n ) ) != 0 )
if( ( ret = load_file( path, &buf, &n ) ) != 0 )
return( ret );
ret = dhm_parse_dhm( dhm, buf, n );
......
......@@ -101,13 +101,13 @@ void ecdh_free( ecdh_context *ctx )
return;
ecp_group_free( &ctx->grp );
mpi_free ( &ctx->d );
ecp_point_free( &ctx->Q );
ecp_point_free( &ctx->Qp );
mpi_free ( &ctx->z );
ecp_point_free( &ctx->Vi );
ecp_point_free( &ctx->Vf );
mpi_free ( &ctx->_d );
mpi_free( &ctx->d );
mpi_free( &ctx->z );
mpi_free( &ctx->_d );
}
/*
......
......@@ -80,7 +80,7 @@ static int derive_mpi( const ecp_group *grp, mpi *x,
const unsigned char *buf, size_t blen )
{
int ret;
size_t n_size = (grp->nbits + 7) / 8;
size_t n_size = ( grp->nbits + 7 ) / 8;
size_t use_size = blen > n_size ? n_size : blen;
MPI_CHK( mpi_read_binary( x, buf, use_size ) );
......@@ -147,7 +147,7 @@ int ecdsa_sign( ecp_group *grp, mpi *r, mpi *s,
blind_tries = 0;
do
{
size_t n_size = (grp->nbits + 7) / 8;
size_t n_size = ( grp->nbits + 7 ) / 8;
MPI_CHK( mpi_fill_random( &t, n_size, f_rng, p_rng ) );
MPI_CHK( mpi_shift_r( &t, 8 * n_size - grp->nbits ) );
......
......@@ -302,7 +302,7 @@ void ecp_group_init( ecp_group *grp )
*/
void ecp_keypair_init( ecp_keypair *key )
{
if ( key == NULL )
if( key == NULL )
return;
ecp_group_init( &key->grp );
......@@ -357,7 +357,7 @@ void ecp_group_free( ecp_group *grp )
*/
void ecp_keypair_free( ecp_keypair *key )
{
if ( key == NULL )
if( key == NULL )
return;
ecp_group_free( &key->grp );
......@@ -1123,7 +1123,7 @@ static int ecp_randomize_jac( const ecp_group *grp, ecp_point *pt,
{
int ret;
mpi l, ll;
size_t p_size = (grp->pbits + 7) / 8;
size_t p_size = ( grp->pbits + 7 ) / 8;
int count = 0;
mpi_init( &l ); mpi_init( &ll );
......@@ -1247,7 +1247,7 @@ static int ecp_precompute_comb( const ecp_group *grp,
MPI_CHK( ecp_copy( &T[0], P ) );
k = 0;
for( i = 1; i < ( 1U << (w-1) ); i <<= 1 )
for( i = 1; i < ( 1U << ( w - 1 ) ); i <<= 1 )
{
cur = T + i;
MPI_CHK( ecp_copy( cur, T + ( i >> 1 ) ) );
......@@ -1264,7 +1264,7 @@ static int ecp_precompute_comb( const ecp_group *grp,
* Be careful to update T[2^l] only after using it!
*/
k = 0;
for( i = 1; i < ( 1U << (w-1) ); i <<= 1 )
for( i = 1; i < ( 1U << ( w - 1 ) ); i <<= 1 )
{
j = i;
while( j-- )
......@@ -1508,7 +1508,7 @@ static int ecp_randomize_mxz( const ecp_group *grp, ecp_point *P,
{
int ret;
mpi l;
size_t p_size = (grp->pbits + 7) / 8;
size_t p_size = ( grp->pbits + 7 ) / 8;
int count = 0;
mpi_init( &l );
......@@ -1805,7 +1805,7 @@ int ecp_gen_keypair( ecp_group *grp, mpi *d, ecp_point *Q,
void *p_rng )
{
int ret;
size_t n_size = (grp->nbits + 7) / 8;
size_t n_size = ( grp->nbits + 7 ) / 8;
#if defined(POLARSSL_ECP_MONTGOMERY)
if( ecp_get_type( grp ) == POLARSSL_ECP_TYPE_MONTGOMERY )
......
......@@ -1288,12 +1288,12 @@ static inline int ecp_mod_koblitz( mpi *N, t_uint *Rp, size_t p_limbs,
M.n = p_limbs + adjust;
memset( Mp, 0, sizeof Mp );
memcpy( Mp, N->p + p_limbs - adjust, M.n * sizeof( t_uint ) );
if (shift != 0 )
if( shift != 0 )
MPI_CHK( mpi_shift_r( &M, shift ) );
M.n += R.n - adjust; /* Make room for multiplication by R */
/* N = A0 */
if (mask != 0 )
if( mask != 0 )
N->p[p_limbs - 1] &= mask;
for( i = p_limbs; i < N->n; i++ )
N->p[i] = 0;
......@@ -1310,12 +1310,12 @@ static inline int ecp_mod_koblitz( mpi *N, t_uint *Rp, size_t p_limbs,
M.n = p_limbs + adjust;
memset( Mp, 0, sizeof Mp );
memcpy( Mp, N->p + p_limbs - adjust, M.n * sizeof( t_uint ) );
if (shift != 0 )
if( shift != 0 )
MPI_CHK( mpi_shift_r( &M, shift ) );
M.n += R.n - adjust; /* Make room for multiplication by R */