Commit d73956c0 authored by Davide Galassi's avatar Davide Galassi

Merge branch 'hotfix/rename_unsigned_int_to_size_t' into 'master'

rename unsigned int to size_t

See merge request TSML/TSC!9
parents 110776cb 75afcaa1
Pipeline #55043021 passed with stages
in 1 minute and 34 seconds
......@@ -21,7 +21,7 @@ struct cry_cbc_ctx {
/** Counter */
unsigned char ctr[CRY_CBC_BLOCK_MAX];
/** Counter length */
unsigned int ctrlen;
size_t ctrlen;
};
typedef struct cry_cbc_ctx cry_cbc_ctx;
......@@ -48,7 +48,7 @@ void cry_cbc_init(struct cry_cbc_ctx *ctx, void *ciph_ctx,
* @param size Cipher key size.
*/
void cry_cbc_key_set(struct cry_cbc_ctx *ctx, const unsigned char *key,
unsigned int size);
size_t size);
/**
* Set the initialization vector.
......@@ -58,7 +58,7 @@ void cry_cbc_key_set(struct cry_cbc_ctx *ctx, const unsigned char *key,
* @param size Initialization vector size.
*/
void cry_cbc_iv_set(struct cry_cbc_ctx *ctx, const unsigned char *iv,
unsigned int size);
size_t size);
/**
* Encryption function.
......@@ -69,7 +69,7 @@ void cry_cbc_iv_set(struct cry_cbc_ctx *ctx, const unsigned char *iv,
* @param size Size should be a multiple of CBC_BLOCK_SIZE
*/
void cry_cbc_encrypt(struct cry_cbc_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size);
const unsigned char *src, size_t size);
/**
* Decryption function.
......@@ -80,7 +80,7 @@ void cry_cbc_encrypt(struct cry_cbc_ctx *ctx, unsigned char *dst,
* @param size Size should be a multiple of CBC_BLOCK_SIZE.
*/
void cry_cbc_decrypt(struct cry_cbc_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size);
const unsigned char *src, size_t size);
#ifdef __cplusplus
}
......
......@@ -26,7 +26,7 @@ struct cry_cfb_ctx {
/** Cipher interface. */
const struct cry_ciph_itf *ciph_itf;
/** Initialization vector length */
unsigned int vlen;
size_t vlen;
/** Initialization vector data. */
unsigned char v[CRY_CFB_BLOCK_MAX];
};
......@@ -55,7 +55,7 @@ void cry_cfb_init(struct cry_cfb_ctx *ctx, void *ciph_ctx,
* @param size Size of cipher key.
*/
void cry_cfb_key_set(struct cry_cfb_ctx *ctx, const unsigned char *key,
unsigned int size);
size_t size);
/**
* Set the initialization vector in the CFB context.
......@@ -65,7 +65,7 @@ void cry_cfb_key_set(struct cry_cfb_ctx *ctx, const unsigned char *key,
* @param size Size of initialization vector (<= CRY_CFB_BLOCK_SIZE).
*/
void cry_cfb_iv_set(struct cry_cfb_ctx *ctx, const unsigned char *iv,
unsigned int size);
size_t size);
/**
* Encrypt/Decrypt function.
......@@ -76,7 +76,7 @@ void cry_cfb_iv_set(struct cry_cfb_ctx *ctx, const unsigned char *iv,
* @param size Size of source/destination.
*/
void cry_cfb_crypt(struct cry_cfb_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size);
const unsigned char *src, size_t size);
/**
* Encryption function.
......@@ -108,7 +108,7 @@ void cry_cfb_crypt(struct cry_cfb_ctx *ctx, unsigned char *dst,
* @param size Size of source/destination.
*/
void cry_cfb8_encrypt(struct cry_cfb_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size);
const unsigned char *src, size_t size);
/**
* Decryption function.
......@@ -119,7 +119,7 @@ void cry_cfb8_encrypt(struct cry_cfb_ctx *ctx, unsigned char *dst,
* @param size Size of ciphertext.
*/
void cry_cfb8_decrypt(struct cry_cfb_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size);
const unsigned char *src, size_t size);
#ifdef __cplusplus
......
......@@ -6,6 +6,8 @@
#ifndef CRY_CIPH_H_
#define CRY_CIPH_H_
#include <stddef.h>
#ifdef __cplusplus
extern "C"{
#endif
......@@ -32,10 +34,10 @@ typedef void (* cry_ciph_clean_f)(void *ctx);
* @param size Key size.
*/
typedef void (* cry_ciph_key_set_f)(void *ctx, const unsigned char *key,
unsigned int size);
size_t size);
typedef void (* cry_ciph_iv_set_f)(void *ctx, const unsigned char *iv,
unsigned int size);
size_t size);
/**
* Encrypt function pointer type.
......@@ -47,7 +49,7 @@ typedef void (* cry_ciph_iv_set_f)(void *ctx, const unsigned char *iv,
*/
typedef void (* cry_ciph_encrypt_f)(void *ctx, unsigned char *dst,
const unsigned char *src,
unsigned int size);
size_t size);
/**
* Decrypt function pointer type.
......@@ -59,7 +61,7 @@ typedef void (* cry_ciph_encrypt_f)(void *ctx, unsigned char *dst,
*/
typedef void (* cry_ciph_decrypt_f)(void *ctx, unsigned char *dst,
const unsigned char *src,
unsigned int size);
size_t size);
#ifdef __cplusplus
}
......
......@@ -29,7 +29,7 @@ struct cry_ctr_ctx {
/** Counter. */
unsigned char ctr[CRY_CTR_BLOCK_MAX];
/** Counter length */
unsigned int ctrlen;
size_t ctrlen;
};
typedef struct cry_ctr_ctx cry_ctr_ctx;
......@@ -56,7 +56,7 @@ void cry_ctr_init(struct cry_ctr_ctx *ctx, void *ciph_ctx,
* @param size Size of cipher key.
*/
void cry_ctr_key_set(struct cry_ctr_ctx *ctx, const unsigned char *key,
unsigned int size);
size_t size);
/**
* Set the initialization vector in the CTR context.
......@@ -66,7 +66,7 @@ void cry_ctr_key_set(struct cry_ctr_ctx *ctx, const unsigned char *key,
* @param size Size of initialization vector (<= CRY_CTR_BLOCK_SIZE).
*/
void cry_ctr_iv_set(struct cry_ctr_ctx *ctx, const unsigned char *iv,
unsigned int size);
size_t size);
/**
* Encryption function.
......@@ -77,7 +77,7 @@ void cry_ctr_iv_set(struct cry_ctr_ctx *ctx, const unsigned char *iv,
* @param size Size of ciphertext.
*/
void cry_ctr_encrypt(struct cry_ctr_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size);
const unsigned char *src, size_t size);
#ifdef __cplusplus
}
......
......@@ -14,7 +14,7 @@
/** DES context */
struct cry_des_ctx {
unsigned int keylen; /* 8 for normal DES, 24 for triple DES */
size_t keylen; /* 8 for normal DES, 24 for triple DES */
unsigned char key[3*CRY_DES_BLOCK_SIZE];
};
......@@ -22,12 +22,12 @@ typedef struct cry_des_ctx cry_des_ctx;
void cry_des_key_set(cry_des_ctx *ctx, unsigned char *key,
unsigned int size);
size_t size);
void cry_des_encrypt(cry_des_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size);
const unsigned char *src, size_t size);
void cry_des_decrypt(cry_des_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size);
const unsigned char *src, size_t size);
#endif /* CRY_DES_H_ */
......@@ -26,9 +26,9 @@ struct cry_gcm_ctx {
/** Hashing subkey. */
unsigned char key[CRY_GCM_BLOCK_SIZE];
/** Authenticated data length. */
unsigned int auth_len;
size_t auth_len;
/** Cipher data length. */
unsigned int ciph_len;
size_t ciph_len;
};
typedef struct cry_gcm_ctx cry_gcm_ctx;
......@@ -56,7 +56,7 @@ void cry_gcm_init(struct cry_gcm_ctx *ctx, void *ciph_ctx,
* @param size Size of cipher key.
*/
void cry_gcm_key_set(struct cry_gcm_ctx *ctx, const unsigned char *key,
unsigned int size);
size_t size);
/**
* Set of the initialization vector.
......@@ -66,7 +66,7 @@ void cry_gcm_key_set(struct cry_gcm_ctx *ctx, const unsigned char *key,
* @param size Size of the initialization vector.
*/
void cry_gcm_iv_set(struct cry_gcm_ctx *ctx, const unsigned char *iv,
unsigned int size);
size_t size);
/**
* Encryption function.
......@@ -77,7 +77,7 @@ void cry_gcm_iv_set(struct cry_gcm_ctx *ctx, const unsigned char *iv,
* @param size Size of source/destination buffers.
*/
void cry_gcm_encrypt(struct cry_gcm_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size);
const unsigned char *src, size_t size);
/**
* Decryption function.
......@@ -88,7 +88,7 @@ void cry_gcm_encrypt(struct cry_gcm_ctx *ctx, unsigned char *dst,
* @param size Size of source/destination buffers.
*/
void cry_gcm_decrypt(struct cry_gcm_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size);
const unsigned char *src, size_t size);
/**
* Set the additional authentication data.
......@@ -101,7 +101,7 @@ void cry_gcm_decrypt(struct cry_gcm_ctx *ctx, unsigned char *dst,
* Constraint: auth_size % GCM_BLOCK_SIZE == 0.
*/
void cry_gcm_update(struct cry_gcm_ctx *ctx, const unsigned char *aad,
unsigned int size);
size_t size);
/**
* Generate the GCM MAC (GMAC).
......@@ -111,7 +111,7 @@ void cry_gcm_update(struct cry_gcm_ctx *ctx, const unsigned char *aad,
* @param size Should be <= GCM_BLOCK_SIZE (16).
*/
void cry_gcm_digest(struct cry_gcm_ctx *ctx, unsigned char *mac,
unsigned int size);
size_t size);
#ifdef __cplusplus
}
......
......@@ -16,7 +16,7 @@ extern "C"{
* @param size Number of bytes to XOR.
*/
void cry_memxor(unsigned char *dst, const unsigned char *src,
unsigned int size);
size_t size);
/**
* XOR two memory regions.
......@@ -29,7 +29,7 @@ void cry_memxor(unsigned char *dst, const unsigned char *src,
* @param size Number of bytes to XOR.
*/
void cry_memxor2(unsigned char *dst, const unsigned char *src1,
const unsigned char *src2, unsigned int size);
const unsigned char *src2, size_t size);
#ifdef __cplusplus
}
......
......@@ -38,7 +38,7 @@ int cry_mpi_copy(cry_mpi *d, const cry_mpi *s);
int cry_mpi_init_copy(cry_mpi *d, const cry_mpi *s);
int cry_mpi_init_size(cry_mpi *a, unsigned int size);
int cry_mpi_init_size(cry_mpi *a, size_t size);
int cry_mpi_init_int(cry_mpi *a, long val);
......@@ -46,11 +46,11 @@ int cry_mpi_set_int(cry_mpi *a, long val);
int cry_mpi_get_int(cry_mpi *a, long *val);
int cry_mpi_init_bin(cry_mpi *a, const void *b, unsigned int size);
int cry_mpi_init_bin(cry_mpi *a, const void *b, size_t size);
int cry_mpi_load_bin(cry_mpi *a, const void *b, unsigned int size);
int cry_mpi_load_bin(cry_mpi *a, const void *b, size_t size);
int cry_mpi_store_bin(const cry_mpi *a, void *b, unsigned int size, int pad);
int cry_mpi_store_bin(const cry_mpi *a, void *b, size_t size, int pad);
int cry_mpi_init_str(cry_mpi *a, unsigned int radix, const char *s);
......
......@@ -80,7 +80,7 @@ void cry_trivium_iv_set(cry_trivium_ctx *ctx, const unsigned char *iv,
* @param size Number of bytes.
*/
void cry_trivium_encrypt(cry_trivium_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size);
const unsigned char *src, size_t size);
/**
* Decryption function.
......@@ -91,7 +91,7 @@ void cry_trivium_encrypt(cry_trivium_ctx *ctx, unsigned char *dst,
* @param size Number of bytes.
*/
void cry_trivium_decrypt(cry_trivium_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size);
const unsigned char *src, size_t size);
......
......@@ -15,7 +15,7 @@ void cry_cbc_init(struct cry_cbc_ctx *ctx, void *ciph_ctx,
}
void cry_cbc_key_set(struct cry_cbc_ctx *ctx, const unsigned char *key,
unsigned int size)
size_t size)
{
void *ciph = ctx->ciph_ctx;
cry_ciph_key_set_f key_set = ctx->ciph_itf->key_set;
......@@ -24,7 +24,7 @@ void cry_cbc_key_set(struct cry_cbc_ctx *ctx, const unsigned char *key,
}
void cry_cbc_iv_set(struct cry_cbc_ctx *ctx, const unsigned char *iv,
unsigned int size)
size_t size)
{
ctx->ctrlen = CRY_MIN(CRY_CBC_BLOCK_MAX, size);
memcpy(ctx->ctr, iv, ctx->ctrlen);
......@@ -32,7 +32,7 @@ void cry_cbc_iv_set(struct cry_cbc_ctx *ctx, const unsigned char *iv,
}
void cry_cbc_encrypt(struct cry_cbc_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size)
const unsigned char *src, size_t size)
{
void *ciph = ctx->ciph_ctx;
cry_ciph_encrypt_f encrypt = ctx->ciph_itf->encrypt;
......@@ -53,7 +53,7 @@ void cry_cbc_encrypt(struct cry_cbc_ctx *ctx, unsigned char *dst,
#define CBC_BUFFER_LIMIT 512
void cry_cbc_decrypt(struct cry_cbc_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size)
const unsigned char *src, size_t size)
{
void *ciph = ctx->ciph_ctx;
cry_ciph_encrypt_f decrypt = ctx->ciph_itf->decrypt;
......
......@@ -12,7 +12,7 @@ void cry_cfb_init(struct cry_cfb_ctx *ctx, void *ciph_ctx,
}
void cry_cfb_key_set(struct cry_cfb_ctx *ctx, const unsigned char *key,
unsigned int size)
size_t size)
{
void *ciph = ctx->ciph_ctx;
cry_ciph_key_set_f key_set = ctx->ciph_itf->key_set;
......@@ -21,7 +21,7 @@ void cry_cfb_key_set(struct cry_cfb_ctx *ctx, const unsigned char *key,
}
void cry_cfb_iv_set(struct cry_cfb_ctx *ctx, const unsigned char *iv,
unsigned int size)
size_t size)
{
ctx->vlen = CRY_MIN(CRY_CFB_BLOCK_MAX, size);
memcpy(ctx->v, iv, ctx->vlen);
......@@ -29,7 +29,7 @@ void cry_cfb_iv_set(struct cry_cfb_ctx *ctx, const unsigned char *iv,
}
void cry_cfb_crypt(struct cry_cfb_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int len)
const unsigned char *src, size_t len)
{
void *ciph = ctx->ciph_ctx;
cry_ciph_encrypt_f encrypt = ctx->ciph_itf->encrypt;
......@@ -51,7 +51,7 @@ void cry_cfb_crypt(struct cry_cfb_ctx *ctx, unsigned char *dst,
}
void cry_cfb8_encrypt(struct cry_cfb_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int len)
const unsigned char *src, size_t len)
{
void *ciph = ctx->ciph_ctx;
cry_ciph_encrypt_f encrypt = ctx->ciph_itf->encrypt;
......@@ -74,7 +74,7 @@ void cry_cfb8_encrypt(struct cry_cfb_ctx *ctx, unsigned char *dst,
}
void cry_cfb8_decrypt(struct cry_cfb_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int len)
const unsigned char *src, size_t len)
{
void *ciph = ctx->ciph_ctx;
cry_ciph_encrypt_f encrypt = ctx->ciph_itf->encrypt;
......
......@@ -15,7 +15,7 @@ void cry_ctr_init(struct cry_ctr_ctx *ctx, void *ciph_ctx,
}
void cry_ctr_key_set(struct cry_ctr_ctx *ctx, const unsigned char *key,
unsigned int size)
size_t size)
{
void *ciph = ctx->ciph_ctx;
cry_ciph_key_set_f key_set = ctx->ciph_itf->key_set;
......@@ -24,7 +24,7 @@ void cry_ctr_key_set(struct cry_ctr_ctx *ctx, const unsigned char *key,
}
void cry_ctr_iv_set(struct cry_ctr_ctx *ctx, const unsigned char *iv,
unsigned int size)
size_t size)
{
ctx->ctrlen = CRY_MIN(CRY_CTR_BLOCK_MAX, size);
memcpy(ctx->ctr, iv, ctx->ctrlen);
......@@ -32,7 +32,7 @@ void cry_ctr_iv_set(struct cry_ctr_ctx *ctx, const unsigned char *iv,
}
void cry_ctr_encrypt(struct cry_ctr_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int len)
const unsigned char *src, size_t len)
{
unsigned char buf[BUF_LEN];
void *ciph = ctx->ciph_ctx;
......
......@@ -146,7 +146,7 @@ static const unsigned char sbox[8][64] = {
* specification.
*/
static void permute(unsigned char *dst, const unsigned char *src,
const unsigned char *tab, unsigned int len)
const unsigned char *tab, size_t len)
{
unsigned int i;
......@@ -203,7 +203,7 @@ static void ror(unsigned char *buf)
}
static void memxor(unsigned char *dst, unsigned char *src,
unsigned int len)
size_t len)
{
while (len--)
*dst++ ^= *src++;
......@@ -301,7 +301,7 @@ static void des_block_operate(unsigned char *dst, const unsigned char *src,
}
void cry_des_encrypt(cry_des_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size)
const unsigned char *src, size_t size)
{
while (size) {
des_block_operate(dst, src, ctx->key, 1);
......@@ -316,7 +316,7 @@ void cry_des_encrypt(cry_des_ctx *ctx, unsigned char *dst,
}
void cry_des_decrypt(cry_des_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size)
const unsigned char *src, size_t size)
{
while (size) {
if (ctx->keylen == 24) {
......@@ -334,7 +334,7 @@ void cry_des_decrypt(cry_des_ctx *ctx, unsigned char *dst,
}
void cry_des_key_set(cry_des_ctx *ctx, unsigned char *key,
unsigned int size)
size_t size)
{
memset(ctx, 0, sizeof(*ctx));
if (size > CRY_DES_BLOCK_SIZE*3)
......
......@@ -83,7 +83,7 @@ void cry_gcm_init(struct cry_gcm_ctx *ctx, void *ciph_ctx,
}
void cry_gcm_key_set(struct cry_gcm_ctx *gcm, const unsigned char *key,
unsigned int size)
size_t size)
{
void *ciph = gcm->ciph_ctx;
cry_ciph_encrypt_f encrypt = gcm->ciph_itf->encrypt;
......@@ -105,7 +105,7 @@ void cry_gcm_key_set(struct cry_gcm_ctx *gcm, const unsigned char *key,
void cry_gcm_iv_set(struct cry_gcm_ctx *ctx, const unsigned char *iv,
unsigned int size)
size_t size)
{
if (size == (CRY_GCM_BLOCK_SIZE-4)) {
memcpy(ctx->iv, iv, CRY_GCM_BLOCK_SIZE-4);
......@@ -128,7 +128,7 @@ void cry_gcm_iv_set(struct cry_gcm_ctx *ctx, const unsigned char *iv,
}
static void gcm_operate(struct cry_gcm_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size)
const unsigned char *src, size_t size)
{
void *ciph = ctx->ciph_ctx;
cry_ciph_encrypt_f encrypt = ctx->ciph_itf->encrypt;
......@@ -158,7 +158,7 @@ static void gcm_operate(struct cry_gcm_ctx *ctx, unsigned char *dst,
}
void cry_gcm_encrypt(struct cry_gcm_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size)
const unsigned char *src, size_t size)
{
gcm_operate(ctx, dst, src, size);
gcm_hash(ctx->hs, ctx->key, dst, size);
......@@ -166,7 +166,7 @@ void cry_gcm_encrypt(struct cry_gcm_ctx *ctx, unsigned char *dst,
}
void cry_gcm_decrypt(struct cry_gcm_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size)
const unsigned char *src, size_t size)
{
gcm_hash(ctx->hs, ctx->key, src, size);
gcm_operate(ctx, dst, src, size);
......@@ -174,14 +174,14 @@ void cry_gcm_decrypt(struct cry_gcm_ctx *ctx, unsigned char *dst,
}
void cry_gcm_update(struct cry_gcm_ctx *ctx, const unsigned char *aad,
unsigned int size)
size_t size)
{
gcm_hash(ctx->hs, ctx->key, aad, size);
ctx->auth_len += size;
}
void cry_gcm_digest(struct cry_gcm_ctx *ctx, unsigned char *mac,
unsigned int size)
size_t size)
{
void *ciph = ctx->ciph_ctx;
cry_ciph_encrypt_f encrypt = ctx->ciph_itf->encrypt;
......
......@@ -50,10 +50,11 @@
* dst : [----------]
*/
void cry_memxor2(unsigned char *dst, const unsigned char *src1,
const unsigned char *src2, unsigned int n)
const unsigned char *src2, size_t size)
{
size_t i, j;
unsigned char *tmp, t;
size_t n = size;
if (src2 < src1) {
tmp = (unsigned char *)src1;
......@@ -100,8 +101,10 @@ void cry_memxor2(unsigned char *dst, const unsigned char *src1,
}
void cry_memxor(unsigned char *dst, const unsigned char *src,
unsigned int n)
size_t size)
{
size_t n = size;
if (dst <= src) {
while (n--)
*dst++ ^= *src++;
......
#ifndef CRY_MEMXOR_H_
#define CRY_MEMXOR_H_
#include <stddef.h>
#ifdef __cplusplus
extern "C"{
#endif
......@@ -16,7 +18,7 @@ extern "C"{
* @param size Number of bytes to XOR.
*/
void cry_memxor(unsigned char *dst, const unsigned char *src,
unsigned int size);
size_t size);
/**
* XOR two memory regions.
......@@ -29,7 +31,7 @@ void cry_memxor(unsigned char *dst, const unsigned char *src,
* @param size Number of bytes to XOR.
*/
void cry_memxor2(unsigned char *dst, const unsigned char *src1,
const unsigned char *src2, unsigned int size);
const unsigned char *src2, size_t size);
#ifdef __cplusplus
}
......
......@@ -122,7 +122,7 @@ void cry_trivium_iv_set(cry_trivium_ctx *ctx, const unsigned char *iv,
static void operate(cry_trivium_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size)
const unsigned char *src, size_t size)
{
size_t i;
......@@ -161,13 +161,13 @@ static void operate(cry_trivium_ctx *ctx, unsigned char *dst,
}
void cry_trivium_encrypt(cry_trivium_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size)
const unsigned char *src, size_t size)
{
operate(ctx, dst, src, size);
}
void cry_trivium_decrypt(cry_trivium_ctx *ctx, unsigned char *dst,
const unsigned char *src, unsigned int size)
const unsigned char *src, size_t size)
{
operate(ctx, dst, src, size);
}
......@@ -202,7 +202,7 @@ void cry_md5_digest(struct cry_md5_ctx *ctx, unsigned char *digest)
uint32_t in[16];
int mdi;
unsigned int i, ii;
unsigned int padlen;
size_t padlen;
/* save number of bits */
in[14] = ctx->len[0];
......
......@@ -4,7 +4,7 @@
/*
* Initialize a big number from big endian binary data.
*/
int cry_mpi_load_bin(cry_mpi *x, const void *b, unsigned int size)
int cry_mpi_load_bin(cry_mpi *x, const void *b, size_t size)
{
unsigned int i, m, res;
cry_mpi_digit l;
......@@ -40,7 +40,7 @@ int cry_mpi_load_bin(cry_mpi *x, const void *b, unsigned int size)
* Write a big number to a memory buffer in big endian byte order.
*/
int cry_mpi_store_bin(const cry_mpi *x, void *buf,
unsigned int bufsiz, int pad)
size_t bufsiz, int pad)
{
int i;
unsigned long l;
......@@ -63,7 +63,7 @@ int cry_mpi_store_bin(const cry_mpi *x, void *buf,
return 0;
}
int cry_mpi_init_bin(cry_mpi *x, const void *b, unsigned int size)
int cry_mpi_init_bin(cry_mpi *x, const void *b, size_t size)
{
int res;
......
......@@ -6,7 +6,7 @@
/* Digits allocation quantum */
#define MPI_PREC 8
int cry_mpi_grow(cry_mpi *a, unsigned int digs)
int cry_mpi_grow(cry_mpi *a, size_t digs)
{
cry_mpi_digit *tmp;
......@@ -44,7 +44,7 @@ int cry_mpi_init(cry_mpi *a)
/*
* Init an cry_mpi for a given size
*/
int cry_mpi_init_size(cry_mpi *a, unsigned int size)
int cry_mpi_init_size(cry_mpi *a, size_t size)
{
a->data = malloc(sizeof(cry_mpi_digit) * size);
if (a->data == NULL)
......
......@@ -37,7 +37,7 @@ typedef uint64_t cry_mpi_dword;
((a != 0) ? (((a) - 1) / CRY_MPI_DIGIT_BYTES + 1) : 0)
int cry_mpi_grow(cry_mpi *a, unsigned int size);
int cry_mpi_grow(cry_mpi *a, size_t size);
int cry_mpi_shrd(cry_mpi *a, int n);
......
......@@ -13,12 +13,12 @@ static const cry_ciph_itf aes_itf = {
};
struct aes_param {
unsigned int keylen;
unsigned int ivlen;
unsigned int aadlen;
unsigned int srclen;
unsigned int dstlen;
unsigned int maclen;
size_t keylen;
size_t ivlen;
size_t aadlen;
size_t srclen;
size_t dstlen;
size_t maclen;
unsigned char key[32];
unsigned char iv[16];
unsigned char mac[16];
......
......@@ -4,9 +4,9 @@
struct cmac_param {
unsigned int keylen;
unsigned int msglen;
unsigned int maclen;
size_t keylen;
size_t msglen;
size_t maclen;
unsigned char key[256];
unsigned char msg[256];
unsigned char mac[64];
......
......@@ -11,12 +11,12 @@ static const cry_ciph_itf des_itf = {
};
struct des_param {
unsigned int keylen;
unsigned int ivlen;
unsigned int aadlen;
unsigned int srclen;
unsigned int dstlen;
unsigned int maclen;
size_t keylen;
size_t ivlen;
size_t aadlen;
size_t srclen;
size_t dstlen;
size_t maclen;
unsigned char key[32];
unsigned char iv[16];
unsigned char mac[16];
......
......@@ -12,12 +12,12 @@ static const struct cry_ciph_itf aes_itf = {
void cry_aes_128_gcm_encrypt(unsigned char *dst,
const unsigned char *src,
const unsigned int src_size,
size_t src_size,
const unsigned char *key,
const unsigned char *iv,
unsigned char *mac,
const unsigned char *aad,
unsigned int aad_size)
size_t aad_size)
{
struct cry_aes_ctx aes;