Commit 23986e5d authored by Paul Bakker's avatar Paul Bakker

- Major type rewrite of int to size_t for most variables and arguments used...

 - Major type rewrite of int to size_t for most variables and arguments used for buffer lengths and loops
parent 1be81a4e
......@@ -6,6 +6,11 @@ Features
(AES CTR, Camellia CTR, XTEA CBC) including the option to
enable and disable individual modes when needed
Changes
* Major argument / variable rewrite. Introduced use of size_t
instead of int for buffer lengths and loop variables for
better unsigned / signed use
= Version 0.99-pre4 released on 2011-04-01
Features
* Added support for PKCS#1 v2.1 encoding and thus support
......
......@@ -27,6 +27,8 @@
#ifndef POLARSSL_AES_H
#define POLARSSL_AES_H
#include <string.h>
#define AES_ENCRYPT 1
#define AES_DECRYPT 0
......@@ -57,7 +59,7 @@ extern "C" {
*
* \return 0 if successful, or POLARSSL_ERR_AES_INVALID_KEY_LENGTH
*/
int aes_setkey_enc( aes_context *ctx, const unsigned char *key, int keysize );
int aes_setkey_enc( aes_context *ctx, const unsigned char *key, unsigned int keysize );
/**
* \brief AES key schedule (decryption)
......@@ -68,7 +70,7 @@ int aes_setkey_enc( aes_context *ctx, const unsigned char *key, int keysize );
*
* \return 0 if successful, or POLARSSL_ERR_AES_INVALID_KEY_LENGTH
*/
int aes_setkey_dec( aes_context *ctx, const unsigned char *key, int keysize );
int aes_setkey_dec( aes_context *ctx, const unsigned char *key, unsigned int keysize );
/**
* \brief AES-ECB block encryption/decryption
......@@ -101,7 +103,7 @@ int aes_crypt_ecb( aes_context *ctx,
*/
int aes_crypt_cbc( aes_context *ctx,
int mode,
int length,
size_t length,
unsigned char iv[16],
const unsigned char *input,
unsigned char *output );
......@@ -121,7 +123,7 @@ int aes_crypt_cbc( aes_context *ctx,
*/
int aes_crypt_cfb128( aes_context *ctx,
int mode,
int length,
size_t length,
int *iv_off,
unsigned char iv[16],
const unsigned char *input,
......
......@@ -27,6 +27,8 @@
#ifndef POLARSSL_ARC4_H
#define POLARSSL_ARC4_H
#include <string.h>
/**
* \brief ARC4 context structure
*/
......@@ -49,7 +51,7 @@ extern "C" {
* \param key the secret key
* \param keylen length of the key
*/
void arc4_setup( arc4_context *ctx, const unsigned char *key, int keylen );
void arc4_setup( arc4_context *ctx, const unsigned char *key, unsigned int keylen );
/**
* \brief ARC4 cipher function
......@@ -61,7 +63,7 @@ void arc4_setup( arc4_context *ctx, const unsigned char *key, int keylen );
*
* \return 0 if successful
*/
int arc4_crypt( arc4_context *ctx, int length, const unsigned char *input,
int arc4_crypt( arc4_context *ctx, size_t length, const unsigned char *input,
unsigned char *output );
/*
......
......@@ -27,6 +27,8 @@
#ifndef POLARSSL_BASE64_H
#define POLARSSL_BASE64_H
#include <string.h>
#define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL 0x0010
#define POLARSSL_ERR_BASE64_INVALID_CHARACTER 0x0012
......@@ -49,8 +51,8 @@ extern "C" {
* \note Call this function with *dlen = 0 to obtain the
* required buffer size in *dlen
*/
int base64_encode( unsigned char *dst, int *dlen,
const unsigned char *src, int slen );
int base64_encode( unsigned char *dst, size_t *dlen,
const unsigned char *src, size_t slen );
/**
* \brief Decode a base64-formatted buffer
......@@ -68,8 +70,8 @@ int base64_encode( unsigned char *dst, int *dlen,
* \note Call this function with *dlen = 0 to obtain the
* required buffer size in *dlen
*/
int base64_decode( unsigned char *dst, int *dlen,
const unsigned char *src, int slen );
int base64_decode( unsigned char *dst, size_t *dlen,
const unsigned char *src, size_t slen );
/**
* \brief Checkup routine
......
......@@ -28,6 +28,7 @@
#define POLARSSL_BIGNUM_H
#include <stdio.h>
#include <string.h>
#define POLARSSL_ERR_MPI_FILE_IO_ERROR 0x0002
#define POLARSSL_ERR_MPI_BAD_INPUT_DATA 0x0004
......@@ -43,13 +44,16 @@
* Define the base integer type, architecture-wise
*/
#if defined(POLARSSL_HAVE_INT8)
typedef signed char t_s_int;
typedef unsigned char t_int;
typedef unsigned short t_dbl;
#else
#if defined(POLARSSL_HAVE_INT16)
typedef signed short t_s_int;
typedef unsigned short t_int;
typedef unsigned long t_dbl;
#else
typedef signed long t_s_int;
typedef unsigned long t_int;
#if defined(_MSC_VER) && defined(_M_IX86)
typedef unsigned __int64 t_dbl;
......@@ -73,7 +77,7 @@ typedef unsigned long t_dbl;
typedef struct
{
int s; /*!< integer sign */
int n; /*!< total # of limbs */
size_t n; /*!< total # of limbs */
t_int *p; /*!< pointer to limbs */
}
mpi;
......@@ -101,7 +105,7 @@ void mpi_free( mpi *X, ... );
* \return 0 if successful,
* 1 if memory allocation failed
*/
int mpi_grow( mpi *X, int nblimbs );
int mpi_grow( mpi *X, size_t nblimbs );
/**
* \brief Copy the contents of Y into X
......@@ -131,28 +135,28 @@ void mpi_swap( mpi *X, mpi *Y );
* \return 0 if successful,
* 1 if memory allocation failed
*/
int mpi_lset( mpi *X, int z );
int mpi_lset( mpi *X, t_s_int z );
/**
* \brief Return the number of least significant bits
*
* \param X MPI to use
*/
int mpi_lsb( const mpi *X );
size_t mpi_lsb( const mpi *X );
/**
* \brief Return the number of most significant bits
*
* \param X MPI to use
*/
int mpi_msb( const mpi *X );
size_t mpi_msb( const mpi *X );
/**
* \brief Return the total size in bytes
*
* \param X MPI to use
*/
int mpi_size( const mpi *X );
size_t mpi_size( const mpi *X );
/**
* \brief Import from an ASCII string
......@@ -180,7 +184,7 @@ int mpi_read_string( mpi *X, int radix, const char *s );
* \note Call this function with *slen = 0 to obtain the
* minimum required buffer size in *slen.
*/
int mpi_write_string( const mpi *X, int radix, char *s, int *slen );
int mpi_write_string( const mpi *X, int radix, char *s, size_t *slen );
/**
* \brief Read X from an opened file
......@@ -217,7 +221,7 @@ int mpi_write_file( const char *p, const mpi *X, int radix, FILE *fout );
* \return 0 if successful,
* 1 if memory allocation failed
*/
int mpi_read_binary( mpi *X, const unsigned char *buf, int buflen );
int mpi_read_binary( mpi *X, const unsigned char *buf, size_t buflen );
/**
* \brief Export X into unsigned binary data, big endian
......@@ -229,7 +233,7 @@ int mpi_read_binary( mpi *X, const unsigned char *buf, int buflen );
* \return 0 if successful,
* POLARSSL_ERR_MPI_BUFFER_TOO_SMALL if buf isn't large enough
*/
int mpi_write_binary( const mpi *X, unsigned char *buf, int buflen );
int mpi_write_binary( const mpi *X, unsigned char *buf, size_t buflen );
/**
* \brief Left-shift: X <<= count
......@@ -240,7 +244,7 @@ int mpi_write_binary( const mpi *X, unsigned char *buf, int buflen );
* \return 0 if successful,
* 1 if memory allocation failed
*/
int mpi_shift_l( mpi *X, int count );
int mpi_shift_l( mpi *X, size_t count );
/**
* \brief Right-shift: X >>= count
......@@ -251,7 +255,7 @@ int mpi_shift_l( mpi *X, int count );
* \return 0 if successful,
* 1 if memory allocation failed
*/
int mpi_shift_r( mpi *X, int count );
int mpi_shift_r( mpi *X, size_t count );
/**
* \brief Compare unsigned values
......@@ -287,7 +291,7 @@ int mpi_cmp_mpi( const mpi *X, const mpi *Y );
* -1 if X is lesser than z or
* 0 if X is equal to z
*/
int mpi_cmp_int( const mpi *X, int z );
int mpi_cmp_int( const mpi *X, t_s_int z );
/**
* \brief Unsigned addition: X = |A| + |B|
......@@ -347,7 +351,7 @@ int mpi_sub_mpi( mpi *X, const mpi *A, const mpi *B );
* \return 0 if successful,
* 1 if memory allocation failed
*/
int mpi_add_int( mpi *X, const mpi *A, int b );
int mpi_add_int( mpi *X, const mpi *A, t_s_int b );
/**
* \brief Signed substraction: X = A - b
......@@ -359,7 +363,7 @@ int mpi_add_int( mpi *X, const mpi *A, int b );
* \return 0 if successful,
* 1 if memory allocation failed
*/
int mpi_sub_int( mpi *X, const mpi *A, int b );
int mpi_sub_int( mpi *X, const mpi *A, t_s_int b );
/**
* \brief Baseline multiplication: X = A * B
......@@ -385,7 +389,7 @@ int mpi_mul_mpi( mpi *X, const mpi *A, const mpi *B );
* \return 0 if successful,
* 1 if memory allocation failed
*/
int mpi_mul_int( mpi *X, const mpi *A, t_int b );
int mpi_mul_int( mpi *X, const mpi *A, t_s_int b );
/**
* \brief Division by mpi: A = Q * B + R
......@@ -417,7 +421,7 @@ int mpi_div_mpi( mpi *Q, mpi *R, const mpi *A, const mpi *B );
*
* \note Either Q or R can be NULL.
*/
int mpi_div_int( mpi *Q, mpi *R, const mpi *A, int b );
int mpi_div_int( mpi *Q, mpi *R, const mpi *A, t_s_int b );
/**
* \brief Modulo: R = A mod B
......@@ -445,7 +449,7 @@ int mpi_mod_mpi( mpi *R, const mpi *A, const mpi *B );
* POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0,
* POLARSSL_ERR_MPI_NEGATIVE_VALUE if b < 0
*/
int mpi_mod_int( t_int *r, const mpi *A, int b );
int mpi_mod_int( t_int *r, const mpi *A, t_s_int b );
/**
* \brief Sliding-window exponentiation: X = A^E mod N
......@@ -477,7 +481,7 @@ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR );
* \return 0 if successful,
* 1 if memory allocation failed
*/
int mpi_fill_random( mpi *X, int size, int (*f_rng)(void *), void *p_rng );
int mpi_fill_random( mpi *X, size_t size, int (*f_rng)(void *), void *p_rng );
/**
* \brief Greatest common divisor: G = gcd(A, B)
......@@ -531,7 +535,7 @@ int mpi_is_prime( mpi *X, int (*f_rng)(void *), void *p_rng );
* 1 if memory allocation failed,
* POLARSSL_ERR_MPI_BAD_INPUT_DATA if nbits is < 3
*/
int mpi_gen_prime( mpi *X, int nbits, int dh_flag,
int mpi_gen_prime( mpi *X, size_t nbits, int dh_flag,
int (*f_rng)(void *), void *p_rng );
/**
......
......@@ -27,6 +27,8 @@
#ifndef POLARSSL_CAMELLIA_H
#define POLARSSL_CAMELLIA_H
#include <string.h>
#ifdef _MSC_VER
#include <basetsd.h>
typedef UINT32 uint32_t;
......@@ -63,7 +65,7 @@ extern "C" {
*
* \return 0 if successful, or POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH
*/
int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, int keysize );
int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, unsigned int keysize );
/**
* \brief CAMELLIA key schedule (decryption)
......@@ -74,7 +76,7 @@ int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, int ke
*
* \return 0 if successful, or POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH
*/
int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key, int keysize );
int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key, unsigned int keysize );
/**
* \brief CAMELLIA-ECB block encryption/decryption
......@@ -107,7 +109,7 @@ int camellia_crypt_ecb( camellia_context *ctx,
*/
int camellia_crypt_cbc( camellia_context *ctx,
int mode,
int length,
size_t length,
unsigned char iv[16],
const unsigned char *input,
unsigned char *output );
......@@ -127,7 +129,7 @@ int camellia_crypt_cbc( camellia_context *ctx,
*/
int camellia_crypt_cfb128( camellia_context *ctx,
int mode,
int length,
size_t length,
int *iv_off,
unsigned char iv[16],
const unsigned char *input,
......
......@@ -96,26 +96,26 @@ typedef struct {
cipher_mode_t mode;
/** Cipher key length, in bits (default length for variable sized ciphers) */
int key_length;
unsigned int key_length;
/** Name of the cipher */
const char * name;
/** IV size, in bytes */
int iv_size;
unsigned int iv_size;
/** block size, in bytes */
int block_size;
unsigned int block_size;
/** Encrypt using CBC */
int (*cbc_func)( void *ctx, operation_t mode, int length, unsigned char *iv,
int (*cbc_func)( void *ctx, operation_t mode, size_t length, unsigned char *iv,
const unsigned char *input, unsigned char *output );
/** Set key for encryption purposes */
int (*setkey_enc_func)( void *ctx, const unsigned char *key, int key_length);
int (*setkey_enc_func)( void *ctx, const unsigned char *key, unsigned int key_length);
/** Set key for decryption purposes */
int (*setkey_dec_func)( void *ctx, const unsigned char *key, int key_length);
int (*setkey_dec_func)( void *ctx, const unsigned char *key, unsigned int key_length);
/** Allocate a new context */
void * (*ctx_alloc_func)( void );
......@@ -142,7 +142,7 @@ typedef struct {
unsigned char unprocessed_data[POLARSSL_MAX_IV_LENGTH];
/** Number of bytes that still need processing */
int unprocessed_len;
size_t unprocessed_len;
/** Current IV */
unsigned char iv[POLARSSL_MAX_IV_LENGTH];
......@@ -167,7 +167,7 @@ const int *cipher_list( void );
* \brief Returns the cipher information structure associated
* with the given cipher name.
*
* \param cipher_name Name of the cipher to search for.
* \param cipher_name Name of the cipher to search for.
*
* \return the cipher information structure associated with the
* given cipher_name, or NULL if not found.
......@@ -215,7 +215,7 @@ int cipher_free_ctx( cipher_context_t *ctx );
* \return size of the cipher's blocks, or 0 if ctx has not been
* initialised.
*/
static inline int cipher_get_block_size( const cipher_context_t *ctx )
static inline unsigned int cipher_get_block_size( const cipher_context_t *ctx )
{
if( NULL == ctx || NULL == ctx->cipher_info )
return 0;
......@@ -332,8 +332,8 @@ int cipher_reset( cipher_context_t *ctx, const unsigned char *iv );
*
* \returns 0 on success, 1 if parameter verification fails.
*/
int cipher_update( cipher_context_t *ctx, const unsigned char *input, int ilen,
unsigned char *output, int *olen );
int cipher_update( cipher_context_t *ctx, const unsigned char *input, size_t ilen,
unsigned char *output, size_t *olen );
/**
* \brief Generic cipher finalisation function. If data still
......@@ -347,7 +347,7 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input, int ilen,
*
* \returns 0 on success, 1 if parameter verification fails.
*/
int cipher_finish( cipher_context_t *ctx, unsigned char *output, int *olen);
int cipher_finish( cipher_context_t *ctx, unsigned char *output, size_t *olen);
/**
......
......@@ -72,7 +72,7 @@ void debug_print_ret( const ssl_context *ssl, int level,
void debug_print_buf( const ssl_context *ssl, int level,
const char *file, int line, const char *text,
unsigned char *buf, int len );
unsigned char *buf, size_t len );
void debug_print_mpi( const ssl_context *ssl, int level,
const char *file, int line,
......
......@@ -27,6 +27,8 @@
#ifndef POLARSSL_DES_H
#define POLARSSL_DES_H
#include <string.h>
#define DES_ENCRYPT 1
#define DES_DECRYPT 0
......@@ -171,7 +173,7 @@ int des_crypt_ecb( des_context *ctx,
*/
int des_crypt_cbc( des_context *ctx,
int mode,
int length,
size_t length,
unsigned char iv[8],
const unsigned char *input,
unsigned char *output );
......@@ -203,7 +205,7 @@ int des3_crypt_ecb( des3_context *ctx,
*/
int des3_crypt_cbc( des3_context *ctx,
int mode,
int length,
size_t length,
unsigned char iv[8],
const unsigned char *input,
unsigned char *output );
......
......@@ -44,7 +44,7 @@
*/
typedef struct
{
int len; /*!< size(P) in chars */
size_t len; /*!< size(P) in chars */
mpi P; /*!< prime modulus */
mpi G; /*!< generator */
mpi X; /*!< secret value */
......@@ -89,7 +89,7 @@ int dhm_read_params( dhm_context *ctx,
* \return 0 if successful, or an POLARSSL_ERR_DHM_XXX error code
*/
int dhm_make_params( dhm_context *ctx, int x_size,
unsigned char *output, int *olen,
unsigned char *output, size_t *olen,
int (*f_rng)(void *), void *p_rng );
/**
......@@ -102,7 +102,7 @@ int dhm_make_params( dhm_context *ctx, int x_size,
* \return 0 if successful, or an POLARSSL_ERR_DHM_XXX error code
*/
int dhm_read_public( dhm_context *ctx,
const unsigned char *input, int ilen );
const unsigned char *input, size_t ilen );
/**
* \brief Create own private value X and export G^X
......@@ -117,7 +117,7 @@ int dhm_read_public( dhm_context *ctx,
* \return 0 if successful, or an POLARSSL_ERR_DHM_XXX error code
*/
int dhm_make_public( dhm_context *ctx, int x_size,
unsigned char *output, int olen,
unsigned char *output, size_t olen,
int (*f_rng)(void *), void *p_rng );
/**
......@@ -130,7 +130,7 @@ int dhm_make_public( dhm_context *ctx, int x_size,
* \return 0 if successful, or an POLARSSL_ERR_DHM_XXX error code
*/
int dhm_calc_secret( dhm_context *ctx,
unsigned char *output, int *olen );
unsigned char *output, size_t *olen );
/*
* \brief Free the components of a DHM key
......
......@@ -30,6 +30,8 @@
#ifndef POLARSSL_MD_H
#define POLARSSL_MD_H
#include <string.h>
#ifdef _MSC_VER
#define inline _inline
#endif
......@@ -66,23 +68,23 @@ typedef struct {
void (*starts_func)( void *ctx );
/** Digest update function */
void (*update_func)( void *ctx, const unsigned char *input, int ilen );
void (*update_func)( void *ctx, const unsigned char *input, size_t ilen );
/** Digest finalisation function */
void (*finish_func)( void *ctx, unsigned char *output );
/** Generic digest function */
void (*digest_func)( const unsigned char *input, int ilen,
void (*digest_func)( const unsigned char *input, size_t ilen,
unsigned char *output );
/** Generic file digest function */
int (*file_func)( const char *path, unsigned char *output );
/** HMAC Initialisation function */
void (*hmac_starts_func)( void *ctx, const unsigned char *key, int keylen );
void (*hmac_starts_func)( void *ctx, const unsigned char *key, size_t keylen );
/** HMAC update function */
void (*hmac_update_func)( void *ctx, const unsigned char *input, int ilen );
void (*hmac_update_func)( void *ctx, const unsigned char *input, size_t ilen );
/** HMAC finalisation function */
void (*hmac_finish_func)( void *ctx, unsigned char *output);
......@@ -91,8 +93,8 @@ typedef struct {
void (*hmac_reset_func)( void *ctx );
/** Generic HMAC function */
void (*hmac_func)( const unsigned char *key, int keylen,
const unsigned char *input, int ilen,
void (*hmac_func)( const unsigned char *key, size_t keylen,
const unsigned char *input, size_t ilen,
unsigned char *output );
/** Allocate a new context */
......@@ -135,7 +137,7 @@ const int *md_list( void );
* \brief Returns the message digest information associated with the
* given digest name.
*
* \param md_name Name of the digest to search for.
* \param md_name Name of the digest to search for.
*
* \return The message digest information associated with md_name or
* NULL if not found.
......@@ -184,7 +186,7 @@ int md_free_ctx( md_context_t *ctx );
*
* \return size of the message digest output.
*/
static inline unsigned char md_get_size ( const md_info_t *md_info)
static inline unsigned char md_get_size( const md_info_t *md_info )
{
return md_info->size;
}
......@@ -196,7 +198,7 @@ static inline unsigned char md_get_size ( const md_info_t *md_info)
*
* \return type of the message digest output.
*/
static inline md_type_t md_get_type ( const md_info_t *md_info )
static inline md_type_t md_get_type( const md_info_t *md_info )
{
return md_info->type;
}
......@@ -208,7 +210,7 @@ static inline md_type_t md_get_type ( const md_info_t *md_info )
*
* \return name of the message digest output.
*/
static inline const char *md_get_name ( const md_info_t *md_info )
static inline const char *md_get_name( const md_info_t *md_info )
{
return md_info->name;
}
......@@ -231,7 +233,7 @@ int md_starts( md_context_t *ctx );
*
* \returns 0 on success, 1 if parameter verification fails.
*/
int md_update( md_context_t *ctx, const unsigned char *input, int ilen );
int md_update( md_context_t *ctx, const unsigned char *input, size_t ilen );
/**
* \brief Generic message digest final digest
......@@ -253,7 +255,7 @@ int md_finish( md_context_t *ctx, unsigned char *output );
*
* \returns 0 on success, 1 if parameter verification fails.
*/
int md( const md_info_t *md_info, const unsigned char *input, int ilen,
int md( const md_info_t *md_info, const unsigned char *input, size_t ilen,
unsigned char *output );
/**
......@@ -277,7 +279,7 @@ int md_file( const md_info_t *md_info, const char *path, unsigned char *output )
*
* \returns 0 on success, 1 if parameter verification fails.
*/
int md_hmac_starts( md_context_t *ctx, const unsigned char *key, int keylen );
int md_hmac_starts( md_context_t *ctx, const unsigned char *key, size_t keylen );
/**
* \brief Generic HMAC process buffer
......@@ -288,7 +290,7 @@ int md_hmac_starts( md_context_t *ctx, const unsigned char *key, int keylen );
*
* \returns 0 on success, 1 if parameter verification fails.
*/
int md_hmac_update( md_context_t *ctx, const unsigned char *input, int ilen );
int md_hmac_update( md_context_t *ctx, const unsigned char *input, size_t ilen );
/**
* \brief Generic HMAC final digest
......@@ -321,8 +323,8 @@ int md_hmac_reset( md_context_t *ctx );
*
* \returns 0 on success, 1 if parameter verification fails.
*/
int md_hmac( const md_info_t *md_info, const unsigned char *key, int keylen,
const unsigned char *input, int ilen,
int md_hmac( const md_info_t *md_info, const unsigned char *key, size_t keylen,
const unsigned char *input, size_t ilen,
unsigned char *output );
#ifdef __cplusplus
......
......@@ -27,6 +27,8 @@
#ifndef POLARSSL_MD2_H
#define POLARSSL_MD2_H
#include <string.h>
/**
* \brief MD2 context structure
*/
......@@ -38,7 +40,7 @@ typedef struct
unsigned char ipad[64]; /*!< HMAC: inner padding */
unsigned char opad[64]; /*!< HMAC: outer padding */
int left; /*!< amount of data in buffer */
size_t left; /*!< amount of data in buffer */
}
md2_context;
......@@ -60,7 +62,7 @@ void md2_starts( md2_context *ctx );
* \param input buffer holding the data
* \param ilen length of the input data
*/
void md2_update( md2_context *ctx, const unsigned char *input, int ilen );
void md2_update( md2_context *ctx, const unsigned char *input, size_t ilen );
/**
* \brief MD2 final digest
......@@ -77,7 +79,7 @@ void md2_finish( md2_context *ctx, unsigned char output[16] );
* \param ilen length of the input data
* \param output MD2 checksum result
*/
void md2( const unsigned char *input, int ilen, unsigned char output[16] );
void md2( const unsigned char *input, size_t ilen, unsigned char output[16] );
/**
* \brief Output = MD2( file contents )
......@@ -97,7 +99,7 @@ int md2_file( const char *path, unsigned char output[16] );
* \param key HMAC secret key
* \param keylen length of the HMAC key
*/
void md2_hmac_starts( md2_context *ctx, const unsigned char *key, int keylen );
void md2_hmac_starts( md2_context *ctx, const unsigned char *key, size_t keylen );
/**
* \brief MD2 HMAC process buffer
......@@ -106,7 +108,7 @@ void md2_hmac_starts( md2_context *ctx, const unsigned char *key, int keylen );
* \param input buffer holding the data
* \param ilen length of the input data
*/
void md2_hmac_update( md2_context *ctx, const unsigned char *input, int ilen );
void md2_hmac_update( md2_context *ctx, const unsigned char *input, size_t ilen );
/**
* \brief MD2 HMAC final digest
......@@ -132,8 +134,8 @@ void md2_hmac_reset( md2_context *ctx );
* \param ilen length of the input data
* \param output HMAC-MD2 result
*/
void md2_hmac( const unsigned char *key, int keylen,
const unsigned char *input, int ilen,
void md2_hmac( const unsigned char *key, size_t keylen,
const unsigned char *input, size_t ilen,
unsigned char output[16] );
/**
......
......@@ -27,6 +27,8 @@
#ifndef POLARSSL_MD4_H
#define POLARSSL_MD4_H
#include <string.h>
/**
* \brief MD4 context structure
*/
......@@ -59,7 +61,7 @@ void md4_starts( md4_context *ctx );
* \param input buffer holding the data
* \param ilen length of the input data
*/
void md4_update( md4_context *ctx, const unsigned char *input, int ilen );
void md4_update( md4_context *ctx, const unsigned char *input, size_t ilen );
/**
* \brief MD4 final digest
......@@ -76,7 +78,7 @@ void md4_finish( md4_context *ctx, unsigned char output[16] );
* \param ilen length of the input data
* \param output MD4 checksum result
*/
void md4( const unsigned char *input, int ilen, unsigned char output[16] );
void md4( const unsigned char *input, size_t ilen, unsigned char output[16] );
/**
* \brief Output = MD4( file contents )
......@@ -96,7 +98,7 @@ int md4_file( const char *path, unsigned char output[16] );
* \param key HMAC secret key
* \param keylen length of the HMAC key
*/
void md4_hmac_starts( md4_context *ctx, const unsigned char *key, int keylen );
void md4_hmac_starts( md4_context *ctx, const unsigned char *key, size_t keylen );
/**
* \brief MD4 HMAC process buffer
......@@ -105,7 +107,7 @@ void md4_hmac_starts( md4_context *ctx, const unsigned char *key, int keylen );
* \param input buffer holding the data
* \param ilen length of the input data
*/
void md4_hmac_update( md4_context *ctx, const unsigned char *input, int ilen );
void md4_hmac_update( md4_context *ctx, const unsigned char *input, size_t ilen );