- Removed deprecated casts to int for now unsigned values

This commit is contained in:
Paul Bakker 2011-06-09 13:55:13 +00:00
parent 887bd502d2
commit 27fdf46d16
9 changed files with 34 additions and 32 deletions

View File

@ -822,12 +822,13 @@ int aes_crypt_cbc( aes_context *ctx,
int aes_crypt_cfb128( aes_context *ctx,
int mode,
size_t length,
int *iv_off,
size_t *iv_off,
unsigned char iv[16],
const unsigned char *input,
unsigned char *output )
{
int c, n = *iv_off;
int c;
size_t n = *iv_off;
if( mode == AES_DECRYPT )
{
@ -867,14 +868,15 @@ int aes_crypt_cfb128( aes_context *ctx,
* AES-CTR buffer encryption/decryption
*/
int aes_crypt_ctr( aes_context *ctx,
int length,
int *nc_off,
size_t length,
size_t *nc_off,
unsigned char nonce_counter[16],
unsigned char stream_block[16],
const unsigned char *input,
unsigned char *output )
{
int c, n = *nc_off, i, cb;
int c, i, cb;
size_t n = *nc_off;
while( length-- )
{
@ -1089,7 +1091,7 @@ int aes_self_test( int verbose )
unsigned char prv[16];
unsigned char iv[16];
#if defined(POLARSSL_CIPHER_MODE_CTR) || defined(POLARSSL_CIPHER_MODE_CFB)
int offset;
size_t offset;
#endif
#if defined(POLARSSL_CIPHER_MODE_CTR)
int len;

View File

@ -194,7 +194,7 @@ int md2_file( const char *path, unsigned char output[16] )
md2_starts( &ctx );
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
md2_update( &ctx, buf, (int) n );
md2_update( &ctx, buf, n );
md2_finish( &ctx, output );

View File

@ -290,7 +290,7 @@ int md4_file( const char *path, unsigned char output[16] )
md4_starts( &ctx );
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
md4_update( &ctx, buf, (int) n );
md4_update( &ctx, buf, n );
md4_finish( &ctx, output );

View File

@ -309,7 +309,7 @@ int md5_file( const char *path, unsigned char output[16] )
md5_starts( &ctx );
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
md5_update( &ctx, buf, (int) n );
md5_update( &ctx, buf, n );
md5_finish( &ctx, output );

View File

@ -482,7 +482,7 @@ int rsa_pkcs1_decrypt( rsa_context *ctx,
ilen = ctx->len;
if( ilen < 16 || ilen > (int) sizeof( buf ) )
if( ilen < 16 || ilen > sizeof( buf ) )
return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
ret = ( mode == RSA_PUBLIC )
@ -565,10 +565,10 @@ int rsa_pkcs1_decrypt( rsa_context *ctx,
return( POLARSSL_ERR_RSA_INVALID_PADDING );
}
if (ilen - (int)(p - buf) > output_max_len)
if (ilen - (p - buf) > output_max_len)
return( POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE );
*olen = ilen - (int)(p - buf);
*olen = ilen - (p - buf);
memcpy( output, p, *olen );
return( 0 );
@ -826,7 +826,7 @@ int rsa_pkcs1_verify( rsa_context *ctx,
#endif
siglen = ctx->len;
if( siglen < 16 || siglen > (int) sizeof( buf ) )
if( siglen < 16 || siglen > sizeof( buf ) )
return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
ret = ( mode == RSA_PUBLIC )
@ -853,7 +853,7 @@ int rsa_pkcs1_verify( rsa_context *ctx,
}
p++;
len = siglen - (int)( p - buf );
len = siglen - ( p - buf );
if( len == 34 )
{

View File

@ -344,7 +344,7 @@ int sha1_file( const char *path, unsigned char output[20] )
sha1_starts( &ctx );
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
sha1_update( &ctx, buf, (int) n );
sha1_update( &ctx, buf, n );
sha1_finish( &ctx, output );

View File

@ -346,7 +346,7 @@ int sha2_file( const char *path, unsigned char output[32], int is224 )
sha2_starts( &ctx, is224 );
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
sha2_update( &ctx, buf, (int) n );
sha2_update( &ctx, buf, n );
sha2_finish( &ctx, output );

View File

@ -233,7 +233,7 @@ void sha4_update( sha4_context *ctx, const unsigned char *input, size_t ilen )
return;
left = ctx->total[0] & 0x7F;
fill = (int)( 128 - left );
fill = 128 - left;
ctx->total[0] += (unsigned int64) ilen;
@ -281,7 +281,7 @@ static const unsigned char sha4_padding[128] =
*/
void sha4_finish( sha4_context *ctx, unsigned char output[64] )
{
int last, padn;
size_t last, padn;
unsigned int64 high, low;
unsigned char msglen[16];
@ -292,7 +292,7 @@ void sha4_finish( sha4_context *ctx, unsigned char output[64] )
PUT_UINT64_BE( high, msglen, 0 );
PUT_UINT64_BE( low, msglen, 8 );
last = (int)( ctx->total[0] & 0x7F );
last = (size_t)( ctx->total[0] & 0x7F );
padn = ( last < 112 ) ? ( 112 - last ) : ( 240 - last );
sha4_update( ctx, (unsigned char *) sha4_padding, padn );
@ -344,7 +344,7 @@ int sha4_file( const char *path, unsigned char output[64], int is384 )
sha4_starts( &ctx, is384 );
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
sha4_update( &ctx, buf, (int) n );
sha4_update( &ctx, buf, n );
sha4_finish( &ctx, output );

View File

@ -145,7 +145,7 @@ static int asn1_get_int( unsigned char **p,
if( ( ret = asn1_get_tag( p, end, &len, ASN1_INTEGER ) ) != 0 )
return( ret );
if( len > (int) sizeof( int ) || ( **p & 0x80 ) != 0 )
if( len > sizeof( int ) || ( **p & 0x80 ) != 0 )
return( POLARSSL_ERR_ASN1_INVALID_LENGTH );
*val = 0;
@ -509,8 +509,8 @@ static int x509_get_time( unsigned char **p,
return( POLARSSL_ERR_X509_CERT_INVALID_DATE + ret );
memset( date, 0, sizeof( date ) );
memcpy( date, *p, ( len < (int) sizeof( date ) - 1 ) ?
len : (int) sizeof( date ) - 1 );
memcpy( date, *p, ( len < sizeof( date ) - 1 ) ?
len : sizeof( date ) - 1 );
if( sscanf( date, "%2d%2d%2d%2d%2d%2d",
&time->year, &time->mon, &time->day,
@ -533,8 +533,8 @@ static int x509_get_time( unsigned char **p,
return( POLARSSL_ERR_X509_CERT_INVALID_DATE + ret );
memset( date, 0, sizeof( date ) );
memcpy( date, *p, ( len < (int) sizeof( date ) - 1 ) ?
len : (int) sizeof( date ) - 1 );
memcpy( date, *p, ( len < sizeof( date ) - 1 ) ?
len : sizeof( date ) - 1 );
if( sscanf( date, "%4d%2d%2d%2d%2d%2d",
&time->year, &time->mon, &time->day,
@ -1789,7 +1789,7 @@ int x509parse_crtfile( x509_cert *chain, const char *path )
if ( load_file( path, &buf, &n ) )
return( 1 );
ret = x509parse_crt( chain, buf, (int) n );
ret = x509parse_crt( chain, buf, n );
memset( buf, 0, n + 1 );
free( buf );
@ -1809,7 +1809,7 @@ int x509parse_crlfile( x509_crl *chain, const char *path )
if ( load_file( path, &buf, &n ) )
return( 1 );
ret = x509parse_crl( chain, buf, (int) n );
ret = x509parse_crl( chain, buf, n );
memset( buf, 0, n + 1 );
free( buf );
@ -1830,9 +1830,9 @@ int x509parse_keyfile( rsa_context *rsa, const char *path, const char *pwd )
return( 1 );
if( pwd == NULL )
ret = x509parse_key( rsa, buf, (int) n, NULL, 0 );
ret = x509parse_key( rsa, buf, n, NULL, 0 );
else
ret = x509parse_key( rsa, buf, (int) n,
ret = x509parse_key( rsa, buf, n,
(unsigned char *) pwd, strlen( pwd ) );
memset( buf, 0, n + 1 );
@ -1853,7 +1853,7 @@ int x509parse_public_keyfile( rsa_context *rsa, const char *path )
if ( load_file( path, &buf, &n ) )
return( 1 );
ret = x509parse_public_key( rsa, buf, (int) n );
ret = x509parse_public_key( rsa, buf, n );
memset( buf, 0, n + 1 );
free( buf );
@ -2177,7 +2177,7 @@ int x509parse_dhmfile( dhm_context *dhm, const char *path )
if ( load_file( path, &buf, &n ) )
return( 1 );
ret = x509parse_dhm( dhm, buf, (int) n);
ret = x509parse_dhm( dhm, buf, n );
memset( buf, 0, n + 1 );
free( buf );
@ -2315,7 +2315,7 @@ int x509parse_dn_gets( char *buf, size_t size, const x509_name *dn )
for( i = 0; i < name->val.len; i++ )
{
if( i >= (int) sizeof( s ) - 1 )
if( i >= sizeof( s ) - 1 )
break;
c = name->val.p[i];