- Major type rewrite of int to size_t for most variables and arguments used for buffer lengths and loops

This commit is contained in:
Paul Bakker 2011-04-24 08:57:21 +00:00
parent 1be81a4e5f
commit 23986e5d5d
67 changed files with 1041 additions and 949 deletions

View file

@ -39,7 +39,6 @@
#include "polarssl/sha2.h"
#include "polarssl/sha4.h"
#include <string.h>
#include <stdlib.h>
#if defined(POLARSSL_MD2_C)
@ -49,7 +48,7 @@ static void md2_starts_wrap( void *ctx )
md2_starts( (md2_context *) ctx );
}
static void md2_update_wrap( void *ctx, const unsigned char *input, int ilen )
static void md2_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
md2_update( (md2_context *) ctx, input, ilen );
}
@ -59,12 +58,12 @@ static void md2_finish_wrap( void *ctx, unsigned char *output )
md2_finish( (md2_context *) ctx, output );
}
static void md2_hmac_starts_wrap( void *ctx, const unsigned char *key, int keylen )
static void md2_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen )
{
md2_hmac_starts( (md2_context *) ctx, key, keylen );
}
static void md2_hmac_update_wrap( void *ctx, const unsigned char *input, int ilen )
static void md2_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
md2_hmac_update( (md2_context *) ctx, input, ilen );
}
@ -90,21 +89,21 @@ static void md2_ctx_free( void *ctx )
}
const md_info_t md2_info = {
POLARSSL_MD_MD2,
"MD2",
16,
md2_starts_wrap,
md2_update_wrap,
md2_finish_wrap,
md2,
md2_file,
md2_hmac_starts_wrap,
md2_hmac_update_wrap,
md2_hmac_finish_wrap,
md2_hmac_reset_wrap,
md2_hmac,
md2_ctx_alloc,
md2_ctx_free,
POLARSSL_MD_MD2,
"MD2",
16,
md2_starts_wrap,
md2_update_wrap,
md2_finish_wrap,
md2,
md2_file,
md2_hmac_starts_wrap,
md2_hmac_update_wrap,
md2_hmac_finish_wrap,
md2_hmac_reset_wrap,
md2_hmac,
md2_ctx_alloc,
md2_ctx_free,
};
#endif
@ -116,7 +115,7 @@ void md4_starts_wrap( void *ctx )
md4_starts( (md4_context *) ctx );
}
void md4_update_wrap( void *ctx, const unsigned char *input, int ilen )
void md4_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
md4_update( (md4_context *) ctx, input, ilen );
}
@ -126,12 +125,12 @@ void md4_finish_wrap( void *ctx, unsigned char *output )
md4_finish( (md4_context *) ctx, output );
}
void md4_hmac_starts_wrap( void *ctx, const unsigned char *key, int keylen )
void md4_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen )
{
md4_hmac_starts( (md4_context *) ctx, key, keylen );
}
void md4_hmac_update_wrap( void *ctx, const unsigned char *input, int ilen )
void md4_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
md4_hmac_update( (md4_context *) ctx, input, ilen );
}
@ -157,21 +156,21 @@ void md4_ctx_free( void *ctx )
}
const md_info_t md4_info = {
POLARSSL_MD_MD4,
"MD4",
16,
md4_starts_wrap,
md4_update_wrap,
md4_finish_wrap,
md4,
md4_file,
md4_hmac_starts_wrap,
md4_hmac_update_wrap,
md4_hmac_finish_wrap,
md4_hmac_reset_wrap,
md4_hmac,
md4_ctx_alloc,
md4_ctx_free,
POLARSSL_MD_MD4,
"MD4",
16,
md4_starts_wrap,
md4_update_wrap,
md4_finish_wrap,
md4,
md4_file,
md4_hmac_starts_wrap,
md4_hmac_update_wrap,
md4_hmac_finish_wrap,
md4_hmac_reset_wrap,
md4_hmac,
md4_ctx_alloc,
md4_ctx_free,
};
#endif
@ -183,7 +182,7 @@ static void md5_starts_wrap( void *ctx )
md5_starts( (md5_context *) ctx );
}
static void md5_update_wrap( void *ctx, const unsigned char *input, int ilen )
static void md5_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
md5_update( (md5_context *) ctx, input, ilen );
}
@ -193,12 +192,12 @@ static void md5_finish_wrap( void *ctx, unsigned char *output )
md5_finish( (md5_context *) ctx, output );
}
static void md5_hmac_starts_wrap( void *ctx, const unsigned char *key, int keylen )
static void md5_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen )
{
md5_hmac_starts( (md5_context *) ctx, key, keylen );
}
static void md5_hmac_update_wrap( void *ctx, const unsigned char *input, int ilen )
static void md5_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
md5_hmac_update( (md5_context *) ctx, input, ilen );
}
@ -224,21 +223,21 @@ static void md5_ctx_free( void *ctx )
}
const md_info_t md5_info = {
POLARSSL_MD_MD5,
"MD5",
16,
md5_starts_wrap,
md5_update_wrap,
md5_finish_wrap,
md5,
md5_file,
md5_hmac_starts_wrap,
md5_hmac_update_wrap,
md5_hmac_finish_wrap,
md5_hmac_reset_wrap,
md5_hmac,
md5_ctx_alloc,
md5_ctx_free,
POLARSSL_MD_MD5,
"MD5",
16,
md5_starts_wrap,
md5_update_wrap,
md5_finish_wrap,
md5,
md5_file,
md5_hmac_starts_wrap,
md5_hmac_update_wrap,
md5_hmac_finish_wrap,
md5_hmac_reset_wrap,
md5_hmac,
md5_ctx_alloc,
md5_ctx_free,
};
#endif
@ -250,7 +249,7 @@ void sha1_starts_wrap( void *ctx )
sha1_starts( (sha1_context *) ctx );
}
void sha1_update_wrap( void *ctx, const unsigned char *input, int ilen )
void sha1_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
sha1_update( (sha1_context *) ctx, input, ilen );
}
@ -260,12 +259,12 @@ void sha1_finish_wrap( void *ctx, unsigned char *output )
sha1_finish( (sha1_context *) ctx, output );
}
void sha1_hmac_starts_wrap( void *ctx, const unsigned char *key, int keylen )
void sha1_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen )
{
sha1_hmac_starts( (sha1_context *) ctx, key, keylen );
}
void sha1_hmac_update_wrap( void *ctx, const unsigned char *input, int ilen )
void sha1_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
sha1_hmac_update( (sha1_context *) ctx, input, ilen );
}
@ -291,21 +290,21 @@ void sha1_ctx_free( void *ctx )
}
const md_info_t sha1_info = {
POLARSSL_MD_SHA1,
"SHA1",
20,
sha1_starts_wrap,
sha1_update_wrap,
sha1_finish_wrap,
sha1,
sha1_file,
sha1_hmac_starts_wrap,
sha1_hmac_update_wrap,
sha1_hmac_finish_wrap,
sha1_hmac_reset_wrap,
sha1_hmac,
sha1_ctx_alloc,
sha1_ctx_free,
POLARSSL_MD_SHA1,
"SHA1",
20,
sha1_starts_wrap,
sha1_update_wrap,
sha1_finish_wrap,
sha1,
sha1_file,
sha1_hmac_starts_wrap,
sha1_hmac_update_wrap,
sha1_hmac_finish_wrap,
sha1_hmac_reset_wrap,
sha1_hmac,
sha1_ctx_alloc,
sha1_ctx_free,
};
#endif
@ -320,7 +319,7 @@ void sha224_starts_wrap( void *ctx )
sha2_starts( (sha2_context *) ctx, 1 );
}
void sha224_update_wrap( void *ctx, const unsigned char *input, int ilen )
void sha224_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
sha2_update( (sha2_context *) ctx, input, ilen );
}
@ -330,7 +329,7 @@ void sha224_finish_wrap( void *ctx, unsigned char *output )
sha2_finish( (sha2_context *) ctx, output );
}
void sha224_wrap( const unsigned char *input, int ilen,
void sha224_wrap( const unsigned char *input, size_t ilen,
unsigned char *output )
{
sha2( input, ilen, output, 1 );
@ -341,12 +340,12 @@ int sha224_file_wrap( const char *path, unsigned char *output )
return sha2_file( path, output, 1 );
}
void sha224_hmac_starts_wrap( void *ctx, const unsigned char *key, int keylen )
void sha224_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen )
{
sha2_hmac_starts( (sha2_context *) ctx, key, keylen, 1 );
}
void sha224_hmac_update_wrap( void *ctx, const unsigned char *input, int ilen )
void sha224_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
sha2_hmac_update( (sha2_context *) ctx, input, ilen );
}
@ -361,8 +360,8 @@ void sha224_hmac_reset_wrap( void *ctx )
sha2_hmac_reset( (sha2_context *) ctx );
}
void sha224_hmac_wrap( const unsigned char *key, int keylen,
const unsigned char *input, int ilen,
void sha224_hmac_wrap( const unsigned char *key, size_t keylen,
const unsigned char *input, size_t ilen,
unsigned char *output )
{
sha2_hmac( key, keylen, input, ilen, output, 1 );
@ -379,21 +378,21 @@ void sha224_ctx_free( void *ctx )
}
const md_info_t sha224_info = {
POLARSSL_MD_SHA224,
"SHA224",
28,
sha224_starts_wrap,
sha224_update_wrap,
sha224_finish_wrap,
sha224_wrap,
sha224_file_wrap,
sha224_hmac_starts_wrap,
sha224_hmac_update_wrap,
sha224_hmac_finish_wrap,
sha224_hmac_reset_wrap,
sha224_hmac_wrap,
sha224_ctx_alloc,
sha224_ctx_free,
POLARSSL_MD_SHA224,
"SHA224",
28,
sha224_starts_wrap,
sha224_update_wrap,
sha224_finish_wrap,
sha224_wrap,
sha224_file_wrap,
sha224_hmac_starts_wrap,
sha224_hmac_update_wrap,
sha224_hmac_finish_wrap,
sha224_hmac_reset_wrap,
sha224_hmac_wrap,
sha224_ctx_alloc,
sha224_ctx_free,
};
void sha256_starts_wrap( void *ctx )
@ -401,7 +400,7 @@ void sha256_starts_wrap( void *ctx )
sha2_starts( (sha2_context *) ctx, 0 );
}
void sha256_update_wrap( void *ctx, const unsigned char *input, int ilen )
void sha256_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
sha2_update( (sha2_context *) ctx, input, ilen );
}
@ -411,7 +410,7 @@ void sha256_finish_wrap( void *ctx, unsigned char *output )
sha2_finish( (sha2_context *) ctx, output );
}
void sha256_wrap( const unsigned char *input, int ilen,
void sha256_wrap( const unsigned char *input, size_t ilen,
unsigned char *output )
{
sha2( input, ilen, output, 0 );
@ -422,12 +421,12 @@ int sha256_file_wrap( const char *path, unsigned char *output )
return sha2_file( path, output, 0 );
}
void sha256_hmac_starts_wrap( void *ctx, const unsigned char *key, int keylen )
void sha256_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen )
{
sha2_hmac_starts( (sha2_context *) ctx, key, keylen, 0 );
}
void sha256_hmac_update_wrap( void *ctx, const unsigned char *input, int ilen )
void sha256_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
sha2_hmac_update( (sha2_context *) ctx, input, ilen );
}
@ -442,8 +441,8 @@ void sha256_hmac_reset_wrap( void *ctx )
sha2_hmac_reset( (sha2_context *) ctx );
}
void sha256_hmac_wrap( const unsigned char *key, int keylen,
const unsigned char *input, int ilen,
void sha256_hmac_wrap( const unsigned char *key, size_t keylen,
const unsigned char *input, size_t ilen,
unsigned char *output )
{
sha2_hmac( key, keylen, input, ilen, output, 0 );
@ -460,21 +459,21 @@ void sha256_ctx_free( void *ctx )
}
const md_info_t sha256_info = {
POLARSSL_MD_SHA256,
"SHA256",
32,
sha256_starts_wrap,
sha256_update_wrap,
sha256_finish_wrap,
sha256_wrap,
sha256_file_wrap,
sha256_hmac_starts_wrap,
sha256_hmac_update_wrap,
sha256_hmac_finish_wrap,
sha256_hmac_reset_wrap,
sha256_hmac_wrap,
sha256_ctx_alloc,
sha256_ctx_free,
POLARSSL_MD_SHA256,
"SHA256",
32,
sha256_starts_wrap,
sha256_update_wrap,
sha256_finish_wrap,
sha256_wrap,
sha256_file_wrap,
sha256_hmac_starts_wrap,
sha256_hmac_update_wrap,
sha256_hmac_finish_wrap,
sha256_hmac_reset_wrap,
sha256_hmac_wrap,
sha256_ctx_alloc,
sha256_ctx_free,
};
#endif
@ -486,7 +485,7 @@ void sha384_starts_wrap( void *ctx )
sha4_starts( (sha4_context *) ctx, 1 );
}
void sha384_update_wrap( void *ctx, const unsigned char *input, int ilen )
void sha384_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
sha4_update( (sha4_context *) ctx, input, ilen );
}
@ -496,7 +495,7 @@ void sha384_finish_wrap( void *ctx, unsigned char *output )
sha4_finish( (sha4_context *) ctx, output );
}
void sha384_wrap( const unsigned char *input, int ilen,
void sha384_wrap( const unsigned char *input, size_t ilen,
unsigned char *output )
{
sha4( input, ilen, output, 1 );
@ -507,12 +506,12 @@ int sha384_file_wrap( const char *path, unsigned char *output )
return sha4_file( path, output, 1 );
}
void sha384_hmac_starts_wrap( void *ctx, const unsigned char *key, int keylen )
void sha384_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen )
{
sha4_hmac_starts( (sha4_context *) ctx, key, keylen, 1 );
}
void sha384_hmac_update_wrap( void *ctx, const unsigned char *input, int ilen )
void sha384_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
sha4_hmac_update( (sha4_context *) ctx, input, ilen );
}
@ -527,8 +526,8 @@ void sha384_hmac_reset_wrap( void *ctx )
sha4_hmac_reset( (sha4_context *) ctx );
}
void sha384_hmac_wrap( const unsigned char *key, int keylen,
const unsigned char *input, int ilen,
void sha384_hmac_wrap( const unsigned char *key, size_t keylen,
const unsigned char *input, size_t ilen,
unsigned char *output )
{
sha4_hmac( key, keylen, input, ilen, output, 1 );
@ -545,21 +544,21 @@ void sha384_ctx_free( void *ctx )
}
const md_info_t sha384_info = {
POLARSSL_MD_SHA384,
"SHA384",
48,
sha384_starts_wrap,
sha384_update_wrap,
sha384_finish_wrap,
sha384_wrap,
sha384_file_wrap,
sha384_hmac_starts_wrap,
sha384_hmac_update_wrap,
sha384_hmac_finish_wrap,
sha384_hmac_reset_wrap,
sha384_hmac_wrap,
sha384_ctx_alloc,
sha384_ctx_free,
POLARSSL_MD_SHA384,
"SHA384",
48,
sha384_starts_wrap,
sha384_update_wrap,
sha384_finish_wrap,
sha384_wrap,
sha384_file_wrap,
sha384_hmac_starts_wrap,
sha384_hmac_update_wrap,
sha384_hmac_finish_wrap,
sha384_hmac_reset_wrap,
sha384_hmac_wrap,
sha384_ctx_alloc,
sha384_ctx_free,
};
void sha512_starts_wrap( void *ctx )
@ -567,7 +566,7 @@ void sha512_starts_wrap( void *ctx )
sha4_starts( (sha4_context *) ctx, 0 );
}
void sha512_update_wrap( void *ctx, const unsigned char *input, int ilen )
void sha512_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
sha4_update( (sha4_context *) ctx, input, ilen );
}
@ -577,7 +576,7 @@ void sha512_finish_wrap( void *ctx, unsigned char *output )
sha4_finish( (sha4_context *) ctx, output );
}
void sha512_wrap( const unsigned char *input, int ilen,
void sha512_wrap( const unsigned char *input, size_t ilen,
unsigned char *output )
{
sha4( input, ilen, output, 0 );
@ -588,12 +587,12 @@ int sha512_file_wrap( const char *path, unsigned char *output )
return sha4_file( path, output, 0 );
}
void sha512_hmac_starts_wrap( void *ctx, const unsigned char *key, int keylen )
void sha512_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen )
{
sha4_hmac_starts( (sha4_context *) ctx, key, keylen, 0 );
}
void sha512_hmac_update_wrap( void *ctx, const unsigned char *input, int ilen )
void sha512_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
{
sha4_hmac_update( (sha4_context *) ctx, input, ilen );
}
@ -608,8 +607,8 @@ void sha512_hmac_reset_wrap( void *ctx )
sha4_hmac_reset( (sha4_context *) ctx );
}
void sha512_hmac_wrap( const unsigned char *key, int keylen,
const unsigned char *input, int ilen,
void sha512_hmac_wrap( const unsigned char *key, size_t keylen,
const unsigned char *input, size_t ilen,
unsigned char *output )
{
sha4_hmac( key, keylen, input, ilen, output, 0 );
@ -626,21 +625,21 @@ void sha512_ctx_free( void *ctx )
}
const md_info_t sha512_info = {
POLARSSL_MD_SHA512,
"SHA512",
64,
sha512_starts_wrap,
sha512_update_wrap,
sha512_finish_wrap,
sha512_wrap,
sha512_file_wrap,
sha512_hmac_starts_wrap,
sha512_hmac_update_wrap,
sha512_hmac_finish_wrap,
sha512_hmac_reset_wrap,
sha512_hmac_wrap,
sha512_ctx_alloc,
sha512_ctx_free,
POLARSSL_MD_SHA512,
"SHA512",
64,
sha512_starts_wrap,
sha512_update_wrap,
sha512_finish_wrap,
sha512_wrap,
sha512_file_wrap,
sha512_hmac_starts_wrap,
sha512_hmac_update_wrap,
sha512_hmac_finish_wrap,
sha512_hmac_reset_wrap,
sha512_hmac_wrap,
sha512_ctx_alloc,
sha512_ctx_free,
};
#endif