Use standard unsigned integer types

This commit is contained in:
Andreas Steffen
2016-03-24 18:52:48 +01:00
parent b210369314
commit b12c53ce77
584 changed files with 3430 additions and 3430 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ struct hasher_t {
* @return TRUE if hash created successfully
*/
bool (*get_hash)(hasher_t *this, chunk_t data,
u_int8_t *hash) __attribute__((warn_unused_result));
uint8_t *hash) __attribute__((warn_unused_result));
/**
* Hash data and allocate space for the hash.
+3 -3
View File
@@ -38,8 +38,8 @@ struct iv_gen_t {
* @param buffer pointer where the generated IV will be written
* @return TRUE if IV allocation was successful, FALSE otherwise
*/
bool (*get_iv)(iv_gen_t *this, u_int64_t seq, size_t size,
u_int8_t *buffer) __attribute__((warn_unused_result));
bool (*get_iv)(iv_gen_t *this, uint64_t seq, size_t size,
uint8_t *buffer) __attribute__((warn_unused_result));
/**
* Generates an IV and allocates space for it.
@@ -49,7 +49,7 @@ struct iv_gen_t {
* @param chunk chunk which will hold the generated IV
* @return TRUE if IV allocation was successful, FALSE otherwise
*/
bool (*allocate_iv)(iv_gen_t *this, u_int64_t seq, size_t size,
bool (*allocate_iv)(iv_gen_t *this, uint64_t seq, size_t size,
chunk_t *chunk) __attribute__((warn_unused_result));
/**
+2 -2
View File
@@ -29,13 +29,13 @@ struct private_iv_gen_t {
};
METHOD(iv_gen_t, get_iv, bool,
private_iv_gen_t *this, u_int64_t seq, size_t size, u_int8_t *buffer)
private_iv_gen_t *this, uint64_t seq, size_t size, uint8_t *buffer)
{
return size == 0;
}
METHOD(iv_gen_t, allocate_iv, bool,
private_iv_gen_t *this, u_int64_t seq, size_t size, chunk_t *chunk)
private_iv_gen_t *this, uint64_t seq, size_t size, chunk_t *chunk)
{
*chunk = chunk_empty;
return size == 0;
+2 -2
View File
@@ -36,7 +36,7 @@ struct private_iv_gen_t {
};
METHOD(iv_gen_t, get_iv, bool,
private_iv_gen_t *this, u_int64_t seq, size_t size, u_int8_t *buffer)
private_iv_gen_t *this, uint64_t seq, size_t size, uint8_t *buffer)
{
if (!this->rng)
{
@@ -46,7 +46,7 @@ METHOD(iv_gen_t, get_iv, bool,
}
METHOD(iv_gen_t, allocate_iv, bool,
private_iv_gen_t *this, u_int64_t seq, size_t size, chunk_t *chunk)
private_iv_gen_t *this, uint64_t seq, size_t size, chunk_t *chunk)
{
if (!this->rng)
{
+14 -14
View File
@@ -18,7 +18,7 @@
/**
* Magic value for the initial IV state
*/
#define SEQ_IV_INIT_STATE (~(u_int64_t)0)
#define SEQ_IV_INIT_STATE (~(uint64_t)0)
#define SEQ_IV_HIGH_MASK (1ULL << 63)
typedef struct private_iv_gen_t private_iv_gen_t;
@@ -36,30 +36,30 @@ struct private_iv_gen_t {
/**
* Previously passed sequence number in lower space to enforce uniqueness
*/
u_int64_t prevl;
uint64_t prevl;
/**
* Previously passed sequence number in upper space to enforce uniqueness
*/
u_int64_t prevh;
uint64_t prevh;
/**
* Salt to mask counter
*/
u_int8_t *salt;
uint8_t *salt;
};
METHOD(iv_gen_t, get_iv, bool,
private_iv_gen_t *this, u_int64_t seq, size_t size, u_int8_t *buffer)
private_iv_gen_t *this, uint64_t seq, size_t size, uint8_t *buffer)
{
u_int8_t iv[sizeof(u_int64_t)];
uint8_t iv[sizeof(uint64_t)];
size_t len = size;
if (!this->salt)
{
return FALSE;
}
if (size < sizeof(u_int64_t))
if (size < sizeof(uint64_t))
{
return FALSE;
}
@@ -83,19 +83,19 @@ METHOD(iv_gen_t, get_iv, bool,
{
this->prevl = seq;
}
if (len > sizeof(u_int64_t))
if (len > sizeof(uint64_t))
{
len = sizeof(u_int64_t);
len = sizeof(uint64_t);
memset(buffer, 0, size - len);
}
htoun64(iv, seq);
memxor(iv, this->salt, sizeof(u_int64_t));
memcpy(buffer + size - len, iv + sizeof(u_int64_t) - len, len);
memxor(iv, this->salt, sizeof(uint64_t));
memcpy(buffer + size - len, iv + sizeof(uint64_t) - len, len);
return TRUE;
}
METHOD(iv_gen_t, allocate_iv, bool,
private_iv_gen_t *this, u_int64_t seq, size_t size, chunk_t *chunk)
private_iv_gen_t *this, uint64_t seq, size_t size, chunk_t *chunk)
{
*chunk = chunk_alloc(size);
if (!get_iv(this, seq, chunk->len, chunk->ptr))
@@ -131,8 +131,8 @@ iv_gen_t *iv_gen_seq_create()
rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
if (rng)
{
this->salt = malloc(sizeof(u_int64_t));
if (!rng->get_bytes(rng, sizeof(u_int64_t), this->salt))
this->salt = malloc(sizeof(uint64_t));
if (!rng->get_bytes(rng, sizeof(uint64_t), this->salt))
{
free(this->salt);
this->salt = NULL;
+1 -1
View File
@@ -47,7 +47,7 @@ struct mac_t {
* @return TRUE if mac generated successfully
*/
bool (*get_mac)(mac_t *this, chunk_t data,
u_int8_t *out) __attribute__((warn_unused_result));
uint8_t *out) __attribute__((warn_unused_result));
/**
* Get the size of the resulting MAC.
+1 -1
View File
@@ -39,7 +39,7 @@ struct private_mgf1_t {
/**
* Counter
*/
u_int32_t counter;
uint32_t counter;
/**
* Set if counter has reached 2^32
+1 -1
View File
@@ -38,7 +38,7 @@ struct nonce_gen_t {
* @return TRUE if nonce allocation was successful, FALSE otherwise
*/
bool (*get_nonce)(nonce_gen_t *this, size_t size,
u_int8_t *buffer) __attribute__((warn_unused_result));
uint8_t *buffer) __attribute__((warn_unused_result));
/**
* Generates a nonce and allocates space for it.
+6 -6
View File
@@ -41,7 +41,7 @@ struct private_pkcs5_t {
/**
* Iterations for key derivation
*/
u_int64_t iterations;
uint64_t iterations;
/**
* Encryption algorithm
@@ -110,7 +110,7 @@ struct private_pkcs5_t {
*/
static bool verify_padding(crypter_t *crypter, chunk_t *blob)
{
u_int8_t padding, count;
uint8_t padding, count;
padding = count = blob->ptr[blob->len - 1];
@@ -181,10 +181,10 @@ static bool pkcs12_kdf(private_pkcs5_t *this, chunk_t password, chunk_t keymat)
* Function F of PBKDF2
*/
static bool pbkdf2_f(chunk_t block, prf_t *prf, chunk_t seed,
u_int64_t iterations)
uint64_t iterations)
{
chunk_t u;
u_int64_t i;
uint64_t i;
u = chunk_alloca(prf->get_block_size(prf));
if (!prf->get_bytes(prf, seed, u.ptr))
@@ -212,7 +212,7 @@ static bool pbkdf2(private_pkcs5_t *this, chunk_t password, chunk_t key)
prf_t *prf;
chunk_t keymat, block, seed;
size_t blocks;
u_int32_t i = 0;
uint32_t i = 0;
prf = this->data.pbes2.prf;
@@ -247,7 +247,7 @@ static bool pbkdf1(private_pkcs5_t *this, chunk_t password, chunk_t key)
{
hasher_t *hasher;
chunk_t hash;
u_int64_t i;
uint64_t i;
hasher = this->data.pbes1.hasher;
+2 -2
View File
@@ -44,7 +44,7 @@ struct private_prf_plus_t {
/**
* Octet which will be appended to the seed, 0 if not used
*/
u_int8_t counter;
uint8_t counter;
/**
* Already given out bytes in current buffer.
@@ -58,7 +58,7 @@ struct private_prf_plus_t {
};
METHOD(prf_plus_t, get_bytes, bool,
private_prf_plus_t *this, size_t length, u_int8_t *buffer)
private_prf_plus_t *this, size_t length, uint8_t *buffer)
{
size_t round, written = 0;
+1 -1
View File
@@ -39,7 +39,7 @@ struct prf_plus_t {
* @return TRUE if bytes generated successfully
*/
bool (*get_bytes)(prf_plus_t *this, size_t length,
u_int8_t *buffer) __attribute__((warn_unused_result));
uint8_t *buffer) __attribute__((warn_unused_result));
/**
* Allocate pseudo random bytes.
+1 -1
View File
@@ -36,7 +36,7 @@ struct private_prf_t {
};
METHOD(prf_t, get_bytes, bool,
private_prf_t *this, chunk_t seed, u_int8_t *buffer)
private_prf_t *this, chunk_t seed, uint8_t *buffer)
{
return this->mac->get_mac(this->mac, seed, buffer);
}
+1 -1
View File
@@ -80,7 +80,7 @@ struct prf_t {
* @return TRUE if bytes generated successfully
*/
bool (*get_bytes)(prf_t *this, chunk_t seed,
u_int8_t *buffer) __attribute__((warn_unused_result));
uint8_t *buffer) __attribute__((warn_unused_result));
/**
* Generates pseudo random bytes and allocate space for them.
@@ -134,7 +134,7 @@ METHOD(proposal_keywords_t, get_token, const proposal_token_t*,
METHOD(proposal_keywords_t, register_token, void,
private_proposal_keywords_t *this, const char *name, transform_type_t type,
u_int16_t algorithm, u_int16_t keysize)
uint16_t algorithm, uint16_t keysize)
{
proposal_token_t *token;
@@ -69,12 +69,12 @@ struct proposal_token_t {
/**
* The IKE id of the algorithm.
*/
u_int16_t algorithm;
uint16_t algorithm;
/**
* The key size associated with the specific algorithm.
*/
u_int16_t keysize;
uint16_t keysize;
};
/**
@@ -100,8 +100,8 @@ struct proposal_keywords_t {
* @param keysize the key size associated with the specific algorithm
*/
void (*register_token)(proposal_keywords_t *this, const char *name,
transform_type_t type, u_int16_t algorithm,
u_int16_t keysize);
transform_type_t type, uint16_t algorithm,
uint16_t keysize);
/**
* Register an algorithm name parser.
+2 -2
View File
@@ -25,9 +25,9 @@ ENUM(rng_quality_names, RNG_WEAK, RNG_TRUE,
/*
* Described in header.
*/
bool rng_get_bytes_not_zero(rng_t *rng, size_t len, u_int8_t *buffer, bool all)
bool rng_get_bytes_not_zero(rng_t *rng, size_t len, uint8_t *buffer, bool all)
{
u_int8_t *pos = buffer, *check = buffer + (all ? len : min(1, len));
uint8_t *pos = buffer, *check = buffer + (all ? len : min(1, len));
if (!rng->get_bytes(rng, len, pos))
{
+2 -2
View File
@@ -57,7 +57,7 @@ struct rng_t {
* @return TRUE if bytes successfully written
*/
bool (*get_bytes)(rng_t *this, size_t len,
u_int8_t *buffer) __attribute__((warn_unused_result));
uint8_t *buffer) __attribute__((warn_unused_result));
/**
* Generates random bytes and allocate space for them.
@@ -85,7 +85,7 @@ struct rng_t {
* @param all TRUE if all bytes have to be non-zero, FALSE for first
* @return TRUE if bytes successfully written
*/
bool rng_get_bytes_not_zero(rng_t *rng, size_t len, u_int8_t *buffer,
bool rng_get_bytes_not_zero(rng_t *rng, size_t len, uint8_t *buffer,
bool all) __attribute__((warn_unused_result));
/**
@@ -41,11 +41,11 @@ struct private_signer_t {
};
METHOD(signer_t, get_signature, bool,
private_signer_t *this, chunk_t data, u_int8_t *buffer)
private_signer_t *this, chunk_t data, uint8_t *buffer)
{
if (buffer)
{
u_int8_t mac[this->mac->get_mac_size(this->mac)];
uint8_t mac[this->mac->get_mac_size(this->mac)];
if (!this->mac->get_mac(this->mac, data, mac))
{
@@ -62,7 +62,7 @@ METHOD(signer_t, allocate_signature, bool,
{
if (chunk)
{
u_int8_t mac[this->mac->get_mac_size(this->mac)];
uint8_t mac[this->mac->get_mac_size(this->mac)];
if (!this->mac->get_mac(this->mac, data, mac))
{
@@ -78,7 +78,7 @@ METHOD(signer_t, allocate_signature, bool,
METHOD(signer_t, verify_signature, bool,
private_signer_t *this, chunk_t data, chunk_t signature)
{
u_int8_t mac[this->mac->get_mac_size(this->mac)];
uint8_t mac[this->mac->get_mac_size(this->mac)];
if (signature.len != this->truncation)
{
+1 -1
View File
@@ -96,7 +96,7 @@ struct signer_t {
* @return TRUE if signature created successfully
*/
bool (*get_signature)(signer_t *this, chunk_t data,
u_int8_t *buffer) __attribute__((warn_unused_result));
uint8_t *buffer) __attribute__((warn_unused_result));
/**
* Generate a signature and allocate space for it.