From 66d5d076f754507e1746597a337053e2f7e64cf7 Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Tue, 17 Jun 2014 16:39:18 +0200
Subject: [PATCH] Fix formatting in various code to match spacing from coding
style
---
library/aes.c | 24 +++---
library/aesni.c | 2 +-
library/asn1parse.c | 4 +-
library/asn1write.c | 4 +-
library/base64.c | 14 ++--
library/bignum.c | 50 ++++++------
library/blowfish.c | 24 +++---
library/camellia.c | 146 +++++++++++++++++-----------------
library/cipher.c | 10 +--
library/cipher_wrap.c | 2 +-
library/ctr_drbg.c | 2 +-
library/debug.c | 6 +-
library/des.c | 4 +-
library/dhm.c | 2 +-
library/ecdh.c | 6 +-
library/ecdsa.c | 4 +-
library/ecp.c | 14 ++--
library/ecp_curves.c | 8 +-
library/entropy.c | 2 +-
library/gcm.c | 2 +-
library/havege.c | 2 +-
library/md.c | 10 +--
library/memory_buffer_alloc.c | 4 +-
library/net.c | 4 +-
library/oid.c | 14 ++--
library/padlock.c | 4 +-
library/pbkdf2.c | 2 +-
library/pk.c | 4 +-
library/pkcs11.c | 10 +--
library/pkcs12.c | 8 +-
library/pkcs5.c | 8 +-
library/pkparse.c | 6 +-
library/rsa.c | 6 +-
library/sha1.c | 4 +-
library/ssl_cli.c | 4 +-
library/ssl_srv.c | 7 +-
library/ssl_tls.c | 60 +++++++-------
library/threading.c | 2 +-
library/timing.c | 10 +--
library/x509.c | 14 ++--
library/x509_create.c | 2 +-
library/x509_crl.c | 22 ++---
library/x509_crt.c | 28 +++----
library/x509_csr.c | 8 +-
library/x509write_crt.c | 8 +-
library/xtea.c | 4 +-
46 files changed, 293 insertions(+), 292 deletions(-)
diff --git a/library/aes.c b/library/aes.c
index 38e5e954b..a90cefff5 100644
--- a/library/aes.c
+++ b/library/aes.c
@@ -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;
diff --git a/library/aesni.c b/library/aesni.c
index 9d21c85d4..9bd780f27 100644
--- a/library/aesni.c
+++ b/library/aesni.c
@@ -1,7 +1,7 @@
/*
* 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
diff --git a/library/asn1parse.c b/library/asn1parse.c
index 79b290124..97443529a 100644
--- a/library/asn1parse.c
+++ b/library/asn1parse.c
@@ -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 ) );
diff --git a/library/asn1write.c b/library/asn1write.c
index b6294bbec..ebc0e9766 100644
--- a/library/asn1write.c
+++ b/library/asn1write.c
@@ -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 );
diff --git a/library/base64.c b/library/base64.c
index d7f364224..5b1418bdd 100644
--- a/library/base64.c
+++ b/library/base64.c
@@ -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 )
{
diff --git a/library/bignum.c b/library/bignum.c
index 110c3f4b0..e7b8d6d6a 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -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] ) );
diff --git a/library/blowfish.c b/library/blowfish.c
index 1ac01caf4..d8b0c36ce 100644
--- a/library/blowfish.c
+++ b/library/blowfish.c
@@ -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;
diff --git a/library/camellia.c b/library/camellia.c
index b5d5eccfb..f1d4d6b24 100644
--- a/library/camellia.c
+++ b/library/camellia.c
@@ -287,14 +287,14 @@ static const signed char transposes[2][20] =
TK[2] = KC[(OFFSET) * 4 + 2]; \
TK[3] = KC[(OFFSET) * 4 + 3]; \
\
- for ( i = 1; i <= 4; i++ ) \
- if (shifts[(INDEX)][(OFFSET)][i -1]) \
- ROTL(TK + i * 4, TK, (15 * i) % 32); \
+ for( i = 1; i <= 4; i++ ) \
+ if( shifts[(INDEX)][(OFFSET)][i -1] ) \
+ ROTL(TK + i * 4, TK, ( 15 * i ) % 32); \
\
- for ( i = 0; i < 20; i++ ) \
- if (indexes[(INDEX)][(OFFSET)][i] != -1) { \
- RK[indexes[(INDEX)][(OFFSET)][i]] = TK[ i ]; \
- } \
+ for( i = 0; i < 20; i++ ) \
+ if( indexes[(INDEX)][(OFFSET)][i] != -1 ) { \
+ RK[indexes[(INDEX)][(OFFSET)][i]] = TK[ i ]; \
+ } \
}
static void camellia_feistel( const uint32_t x[2], const uint32_t k[2],
@@ -338,8 +338,8 @@ int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key,
RK = ctx->rk;
- memset(t, 0, 64);
- memset(RK, 0, sizeof(ctx->rk));
+ memset( t, 0, 64 );
+ memset( RK, 0, sizeof(ctx->rk) );
switch( keysize )
{
@@ -349,52 +349,52 @@ int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key,
default : return( POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH );
}
- for( i = 0; i < keysize / 8; ++i)
+ for( i = 0; i < keysize / 8; ++i )
t[i] = key[i];
- if (keysize == 192) {
- for (i = 0; i < 8; i++)
+ if( keysize == 192 ) {
+ for( i = 0; i < 8; i++ )
t[24 + i] = ~t[16 + i];
}
/*
* Prepare SIGMA values
*/
- for (i = 0; i < 6; i++) {
- GET_UINT32_BE(SIGMA[i][0], SIGMA_CHARS[i], 0);
- GET_UINT32_BE(SIGMA[i][1], SIGMA_CHARS[i], 4);
+ for( i = 0; i < 6; i++ ) {
+ GET_UINT32_BE( SIGMA[i][0], SIGMA_CHARS[i], 0 );
+ GET_UINT32_BE( SIGMA[i][1], SIGMA_CHARS[i], 4 );
}
/*
* Key storage in KC
* Order: KL, KR, KA, KB
*/
- memset(KC, 0, sizeof(KC));
+ memset( KC, 0, sizeof(KC) );
/* Store KL, KR */
- for (i = 0; i < 8; i++)
- GET_UINT32_BE(KC[i], t, i * 4);
+ for( i = 0; i < 8; i++ )
+ GET_UINT32_BE( KC[i], t, i * 4 );
/* Generate KA */
- for( i = 0; i < 4; ++i)
+ for( i = 0; i < 4; ++i )
KC[8 + i] = KC[i] ^ KC[4 + i];
- camellia_feistel(KC + 8, SIGMA[0], KC + 10);
- camellia_feistel(KC + 10, SIGMA[1], KC + 8);
+ camellia_feistel( KC + 8, SIGMA[0], KC + 10 );
+ camellia_feistel( KC + 10, SIGMA[1], KC + 8 );
- for( i = 0; i < 4; ++i)
+ for( i = 0; i < 4; ++i )
KC[8 + i] ^= KC[i];
- camellia_feistel(KC + 8, SIGMA[2], KC + 10);
- camellia_feistel(KC + 10, SIGMA[3], KC + 8);
+ camellia_feistel( KC + 8, SIGMA[2], KC + 10 );
+ camellia_feistel( KC + 10, SIGMA[3], KC + 8 );
- if (keysize > 128) {
+ if( keysize > 128 ) {
/* Generate KB */
- for( i = 0; i < 4; ++i)
+ for( i = 0; i < 4; ++i )
KC[12 + i] = KC[4 + i] ^ KC[8 + i];
- camellia_feistel(KC + 12, SIGMA[4], KC + 14);
- camellia_feistel(KC + 14, SIGMA[5], KC + 12);
+ camellia_feistel( KC + 12, SIGMA[4], KC + 14 );
+ camellia_feistel( KC + 14, SIGMA[5], KC + 12 );
}
/*
@@ -402,24 +402,24 @@ int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key,
*/
/* Manipulating KL */
- SHIFT_AND_PLACE(idx, 0);
+ SHIFT_AND_PLACE( idx, 0 );
/* Manipulating KR */
- if (keysize > 128) {
- SHIFT_AND_PLACE(idx, 1);
+ if( keysize > 128 ) {
+ SHIFT_AND_PLACE( idx, 1 );
}
/* Manipulating KA */
- SHIFT_AND_PLACE(idx, 2);
+ SHIFT_AND_PLACE( idx, 2 );
/* Manipulating KB */
- if (keysize > 128) {
- SHIFT_AND_PLACE(idx, 3);
+ if( keysize > 128 ) {
+ SHIFT_AND_PLACE( idx, 3 );
}
/* Do transpositions */
- for ( i = 0; i < 20; i++ ) {
- if (transposes[idx][i] != -1) {
+ for( i = 0; i < 20; i++ ) {
+ if( transposes[idx][i] != -1 ) {
RK[32 + 12 * idx + i] = RK[transposes[idx][i]];
}
}
@@ -441,7 +441,7 @@ int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key,
int ret;
/* Also checks keysize */
- if( ( ret = camellia_setkey_enc(&cty, key, keysize) ) )
+ if( ( ret = camellia_setkey_enc( &cty, key, keysize ) ) )
return( ret );
ctx->nr = cty.nr;
@@ -455,7 +455,7 @@ int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key,
*RK++ = *SK++;
*RK++ = *SK++;
- for (i = 22 + 8 * idx, SK -= 6; i > 0; i--, SK -= 4)
+ for( i = 22 + 8 * idx, SK -= 6; i > 0; i--, SK -= 4 )
{
*RK++ = *SK++;
*RK++ = *SK++;
@@ -499,22 +499,22 @@ int camellia_crypt_ecb( camellia_context *ctx,
X[2] ^= *RK++;
X[3] ^= *RK++;
- while (NR) {
+ while( NR ) {
--NR;
- camellia_feistel(X, RK, X + 2);
+ camellia_feistel( X, RK, X + 2 );
RK += 2;
- camellia_feistel(X + 2, RK, X);
+ camellia_feistel( X + 2, RK, X );
RK += 2;
- camellia_feistel(X, RK, X + 2);
+ camellia_feistel( X, RK, X + 2 );
RK += 2;
- camellia_feistel(X + 2, RK, X);
+ camellia_feistel( X + 2, RK, X );
RK += 2;
- camellia_feistel(X, RK, X + 2);
+ camellia_feistel( X, RK, X + 2 );
RK += 2;
- camellia_feistel(X + 2, RK, X);
+ camellia_feistel( X + 2, RK, X );
RK += 2;
- if (NR) {
+ if( NR ) {
FL(X[0], X[1], RK[0], RK[1]);
RK += 2;
FLInv(X[2], X[3], RK[0], RK[1]);
@@ -615,7 +615,7 @@ int camellia_crypt_cfb128( camellia_context *ctx,
*output++ = (unsigned char)( c ^ iv[n] );
iv[n] = (unsigned char) c;
- n = (n + 1) & 0x0F;
+ n = ( n + 1 ) & 0x0F;
}
}
else
@@ -627,7 +627,7 @@ int camellia_crypt_cfb128( camellia_context *ctx,
iv[n] = *output++ = (unsigned char)( iv[n] ^ *input++ );
- n = (n + 1) & 0x0F;
+ n = ( n + 1 ) & 0x0F;
}
}
@@ -665,7 +665,7 @@ int camellia_crypt_ctr( camellia_context *ctx,
c = *input++;
*output++ = (unsigned char)( c ^ stream_block[n] );
- n = (n + 1) & 0x0F;
+ n = ( n + 1 ) & 0x0F;
}
*nc_off = n;
@@ -897,7 +897,7 @@ int camellia_self_test( int verbose )
memset( key, 0, 32 );
- for (j = 0; j < 6; j++) {
+ for( j = 0; j < 6; j++ ) {
u = j >> 1;
v = j & 1;
@@ -905,20 +905,20 @@ int camellia_self_test( int verbose )
polarssl_printf( " CAMELLIA-ECB-%3d (%s): ", 128 + u * 64,
(v == CAMELLIA_DECRYPT) ? "dec" : "enc");
- for (i = 0; i < CAMELLIA_TESTS_ECB; i++ ) {
- memcpy( key, camellia_test_ecb_key[u][i], 16 + 8 * u);
+ for( i = 0; i < CAMELLIA_TESTS_ECB; i++ ) {
+ memcpy( key, camellia_test_ecb_key[u][i], 16 + 8 * u );
- if (v == CAMELLIA_DECRYPT) {
- camellia_setkey_dec(&ctx, key, 128 + u * 64);
- memcpy(src, camellia_test_ecb_cipher[u][i], 16);
- memcpy(dst, camellia_test_ecb_plain[i], 16);
+ if( v == CAMELLIA_DECRYPT ) {
+ camellia_setkey_dec( &ctx, key, 128 + u * 64 );
+ memcpy( src, camellia_test_ecb_cipher[u][i], 16 );
+ memcpy( dst, camellia_test_ecb_plain[i], 16 );
} else { /* CAMELLIA_ENCRYPT */
- camellia_setkey_enc(&ctx, key, 128 + u * 64);
- memcpy(src, camellia_test_ecb_plain[i], 16);
- memcpy(dst, camellia_test_ecb_cipher[u][i], 16);
+ camellia_setkey_enc( &ctx, key, 128 + u * 64 );
+ memcpy( src, camellia_test_ecb_plain[i], 16 );
+ memcpy( dst, camellia_test_ecb_cipher[u][i], 16 );
}
- camellia_crypt_ecb(&ctx, v, src, buf);
+ camellia_crypt_ecb( &ctx, v, src, buf );
if( memcmp( buf, dst, 16 ) != 0 )
{
@@ -949,29 +949,29 @@ int camellia_self_test( int verbose )
polarssl_printf( " CAMELLIA-CBC-%3d (%s): ", 128 + u * 64,
( v == CAMELLIA_DECRYPT ) ? "dec" : "enc" );
- memcpy( src, camellia_test_cbc_iv, 16);
- memcpy( dst, camellia_test_cbc_iv, 16);
- memcpy( key, camellia_test_cbc_key[u], 16 + 8 * u);
+ memcpy( src, camellia_test_cbc_iv, 16 );
+ memcpy( dst, camellia_test_cbc_iv, 16 );
+ memcpy( key, camellia_test_cbc_key[u], 16 + 8 * u );
- if (v == CAMELLIA_DECRYPT) {
- camellia_setkey_dec(&ctx, key, 128 + u * 64);
+ if( v == CAMELLIA_DECRYPT ) {
+ camellia_setkey_dec( &ctx, key, 128 + u * 64 );
} else {
- camellia_setkey_enc(&ctx, key, 128 + u * 64);
+ camellia_setkey_enc( &ctx, key, 128 + u * 64 );
}
- for (i = 0; i < CAMELLIA_TESTS_CBC; i++ ) {
+ for( i = 0; i < CAMELLIA_TESTS_CBC; i++ ) {
- if (v == CAMELLIA_DECRYPT) {
+ if( v == CAMELLIA_DECRYPT ) {
memcpy( iv , src, 16 );
- memcpy(src, camellia_test_cbc_cipher[u][i], 16);
- memcpy(dst, camellia_test_cbc_plain[i], 16);
+ memcpy( src, camellia_test_cbc_cipher[u][i], 16 );
+ memcpy( dst, camellia_test_cbc_plain[i], 16 );
} else { /* CAMELLIA_ENCRYPT */
memcpy( iv , dst, 16 );
- memcpy(src, camellia_test_cbc_plain[i], 16);
- memcpy(dst, camellia_test_cbc_cipher[u][i], 16);
+ memcpy( src, camellia_test_cbc_plain[i], 16 );
+ memcpy( dst, camellia_test_cbc_cipher[u][i], 16 );
}
- camellia_crypt_cbc(&ctx, v, 16, iv, src, buf);
+ camellia_crypt_cbc( &ctx, v, 16, iv, src, buf );
if( memcmp( buf, dst, 16 ) != 0 )
{
diff --git a/library/cipher.c b/library/cipher.c
index 2d0d8d70b..edef2f9ac 100644
--- a/library/cipher.c
+++ b/library/cipher.c
@@ -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,
diff --git a/library/cipher_wrap.c b/library/cipher_wrap.c
index ddfb00625..efc4d4436 100644
--- a/library/cipher_wrap.c
+++ b/library/cipher_wrap.c
@@ -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 );
diff --git a/library/ctr_drbg.c b/library/ctr_drbg.c
index 2b507d268..3db517d55 100644
--- a/library/ctr_drbg.c
+++ b/library/ctr_drbg.c
@@ -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
diff --git a/library/debug.c b/library/debug.c
index b747ddc80..a81f502bf 100644
--- a/library/debug.c
+++ b/library/debug.c
@@ -1,7 +1,7 @@
/*
* 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
@@ -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++;
}
diff --git a/library/des.c b/library/des.c
index a979096eb..8c156aef6 100644
--- a/library/des.c
+++ b/library/des.c
@@ -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 );
diff --git a/library/dhm.c b/library/dhm.c
index 362cd1dd3..5a87e3ca7 100644
--- a/library/dhm.c
+++ b/library/dhm.c
@@ -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 );
diff --git a/library/ecdh.c b/library/ecdh.c
index 738d99ffa..b93d82ec6 100644
--- a/library/ecdh.c
+++ b/library/ecdh.c
@@ -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 );
}
/*
diff --git a/library/ecdsa.c b/library/ecdsa.c
index 5d4b0d308..5af7f6b53 100644
--- a/library/ecdsa.c
+++ b/library/ecdsa.c
@@ -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 ) );
diff --git a/library/ecp.c b/library/ecp.c
index 69d393cab..f9fb34b06 100644
--- a/library/ecp.c
+++ b/library/ecp.c
@@ -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 )
diff --git a/library/ecp_curves.c b/library/ecp_curves.c
index 5221b9f02..4c0018cc7 100644
--- a/library/ecp_curves.c
+++ b/library/ecp_curves.c
@@ -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 */
/* 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;
diff --git a/library/entropy.c b/library/entropy.c
index 068a50113..04de07fd2 100644
--- a/library/entropy.c
+++ b/library/entropy.c
@@ -196,7 +196,7 @@ static int entropy_gather_internal( entropy_context *ctx )
for( i = 0; i < ctx->source_count; i++ )
{
olen = 0;
- if ( ( ret = ctx->source[i].f_source( ctx->source[i].p_source,
+ if( ( ret = ctx->source[i].f_source( ctx->source[i].p_source,
buf, ENTROPY_MAX_GATHER, &olen ) ) != 0 )
{
return( ret );
diff --git a/library/gcm.c b/library/gcm.c
index c96da4e60..4e40fbf90 100644
--- a/library/gcm.c
+++ b/library/gcm.c
@@ -134,7 +134,7 @@ static int gcm_gen_table( gcm_context *ctx )
ctx->HH[i] = vh;
}
- for (i = 2; i < 16; i <<= 1 )
+ for( i = 2; i < 16; i <<= 1 )
{
uint64_t *HiL = ctx->HL + i, *HiH = ctx->HH + i;
vh = *HiH;
diff --git a/library/havege.c b/library/havege.c
index c82a24e89..de024de65 100644
--- a/library/havege.c
+++ b/library/havege.c
@@ -149,7 +149,7 @@
*C = (*C >> (15)) ^ (*C << (17)) ^ CLK; \
*D = (*D >> (16)) ^ (*D << (16)) ^ CLK; \
\
- PT1 = ( RES[(i - 8) ^ PTX] ^ \
+ PT1 = ( RES[( i - 8 ) ^ PTX] ^ \
WALK[PT1 ^ PTX ^ 7] ) & (~1); \
PT1 ^= (PT2 ^ 0x10) & 0x10; \
\
diff --git a/library/md.c b/library/md.c
index 51a00c266..55b56350b 100644
--- a/library/md.c
+++ b/library/md.c
@@ -234,7 +234,7 @@ int md_finish( md_context_t *ctx, unsigned char *output )
int md( const md_info_t *md_info, const unsigned char *input, size_t ilen,
unsigned char *output )
{
- if ( md_info == NULL )
+ if( md_info == NULL )
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
md_info->digest_func( input, ilen, output );
@@ -270,7 +270,7 @@ 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 );
- ctx->md_info->hmac_starts_func( ctx->md_ctx, key, keylen);
+ ctx->md_info->hmac_starts_func( ctx->md_ctx, key, keylen );
return( 0 );
}
@@ -285,12 +285,12 @@ int md_hmac_update( md_context_t *ctx, const unsigned char *input, size_t ilen )
return( 0 );
}
-int md_hmac_finish( md_context_t *ctx, unsigned char *output)
+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 );
- ctx->md_info->hmac_finish_func( ctx->md_ctx, output);
+ ctx->md_info->hmac_finish_func( ctx->md_ctx, output );
return( 0 );
}
@@ -300,7 +300,7 @@ int md_hmac_reset( md_context_t *ctx )
if( ctx == NULL || ctx->md_info == NULL )
return( POLARSSL_ERR_MD_BAD_INPUT_DATA );
- ctx->md_info->hmac_reset_func( ctx->md_ctx);
+ ctx->md_info->hmac_reset_func( ctx->md_ctx );
return( 0 );
}
diff --git a/library/memory_buffer_alloc.c b/library/memory_buffer_alloc.c
index 1f0c49db3..7710ba52b 100644
--- a/library/memory_buffer_alloc.c
+++ b/library/memory_buffer_alloc.c
@@ -306,7 +306,7 @@ static void *buffer_alloc_malloc( size_t len )
#if defined(POLARSSL_MEMORY_DEBUG)
heap.total_used += cur->size;
- if( heap.total_used > heap.maximum_used)
+ if( heap.total_used > heap.maximum_used )
heap.maximum_used = heap.total_used;
#endif
#if defined(POLARSSL_MEMORY_BACKTRACE)
@@ -361,7 +361,7 @@ static void *buffer_alloc_malloc( size_t len )
if( heap.header_count > heap.maximum_header_count )
heap.maximum_header_count = heap.header_count;
heap.total_used += cur->size;
- if( heap.total_used > heap.maximum_used)
+ if( heap.total_used > heap.maximum_used )
heap.maximum_used = heap.total_used;
#endif
#if defined(POLARSSL_MEMORY_BACKTRACE)
diff --git a/library/net.c b/library/net.c
index 8ccf12089..ad4b8921c 100644
--- a/library/net.c
+++ b/library/net.c
@@ -130,8 +130,8 @@ typedef UINT32 uint32_t;
(((unsigned long )(n) & 0xFF000000) >> 24))
#endif
-unsigned short net_htons(unsigned short n);
-unsigned long net_htonl(unsigned long n);
+unsigned short net_htons( unsigned short n );
+unsigned long net_htonl( unsigned long n );
#define net_htons(n) POLARSSL_HTONS(n)
#define net_htonl(n) POLARSSL_HTONL(n)
diff --git a/library/oid.c b/library/oid.c
index 1b5073bb5..24018d65d 100644
--- a/library/oid.c
+++ b/library/oid.c
@@ -76,7 +76,7 @@ static const TYPE_T * oid_ ## NAME ## _from_asn1( const asn1_buf *oid ) \
int FN_NAME( const asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \
{ \
const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
- if( data == NULL ) return ( POLARSSL_ERR_OID_NOT_FOUND ); \
+ if( data == NULL ) return( POLARSSL_ERR_OID_NOT_FOUND ); \
*ATTR1 = data->descriptor.ATTR1; \
return( 0 ); \
}
@@ -89,7 +89,7 @@ int FN_NAME( const asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \
int FN_NAME( const asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \
{ \
const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
- if( data == NULL ) return ( POLARSSL_ERR_OID_NOT_FOUND ); \
+ if( data == NULL ) return( POLARSSL_ERR_OID_NOT_FOUND ); \
*ATTR1 = data->ATTR1; \
return( 0 ); \
}
@@ -103,7 +103,7 @@ int FN_NAME( const asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \
int FN_NAME( const asn1_buf *oid, ATTR1_TYPE * ATTR1, ATTR2_TYPE * ATTR2 ) \
{ \
const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
- if( data == NULL ) return ( POLARSSL_ERR_OID_NOT_FOUND ); \
+ if( data == NULL ) return( POLARSSL_ERR_OID_NOT_FOUND ); \
*ATTR1 = data->ATTR1; \
*ATTR2 = data->ATTR2; \
return( 0 ); \
@@ -609,7 +609,7 @@ FN_OID_GET_ATTR2(oid_get_pkcs12_pbe_alg, oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, m
* This fuction tries to 'fix' this by at least suggesting enlarging the
* size by 20.
*/
-static int compat_snprintf(char *str, size_t size, const char *format, ...)
+static int compat_snprintf( char *str, size_t size, const char *format, ... )
{
va_list ap;
int res = -1;
@@ -621,7 +621,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
va_end( ap );
// No quick fix possible
- if ( res < 0 )
+ if( res < 0 )
return( (int) size + 20 );
return( res );
@@ -635,7 +635,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
if( ret == -1 ) \
return( POLARSSL_ERR_OID_BUF_TOO_SMALL ); \
\
- if ( (unsigned int) ret >= n ) { \
+ if( (unsigned int) ret >= n ) { \
p[n - 1] = '\0'; \
return( POLARSSL_ERR_OID_BUF_TOO_SMALL ); \
} \
@@ -667,7 +667,7 @@ int oid_get_numeric_string( char *buf, size_t size,
for( i = 1; i < oid->len; i++ )
{
/* Prevent overflow in value. */
- if ( ( ( value << 7 ) >> 7 ) != value )
+ if( ( ( value << 7 ) >> 7 ) != value )
return( POLARSSL_ERR_OID_BUF_TOO_SMALL );
value <<= 7;
diff --git a/library/padlock.c b/library/padlock.c
index ccc477edf..d277ccf35 100644
--- a/library/padlock.c
+++ b/library/padlock.c
@@ -137,9 +137,9 @@ int padlock_xcryptcbc( aes_context *ctx,
memcpy( iw, iv, 16 );
ctrl = iw + 4;
- *ctrl = 0x80 | ctx->nr | ( ( ctx->nr + (mode^1) - 10 ) << 9 );
+ *ctrl = 0x80 | ctx->nr | ( ( ctx->nr + ( mode ^ 1 ) - 10 ) << 9 );
- count = (length + 15) >> 4;
+ count = ( length + 15 ) >> 4;
asm( "pushfl; popfl \n" \
"movl %%ebx, %0 \n" \
diff --git a/library/pbkdf2.c b/library/pbkdf2.c
index 65722742c..e76f06642 100644
--- a/library/pbkdf2.c
+++ b/library/pbkdf2.c
@@ -6,7 +6,7 @@
*
* \author Mathias Olsson
*
- * Copyright (C) 2006-2012, Brainspark B.V.
+ * Copyright (C) 2006-2014, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker
diff --git a/library/pk.c b/library/pk.c
index 63f27de01..11faf3c8d 100644
--- a/library/pk.c
+++ b/library/pk.c
@@ -1,7 +1,7 @@
/*
* Public Key abstraction layer
*
- * Copyright (C) 2006-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
@@ -66,7 +66,7 @@ void pk_init( pk_context *ctx )
*/
void pk_free( pk_context *ctx )
{
- if( ctx == NULL || ctx->pk_info == NULL)
+ if( ctx == NULL || ctx->pk_info == NULL )
return;
ctx->pk_info->ctx_free_func( ctx->pk_ctx );
diff --git a/library/pkcs11.c b/library/pkcs11.c
index 409313eb7..64e7ce379 100644
--- a/library/pkcs11.c
+++ b/library/pkcs11.c
@@ -75,7 +75,7 @@ int pkcs11_x509_cert_init( x509_crt *cert, pkcs11h_certificate_t pkcs11_cert )
goto cleanup;
}
- if( 0 != x509_crt_parse(cert, cert_blob, cert_blob_size ) )
+ if( 0 != x509_crt_parse( cert, cert_blob, cert_blob_size ) )
{
ret = 6;
goto cleanup;
@@ -105,7 +105,7 @@ int pkcs11_priv_key_init( pkcs11_context *priv_key,
if( 0 != pkcs11_x509_cert_init( &cert, pkcs11_cert ) )
goto cleanup;
- priv_key->len = pk_get_len(&cert.pk);
+ priv_key->len = pk_get_len( &cert.pk );
priv_key->pkcs11h_cert = pkcs11_cert;
ret = 0;
@@ -191,13 +191,13 @@ int pkcs11_sign( pkcs11_context *ctx,
}
sig_len = ctx->len;
- if ( hashlen > sig_len || asn_len > sig_len ||
- hashlen + asn_len > sig_len )
+ if( hashlen > sig_len || asn_len > sig_len ||
+ hashlen + asn_len > sig_len )
{
return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
}
- if( md_alg != POLARSSL_MD_NONE)
+ if( md_alg != POLARSSL_MD_NONE )
{
/*
* DigestInfo ::= SEQUENCE {
diff --git a/library/pkcs12.c b/library/pkcs12.c
index 2b130a2b2..c6372a16c 100644
--- a/library/pkcs12.c
+++ b/library/pkcs12.c
@@ -93,14 +93,14 @@ static int pkcs12_pbe_derive_key_iv( asn1_buf *pbe_params, md_type_t md_type,
size_t i;
unsigned char unipwd[258];
- memset(&salt, 0, sizeof(asn1_buf));
- memset(&unipwd, 0, sizeof(unipwd));
+ memset( &salt, 0, sizeof(asn1_buf) );
+ memset( &unipwd, 0, sizeof(unipwd) );
if( ( ret = pkcs12_parse_pbe_params( pbe_params, &salt,
&iterations ) ) != 0 )
return( ret );
- for(i = 0; i < pwdlen; i++)
+ for( i = 0; i < pwdlen; i++ )
unipwd[i * 2 + 1] = pwd[i];
if( ( ret = pkcs12_derivation( key, keylen, unipwd, pwdlen * 2 + 2,
@@ -252,7 +252,7 @@ int pkcs12_derivation( unsigned char *data, size_t datalen,
if( md_info == NULL )
return( POLARSSL_ERR_PKCS12_FEATURE_UNAVAILABLE );
- if ( ( ret = md_init_ctx( &md_ctx, md_info ) ) != 0 )
+ if( ( ret = md_init_ctx( &md_ctx, md_info ) ) != 0 )
return( ret );
hlen = md_get_size( md_info );
diff --git a/library/pkcs5.c b/library/pkcs5.c
index e8642a609..8f6a814dc 100644
--- a/library/pkcs5.c
+++ b/library/pkcs5.c
@@ -168,7 +168,7 @@ int pkcs5_pbes2( asn1_buf *pbe_params, int mode,
return( POLARSSL_ERR_PKCS5_INVALID_FORMAT + ret );
}
- if ( oid_get_cipher_alg( &enc_scheme_oid, &cipher_alg ) != 0 )
+ if( oid_get_cipher_alg( &enc_scheme_oid, &cipher_alg ) != 0 )
return( POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE );
cipher_info = cipher_info_from_type( cipher_alg );
@@ -188,8 +188,8 @@ int pkcs5_pbes2( asn1_buf *pbe_params, int mode,
if( ( ret = md_init_ctx( &md_ctx, md_info ) ) != 0 )
goto exit;
- if ( ( ret = pkcs5_pbkdf2_hmac( &md_ctx, pwd, pwdlen, salt.p, salt.len,
- iterations, keylen, key ) ) != 0 )
+ if( ( ret = pkcs5_pbkdf2_hmac( &md_ctx, pwd, pwdlen, salt.p, salt.len,
+ iterations, keylen, key ) ) != 0 )
{
goto exit;
}
@@ -260,7 +260,7 @@ int pkcs5_pbkdf2_hmac( md_context_t *ctx, const unsigned char *password,
memcpy( md1, work, md_size );
- for ( i = 1; i < iteration_count; i++ )
+ for( i = 1; i < iteration_count; i++ )
{
// U2 ends up in md1
//
diff --git a/library/pkparse.c b/library/pkparse.c
index 218f38a5f..3c8063fe7 100644
--- a/library/pkparse.c
+++ b/library/pkparse.c
@@ -120,7 +120,7 @@ int pk_parse_keyfile( pk_context *ctx,
size_t n;
unsigned char *buf;
- if ( (ret = load_file( path, &buf, &n ) ) != 0 )
+ if( ( ret = load_file( path, &buf, &n ) ) != 0 )
return( ret );
if( pwd == NULL )
@@ -144,7 +144,7 @@ int pk_parse_public_keyfile( pk_context *ctx, 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 = pk_parse_public_key( ctx, buf, n );
@@ -810,7 +810,7 @@ static int pk_parse_key_sec1_der( ecp_keypair *eck,
return( POLARSSL_ERR_PK_KEY_INVALID_FORMAT );
}
}
- else if ( ret != POLARSSL_ERR_ASN1_UNEXPECTED_TAG )
+ else if( ret != POLARSSL_ERR_ASN1_UNEXPECTED_TAG )
{
ecp_keypair_free( eck );
return( POLARSSL_ERR_PK_KEY_INVALID_FORMAT + ret );
diff --git a/library/rsa.c b/library/rsa.c
index abc028d64..3cbac66e1 100644
--- a/library/rsa.c
+++ b/library/rsa.c
@@ -603,7 +603,7 @@ int rsa_rsaes_pkcs1_v15_encrypt( rsa_context *ctx,
// Check if RNG failed to generate data
//
- if( rng_dl == 0 || ret != 0)
+ if( rng_dl == 0 || ret != 0 )
return( POLARSSL_ERR_RSA_RNG_FAILED + ret );
p++;
@@ -759,7 +759,7 @@ int rsa_rsaes_oaep_decrypt( rsa_context *ctx,
if( bad != 0 )
return( POLARSSL_ERR_RSA_INVALID_PADDING );
- if (ilen - (p - buf) > output_max_len)
+ if( ilen - ( p - buf ) > output_max_len )
return( POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE );
*olen = ilen - (p - buf);
@@ -844,7 +844,7 @@ int rsa_rsaes_pkcs1_v15_decrypt( rsa_context *ctx,
if( bad )
return( POLARSSL_ERR_RSA_INVALID_PADDING );
- if (ilen - (p - buf) > output_max_len)
+ if( ilen - ( p - buf ) > output_max_len )
return( POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE );
*olen = ilen - (p - buf);
diff --git a/library/sha1.c b/library/sha1.c
index ce815792a..a528d8ec7 100644
--- a/library/sha1.c
+++ b/library/sha1.c
@@ -118,8 +118,8 @@ void sha1_process( sha1_context *ctx, const unsigned char data[64] )
#define R(t) \
( \
- temp = W[(t - 3) & 0x0F] ^ W[(t - 8) & 0x0F] ^ \
- W[(t - 14) & 0x0F] ^ W[ t & 0x0F], \
+ temp = W[( t - 3 ) & 0x0F] ^ W[( t - 8 ) & 0x0F] ^ \
+ W[( t - 14 ) & 0x0F] ^ W[ t & 0x0F], \
( W[t & 0x0F] = S(temp,1) ) \
)
diff --git a/library/ssl_cli.c b/library/ssl_cli.c
index 19c33a7ce..fda9ebf51 100644
--- a/library/ssl_cli.c
+++ b/library/ssl_cli.c
@@ -71,7 +71,7 @@ static void ssl_write_hostname_ext( ssl_context *ssl,
*olen = 0;
- if ( ssl->hostname == NULL )
+ if( ssl->hostname == NULL )
return;
SSL_DEBUG_MSG( 3, ( "client hello, adding server name extension: %s",
@@ -2470,7 +2470,7 @@ static int ssl_parse_new_session_ticket( ssl_context *ssl )
* Zero-length ticket means the server changed his mind and doesn't want
* to send a ticket after all, so just forget it
*/
- if( ticket_len == 0)
+ if( ticket_len == 0 )
return( 0 );
polarssl_zeroize( ssl->session_negotiate->ticket,
diff --git a/library/ssl_srv.c b/library/ssl_srv.c
index 03b801099..dfa7e48cd 100644
--- a/library/ssl_srv.c
+++ b/library/ssl_srv.c
@@ -211,7 +211,7 @@ static int ssl_write_ticket( ssl_context *ssl, size_t *tlen )
*/
state = p + 2;
if( ssl_save_session( ssl->session_negotiate, state,
- SSL_MAX_CONTENT_LEN - (state - ssl->out_ctr) - 48,
+ SSL_MAX_CONTENT_LEN - ( state - ssl->out_ctr ) - 48,
&clear_len ) != 0 )
{
return( POLARSSL_ERR_SSL_CERTIFICATE_TOO_LARGE );
@@ -2343,7 +2343,7 @@ curve_matching_done:
#endif /* POLARSSL_SSL_PROTO_TLS1_2 */
#if defined(POLARSSL_SSL_PROTO_SSL3) || defined(POLARSSL_SSL_PROTO_TLS1) || \
defined(POLARSSL_SSL_PROTO_TLS1_1)
- if ( ciphersuite_info->key_exchange ==
+ if( ciphersuite_info->key_exchange ==
POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA )
{
md_alg = POLARSSL_MD_SHA1;
@@ -2397,6 +2397,7 @@ curve_matching_done:
if( md_alg != POLARSSL_MD_NONE )
{
md_context_t ctx;
+ const md_info_t *md_info = md_info_from_type( md_alg );
/* Info from md_alg will be used instead */
hashlen = 0;
@@ -2408,7 +2409,7 @@ curve_matching_done:
* ServerDHParams params;
* };
*/
- if( ( ret = md_init_ctx( &ctx, md_info_from_type(md_alg) ) ) != 0 )
+ if( ( ret = md_init_ctx( &ctx, md_info ) ) != 0 )
{
SSL_DEBUG_RET( 1, "md_init_ctx", ret );
return( ret );
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index a6c924cce..1c5249cd2 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -126,18 +126,18 @@ static int ssl_session_copy( ssl_session *dst, const ssl_session *src )
}
#if defined(POLARSSL_SSL_HW_RECORD_ACCEL)
-int (*ssl_hw_record_init)(ssl_context *ssl,
+int (*ssl_hw_record_init)( ssl_context *ssl,
const unsigned char *key_enc, const unsigned char *key_dec,
size_t keylen,
const unsigned char *iv_enc, const unsigned char *iv_dec,
size_t ivlen,
const unsigned char *mac_enc, const unsigned char *mac_dec,
- size_t maclen) = NULL;
-int (*ssl_hw_record_activate)(ssl_context *ssl, int direction) = NULL;
-int (*ssl_hw_record_reset)(ssl_context *ssl) = NULL;
-int (*ssl_hw_record_write)(ssl_context *ssl) = NULL;
-int (*ssl_hw_record_read)(ssl_context *ssl) = NULL;
-int (*ssl_hw_record_finish)(ssl_context *ssl) = NULL;
+ size_t maclen ) = NULL;
+int (*ssl_hw_record_activate)( ssl_context *ssl, int direction) = NULL;
+int (*ssl_hw_record_reset)( ssl_context *ssl ) = NULL;
+int (*ssl_hw_record_write)( ssl_context *ssl ) = NULL;
+int (*ssl_hw_record_read)( ssl_context *ssl ) = NULL;
+int (*ssl_hw_record_finish)( ssl_context *ssl ) = NULL;
#endif /* POLARSSL_SSL_HW_RECORD_ACCEL */
/*
@@ -339,34 +339,34 @@ static int tls_prf_sha384( const unsigned char *secret, size_t slen,
#endif /* POLARSSL_SHA512_C */
#endif /* POLARSSL_SSL_PROTO_TLS1_2 */
-static void ssl_update_checksum_start(ssl_context *, const unsigned char *, size_t);
+static void ssl_update_checksum_start( ssl_context *, const unsigned char *, size_t );
#if defined(POLARSSL_SSL_PROTO_SSL3) || defined(POLARSSL_SSL_PROTO_TLS1) || \
defined(POLARSSL_SSL_PROTO_TLS1_1)
-static void ssl_update_checksum_md5sha1(ssl_context *, const unsigned char *, size_t);
+static void ssl_update_checksum_md5sha1( ssl_context *, const unsigned char *, size_t );
#endif
#if defined(POLARSSL_SSL_PROTO_SSL3)
-static void ssl_calc_verify_ssl(ssl_context *,unsigned char *);
-static void ssl_calc_finished_ssl(ssl_context *,unsigned char *,int);
+static void ssl_calc_verify_ssl( ssl_context *, unsigned char * );
+static void ssl_calc_finished_ssl( ssl_context *, unsigned char *, int );
#endif
#if defined(POLARSSL_SSL_PROTO_TLS1) || defined(POLARSSL_SSL_PROTO_TLS1_1)
-static void ssl_calc_verify_tls(ssl_context *,unsigned char *);
-static void ssl_calc_finished_tls(ssl_context *,unsigned char *,int);
+static void ssl_calc_verify_tls( ssl_context *, unsigned char * );
+static void ssl_calc_finished_tls( ssl_context *, unsigned char *, int );
#endif
#if defined(POLARSSL_SSL_PROTO_TLS1_2)
#if defined(POLARSSL_SHA256_C)
-static void ssl_update_checksum_sha256(ssl_context *, const unsigned char *, size_t);
-static void ssl_calc_verify_tls_sha256(ssl_context *,unsigned char *);
-static void ssl_calc_finished_tls_sha256(ssl_context *,unsigned char *,int);
+static void ssl_update_checksum_sha256( ssl_context *, const unsigned char *, size_t );
+static void ssl_calc_verify_tls_sha256( ssl_context *,unsigned char * );
+static void ssl_calc_finished_tls_sha256( ssl_context *,unsigned char *, int );
#endif
#if defined(POLARSSL_SHA512_C)
-static void ssl_update_checksum_sha384(ssl_context *, const unsigned char *, size_t);
-static void ssl_calc_verify_tls_sha384(ssl_context *,unsigned char *);
-static void ssl_calc_finished_tls_sha384(ssl_context *,unsigned char *,int);
+static void ssl_update_checksum_sha384( ssl_context *, const unsigned char *, size_t );
+static void ssl_calc_verify_tls_sha384( ssl_context *, unsigned char * );
+static void ssl_calc_finished_tls_sha384( ssl_context *, unsigned char *, int );
#endif
#endif /* POLARSSL_SSL_PROTO_TLS1_2 */
@@ -637,7 +637,7 @@ int ssl_derive_keys( ssl_context *ssl )
}
#if defined(POLARSSL_SSL_HW_RECORD_ACCEL)
- if( ssl_hw_record_init != NULL)
+ if( ssl_hw_record_init != NULL )
{
int ret = 0;
@@ -911,7 +911,7 @@ int ssl_psk_derive_premaster( ssl_context *ssl, key_exchange_type_t key_ex )
size_t zlen;
if( ( ret = ecdh_calc_secret( &ssl->handshake->ecdh_ctx, &zlen,
- p + 2, end - (p + 2),
+ p + 2, end - ( p + 2 ),
ssl->f_rng, ssl->p_rng ) ) != 0 )
{
SSL_DEBUG_RET( 1, "ecdh_calc_secret", ret );
@@ -1529,7 +1529,7 @@ static int ssl_decrypt_buf( ssl_context *ssl )
correct &= ( pad_count == padlen ); /* Only 1 on correct padding */
#if defined(POLARSSL_SSL_DEBUG_ALL)
- if( padlen > 0 && correct == 0)
+ if( padlen > 0 && correct == 0 )
SSL_DEBUG_MSG( 1, ( "bad padding byte detected" ) );
#endif
padlen &= correct * 0x1FF;
@@ -1879,7 +1879,7 @@ int ssl_write_record( ssl_context *ssl )
#endif /*POLARSSL_ZLIB_SUPPORT */
#if defined(POLARSSL_SSL_HW_RECORD_ACCEL)
- if( ssl_hw_record_write != NULL)
+ if( ssl_hw_record_write != NULL )
{
SSL_DEBUG_MSG( 2, ( "going for ssl_hw_record_write()" ) );
@@ -2077,7 +2077,7 @@ int ssl_read_record( ssl_context *ssl )
ssl->in_hdr, 5 + ssl->in_msglen );
#if defined(POLARSSL_SSL_HW_RECORD_ACCEL)
- if( ssl_hw_record_read != NULL)
+ if( ssl_hw_record_read != NULL )
{
SSL_DEBUG_MSG( 2, ( "going for ssl_hw_record_read()" ) );
@@ -3118,7 +3118,7 @@ int ssl_write_finished( ssl_context *ssl )
memset( ssl->out_ctr, 0, 8 );
#if defined(POLARSSL_SSL_HW_RECORD_ACCEL)
- if( ssl_hw_record_activate != NULL)
+ if( ssl_hw_record_activate != NULL )
{
if( ( ret = ssl_hw_record_activate( ssl, SSL_CHANNEL_OUTBOUND ) ) != 0 )
{
@@ -3170,7 +3170,7 @@ int ssl_parse_finished( ssl_context *ssl )
ssl->in_msg = ssl->in_iv;
#if defined(POLARSSL_SSL_HW_RECORD_ACCEL)
- if( ssl_hw_record_activate != NULL)
+ if( ssl_hw_record_activate != NULL )
{
if( ( ret = ssl_hw_record_activate( ssl, SSL_CHANNEL_INBOUND ) ) != 0 )
{
@@ -3412,7 +3412,7 @@ int ssl_session_reset( ssl_context *ssl )
memset( ssl->in_ctr, 0, SSL_BUFFER_LEN );
#if defined(POLARSSL_SSL_HW_RECORD_ACCEL)
- if( ssl_hw_record_reset != NULL)
+ if( ssl_hw_record_reset != NULL )
{
SSL_DEBUG_MSG( 2, ( "going for ssl_hw_record_reset()" ) );
if( ( ret = ssl_hw_record_reset( ssl ) ) != 0 )
@@ -3777,13 +3777,13 @@ int ssl_set_dh_param_ctx( ssl_context *ssl, dhm_context *dhm_ctx )
{
int ret;
- if( ( ret = mpi_copy(&ssl->dhm_P, &dhm_ctx->P) ) != 0 )
+ if( ( ret = mpi_copy( &ssl->dhm_P, &dhm_ctx->P ) ) != 0 )
{
SSL_DEBUG_RET( 1, "mpi_copy", ret );
return( ret );
}
- if( ( ret = mpi_copy(&ssl->dhm_G, &dhm_ctx->G) ) != 0 )
+ if( ( ret = mpi_copy( &ssl->dhm_G, &dhm_ctx->G ) ) != 0 )
{
SSL_DEBUG_RET( 1, "mpi_copy", ret );
return( ret );
@@ -4544,7 +4544,7 @@ void ssl_free( ssl_context *ssl )
#endif
#if defined(POLARSSL_SSL_SERVER_NAME_INDICATION)
- if ( ssl->hostname != NULL )
+ if( ssl->hostname != NULL )
{
polarssl_zeroize( ssl->hostname, ssl->hostname_len );
polarssl_free( ssl->hostname );
diff --git a/library/threading.c b/library/threading.c
index 5b25e015c..522c70fef 100644
--- a/library/threading.c
+++ b/library/threading.c
@@ -1,7 +1,7 @@
/*
* Threading abstraction layer
*
- * Copyright (C) 2006-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
diff --git a/library/timing.c b/library/timing.c
index 5437320a3..6c1dfa46b 100644
--- a/library/timing.c
+++ b/library/timing.c
@@ -66,7 +66,7 @@ struct _hr_time
#endif /* _WIN32 && !EFIX64 && !EFI32 */
#if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(POLARSSL_HAVE_ASM) && \
- (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
+ ( defined(_MSC_VER) && defined(_M_IX86) ) || defined(__WATCOMC__)
#define POLARSSL_HAVE_HARDCLOCK
@@ -95,7 +95,7 @@ unsigned long hardclock( void )
__GNUC__ && __i386__ */
#if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(POLARSSL_HAVE_ASM) && \
- defined(__GNUC__) && (defined(__amd64__) || defined(__x86_64__))
+ defined(__GNUC__) && ( defined(__amd64__) || defined(__x86_64__) )
#define POLARSSL_HAVE_HARDCLOCK
@@ -103,13 +103,13 @@ unsigned long hardclock( void )
{
unsigned long lo, hi;
asm volatile( "rdtsc" : "=a" (lo), "=d" (hi) );
- return( lo | (hi << 32) );
+ return( lo | ( hi << 32 ) );
}
#endif /* !POLARSSL_HAVE_HARDCLOCK && POLARSSL_HAVE_ASM &&
__GNUC__ && ( __amd64__ || __x86_64__ ) */
#if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(POLARSSL_HAVE_ASM) && \
- defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
+ defined(__GNUC__) && ( defined(__powerpc__) || defined(__ppc__) )
#define POLARSSL_HAVE_HARDCLOCK
@@ -368,7 +368,7 @@ int timing_self_test( int verbose )
int hardfail;
struct hr_time hires;
- if( verbose != 0)
+ if( verbose != 0 )
polarssl_printf( " TIMING tests note: will take some time!\n" );
if( verbose != 0 )
diff --git a/library/x509.c b/library/x509.c
index 73e13475f..4c54b5b00 100644
--- a/library/x509.c
+++ b/library/x509.c
@@ -483,7 +483,7 @@ int x509_get_time( unsigned char **p, const unsigned char *end,
tag = **p;
- if ( tag == ASN1_UTC_TIME )
+ if( tag == ASN1_UTC_TIME )
{
(*p)++;
ret = asn1_get_len( p, end, &len );
@@ -507,7 +507,7 @@ int x509_get_time( unsigned char **p, const unsigned char *end,
return( 0 );
}
- else if ( tag == ASN1_GENERALIZED_TIME )
+ else if( tag == ASN1_GENERALIZED_TIME )
{
(*p)++;
ret = asn1_get_len( p, end, &len );
@@ -703,7 +703,7 @@ int x509_load_file( const char *path, unsigned char **buf, size_t *n )
* This fuction tries to 'fix' this by at least suggesting enlarging the
* size by 20.
*/
-static int compat_snprintf(char *str, size_t size, const char *format, ...)
+static int compat_snprintf( char *str, size_t size, const char *format, ... )
{
va_list ap;
int res = -1;
@@ -715,7 +715,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
va_end( ap );
// No quick fix possible
- if ( res < 0 )
+ if( res < 0 )
return( (int) size + 20 );
return( res );
@@ -731,7 +731,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
if( ret == -1 ) \
return( -1 ); \
\
- if ( (unsigned int) ret > n ) { \
+ if( (unsigned int) ret > n ) { \
p[n - 1] = '\0'; \
return( POLARSSL_ERR_DEBUG_BUF_TOO_SMALL ); \
} \
@@ -930,7 +930,7 @@ static void x509_get_current_time( x509_time *now )
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
SYSTEMTIME st;
- GetSystemTime(&st);
+ GetSystemTime( &st );
now->year = st.wYear;
now->mon = st.wMonth;
@@ -1080,7 +1080,7 @@ int x509_self_test( int verbose )
if( verbose != 0 )
polarssl_printf( "failed\n" );
- polarssl_printf("ret = %d, &flags = %04x\n", ret, flags);
+ polarssl_printf( "ret = %d, &flags = %04x\n", ret, flags );
return( ret );
}
diff --git a/library/x509_create.c b/library/x509_create.c
index 8976c72d2..96b153bdc 100644
--- a/library/x509_create.c
+++ b/library/x509_create.c
@@ -1,7 +1,7 @@
/*
* X.509 base functions for creating certificates / CSRs
*
- * Copyright (C) 2006-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
diff --git a/library/x509_crl.c b/library/x509_crl.c
index c7b1d6470..7f8600dbf 100644
--- a/library/x509_crl.c
+++ b/library/x509_crl.c
@@ -142,7 +142,7 @@ static int x509_get_crl_entry_ext( unsigned char **p,
size_t len = 0;
/* OPTIONAL */
- if (end <= *p)
+ if( end <= *p )
return( 0 );
ext->tag = **p;
@@ -237,7 +237,7 @@ static int x509_get_entries( unsigned char **p,
&cur_entry->entry_ext ) ) != 0 )
return( ret );
- if ( *p < end )
+ if( *p < end )
{
cur_entry->next = polarssl_malloc( sizeof( x509_crl_entry ) );
@@ -285,7 +285,7 @@ int x509_crl_parse( x509_crl *chain, const unsigned char *buf, size_t buflen )
/*
* Add new CRL on the end of the chain if needed.
*/
- if ( crl->version != 0 && crl->next == NULL)
+ if( crl->version != 0 && crl->next == NULL )
{
crl->next = (x509_crl *) polarssl_malloc( sizeof( x509_crl ) );
@@ -443,9 +443,9 @@ int x509_crl_parse( x509_crl *chain, const unsigned char *buf, size_t buflen )
if( ( ret = x509_get_time( &p, end, &crl->next_update ) ) != 0 )
{
- if ( ret != ( POLARSSL_ERR_X509_INVALID_DATE +
+ if( ret != ( POLARSSL_ERR_X509_INVALID_DATE +
POLARSSL_ERR_ASN1_UNEXPECTED_TAG ) &&
- ret != ( POLARSSL_ERR_X509_INVALID_DATE +
+ ret != ( POLARSSL_ERR_X509_INVALID_DATE +
POLARSSL_ERR_ASN1_OUT_OF_DATA ) )
{
x509_crl_free( crl );
@@ -504,7 +504,7 @@ int x509_crl_parse( x509_crl *chain, const unsigned char *buf, size_t buflen )
if( crl->sig_oid1.len != crl->sig_oid2.len ||
memcmp( crl->sig_oid1.p, crl->sig_oid2.p, crl->sig_oid1.len ) != 0 ||
sig_params1.len != sig_params2.len ||
- memcmp( sig_params1.p, sig_params2.p, sig_params1.len ) != 0)
+ memcmp( sig_params1.p, sig_params2.p, sig_params1.len ) != 0 )
{
x509_crl_free( crl );
return( POLARSSL_ERR_X509_SIG_MISMATCH );
@@ -552,7 +552,7 @@ int x509_crl_parse_file( x509_crl *chain, const char *path )
size_t n;
unsigned char *buf;
- if ( ( ret = x509_load_file( path, &buf, &n ) ) != 0 )
+ if( ( ret = x509_load_file( path, &buf, &n ) ) != 0 )
return( ret );
ret = x509_crl_parse( chain, buf, n );
@@ -579,7 +579,7 @@ int x509_crl_parse_file( x509_crl *chain, const char *path )
* This fuction tries to 'fix' this by at least suggesting enlarging the
* size by 20.
*/
-static int compat_snprintf(char *str, size_t size, const char *format, ...)
+static int compat_snprintf( char *str, size_t size, const char *format, ... )
{
va_list ap;
int res = -1;
@@ -591,7 +591,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
va_end( ap );
// No quick fix possible
- if ( res < 0 )
+ if( res < 0 )
return( (int) size + 20 );
return( res );
@@ -607,7 +607,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
if( ret == -1 ) \
return( -1 ); \
\
- if ( (unsigned int) ret > n ) { \
+ if( (unsigned int) ret > n ) { \
p[n - 1] = '\0'; \
return( POLARSSL_ERR_DEBUG_BUF_TOO_SMALL ); \
} \
@@ -670,7 +670,7 @@ int x509_crl_info( char *buf, size_t size, const char *prefix,
prefix );
SAFE_SNPRINTF();
- ret = x509_serial_gets( p, n, &entry->serial);
+ ret = x509_serial_gets( p, n, &entry->serial );
SAFE_SNPRINTF();
ret = snprintf( p, n, " revocation date: " \
diff --git a/library/x509_crt.c b/library/x509_crt.c
index 4fc35664d..50f92e6ad 100644
--- a/library/x509_crt.c
+++ b/library/x509_crt.c
@@ -723,7 +723,7 @@ static int x509_crt_parse_der_core( x509_crt *crt, const unsigned char *buf,
if( crt->version == 3 )
{
#endif
- ret = x509_get_crt_ext( &p, end, crt);
+ ret = x509_get_crt_ext( &p, end, crt );
if( ret != 0 )
{
x509_crt_free( crt );
@@ -758,7 +758,7 @@ static int x509_crt_parse_der_core( x509_crt *crt, const unsigned char *buf,
if( crt->sig_oid1.len != crt->sig_oid2.len ||
memcmp( crt->sig_oid1.p, crt->sig_oid2.p, crt->sig_oid1.len ) != 0 ||
sig_params1.len != sig_params2.len ||
- memcmp( sig_params1.p, sig_params2.p, sig_params1.len ) != 0)
+ memcmp( sig_params1.p, sig_params2.p, sig_params1.len ) != 0 )
{
x509_crt_free( crt );
return( POLARSSL_ERR_X509_SIG_MISMATCH );
@@ -805,7 +805,7 @@ int x509_crt_parse_der( x509_crt *chain, const unsigned char *buf,
/*
* Add new certificate on the end of the chain if needed.
*/
- if ( crt->version != 0 && crt->next == NULL)
+ if( crt->version != 0 && crt->next == NULL )
{
crt->next = (x509_crt *) polarssl_malloc( sizeof( x509_crt ) );
@@ -946,7 +946,7 @@ int x509_crt_parse_file( x509_crt *chain, const char *path )
size_t n;
unsigned char *buf;
- if ( ( ret = x509_load_file( path, &buf, &n ) ) != 0 )
+ if( ( ret = x509_load_file( path, &buf, &n ) ) != 0 )
return( ret );
ret = x509_crt_parse( chain, buf, n );
@@ -988,7 +988,7 @@ int x509_crt_parse_path( x509_crt *chain, const char *path )
MAX_PATH - 3 );
hFind = FindFirstFileW( szDir, &file_data );
- if (hFind == INVALID_HANDLE_VALUE)
+ if( hFind == INVALID_HANDLE_VALUE )
return( POLARSSL_ERR_X509_FILE_IO_ERROR );
len = MAX_PATH - len;
@@ -1000,7 +1000,7 @@ int x509_crt_parse_path( x509_crt *chain, const char *path )
continue;
w_ret = WideCharToMultiByte( CP_ACP, 0, file_data.cFileName,
- lstrlenW(file_data.cFileName),
+ lstrlenW( file_data.cFileName ),
p, len - 1,
NULL, NULL );
@@ -1012,7 +1012,7 @@ int x509_crt_parse_path( x509_crt *chain, const char *path )
}
while( FindNextFileW( hFind, &file_data ) != 0 );
- if (GetLastError() != ERROR_NO_MORE_FILES)
+ if( GetLastError() != ERROR_NO_MORE_FILES )
ret = POLARSSL_ERR_X509_FILE_IO_ERROR;
FindClose( hFind );
@@ -1023,7 +1023,7 @@ int x509_crt_parse_path( x509_crt *chain, const char *path )
char entry_name[255];
DIR *dir = opendir( path );
- if( dir == NULL)
+ if( dir == NULL )
return( POLARSSL_ERR_X509_FILE_IO_ERROR );
#if defined(POLARSSL_THREADING_PTHREAD)
@@ -1082,7 +1082,7 @@ cleanup:
* This fuction tries to 'fix' this by at least suggesting enlarging the
* size by 20.
*/
-static int compat_snprintf(char *str, size_t size, const char *format, ...)
+static int compat_snprintf( char *str, size_t size, const char *format, ... )
{
va_list ap;
int res = -1;
@@ -1094,7 +1094,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
va_end( ap );
// No quick fix possible
- if ( res < 0 )
+ if( res < 0 )
return( (int) size + 20 );
return( res );
@@ -1110,7 +1110,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
if( ret == -1 ) \
return( -1 ); \
\
- if ( (unsigned int) ret > n ) { \
+ if( (unsigned int) ret > n ) { \
p[n - 1] = '\0'; \
return( POLARSSL_ERR_DEBUG_BUF_TOO_SMALL ); \
} \
@@ -1269,7 +1269,7 @@ int x509_crt_info( char *buf, size_t size, const char *prefix,
prefix );
SAFE_SNPRINTF();
- ret = x509_serial_gets( p, n, &crt->serial);
+ ret = x509_serial_gets( p, n, &crt->serial );
SAFE_SNPRINTF();
ret = snprintf( p, n, "\n%sissuer name : ", prefix );
@@ -1517,7 +1517,7 @@ static int x509_crt_verifycrl( x509_crt *crt, x509_crt *ca,
/*
* Check if certificate is revoked
*/
- if( x509_crt_revoked(crt, crl_list) )
+ if( x509_crt_revoked( crt, crl_list ) )
{
flags |= BADCERT_REVOKED;
break;
@@ -1714,7 +1714,7 @@ static int x509_crt_verify_top(
/* Call callback on top cert */
if( NULL != f_vrfy )
{
- if( ( ret = f_vrfy(p_vrfy, child, path_cnt, flags ) ) != 0 )
+ if( ( ret = f_vrfy( p_vrfy, child, path_cnt, flags ) ) != 0 )
return( ret );
}
diff --git a/library/x509_csr.c b/library/x509_csr.c
index 75e3763e7..f6d268be2 100644
--- a/library/x509_csr.c
+++ b/library/x509_csr.c
@@ -295,7 +295,7 @@ int x509_csr_parse_file( x509_csr *csr, const char *path )
size_t n;
unsigned char *buf;
- if ( ( ret = x509_load_file( path, &buf, &n ) ) != 0 )
+ if( ( ret = x509_load_file( path, &buf, &n ) ) != 0 )
return( ret );
ret = x509_csr_parse( csr, buf, n );
@@ -322,7 +322,7 @@ int x509_csr_parse_file( x509_csr *csr, const char *path )
* This fuction tries to 'fix' this by at least suggesting enlarging the
* size by 20.
*/
-static int compat_snprintf(char *str, size_t size, const char *format, ...)
+static int compat_snprintf( char *str, size_t size, const char *format, ... )
{
va_list ap;
int res = -1;
@@ -334,7 +334,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
va_end( ap );
// No quick fix possible
- if ( res < 0 )
+ if( res < 0 )
return( (int) size + 20 );
return( res );
@@ -350,7 +350,7 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
if( ret == -1 ) \
return( -1 ); \
\
- if ( (unsigned int) ret > n ) { \
+ if( (unsigned int) ret > n ) { \
p[n - 1] = '\0'; \
return( POLARSSL_ERR_DEBUG_BUF_TOO_SMALL ); \
} \
diff --git a/library/x509write_crt.c b/library/x509write_crt.c
index 4b6d75b81..e298c24ec 100644
--- a/library/x509write_crt.c
+++ b/library/x509write_crt.c
@@ -115,8 +115,8 @@ int x509write_crt_set_serial( x509write_cert *ctx, const mpi *serial )
int x509write_crt_set_validity( x509write_cert *ctx, const char *not_before,
const char *not_after )
{
- if( strlen(not_before) != X509_RFC5280_UTC_TIME_LEN - 1 ||
- strlen(not_after) != X509_RFC5280_UTC_TIME_LEN - 1 )
+ if( strlen( not_before ) != X509_RFC5280_UTC_TIME_LEN - 1 ||
+ strlen( not_after ) != X509_RFC5280_UTC_TIME_LEN - 1 )
{
return( POLARSSL_ERR_X509_BAD_INPUT_DATA );
}
@@ -176,7 +176,7 @@ int x509write_crt_set_subject_key_identifier( x509write_cert *ctx )
unsigned char *c = buf + sizeof(buf);
size_t len = 0;
- memset( buf, 0, sizeof(buf));
+ memset( buf, 0, sizeof(buf) );
ASN1_CHK_ADD( len, pk_write_pubkey( &c, buf, ctx->subject_key ) );
sha1( buf + sizeof(buf) - len, len, buf + sizeof(buf) - 20 );
@@ -198,7 +198,7 @@ int x509write_crt_set_authority_key_identifier( x509write_cert *ctx )
unsigned char *c = buf + sizeof(buf);
size_t len = 0;
- memset( buf, 0, sizeof(buf));
+ memset( buf, 0, sizeof(buf) );
ASN1_CHK_ADD( len, pk_write_pubkey( &c, buf, ctx->issuer_key ) );
sha1( buf + sizeof(buf) - len, len, buf + sizeof(buf) - 20 );
diff --git a/library/xtea.c b/library/xtea.c
index 18a4d462f..5ff8a044f 100644
--- a/library/xtea.c
+++ b/library/xtea.c
@@ -71,7 +71,7 @@ void xtea_setup( xtea_context *ctx, const unsigned char key[16] )
{
int i;
- memset(ctx, 0, sizeof(xtea_context));
+ memset( ctx, 0, sizeof(xtea_context) );
for( i = 0; i < 4; i++ )
{
@@ -142,7 +142,7 @@ int xtea_crypt_cbc( xtea_context *ctx, int mode, size_t length,
memcpy( temp, input, 8 );
xtea_crypt_ecb( ctx, mode, input, output );
- for(i = 0; i < 8; i++)
+ for( i = 0; i < 8; i++ )
output[i] = (unsigned char)( output[i] ^ iv[i] );
memcpy( iv, temp, 8 );