- Removed deprecated casts to int for now unsigned values

diff --git a/library/aes.c b/library/aes.c
index ce418d6..7bccdf9 100644
--- a/library/aes.c
+++ b/library/aes.c
@@ -822,12 +822,13 @@
 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 @@
  * 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 @@
     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;
diff --git a/library/md2.c b/library/md2.c
index de64d70..4616b83 100644
--- a/library/md2.c
+++ b/library/md2.c
@@ -194,7 +194,7 @@
     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 );
 
diff --git a/library/md4.c b/library/md4.c
index 2b5fcff..a1c8244 100644
--- a/library/md4.c
+++ b/library/md4.c
@@ -290,7 +290,7 @@
     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 );
 
diff --git a/library/md5.c b/library/md5.c
index a7faa8d..1c5b397 100644
--- a/library/md5.c
+++ b/library/md5.c
@@ -309,7 +309,7 @@
     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 );
 
diff --git a/library/rsa.c b/library/rsa.c
index 90ea54b..1a6a162 100644
--- a/library/rsa.c
+++ b/library/rsa.c
@@ -482,7 +482,7 @@
 
     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 @@
             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 @@
 #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 @@
             }
             p++;
 
-            len = siglen - (int)( p - buf );
+            len = siglen - ( p - buf );
 
             if( len == 34 )
             {
diff --git a/library/sha1.c b/library/sha1.c
index b65ab24..56028fe 100644
--- a/library/sha1.c
+++ b/library/sha1.c
@@ -344,7 +344,7 @@
     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 );
 
diff --git a/library/sha2.c b/library/sha2.c
index 385c048..9cc88e8 100644
--- a/library/sha2.c
+++ b/library/sha2.c
@@ -346,7 +346,7 @@
     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 );
 
diff --git a/library/sha4.c b/library/sha4.c
index e023237..54d94fd 100644
--- a/library/sha4.c
+++ b/library/sha4.c
@@ -233,7 +233,7 @@
         return;
 
     left = ctx->total[0] & 0x7F;
-    fill = (int)( 128 - left );
+    fill = 128 - left;
 
     ctx->total[0] += (unsigned int64) ilen;
 
@@ -281,7 +281,7 @@
  */
 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 @@
     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 @@
     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 );
 
diff --git a/library/x509parse.c b/library/x509parse.c
index 16b2034..74c4fd5 100644
--- a/library/x509parse.c
+++ b/library/x509parse.c
@@ -145,7 +145,7 @@
     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 @@
             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 @@
             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 @@
     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 @@
     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 @@
         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 @@
     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 @@
     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 @@
 
         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];