Use standard unsigned integer types
This commit is contained in:
@@ -592,15 +592,15 @@ bool asn1_parse_simple_object(chunk_t *object, asn1_t type, u_int level, const c
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
u_int64_t asn1_parse_integer_uint64(chunk_t blob)
|
||||
uint64_t asn1_parse_integer_uint64(chunk_t blob)
|
||||
{
|
||||
u_int64_t val = 0;
|
||||
uint64_t val = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < blob.len; i++)
|
||||
{ /* if it is longer than 8 bytes, we just use the 8 LSBs */
|
||||
val <<= 8;
|
||||
val |= (u_int64_t)blob.ptr[i];
|
||||
val |= (uint64_t)blob.ptr[i];
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -172,13 +172,13 @@ bool asn1_parse_simple_object(chunk_t *object, asn1_t type, u_int level0,
|
||||
const char* name);
|
||||
|
||||
/**
|
||||
* Converts an ASN.1 INTEGER object to an u_int64_t. If the INTEGER is longer
|
||||
* Converts an ASN.1 INTEGER object to an uint64_t. If the INTEGER is longer
|
||||
* than 8 bytes only the 8 LSBs are returned.
|
||||
*
|
||||
* @param blob body of an ASN.1 coded integer object
|
||||
* @return converted integer
|
||||
*/
|
||||
u_int64_t asn1_parse_integer_uint64(chunk_t blob);
|
||||
uint64_t asn1_parse_integer_uint64(chunk_t blob);
|
||||
|
||||
/**
|
||||
* Print the value of an ASN.1 simple object
|
||||
|
||||
@@ -43,7 +43,7 @@ struct private_bio_reader_t {
|
||||
chunk_t cleanup;
|
||||
};
|
||||
|
||||
METHOD(bio_reader_t, remaining, u_int32_t,
|
||||
METHOD(bio_reader_t, remaining, uint32_t,
|
||||
private_bio_reader_t *this)
|
||||
{
|
||||
return this->buf.len;
|
||||
@@ -76,16 +76,16 @@ static inline chunk_t chunk_skip_end(chunk_t chunk, size_t bytes, bool from_end)
|
||||
/**
|
||||
* Returns a pointer to the data to read, optionally from the end
|
||||
*/
|
||||
static inline u_char *get_ptr_end(private_bio_reader_t *this, u_int32_t len,
|
||||
static inline u_char *get_ptr_end(private_bio_reader_t *this, uint32_t len,
|
||||
bool from_end)
|
||||
{
|
||||
return from_end ? this->buf.ptr + (this->buf.len - len) : this->buf.ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an u_int8_t from the buffer, optionally from the end of the buffer
|
||||
* Read an uint8_t from the buffer, optionally from the end of the buffer
|
||||
*/
|
||||
static bool read_uint8_internal(private_bio_reader_t *this, u_int8_t *res,
|
||||
static bool read_uint8_internal(private_bio_reader_t *this, uint8_t *res,
|
||||
bool from_end)
|
||||
{
|
||||
if (this->buf.len < 1)
|
||||
@@ -100,9 +100,9 @@ static bool read_uint8_internal(private_bio_reader_t *this, u_int8_t *res,
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an u_int16_t from the buffer, optionally from the end
|
||||
* Read an uint16_t from the buffer, optionally from the end
|
||||
*/
|
||||
static bool read_uint16_internal(private_bio_reader_t *this, u_int16_t *res,
|
||||
static bool read_uint16_internal(private_bio_reader_t *this, uint16_t *res,
|
||||
bool from_end)
|
||||
{
|
||||
if (this->buf.len < 2)
|
||||
@@ -117,9 +117,9 @@ static bool read_uint16_internal(private_bio_reader_t *this, u_int16_t *res,
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an u_int32_t (only 24-bit) from the buffer, optionally from the end
|
||||
* Read an uint32_t (only 24-bit) from the buffer, optionally from the end
|
||||
*/
|
||||
static bool read_uint24_internal(private_bio_reader_t *this, u_int32_t *res,
|
||||
static bool read_uint24_internal(private_bio_reader_t *this, uint32_t *res,
|
||||
bool from_end)
|
||||
{
|
||||
if (this->buf.len < 3)
|
||||
@@ -134,9 +134,9 @@ static bool read_uint24_internal(private_bio_reader_t *this, u_int32_t *res,
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an u_int32_t from the buffer, optionally from the end
|
||||
* Read an uint32_t from the buffer, optionally from the end
|
||||
*/
|
||||
static bool read_uint32_internal(private_bio_reader_t *this, u_int32_t *res,
|
||||
static bool read_uint32_internal(private_bio_reader_t *this, uint32_t *res,
|
||||
bool from_end)
|
||||
{
|
||||
if (this->buf.len < 4)
|
||||
@@ -151,9 +151,9 @@ static bool read_uint32_internal(private_bio_reader_t *this, u_int32_t *res,
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an u_int64_t from the buffer, optionally from the end
|
||||
* Read an uint64_t from the buffer, optionally from the end
|
||||
*/
|
||||
static bool read_uint64_internal(private_bio_reader_t *this, u_int64_t *res,
|
||||
static bool read_uint64_internal(private_bio_reader_t *this, uint64_t *res,
|
||||
bool from_end)
|
||||
{
|
||||
if (this->buf.len < 8)
|
||||
@@ -170,7 +170,7 @@ static bool read_uint64_internal(private_bio_reader_t *this, u_int64_t *res,
|
||||
/**
|
||||
* Read a chunk of data from the buffer, optionally from the end
|
||||
*/
|
||||
static bool read_data_internal(private_bio_reader_t *this, u_int32_t len,
|
||||
static bool read_data_internal(private_bio_reader_t *this, uint32_t len,
|
||||
chunk_t *res, bool from_end)
|
||||
{
|
||||
if (this->buf.len < len)
|
||||
@@ -185,73 +185,73 @@ static bool read_data_internal(private_bio_reader_t *this, u_int32_t len,
|
||||
}
|
||||
|
||||
METHOD(bio_reader_t, read_uint8, bool,
|
||||
private_bio_reader_t *this, u_int8_t *res)
|
||||
private_bio_reader_t *this, uint8_t *res)
|
||||
{
|
||||
return read_uint8_internal(this, res, FALSE);
|
||||
}
|
||||
|
||||
METHOD(bio_reader_t, read_uint16, bool,
|
||||
private_bio_reader_t *this, u_int16_t *res)
|
||||
private_bio_reader_t *this, uint16_t *res)
|
||||
{
|
||||
return read_uint16_internal(this, res, FALSE);
|
||||
}
|
||||
|
||||
METHOD(bio_reader_t, read_uint24, bool,
|
||||
private_bio_reader_t *this, u_int32_t *res)
|
||||
private_bio_reader_t *this, uint32_t *res)
|
||||
{
|
||||
return read_uint24_internal(this, res, FALSE);
|
||||
}
|
||||
|
||||
METHOD(bio_reader_t, read_uint32, bool,
|
||||
private_bio_reader_t *this, u_int32_t *res)
|
||||
private_bio_reader_t *this, uint32_t *res)
|
||||
{
|
||||
return read_uint32_internal(this, res, FALSE);
|
||||
}
|
||||
|
||||
METHOD(bio_reader_t, read_uint64, bool,
|
||||
private_bio_reader_t *this, u_int64_t *res)
|
||||
private_bio_reader_t *this, uint64_t *res)
|
||||
{
|
||||
return read_uint64_internal(this, res, FALSE);
|
||||
}
|
||||
|
||||
METHOD(bio_reader_t, read_data, bool,
|
||||
private_bio_reader_t *this, u_int32_t len, chunk_t *res)
|
||||
private_bio_reader_t *this, uint32_t len, chunk_t *res)
|
||||
{
|
||||
return read_data_internal(this, len, res, FALSE);
|
||||
}
|
||||
|
||||
METHOD(bio_reader_t, read_uint8_end, bool,
|
||||
private_bio_reader_t *this, u_int8_t *res)
|
||||
private_bio_reader_t *this, uint8_t *res)
|
||||
{
|
||||
return read_uint8_internal(this, res, TRUE);
|
||||
}
|
||||
|
||||
METHOD(bio_reader_t, read_uint16_end, bool,
|
||||
private_bio_reader_t *this, u_int16_t *res)
|
||||
private_bio_reader_t *this, uint16_t *res)
|
||||
{
|
||||
return read_uint16_internal(this, res, TRUE);
|
||||
}
|
||||
|
||||
METHOD(bio_reader_t, read_uint24_end, bool,
|
||||
private_bio_reader_t *this, u_int32_t *res)
|
||||
private_bio_reader_t *this, uint32_t *res)
|
||||
{
|
||||
return read_uint24_internal(this, res, TRUE);
|
||||
}
|
||||
|
||||
METHOD(bio_reader_t, read_uint32_end, bool,
|
||||
private_bio_reader_t *this, u_int32_t *res)
|
||||
private_bio_reader_t *this, uint32_t *res)
|
||||
{
|
||||
return read_uint32_internal(this, res, TRUE);
|
||||
}
|
||||
|
||||
METHOD(bio_reader_t, read_uint64_end, bool,
|
||||
private_bio_reader_t *this, u_int64_t *res)
|
||||
private_bio_reader_t *this, uint64_t *res)
|
||||
{
|
||||
return read_uint64_internal(this, res, TRUE);
|
||||
}
|
||||
|
||||
METHOD(bio_reader_t, read_data_end, bool,
|
||||
private_bio_reader_t *this, u_int32_t len, chunk_t *res)
|
||||
private_bio_reader_t *this, uint32_t len, chunk_t *res)
|
||||
{
|
||||
return read_data_internal(this, len, res, TRUE);
|
||||
}
|
||||
@@ -259,7 +259,7 @@ METHOD(bio_reader_t, read_data_end, bool,
|
||||
METHOD(bio_reader_t, read_data8, bool,
|
||||
private_bio_reader_t *this, chunk_t *res)
|
||||
{
|
||||
u_int8_t len;
|
||||
uint8_t len;
|
||||
|
||||
if (!read_uint8(this, &len))
|
||||
{
|
||||
@@ -271,7 +271,7 @@ METHOD(bio_reader_t, read_data8, bool,
|
||||
METHOD(bio_reader_t, read_data16, bool,
|
||||
private_bio_reader_t *this, chunk_t *res)
|
||||
{
|
||||
u_int16_t len;
|
||||
uint16_t len;
|
||||
|
||||
if (!read_uint16(this, &len))
|
||||
{
|
||||
@@ -283,7 +283,7 @@ METHOD(bio_reader_t, read_data16, bool,
|
||||
METHOD(bio_reader_t, read_data24, bool,
|
||||
private_bio_reader_t *this, chunk_t *res)
|
||||
{
|
||||
u_int32_t len;
|
||||
uint32_t len;
|
||||
|
||||
if (!read_uint24(this, &len))
|
||||
{
|
||||
@@ -295,7 +295,7 @@ METHOD(bio_reader_t, read_data24, bool,
|
||||
METHOD(bio_reader_t, read_data32, bool,
|
||||
private_bio_reader_t *this, chunk_t *res)
|
||||
{
|
||||
u_int32_t len;
|
||||
uint32_t len;
|
||||
|
||||
if (!read_uint32(this, &len))
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ struct bio_reader_t {
|
||||
*
|
||||
* @return number of remaining bytes in buffer
|
||||
*/
|
||||
u_int32_t (*remaining)(bio_reader_t *this);
|
||||
uint32_t (*remaining)(bio_reader_t *this);
|
||||
|
||||
/**
|
||||
* Peek the remaining data, not consuming any bytes.
|
||||
@@ -55,7 +55,7 @@ struct bio_reader_t {
|
||||
* @param res pointer to result
|
||||
* @return TRUE if integer read successfully
|
||||
*/
|
||||
bool (*read_uint8)(bio_reader_t *this, u_int8_t *res);
|
||||
bool (*read_uint8)(bio_reader_t *this, uint8_t *res);
|
||||
|
||||
/**
|
||||
* Read a 16-bit integer from the buffer, advance.
|
||||
@@ -63,7 +63,7 @@ struct bio_reader_t {
|
||||
* @param res pointer to result
|
||||
* @return TRUE if integer read successfully
|
||||
*/
|
||||
bool (*read_uint16)(bio_reader_t *this, u_int16_t *res);
|
||||
bool (*read_uint16)(bio_reader_t *this, uint16_t *res);
|
||||
|
||||
/**
|
||||
* Read a 24-bit integer from the buffer, advance.
|
||||
@@ -71,7 +71,7 @@ struct bio_reader_t {
|
||||
* @param res pointer to result
|
||||
* @return TRUE if integer read successfully
|
||||
*/
|
||||
bool (*read_uint24)(bio_reader_t *this, u_int32_t *res);
|
||||
bool (*read_uint24)(bio_reader_t *this, uint32_t *res);
|
||||
|
||||
/**
|
||||
* Read a 32-bit integer from the buffer, advance.
|
||||
@@ -79,7 +79,7 @@ struct bio_reader_t {
|
||||
* @param res pointer to result
|
||||
* @return TRUE if integer read successfully
|
||||
*/
|
||||
bool (*read_uint32)(bio_reader_t *this, u_int32_t *res);
|
||||
bool (*read_uint32)(bio_reader_t *this, uint32_t *res);
|
||||
|
||||
/**
|
||||
* Read a 64-bit integer from the buffer, advance.
|
||||
@@ -87,7 +87,7 @@ struct bio_reader_t {
|
||||
* @param res pointer to result
|
||||
* @return TRUE if integer read successfully
|
||||
*/
|
||||
bool (*read_uint64)(bio_reader_t *this, u_int64_t *res);
|
||||
bool (*read_uint64)(bio_reader_t *this, uint64_t *res);
|
||||
|
||||
/**
|
||||
* Read a chunk of len bytes, advance.
|
||||
@@ -96,7 +96,7 @@ struct bio_reader_t {
|
||||
* @param res pointer to result, not cloned
|
||||
* @return TRUE if data read successfully
|
||||
*/
|
||||
bool (*read_data)(bio_reader_t *this, u_int32_t len, chunk_t *res);
|
||||
bool (*read_data)(bio_reader_t *this, uint32_t len, chunk_t *res);
|
||||
|
||||
/**
|
||||
* Read a 8-bit integer from the end of the buffer, reduce remaining.
|
||||
@@ -104,7 +104,7 @@ struct bio_reader_t {
|
||||
* @param res pointer to result
|
||||
* @return TRUE if integer read successfully
|
||||
*/
|
||||
bool (*read_uint8_end)(bio_reader_t *this, u_int8_t *res);
|
||||
bool (*read_uint8_end)(bio_reader_t *this, uint8_t *res);
|
||||
|
||||
/**
|
||||
* Read a 16-bit integer from the end of the buffer, reduce remaining.
|
||||
@@ -112,7 +112,7 @@ struct bio_reader_t {
|
||||
* @param res pointer to result
|
||||
* @return TRUE if integer read successfully
|
||||
*/
|
||||
bool (*read_uint16_end)(bio_reader_t *this, u_int16_t *res);
|
||||
bool (*read_uint16_end)(bio_reader_t *this, uint16_t *res);
|
||||
|
||||
/**
|
||||
* Read a 24-bit integer from the end of the buffer, reduce remaining.
|
||||
@@ -120,7 +120,7 @@ struct bio_reader_t {
|
||||
* @param res pointer to result
|
||||
* @return TRUE if integer read successfully
|
||||
*/
|
||||
bool (*read_uint24_end)(bio_reader_t *this, u_int32_t *res);
|
||||
bool (*read_uint24_end)(bio_reader_t *this, uint32_t *res);
|
||||
|
||||
/**
|
||||
* Read a 32-bit integer from the end of the buffer, reduce remaining.
|
||||
@@ -128,7 +128,7 @@ struct bio_reader_t {
|
||||
* @param res pointer to result
|
||||
* @return TRUE if integer read successfully
|
||||
*/
|
||||
bool (*read_uint32_end)(bio_reader_t *this, u_int32_t *res);
|
||||
bool (*read_uint32_end)(bio_reader_t *this, uint32_t *res);
|
||||
|
||||
/**
|
||||
* Read a 64-bit integer from the end of the buffer, reduce remaining.
|
||||
@@ -136,7 +136,7 @@ struct bio_reader_t {
|
||||
* @param res pointer to result
|
||||
* @return TRUE if integer read successfully
|
||||
*/
|
||||
bool (*read_uint64_end)(bio_reader_t *this, u_int64_t *res);
|
||||
bool (*read_uint64_end)(bio_reader_t *this, uint64_t *res);
|
||||
|
||||
/**
|
||||
* Read a chunk of len bytes from the end of the buffer, reduce remaining.
|
||||
@@ -145,7 +145,7 @@ struct bio_reader_t {
|
||||
* @param res ponter to result, not cloned
|
||||
* @return TRUE if data read successfully
|
||||
*/
|
||||
bool (*read_data_end)(bio_reader_t *this, u_int32_t len, chunk_t *res);
|
||||
bool (*read_data_end)(bio_reader_t *this, uint32_t len, chunk_t *res);
|
||||
|
||||
/**
|
||||
* Read a chunk of bytes with a 8-bit length header, advance.
|
||||
|
||||
@@ -65,7 +65,7 @@ static inline void increase(private_bio_writer_t *this, size_t required)
|
||||
}
|
||||
|
||||
METHOD(bio_writer_t, write_uint8, void,
|
||||
private_bio_writer_t *this, u_int8_t value)
|
||||
private_bio_writer_t *this, uint8_t value)
|
||||
{
|
||||
increase(this, 1);
|
||||
this->buf.ptr[this->used] = value;
|
||||
@@ -73,7 +73,7 @@ METHOD(bio_writer_t, write_uint8, void,
|
||||
}
|
||||
|
||||
METHOD(bio_writer_t, write_uint16, void,
|
||||
private_bio_writer_t *this, u_int16_t value)
|
||||
private_bio_writer_t *this, uint16_t value)
|
||||
{
|
||||
increase(this, 2);
|
||||
htoun16(this->buf.ptr + this->used, value);
|
||||
@@ -81,7 +81,7 @@ METHOD(bio_writer_t, write_uint16, void,
|
||||
}
|
||||
|
||||
METHOD(bio_writer_t, write_uint24, void,
|
||||
private_bio_writer_t *this, u_int32_t value)
|
||||
private_bio_writer_t *this, uint32_t value)
|
||||
{
|
||||
increase(this, 3);
|
||||
value = htonl(value);
|
||||
@@ -90,7 +90,7 @@ METHOD(bio_writer_t, write_uint24, void,
|
||||
}
|
||||
|
||||
METHOD(bio_writer_t, write_uint32, void,
|
||||
private_bio_writer_t *this, u_int32_t value)
|
||||
private_bio_writer_t *this, uint32_t value)
|
||||
{
|
||||
increase(this, 4);
|
||||
htoun32(this->buf.ptr + this->used, value);
|
||||
@@ -98,7 +98,7 @@ METHOD(bio_writer_t, write_uint32, void,
|
||||
}
|
||||
|
||||
METHOD(bio_writer_t, write_uint64, void,
|
||||
private_bio_writer_t *this, u_int64_t value)
|
||||
private_bio_writer_t *this, uint64_t value)
|
||||
{
|
||||
increase(this, 8);
|
||||
htoun64(this->buf.ptr + this->used, value);
|
||||
@@ -166,7 +166,7 @@ METHOD(bio_writer_t, wrap16, void,
|
||||
METHOD(bio_writer_t, wrap24, void,
|
||||
private_bio_writer_t *this)
|
||||
{
|
||||
u_int32_t len;
|
||||
uint32_t len;
|
||||
|
||||
increase(this, 3);
|
||||
memmove(this->buf.ptr + 3, this->buf.ptr, this->used);
|
||||
@@ -221,7 +221,7 @@ METHOD(bio_writer_t, destroy, void,
|
||||
/**
|
||||
* See header
|
||||
*/
|
||||
bio_writer_t *bio_writer_create(u_int32_t bufsize)
|
||||
bio_writer_t *bio_writer_create(uint32_t bufsize)
|
||||
{
|
||||
private_bio_writer_t *this;
|
||||
|
||||
|
||||
@@ -40,35 +40,35 @@ struct bio_writer_t {
|
||||
*
|
||||
* @param value value to append
|
||||
*/
|
||||
void (*write_uint8)(bio_writer_t *this, u_int8_t value);
|
||||
void (*write_uint8)(bio_writer_t *this, uint8_t value);
|
||||
|
||||
/**
|
||||
* Append a 16-bit integer to the buffer.
|
||||
*
|
||||
* @param value value to append
|
||||
*/
|
||||
void (*write_uint16)(bio_writer_t *this, u_int16_t value);
|
||||
void (*write_uint16)(bio_writer_t *this, uint16_t value);
|
||||
|
||||
/**
|
||||
* Append a 24-bit integer to the buffer.
|
||||
*
|
||||
* @param value value to append
|
||||
*/
|
||||
void (*write_uint24)(bio_writer_t *this, u_int32_t value);
|
||||
void (*write_uint24)(bio_writer_t *this, uint32_t value);
|
||||
|
||||
/**
|
||||
* Append a 32-bit integer to the buffer.
|
||||
*
|
||||
* @param value value to append
|
||||
*/
|
||||
void (*write_uint32)(bio_writer_t *this, u_int32_t value);
|
||||
void (*write_uint32)(bio_writer_t *this, uint32_t value);
|
||||
|
||||
/**
|
||||
* Append a 64-bit integer to the buffer.
|
||||
*
|
||||
* @param value value to append
|
||||
*/
|
||||
void (*write_uint64)(bio_writer_t *this, u_int64_t value);
|
||||
void (*write_uint64)(bio_writer_t *this, uint64_t value);
|
||||
|
||||
/**
|
||||
* Append a chunk of data without a length header.
|
||||
@@ -166,6 +166,6 @@ struct bio_writer_t {
|
||||
*
|
||||
* @param bufsize initially allocated buffer size
|
||||
*/
|
||||
bio_writer_t *bio_writer_create(u_int32_t bufsize);
|
||||
bio_writer_t *bio_writer_create(uint32_t bufsize);
|
||||
|
||||
#endif /** BIO_WRITER_H_ @}*/
|
||||
|
||||
@@ -42,13 +42,13 @@
|
||||
*/
|
||||
struct array_t {
|
||||
/** number of elements currently in array (not counting head/tail) */
|
||||
u_int32_t count;
|
||||
uint32_t count;
|
||||
/** size of each element, 0 for a pointer based array */
|
||||
u_int16_t esize;
|
||||
uint16_t esize;
|
||||
/** allocated but unused elements at array front */
|
||||
u_int8_t head;
|
||||
uint8_t head;
|
||||
/** allocated but unused elements at array end */
|
||||
u_int8_t tail;
|
||||
uint8_t tail;
|
||||
/** array elements */
|
||||
void *data;
|
||||
};
|
||||
@@ -64,7 +64,7 @@ struct array_t {
|
||||
/**
|
||||
* Get the actual size of a number of elements
|
||||
*/
|
||||
static size_t get_size(array_t *array, u_int32_t num)
|
||||
static size_t get_size(array_t *array, uint32_t num)
|
||||
{
|
||||
if (array->esize)
|
||||
{
|
||||
@@ -76,7 +76,7 @@ static size_t get_size(array_t *array, u_int32_t num)
|
||||
/**
|
||||
* Increase allocated but unused tail room to at least "room"
|
||||
*/
|
||||
static void make_tail_room(array_t *array, u_int8_t room)
|
||||
static void make_tail_room(array_t *array, uint8_t room)
|
||||
{
|
||||
if (array->tail < room)
|
||||
{
|
||||
@@ -89,11 +89,11 @@ static void make_tail_room(array_t *array, u_int8_t room)
|
||||
/**
|
||||
* Increase allocated but unused head room to at least "room"
|
||||
*/
|
||||
static void make_head_room(array_t *array, u_int8_t room)
|
||||
static void make_head_room(array_t *array, uint8_t room)
|
||||
{
|
||||
if (array->head < room)
|
||||
{
|
||||
u_int8_t increase = room - array->head;
|
||||
uint8_t increase = room - array->head;
|
||||
|
||||
array->data = realloc(array->data,
|
||||
get_size(array, array->count + array->tail + room));
|
||||
@@ -158,7 +158,7 @@ static void remove_head(array_t *array, int idx)
|
||||
array->head++;
|
||||
}
|
||||
|
||||
array_t *array_create(u_int esize, u_int8_t reserve)
|
||||
array_t *array_create(u_int esize, uint8_t reserve)
|
||||
{
|
||||
array_t *array;
|
||||
|
||||
@@ -186,7 +186,7 @@ void array_compress(array_t *array)
|
||||
{
|
||||
if (array)
|
||||
{
|
||||
u_int32_t tail;
|
||||
uint32_t tail;
|
||||
|
||||
tail = array->tail;
|
||||
if (array->head)
|
||||
|
||||
@@ -68,7 +68,7 @@ typedef void (*array_callback_t)(void *data, int idx, void *user);
|
||||
* @param reserve number of items to allocate space for
|
||||
* @return array instance
|
||||
*/
|
||||
array_t *array_create(u_int esize, u_int8_t reserve);
|
||||
array_t *array_create(u_int esize, uint8_t reserve);
|
||||
|
||||
/**
|
||||
* Get the number of elements currently in the array.
|
||||
|
||||
@@ -78,7 +78,7 @@ enum auth_rule_t {
|
||||
AUTH_RULE_EAP_IDENTITY,
|
||||
/** EAP type to propose for peer authentication, eap_type_t */
|
||||
AUTH_RULE_EAP_TYPE,
|
||||
/** EAP vendor for vendor specific type, u_int32_t */
|
||||
/** EAP vendor for vendor specific type, uint32_t */
|
||||
AUTH_RULE_EAP_VENDOR,
|
||||
/** XAUTH backend name to use, char* */
|
||||
AUTH_RULE_XAUTH_BACKEND,
|
||||
|
||||
@@ -42,8 +42,8 @@ static inline void copy_chunk(chunk_t dst, chunk_t src)
|
||||
*/
|
||||
static void add_chunks(chunk_t a, chunk_t b)
|
||||
{
|
||||
u_int16_t sum;
|
||||
u_int8_t rem = 0;
|
||||
uint16_t sum;
|
||||
uint8_t rem = 0;
|
||||
ssize_t i, j;
|
||||
|
||||
for (i = a.len - 1, j = b.len -1; i >= 0 && j >= 0; i--, j--)
|
||||
@@ -64,12 +64,12 @@ static void add_chunks(chunk_t a, chunk_t b)
|
||||
* Do the actual key derivation with the given hasher, password and id.
|
||||
*/
|
||||
static bool derive_key(hash_algorithm_t hash, chunk_t unicode, chunk_t salt,
|
||||
u_int64_t iterations, char id, chunk_t result)
|
||||
uint64_t iterations, char id, chunk_t result)
|
||||
{
|
||||
chunk_t out = result, D, S, P = chunk_empty, I, Ai, B, Ij;
|
||||
hasher_t *hasher;
|
||||
size_t Slen, v, u;
|
||||
u_int64_t i;
|
||||
uint64_t i;
|
||||
bool success = FALSE;
|
||||
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, hash);
|
||||
@@ -149,7 +149,7 @@ end:
|
||||
* Described in header
|
||||
*/
|
||||
bool pkcs12_derive_key(hash_algorithm_t hash, chunk_t password, chunk_t salt,
|
||||
u_int64_t iterations, pkcs12_key_type_t type, chunk_t key)
|
||||
uint64_t iterations, pkcs12_key_type_t type, chunk_t key)
|
||||
{
|
||||
chunk_t unicode = chunk_empty;
|
||||
bool success;
|
||||
|
||||
@@ -73,6 +73,6 @@ struct pkcs12_t {
|
||||
* @return TRUE on success
|
||||
*/
|
||||
bool pkcs12_derive_key(hash_algorithm_t hash, chunk_t password, chunk_t salt,
|
||||
u_int64_t iterations, pkcs12_key_type_t type, chunk_t key);
|
||||
uint64_t iterations, pkcs12_key_type_t type, chunk_t key);
|
||||
|
||||
#endif /** PKCS12_H_ @}*/
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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));
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -39,7 +39,7 @@ struct private_mgf1_t {
|
||||
/**
|
||||
* Counter
|
||||
*/
|
||||
u_int32_t counter;
|
||||
uint32_t counter;
|
||||
|
||||
/**
|
||||
* Set if counter has reached 2^32
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -99,18 +99,18 @@ struct eap_vendor_type_t {
|
||||
/**
|
||||
* Vendor Id
|
||||
*/
|
||||
u_int32_t vendor;
|
||||
uint32_t vendor;
|
||||
};
|
||||
|
||||
/**
|
||||
* EAP packet format
|
||||
*/
|
||||
typedef struct __attribute__((packed)) {
|
||||
u_int8_t code;
|
||||
u_int8_t identifier;
|
||||
u_int16_t length;
|
||||
u_int8_t type;
|
||||
u_int8_t data;
|
||||
uint8_t code;
|
||||
uint8_t identifier;
|
||||
uint16_t length;
|
||||
uint8_t type;
|
||||
uint8_t data;
|
||||
} eap_packet_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -123,22 +123,22 @@ struct ipsec_sa_cfg_t {
|
||||
/** mode of SA (tunnel, transport) */
|
||||
ipsec_mode_t mode;
|
||||
/** unique ID */
|
||||
u_int32_t reqid;
|
||||
uint32_t reqid;
|
||||
/** number of policies of the same kind (in/out/fwd) attached to SA */
|
||||
u_int32_t policy_count;
|
||||
uint32_t policy_count;
|
||||
/** details about ESP/AH */
|
||||
struct {
|
||||
/** TRUE if this protocol is used */
|
||||
bool use;
|
||||
/** SPI for ESP/AH */
|
||||
u_int32_t spi;
|
||||
uint32_t spi;
|
||||
} esp, ah;
|
||||
/** details about IPComp */
|
||||
struct {
|
||||
/** the IPComp transform used */
|
||||
u_int16_t transform;
|
||||
uint16_t transform;
|
||||
/** CPI for IPComp */
|
||||
u_int16_t cpi;
|
||||
uint16_t cpi;
|
||||
} ipcomp;
|
||||
};
|
||||
|
||||
@@ -150,11 +150,11 @@ struct ipsec_sa_cfg_t {
|
||||
struct lifetime_cfg_t {
|
||||
struct {
|
||||
/** Limit before the SA gets invalid. */
|
||||
u_int64_t life;
|
||||
uint64_t life;
|
||||
/** Limit before the SA gets rekeyed. */
|
||||
u_int64_t rekey;
|
||||
uint64_t rekey;
|
||||
/** The range of a random value subtracted from rekey. */
|
||||
u_int64_t jitter;
|
||||
uint64_t jitter;
|
||||
} time, bytes, packets;
|
||||
};
|
||||
|
||||
@@ -163,9 +163,9 @@ struct lifetime_cfg_t {
|
||||
*/
|
||||
struct mark_t {
|
||||
/** Mark value */
|
||||
u_int32_t value;
|
||||
uint32_t value;
|
||||
/** Mark mask */
|
||||
u_int32_t mask;
|
||||
uint32_t mask;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,7 +79,7 @@ METHOD(host_t, get_sockaddr_len, socklen_t*,
|
||||
METHOD(host_t, is_anyaddr, bool,
|
||||
private_host_t *this)
|
||||
{
|
||||
static const u_int8_t zeroes[IPV6_LEN];
|
||||
static const uint8_t zeroes[IPV6_LEN];
|
||||
|
||||
switch (this->address.sa_family)
|
||||
{
|
||||
@@ -119,7 +119,7 @@ int host_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
|
||||
else
|
||||
{
|
||||
void *address;
|
||||
u_int16_t port;
|
||||
uint16_t port;
|
||||
int len;
|
||||
|
||||
address = &this->address6.sin6_addr;
|
||||
@@ -191,7 +191,7 @@ METHOD(host_t, get_family, int,
|
||||
return this->address.sa_family;
|
||||
}
|
||||
|
||||
METHOD(host_t, get_port, u_int16_t,
|
||||
METHOD(host_t, get_port, uint16_t,
|
||||
private_host_t *this)
|
||||
{
|
||||
switch (this->address.sa_family)
|
||||
@@ -212,7 +212,7 @@ METHOD(host_t, get_port, u_int16_t,
|
||||
}
|
||||
|
||||
METHOD(host_t, set_port, void,
|
||||
private_host_t *this, u_int16_t port)
|
||||
private_host_t *this, uint16_t port)
|
||||
{
|
||||
switch (this->address.sa_family)
|
||||
{
|
||||
@@ -334,7 +334,7 @@ static private_host_t *host_create_empty(void)
|
||||
/*
|
||||
* Create a %any host with port
|
||||
*/
|
||||
static host_t *host_create_any_port(int family, u_int16_t port)
|
||||
static host_t *host_create_any_port(int family, uint16_t port)
|
||||
{
|
||||
host_t *this;
|
||||
|
||||
@@ -347,7 +347,7 @@ static host_t *host_create_any_port(int family, u_int16_t port)
|
||||
* Described in header.
|
||||
*/
|
||||
host_t *host_create_from_string_and_family(char *string, int family,
|
||||
u_int16_t port)
|
||||
uint16_t port)
|
||||
{
|
||||
union {
|
||||
struct sockaddr_in v4;
|
||||
@@ -415,7 +415,7 @@ host_t *host_create_from_string_and_family(char *string, int family,
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
host_t *host_create_from_string(char *string, u_int16_t port)
|
||||
host_t *host_create_from_string(char *string, uint16_t port)
|
||||
{
|
||||
return host_create_from_string_and_family(string, AF_UNSPEC, port);
|
||||
}
|
||||
@@ -455,7 +455,7 @@ host_t *host_create_from_sockaddr(sockaddr_t *sockaddr)
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
host_t *host_create_from_dns(char *string, int af, u_int16_t port)
|
||||
host_t *host_create_from_dns(char *string, int af, uint16_t port)
|
||||
{
|
||||
host_t *this;
|
||||
|
||||
@@ -474,7 +474,7 @@ host_t *host_create_from_dns(char *string, int af, u_int16_t port)
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port)
|
||||
host_t *host_create_from_chunk(int family, chunk_t address, uint16_t port)
|
||||
{
|
||||
private_host_t *this;
|
||||
|
||||
@@ -646,7 +646,7 @@ host_t *host_create_netmask(int family, int netbits)
|
||||
if (bytes < len)
|
||||
{
|
||||
memset(target + bytes, 0x00, len - bytes);
|
||||
target[bytes] = (u_int8_t)(0xff << bits);
|
||||
target[bytes] = (uint8_t)(0xff << bits);
|
||||
}
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -99,14 +99,14 @@ struct host_t {
|
||||
*
|
||||
* @return port number
|
||||
*/
|
||||
u_int16_t (*get_port) (host_t *this);
|
||||
uint16_t (*get_port) (host_t *this);
|
||||
|
||||
/**
|
||||
* Set the port of this host
|
||||
*
|
||||
* @param port port number
|
||||
*/
|
||||
void (*set_port) (host_t *this, u_int16_t port);
|
||||
void (*set_port) (host_t *this, uint16_t port);
|
||||
|
||||
/**
|
||||
* Compare the ips of two hosts hosts.
|
||||
@@ -137,7 +137,7 @@ struct host_t {
|
||||
* @param port port number
|
||||
* @return host_t, NULL if string not an address.
|
||||
*/
|
||||
host_t *host_create_from_string(char *string, u_int16_t port);
|
||||
host_t *host_create_from_string(char *string, uint16_t port);
|
||||
|
||||
/**
|
||||
* Same as host_create_from_string(), but with the option to enforce a family.
|
||||
@@ -148,7 +148,7 @@ host_t *host_create_from_string(char *string, u_int16_t port);
|
||||
* @return host_t, NULL if string not an address.
|
||||
*/
|
||||
host_t *host_create_from_string_and_family(char *string, int family,
|
||||
u_int16_t port);
|
||||
uint16_t port);
|
||||
|
||||
/**
|
||||
* Constructor to create a host_t from a DNS name.
|
||||
@@ -158,7 +158,7 @@ host_t *host_create_from_string_and_family(char *string, int family,
|
||||
* @param port port number
|
||||
* @return host_t, NULL lookup failed
|
||||
*/
|
||||
host_t *host_create_from_dns(char *string, int family, u_int16_t port);
|
||||
host_t *host_create_from_dns(char *string, int family, uint16_t port);
|
||||
|
||||
/**
|
||||
* Constructor to create a host_t object from an address chunk.
|
||||
@@ -170,7 +170,7 @@ host_t *host_create_from_dns(char *string, int family, u_int16_t port);
|
||||
* @param port port number
|
||||
* @return host_t, NULL if family not supported/chunk invalid
|
||||
*/
|
||||
host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port);
|
||||
host_t *host_create_from_chunk(int family, chunk_t address, uint16_t port);
|
||||
|
||||
/**
|
||||
* Constructor to create a host_t object from a sockaddr struct
|
||||
|
||||
@@ -42,7 +42,7 @@ struct private_packet_t {
|
||||
/**
|
||||
* DSCP value on packet
|
||||
*/
|
||||
u_int8_t dscp;
|
||||
uint8_t dscp;
|
||||
|
||||
/**
|
||||
* message data
|
||||
@@ -94,13 +94,13 @@ METHOD(packet_t, set_data, void,
|
||||
this->adjusted_data = this->data = data;
|
||||
}
|
||||
|
||||
METHOD(packet_t, get_dscp, u_int8_t,
|
||||
METHOD(packet_t, get_dscp, uint8_t,
|
||||
private_packet_t *this)
|
||||
{
|
||||
return this->dscp;
|
||||
}
|
||||
METHOD(packet_t, set_dscp, void,
|
||||
private_packet_t *this, u_int8_t value)
|
||||
private_packet_t *this, uint8_t value)
|
||||
{
|
||||
this->dscp = value;
|
||||
}
|
||||
|
||||
@@ -85,14 +85,14 @@ struct packet_t {
|
||||
*
|
||||
* @return DSCP value
|
||||
*/
|
||||
u_int8_t (*get_dscp)(packet_t *this);
|
||||
uint8_t (*get_dscp)(packet_t *this);
|
||||
|
||||
/**
|
||||
* Set the DiffServ Code Point to use on this packet.
|
||||
*
|
||||
* @param value DSCP value
|
||||
*/
|
||||
void (*set_dscp)(packet_t *this, u_int8_t value);
|
||||
void (*set_dscp)(packet_t *this, uint8_t value);
|
||||
|
||||
/**
|
||||
* Increase the offset where the actual packet data starts.
|
||||
|
||||
@@ -96,7 +96,7 @@ struct private_tun_device_t {
|
||||
/**
|
||||
* Netmask for address
|
||||
*/
|
||||
u_int8_t netmask;
|
||||
uint8_t netmask;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -105,7 +105,7 @@ struct private_tun_device_t {
|
||||
#if __FreeBSD__ >= 10
|
||||
|
||||
static bool set_address_and_mask(struct in_aliasreq *ifra, host_t *addr,
|
||||
u_int8_t netmask)
|
||||
uint8_t netmask)
|
||||
{
|
||||
host_t *mask;
|
||||
|
||||
@@ -132,7 +132,7 @@ static bool set_address_and_mask(struct in_aliasreq *ifra, host_t *addr,
|
||||
* on FreeBSD 10 an newer.
|
||||
*/
|
||||
static bool set_address_impl(private_tun_device_t *this, host_t *addr,
|
||||
u_int8_t netmask)
|
||||
uint8_t netmask)
|
||||
{
|
||||
struct in_aliasreq ifra;
|
||||
|
||||
@@ -171,7 +171,7 @@ static bool set_address_impl(private_tun_device_t *this, host_t *addr,
|
||||
* Set the address using the classic SIOCSIFADDR etc. commands on other systems.
|
||||
*/
|
||||
static bool set_address_impl(private_tun_device_t *this, host_t *addr,
|
||||
u_int8_t netmask)
|
||||
uint8_t netmask)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
host_t *mask;
|
||||
@@ -218,7 +218,7 @@ static bool set_address_impl(private_tun_device_t *this, host_t *addr,
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
METHOD(tun_device_t, set_address, bool,
|
||||
private_tun_device_t *this, host_t *addr, u_int8_t netmask)
|
||||
private_tun_device_t *this, host_t *addr, uint8_t netmask)
|
||||
{
|
||||
if (!set_address_impl(this, addr, netmask))
|
||||
{
|
||||
@@ -231,7 +231,7 @@ METHOD(tun_device_t, set_address, bool,
|
||||
}
|
||||
|
||||
METHOD(tun_device_t, get_address, host_t*,
|
||||
private_tun_device_t *this, u_int8_t *netmask)
|
||||
private_tun_device_t *this, uint8_t *netmask)
|
||||
{
|
||||
if (netmask && this->address)
|
||||
{
|
||||
@@ -326,7 +326,7 @@ METHOD(tun_device_t, write_packet, bool,
|
||||
#ifdef __APPLE__
|
||||
/* UTUN's expect the packets to be prepended by a 32-bit protocol number
|
||||
* instead of parsing the packet again, we assume IPv4 for now */
|
||||
u_int32_t proto = htonl(AF_INET);
|
||||
uint32_t proto = htonl(AF_INET);
|
||||
packet = chunk_cata("cc", chunk_from_thing(proto), packet);
|
||||
#endif
|
||||
s = write(this->tunfd, packet.ptr, packet.len);
|
||||
@@ -364,7 +364,7 @@ METHOD(tun_device_t, read_packet, bool,
|
||||
data.len = len;
|
||||
#ifdef __APPLE__
|
||||
/* UTUN's prepend packets with a 32-bit protocol number */
|
||||
data = chunk_skip(data, sizeof(u_int32_t));
|
||||
data = chunk_skip(data, sizeof(uint32_t));
|
||||
#endif
|
||||
*packet = chunk_clone(data);
|
||||
return TRUE;
|
||||
|
||||
@@ -60,7 +60,7 @@ struct tun_device_t {
|
||||
* @param netmask the netmask to use
|
||||
* @return TRUE if operation successful
|
||||
*/
|
||||
bool (*set_address)(tun_device_t *this, host_t *addr, u_int8_t netmask);
|
||||
bool (*set_address)(tun_device_t *this, host_t *addr, uint8_t netmask);
|
||||
|
||||
/**
|
||||
* Get the IP address previously assigned to using set_address().
|
||||
@@ -68,7 +68,7 @@ struct tun_device_t {
|
||||
* @param netmask pointer receiving the configured netmask, or NULL
|
||||
* @return address previously set, NULL if none
|
||||
*/
|
||||
host_t* (*get_address)(tun_device_t *this, u_int8_t *netmask);
|
||||
host_t* (*get_address)(tun_device_t *this, uint8_t *netmask);
|
||||
|
||||
/**
|
||||
* Bring the TUN device up
|
||||
|
||||
@@ -59,7 +59,7 @@ enum pen_t {
|
||||
*/
|
||||
struct pen_type_t {
|
||||
pen_t vendor_id;
|
||||
u_int32_t type;
|
||||
uint32_t type;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -69,7 +69,7 @@ struct pen_type_t {
|
||||
* @param type type to create a pen_type_t
|
||||
* @return created pen_type_t
|
||||
*/
|
||||
static inline pen_type_t pen_type_create(pen_t vendor_id, u_int32_t type)
|
||||
static inline pen_type_t pen_type_create(pen_t vendor_id, uint32_t type)
|
||||
{
|
||||
pen_type_t pen_type = { vendor_id, type };
|
||||
return pen_type;
|
||||
@@ -96,7 +96,7 @@ static inline bool pen_type_equals(pen_type_t a, pen_type_t b)
|
||||
* @return TRUE if vendor_id and type matches pen_type
|
||||
*/
|
||||
static inline bool pen_type_is(pen_type_t pen_type,
|
||||
pen_t vendor_id, u_int32_t type)
|
||||
pen_t vendor_id, uint32_t type)
|
||||
{
|
||||
return pen_type.vendor_id == vendor_id && pen_type.type == type;
|
||||
}
|
||||
|
||||
@@ -49,27 +49,27 @@ struct private_aes_crypter_t {
|
||||
/**
|
||||
* Number of words in the key input block.
|
||||
*/
|
||||
u_int32_t aes_Nkey;
|
||||
uint32_t aes_Nkey;
|
||||
|
||||
/**
|
||||
* The number of cipher rounds.
|
||||
*/
|
||||
u_int32_t aes_Nrnd;
|
||||
uint32_t aes_Nrnd;
|
||||
|
||||
/**
|
||||
* The encryption key schedule.
|
||||
*/
|
||||
u_int32_t aes_e_key[AES_KS_LENGTH];
|
||||
uint32_t aes_e_key[AES_KS_LENGTH];
|
||||
|
||||
/**
|
||||
* The decryption key schedule.
|
||||
*/
|
||||
u_int32_t aes_d_key[AES_KS_LENGTH];
|
||||
uint32_t aes_d_key[AES_KS_LENGTH];
|
||||
|
||||
/**
|
||||
* Key size of this AES cypher object.
|
||||
*/
|
||||
u_int32_t key_size;
|
||||
uint32_t key_size;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ struct private_aes_crypter_t {
|
||||
*/
|
||||
#define bval(x,n) ((unsigned char)((x) >> 8 * (n)))
|
||||
#define bytes2word(b0, b1, b2, b3) \
|
||||
((u_int32_t)(b3) << 24 | (u_int32_t)(b2) << 16 | (u_int32_t)(b1) << 8 | (b0))
|
||||
((uint32_t)(b3) << 24 | (uint32_t)(b2) << 16 | (uint32_t)(b1) << 8 | (b0))
|
||||
|
||||
|
||||
/* little endian processor without data alignment restrictions: AES_LE_OK */
|
||||
@@ -105,15 +105,15 @@ struct private_aes_crypter_t {
|
||||
|
||||
#ifdef AES_LE_OK
|
||||
/* little endian processor without data alignment restrictions */
|
||||
#define word_in(x) *(u_int32_t*)(x)
|
||||
#define const_word_in(x) *(const u_int32_t*)(x)
|
||||
#define word_out(x,v) *(u_int32_t*)(x) = (v)
|
||||
#define const_word_out(x,v) *(const u_int32_t*)(x) = (v)
|
||||
#define word_in(x) *(uint32_t*)(x)
|
||||
#define const_word_in(x) *(const uint32_t*)(x)
|
||||
#define word_out(x,v) *(uint32_t*)(x) = (v)
|
||||
#define const_word_out(x,v) *(const uint32_t*)(x) = (v)
|
||||
#else
|
||||
/* slower but generic big endian or with data alignment restrictions */
|
||||
/* some additional "const" touches to stop "gcc -Wcast-qual" complains --jjo */
|
||||
#define word_in(x) ((u_int32_t)(((unsigned char *)(x))[0])|((u_int32_t)(((unsigned char *)(x))[1])<<8)|((u_int32_t)(((unsigned char *)(x))[2])<<16)|((u_int32_t)(((unsigned char *)(x))[3])<<24))
|
||||
#define const_word_in(x) ((const u_int32_t)(((const unsigned char *)(x))[0])|((const u_int32_t)(((const unsigned char *)(x))[1])<<8)|((const u_int32_t)(((const unsigned char *)(x))[2])<<16)|((const u_int32_t)(((const unsigned char *)(x))[3])<<24))
|
||||
#define word_in(x) ((uint32_t)(((unsigned char *)(x))[0])|((uint32_t)(((unsigned char *)(x))[1])<<8)|((uint32_t)(((unsigned char *)(x))[2])<<16)|((uint32_t)(((unsigned char *)(x))[3])<<24))
|
||||
#define const_word_in(x) ((const uint32_t)(((const unsigned char *)(x))[0])|((const uint32_t)(((const unsigned char *)(x))[1])<<8)|((const uint32_t)(((const unsigned char *)(x))[2])<<16)|((const uint32_t)(((const unsigned char *)(x))[3])<<24))
|
||||
#define word_out(x,v) ((unsigned char *)(x))[0]=(v),((unsigned char *)(x))[1]=((v)>>8),((unsigned char *)(x))[2]=((v)>>16),((unsigned char *)(x))[3]=((v)>>24)
|
||||
#define const_word_out(x,v) ((const unsigned char *)(x))[0]=(v),((const unsigned char *)(x))[1]=((v)>>8),((const unsigned char *)(x))[2]=((v)>>16),((const unsigned char *)(x))[3]=((v)>>24)
|
||||
#endif
|
||||
@@ -156,7 +156,7 @@ struct private_aes_crypter_t {
|
||||
// this table can be a table of bytes if the key schedule
|
||||
// code is adjusted accordingly
|
||||
|
||||
static const u_int32_t rcon_tab[29] =
|
||||
static const uint32_t rcon_tab[29] =
|
||||
{
|
||||
w0(01), w0(02), w0(04), w0(08),
|
||||
w0(10), w0(20), w0(40), w0(80),
|
||||
@@ -320,7 +320,7 @@ static const u_int32_t rcon_tab[29] =
|
||||
#undef r
|
||||
#define r r0
|
||||
|
||||
static const u_int32_t ft_tab[4][256] =
|
||||
static const uint32_t ft_tab[4][256] =
|
||||
{ { f_table },
|
||||
#undef r
|
||||
#define r r1
|
||||
@@ -335,7 +335,7 @@ static const u_int32_t ft_tab[4][256] =
|
||||
|
||||
#undef r
|
||||
#define r r0
|
||||
static const u_int32_t it_tab[4][256] =
|
||||
static const uint32_t it_tab[4][256] =
|
||||
{ { i_table },
|
||||
#undef r
|
||||
#define r r1
|
||||
@@ -386,7 +386,7 @@ static const u_int32_t it_tab[4][256] =
|
||||
|
||||
#undef r
|
||||
#define r(p,q,r,s) w0(q)
|
||||
static const u_int32_t fl_tab[4][256] =
|
||||
static const uint32_t fl_tab[4][256] =
|
||||
{ { f_table },
|
||||
#undef r
|
||||
#define r(p,q,r,s) w1(q)
|
||||
@@ -401,7 +401,7 @@ static const u_int32_t fl_tab[4][256] =
|
||||
|
||||
#undef w
|
||||
#define w w0
|
||||
static const u_int32_t il_tab[4][256] =
|
||||
static const uint32_t il_tab[4][256] =
|
||||
{ { li_table },
|
||||
#undef w
|
||||
#define w w1
|
||||
@@ -483,7 +483,7 @@ static const u_int32_t il_tab[4][256] =
|
||||
#undef r
|
||||
#define r r0
|
||||
|
||||
static const u_int32_t im_tab[4][256] =
|
||||
static const uint32_t im_tab[4][256] =
|
||||
{ { m_table },
|
||||
#undef r
|
||||
#define r r1
|
||||
@@ -717,8 +717,8 @@ static const u_int32_t im_tab[4][256] =
|
||||
static void encrypt_block(const private_aes_crypter_t *this,
|
||||
const unsigned char in_blk[], unsigned char out_blk[])
|
||||
{
|
||||
u_int32_t locals(b0, b1);
|
||||
const u_int32_t *kp = this->aes_e_key;
|
||||
uint32_t locals(b0, b1);
|
||||
const uint32_t *kp = this->aes_e_key;
|
||||
|
||||
state_in(b0, in_blk, kp); kp += nc;
|
||||
|
||||
@@ -754,8 +754,8 @@ static void encrypt_block(const private_aes_crypter_t *this,
|
||||
static void decrypt_block(const private_aes_crypter_t *this,
|
||||
const unsigned char in_blk[], unsigned char out_blk[])
|
||||
{
|
||||
u_int32_t locals(b0, b1);
|
||||
const u_int32_t *kp = this->aes_d_key;
|
||||
uint32_t locals(b0, b1);
|
||||
const uint32_t *kp = this->aes_d_key;
|
||||
|
||||
state_in(b0, in_blk, kp); kp += nc;
|
||||
|
||||
@@ -789,8 +789,8 @@ METHOD(crypter_t, decrypt, bool,
|
||||
private_aes_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *decrypted)
|
||||
{
|
||||
int pos;
|
||||
const u_int32_t *iv_i;
|
||||
u_int8_t *in, *out;
|
||||
const uint32_t *iv_i;
|
||||
uint8_t *in, *out;
|
||||
|
||||
if (decrypted)
|
||||
{
|
||||
@@ -811,16 +811,16 @@ METHOD(crypter_t, decrypt, bool,
|
||||
decrypt_block(this, in, out);
|
||||
if (pos==0)
|
||||
{
|
||||
iv_i=(const u_int32_t*) (iv.ptr);
|
||||
iv_i=(const uint32_t*) (iv.ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
iv_i=(const u_int32_t*) (in-16);
|
||||
iv_i=(const uint32_t*) (in-16);
|
||||
}
|
||||
*((u_int32_t *)(&out[ 0])) ^= iv_i[0];
|
||||
*((u_int32_t *)(&out[ 4])) ^= iv_i[1];
|
||||
*((u_int32_t *)(&out[ 8])) ^= iv_i[2];
|
||||
*((u_int32_t *)(&out[12])) ^= iv_i[3];
|
||||
*((uint32_t *)(&out[ 0])) ^= iv_i[0];
|
||||
*((uint32_t *)(&out[ 4])) ^= iv_i[1];
|
||||
*((uint32_t *)(&out[ 8])) ^= iv_i[2];
|
||||
*((uint32_t *)(&out[12])) ^= iv_i[3];
|
||||
in-=16;
|
||||
out-=16;
|
||||
pos-=16;
|
||||
@@ -832,8 +832,8 @@ METHOD(crypter_t, encrypt, bool,
|
||||
private_aes_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *encrypted)
|
||||
{
|
||||
int pos;
|
||||
const u_int32_t *iv_i;
|
||||
u_int8_t *in, *out;
|
||||
const uint32_t *iv_i;
|
||||
uint8_t *in, *out;
|
||||
|
||||
in = data.ptr;
|
||||
out = data.ptr;
|
||||
@@ -848,16 +848,16 @@ METHOD(crypter_t, encrypt, bool,
|
||||
{
|
||||
if (pos==0)
|
||||
{
|
||||
iv_i=(const u_int32_t*) iv.ptr;
|
||||
iv_i=(const uint32_t*) iv.ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
iv_i=(const u_int32_t*) (out-16);
|
||||
iv_i=(const uint32_t*) (out-16);
|
||||
}
|
||||
*((u_int32_t *)(&out[ 0])) = iv_i[0]^*((const u_int32_t *)(&in[ 0]));
|
||||
*((u_int32_t *)(&out[ 4])) = iv_i[1]^*((const u_int32_t *)(&in[ 4]));
|
||||
*((u_int32_t *)(&out[ 8])) = iv_i[2]^*((const u_int32_t *)(&in[ 8]));
|
||||
*((u_int32_t *)(&out[12])) = iv_i[3]^*((const u_int32_t *)(&in[12]));
|
||||
*((uint32_t *)(&out[ 0])) = iv_i[0]^*((const uint32_t *)(&in[ 0]));
|
||||
*((uint32_t *)(&out[ 4])) = iv_i[1]^*((const uint32_t *)(&in[ 4]));
|
||||
*((uint32_t *)(&out[ 8])) = iv_i[2]^*((const uint32_t *)(&in[ 8]));
|
||||
*((uint32_t *)(&out[12])) = iv_i[3]^*((const uint32_t *)(&in[12]));
|
||||
encrypt_block(this, out, out);
|
||||
in+=16;
|
||||
out+=16;
|
||||
@@ -887,8 +887,8 @@ METHOD(crypter_t, get_key_size, size_t,
|
||||
METHOD(crypter_t, set_key, bool,
|
||||
private_aes_crypter_t *this, chunk_t key)
|
||||
{
|
||||
u_int32_t *kf, *kt, rci, f = 0;
|
||||
u_int8_t *in_key = key.ptr;
|
||||
uint32_t *kf, *kt, rci, f = 0;
|
||||
uint8_t *in_key = key.ptr;
|
||||
|
||||
this->aes_Nrnd = (this->aes_Nkey > (nc) ? this->aes_Nkey : (nc)) + 6;
|
||||
|
||||
@@ -948,7 +948,7 @@ METHOD(crypter_t, set_key, bool,
|
||||
|
||||
if(!f)
|
||||
{
|
||||
u_int32_t i;
|
||||
uint32_t i;
|
||||
|
||||
kt = this->aes_d_key + nc * this->aes_Nrnd;
|
||||
kf = this->aes_e_key;
|
||||
|
||||
@@ -83,7 +83,7 @@ struct private_aesni_ccm_t {
|
||||
* First block with control information
|
||||
*/
|
||||
typedef struct __attribute__((packed)) {
|
||||
BITFIELD4(u_int8_t,
|
||||
BITFIELD4(uint8_t,
|
||||
/* size of p length field q, as q-1 */
|
||||
q_len: 3,
|
||||
/* size of our ICV t, as (t-2)/2 */
|
||||
@@ -105,7 +105,7 @@ typedef struct __attribute__((packed)) {
|
||||
* Counter block
|
||||
*/
|
||||
typedef struct __attribute__((packed)) {
|
||||
BITFIELD3(u_int8_t,
|
||||
BITFIELD3(uint8_t,
|
||||
/* size of p length field q, as q-1 */
|
||||
q_len: 3,
|
||||
zero: 3,
|
||||
@@ -140,7 +140,7 @@ static void build_b0(private_aesni_ccm_t *this, size_t len, size_t alen,
|
||||
/**
|
||||
* Build a counter block for counter i
|
||||
*/
|
||||
static void build_ctr(private_aesni_ccm_t *this, u_int32_t i, u_char *iv,
|
||||
static void build_ctr(private_aesni_ccm_t *this, uint32_t i, u_char *iv,
|
||||
void *out)
|
||||
{
|
||||
ctr_t *ctr = out;
|
||||
@@ -157,7 +157,7 @@ static void build_ctr(private_aesni_ccm_t *this, u_int32_t i, u_char *iv,
|
||||
* Calculate the ICV for the b0 and associated data
|
||||
*/
|
||||
static __m128i icv_header(private_aesni_ccm_t *this, size_t len, u_char *iv,
|
||||
u_int16_t alen, u_char *assoc)
|
||||
uint16_t alen, u_char *assoc)
|
||||
{
|
||||
__m128i *ks, b, t, c;
|
||||
u_int i, round, blocks, rem;
|
||||
|
||||
@@ -65,7 +65,7 @@ struct private_mac_t {
|
||||
};
|
||||
|
||||
METHOD(mac_t, get_mac, bool,
|
||||
private_mac_t *this, chunk_t data, u_int8_t *out)
|
||||
private_mac_t *this, chunk_t data, uint8_t *out)
|
||||
{
|
||||
__m128i *ks, t, l, *bi;
|
||||
u_int blocks, rem, i;
|
||||
|
||||
@@ -61,7 +61,7 @@ struct private_aesni_ctr_t {
|
||||
struct {
|
||||
char nonce[4];
|
||||
char iv[8];
|
||||
u_int32_t counter;
|
||||
uint32_t counter;
|
||||
} __attribute__((packed, aligned(sizeof(__m128i)))) state;
|
||||
};
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ static __m128i icv_tailer(private_aesni_gcm_t *this, __m128i y,
|
||||
__m128i b;
|
||||
|
||||
htoun64(&b, alen * 8);
|
||||
htoun64((u_char*)&b + sizeof(u_int64_t), dlen * 8);
|
||||
htoun64((u_char*)&b + sizeof(uint64_t), dlen * 8);
|
||||
|
||||
return ghash(this->h, y, b);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ struct private_aesni_mac_t {
|
||||
};
|
||||
|
||||
METHOD(mac_t, get_mac, bool,
|
||||
private_aesni_mac_t *this, chunk_t data, u_int8_t *out)
|
||||
private_aesni_mac_t *this, chunk_t data, uint8_t *out)
|
||||
{
|
||||
__m128i *ks, e, *bi;
|
||||
u_int blocks, rem, i;
|
||||
|
||||
@@ -107,7 +107,7 @@ METHOD(hasher_t, reset, bool,
|
||||
}
|
||||
|
||||
METHOD(hasher_t, get_hash, bool,
|
||||
private_af_alg_hasher_t *this, chunk_t chunk, u_int8_t *hash)
|
||||
private_af_alg_hasher_t *this, chunk_t chunk, uint8_t *hash)
|
||||
{
|
||||
return this->ops->hash(this->ops, chunk, hash, this->size);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ METHOD(af_alg_ops_t, hash, bool,
|
||||
}
|
||||
|
||||
METHOD(af_alg_ops_t, crypt, bool,
|
||||
private_af_alg_ops_t *this, u_int32_t type, chunk_t iv, chunk_t data,
|
||||
private_af_alg_ops_t *this, uint32_t type, chunk_t iv, chunk_t data,
|
||||
char *out)
|
||||
{
|
||||
struct msghdr msg = {};
|
||||
|
||||
@@ -64,7 +64,7 @@ struct af_alg_ops_t {
|
||||
* @param out buffer write processed data to
|
||||
* @return TRUE if successful
|
||||
*/
|
||||
bool (*crypt)(af_alg_ops_t *this, u_int32_t type, chunk_t iv, chunk_t data,
|
||||
bool (*crypt)(af_alg_ops_t *this, uint32_t type, chunk_t iv, chunk_t data,
|
||||
char *out);
|
||||
|
||||
/**
|
||||
|
||||
@@ -106,7 +106,7 @@ static size_t lookup_alg(pseudo_random_function_t algo, char **name, bool *xcbc)
|
||||
}
|
||||
|
||||
METHOD(prf_t, get_bytes, bool,
|
||||
private_af_alg_prf_t *this, chunk_t seed, u_int8_t *buffer)
|
||||
private_af_alg_prf_t *this, chunk_t seed, uint8_t *buffer)
|
||||
{
|
||||
return this->ops->hash(this->ops, seed, buffer, this->block_size);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ static size_t lookup_alg(integrity_algorithm_t algo, char **name,
|
||||
}
|
||||
|
||||
METHOD(signer_t, get_signature, bool,
|
||||
private_af_alg_signer_t *this, chunk_t data, u_int8_t *buffer)
|
||||
private_af_alg_signer_t *this, chunk_t data, uint8_t *buffer)
|
||||
{
|
||||
return this->ops->hash(this->ops, data, buffer, this->block_size);
|
||||
}
|
||||
|
||||
@@ -98,18 +98,18 @@ static u_char read_byte(chunk_t *blob)
|
||||
}
|
||||
|
||||
/**
|
||||
* read a u_int32_t from a blob
|
||||
* read a uint32_t from a blob
|
||||
*/
|
||||
static u_int32_t read_uint32(chunk_t *blob)
|
||||
static uint32_t read_uint32(chunk_t *blob)
|
||||
{
|
||||
u_int32_t val;
|
||||
uint32_t val;
|
||||
|
||||
if (blob->len < sizeof(u_int32_t))
|
||||
if (blob->len < sizeof(uint32_t))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
val = ntohl(*(u_int32_t*)blob->ptr);
|
||||
*blob = chunk_skip(*blob, sizeof(u_int32_t));
|
||||
val = ntohl(*(uint32_t*)blob->ptr);
|
||||
*blob = chunk_skip(*blob, sizeof(uint32_t));
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ static bool read_key(private_agent_private_key_t *this, public_key_t *pubkey)
|
||||
blob = chunk_create(buf, sizeof(buf));
|
||||
blob.len = read(this->socket, blob.ptr, blob.len);
|
||||
|
||||
if (blob.len < sizeof(u_int32_t) + sizeof(u_char) ||
|
||||
if (blob.len < sizeof(uint32_t) + sizeof(u_char) ||
|
||||
read_uint32(&blob) != blob.len ||
|
||||
read_byte(&blob) != SSH_AGENT_ID_RESPONSE)
|
||||
{
|
||||
@@ -236,7 +236,7 @@ METHOD(private_key_t, sign, bool,
|
||||
private_agent_private_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t *signature)
|
||||
{
|
||||
u_int32_t len, flags;
|
||||
uint32_t len, flags;
|
||||
char buf[2048];
|
||||
chunk_t blob;
|
||||
|
||||
@@ -247,7 +247,7 @@ METHOD(private_key_t, sign, bool,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
len = htonl(1 + sizeof(u_int32_t) * 3 + this->key.len + data.len);
|
||||
len = htonl(1 + sizeof(uint32_t) * 3 + this->key.len + data.len);
|
||||
buf[0] = SSH_AGENT_SIGN_REQUEST;
|
||||
if (write(this->socket, &len, sizeof(len)) != sizeof(len) ||
|
||||
write(this->socket, &buf, 1) != 1)
|
||||
@@ -281,7 +281,7 @@ METHOD(private_key_t, sign, bool,
|
||||
|
||||
blob = chunk_create(buf, sizeof(buf));
|
||||
blob.len = read(this->socket, blob.ptr, blob.len);
|
||||
if (blob.len < sizeof(u_int32_t) + sizeof(u_char) ||
|
||||
if (blob.len < sizeof(uint32_t) + sizeof(u_char) ||
|
||||
read_uint32(&blob) != blob.len ||
|
||||
read_byte(&blob) != SSH_AGENT_SIGN_RESPONSE)
|
||||
{
|
||||
|
||||
@@ -98,7 +98,7 @@ extern "C" {
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#define BF_LONG u_int32_t
|
||||
#define BF_LONG uint32_t
|
||||
#endif
|
||||
|
||||
#define BF_ROUNDS 16
|
||||
|
||||
@@ -84,14 +84,14 @@ struct private_blowfish_crypter_t {
|
||||
/**
|
||||
* Key size of this Blowfish cipher object.
|
||||
*/
|
||||
u_int32_t key_size;
|
||||
uint32_t key_size;
|
||||
};
|
||||
|
||||
METHOD(crypter_t, decrypt, bool,
|
||||
private_blowfish_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
chunk_t *decrypted)
|
||||
{
|
||||
u_int8_t *in, *out;
|
||||
uint8_t *in, *out;
|
||||
|
||||
if (decrypted)
|
||||
{
|
||||
@@ -116,7 +116,7 @@ METHOD(crypter_t, encrypt, bool,
|
||||
private_blowfish_crypter_t *this, chunk_t data, chunk_t iv,
|
||||
chunk_t *encrypted)
|
||||
{
|
||||
u_int8_t *in, *out;
|
||||
uint8_t *in, *out;
|
||||
|
||||
if (encrypted)
|
||||
{
|
||||
|
||||
@@ -60,7 +60,7 @@ struct private_ccm_aead_t {
|
||||
* First block with control information
|
||||
*/
|
||||
typedef struct __attribute__((packed)) {
|
||||
BITFIELD4(u_int8_t,
|
||||
BITFIELD4(uint8_t,
|
||||
/* size of p length field q, as q-1 */
|
||||
q_len: 3,
|
||||
/* size of our ICV t, as (t-2)/2 */
|
||||
@@ -82,7 +82,7 @@ typedef struct __attribute__((packed)) {
|
||||
* Counter block
|
||||
*/
|
||||
typedef struct __attribute__((packed)) {
|
||||
BITFIELD3(u_int8_t,
|
||||
BITFIELD3(uint8_t,
|
||||
/* size of p length field q, as q-1 */
|
||||
q_len: 3,
|
||||
zero: 3,
|
||||
@@ -117,7 +117,7 @@ static void build_b0(private_ccm_aead_t *this, chunk_t plain, chunk_t assoc,
|
||||
/**
|
||||
* Build a counter block for counter i
|
||||
*/
|
||||
static void build_ctr(private_ccm_aead_t *this, u_int32_t i, chunk_t iv,
|
||||
static void build_ctr(private_ccm_aead_t *this, uint32_t i, chunk_t iv,
|
||||
char *out)
|
||||
{
|
||||
ctr_t *ctr = (ctr_t*)out;
|
||||
|
||||
@@ -84,8 +84,8 @@ static bool poly_head(private_chapoly_aead_t *this, u_char *assoc, size_t len)
|
||||
static bool poly_tail(private_chapoly_aead_t *this, size_t alen, size_t clen)
|
||||
{
|
||||
struct {
|
||||
u_int64_t alen;
|
||||
u_int64_t clen;
|
||||
uint64_t alen;
|
||||
uint64_t clen;
|
||||
} b;
|
||||
|
||||
b.alen = htole64(alen);
|
||||
@@ -190,7 +190,7 @@ METHOD(aead_t, encrypt, bool,
|
||||
{
|
||||
u_char *out;
|
||||
|
||||
if (sizeof(plain.len) > sizeof(u_int32_t) && plain.len > P_MAX)
|
||||
if (sizeof(plain.len) > sizeof(uint32_t) && plain.len > P_MAX)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -220,7 +220,7 @@ METHOD(aead_t, decrypt, bool,
|
||||
return FALSE;
|
||||
}
|
||||
encr.len -= POLY_ICV_SIZE;
|
||||
if (sizeof(encr.len) > sizeof(u_int32_t) && encr.len > P_MAX)
|
||||
if (sizeof(encr.len) > sizeof(uint32_t) && encr.len > P_MAX)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -39,30 +39,30 @@ struct private_chapoly_drv_portable_t {
|
||||
/**
|
||||
* ChaCha20 state matrix
|
||||
*/
|
||||
u_int32_t m[16];
|
||||
uint32_t m[16];
|
||||
|
||||
/**
|
||||
* Poly1305 update key
|
||||
*/
|
||||
u_int32_t r[5];
|
||||
uint32_t r[5];
|
||||
|
||||
/**
|
||||
* Poly1305 state
|
||||
*/
|
||||
u_int32_t h[5];
|
||||
uint32_t h[5];
|
||||
|
||||
/**
|
||||
* Poly1305 finalize key
|
||||
*/
|
||||
u_int32_t s[4];
|
||||
uint32_t s[4];
|
||||
};
|
||||
|
||||
/**
|
||||
* XOR a 32-bit integer into an unaligned destination
|
||||
*/
|
||||
static inline void xor32u(void *p, u_int32_t x)
|
||||
static inline void xor32u(void *p, uint32_t x)
|
||||
{
|
||||
u_int32_t y;
|
||||
uint32_t y;
|
||||
|
||||
memcpy(&y, p, sizeof(y));
|
||||
y ^= x;
|
||||
@@ -72,7 +72,7 @@ static inline void xor32u(void *p, u_int32_t x)
|
||||
/**
|
||||
* Multiply two 64-bit words
|
||||
*/
|
||||
static inline u_int64_t mlt(u_int64_t a, u_int64_t b)
|
||||
static inline uint64_t mlt(uint64_t a, uint64_t b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ static inline u_int64_t mlt(u_int64_t a, u_int64_t b)
|
||||
/**
|
||||
* Shift a 64-bit unsigned integer v right by n bits, clamp to 32 bit
|
||||
*/
|
||||
static inline u_int32_t sr(u_int64_t v, u_char n)
|
||||
static inline uint32_t sr(uint64_t v, u_char n)
|
||||
{
|
||||
return v >> n;
|
||||
}
|
||||
@@ -88,13 +88,13 @@ static inline u_int32_t sr(u_int64_t v, u_char n)
|
||||
/**
|
||||
* Circular left shift by n bits
|
||||
*/
|
||||
static inline u_int32_t rotl32(u_int32_t v, u_char n)
|
||||
static inline uint32_t rotl32(uint32_t v, u_char n)
|
||||
{
|
||||
return (v << n) | (v >> (sizeof(v) * 8 - n));
|
||||
}
|
||||
|
||||
/**
|
||||
* AND two values, using a native integer size >= sizeof(u_int32_t)
|
||||
* AND two values, using a native integer size >= sizeof(uint32_t)
|
||||
*/
|
||||
static inline u_long and(u_long v, u_long mask)
|
||||
{
|
||||
@@ -106,8 +106,8 @@ static inline u_long and(u_long v, u_long mask)
|
||||
*/
|
||||
static void chacha_block_xor(private_chapoly_drv_portable_t *this, void *data)
|
||||
{
|
||||
u_int32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, xa, xb, xc, xd, xe, xf;
|
||||
u_int32_t *out = data;
|
||||
uint32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, xa, xb, xc, xd, xe, xf;
|
||||
uint32_t *out = data;
|
||||
u_int i;
|
||||
|
||||
x0 = this->m[ 0];
|
||||
@@ -246,10 +246,10 @@ METHOD(chapoly_drv_t, init, bool,
|
||||
METHOD(chapoly_drv_t, poly, bool,
|
||||
private_chapoly_drv_portable_t *this, u_char *data, u_int blocks)
|
||||
{
|
||||
u_int32_t r0, r1, r2, r3, r4;
|
||||
u_int32_t s1, s2, s3, s4;
|
||||
u_int32_t h0, h1, h2, h3, h4;
|
||||
u_int64_t d0, d1, d2, d3, d4;
|
||||
uint32_t r0, r1, r2, r3, r4;
|
||||
uint32_t s1, s2, s3, s4;
|
||||
uint32_t h0, h1, h2, h3, h4;
|
||||
uint64_t d0, d1, d2, d3, d4;
|
||||
u_int i;
|
||||
|
||||
r0 = this->r[0];
|
||||
@@ -345,10 +345,10 @@ METHOD(chapoly_drv_t, decrypt, bool,
|
||||
METHOD(chapoly_drv_t, finish, bool,
|
||||
private_chapoly_drv_portable_t *this, u_char *mac)
|
||||
{
|
||||
u_int32_t h0, h1, h2, h3, h4;
|
||||
u_int32_t g0, g1, g2, g3, g4;
|
||||
u_int32_t mask;
|
||||
u_int64_t f = 0;
|
||||
uint32_t h0, h1, h2, h3, h4;
|
||||
uint32_t g0, g1, g2, g3, g4;
|
||||
uint32_t mask;
|
||||
uint64_t f = 0;
|
||||
|
||||
/* fully carry h */
|
||||
h0 = this->h[0];
|
||||
@@ -371,7 +371,7 @@ METHOD(chapoly_drv_t, finish, bool,
|
||||
g4 = h4 + (g3 >> 26) - (1 << 26); g3 &= 0x3ffffff;
|
||||
|
||||
/* select h if h < p, or h + -p if h >= p */
|
||||
mask = (g4 >> ((sizeof(u_int32_t) * 8) - 1)) - 1;
|
||||
mask = (g4 >> ((sizeof(uint32_t) * 8) - 1)) - 1;
|
||||
g0 &= mask;
|
||||
g1 &= mask;
|
||||
g2 &= mask;
|
||||
|
||||
@@ -45,30 +45,30 @@ struct private_chapoly_drv_ssse3_t {
|
||||
/**
|
||||
* Poly1305 update key
|
||||
*/
|
||||
u_int32_t r[5];
|
||||
uint32_t r[5];
|
||||
|
||||
/**
|
||||
* Poly1305 update key r^2
|
||||
*/
|
||||
u_int32_t u[5];
|
||||
uint32_t u[5];
|
||||
|
||||
/**
|
||||
* Poly1305 state
|
||||
*/
|
||||
u_int32_t h[5];
|
||||
uint32_t h[5];
|
||||
|
||||
/**
|
||||
* Poly1305 finalize key
|
||||
*/
|
||||
u_int32_t s[4];
|
||||
uint32_t s[4];
|
||||
};
|
||||
|
||||
/**
|
||||
* Read a 32-bit integer from an unaligned address
|
||||
*/
|
||||
static inline u_int32_t ru32(void *p)
|
||||
static inline uint32_t ru32(void *p)
|
||||
{
|
||||
u_int32_t ret;
|
||||
uint32_t ret;
|
||||
|
||||
memcpy(&ret, p, sizeof(ret));
|
||||
return ret;
|
||||
@@ -77,7 +77,7 @@ static inline u_int32_t ru32(void *p)
|
||||
/**
|
||||
* Write a 32-bit word to an unaligned address
|
||||
*/
|
||||
static inline void wu32(void *p, u_int32_t v)
|
||||
static inline void wu32(void *p, uint32_t v)
|
||||
{
|
||||
memcpy(p, &v, sizeof(v));
|
||||
}
|
||||
@@ -85,13 +85,13 @@ static inline void wu32(void *p, u_int32_t v)
|
||||
/**
|
||||
* Shift a 64-bit unsigned integer v right by n bits, clamp to 32 bit
|
||||
*/
|
||||
static inline u_int32_t sr(u_int64_t v, u_char n)
|
||||
static inline uint32_t sr(uint64_t v, u_char n)
|
||||
{
|
||||
return v >> n;
|
||||
}
|
||||
|
||||
/**
|
||||
* AND two values, using a native integer size >= sizeof(u_int32_t)
|
||||
* AND two values, using a native integer size >= sizeof(uint32_t)
|
||||
*/
|
||||
static inline u_long and(u_long v, u_long mask)
|
||||
{
|
||||
@@ -189,7 +189,7 @@ static void chacha_4block_xor(private_chapoly_drv_ssse3_t *this, void *data)
|
||||
{
|
||||
__m128i x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, xa, xb, xc, xd, xe, xf;
|
||||
__m128i r8, r16, ctrinc, t, *out = data;
|
||||
u_int32_t *m = (u_int32_t*)this->m;
|
||||
uint32_t *m = (uint32_t*)this->m;
|
||||
u_int i;
|
||||
|
||||
r8 = _mm_set_epi8(14, 13, 12, 15, 10, 9, 8, 11, 6, 5, 4, 7, 2, 1, 0, 3);
|
||||
@@ -364,7 +364,7 @@ METHOD(chapoly_drv_t, set_key, bool,
|
||||
/**
|
||||
* r[127:64] = h[95:64] * a, r[63:0] = h[31:0] * b
|
||||
*/
|
||||
static inline __m128i mul2(__m128i h, u_int32_t a, u_int32_t b)
|
||||
static inline __m128i mul2(__m128i h, uint32_t a, uint32_t b)
|
||||
{
|
||||
return _mm_mul_epu32(h, _mm_set_epi32(0, a, 0, b));
|
||||
}
|
||||
@@ -374,7 +374,7 @@ static inline __m128i mul2(__m128i h, u_int32_t a, u_int32_t b)
|
||||
* z = x[127:64] + x[63:0] + y[127:64] + y[63:0]
|
||||
*/
|
||||
static inline void sum2(__m128i a, __m128i b, __m128i x, __m128i y,
|
||||
u_int64_t *c, u_int64_t *z)
|
||||
uint64_t *c, uint64_t *z)
|
||||
{
|
||||
__m128i r, s;
|
||||
|
||||
@@ -392,10 +392,10 @@ static inline void sum2(__m128i a, __m128i b, __m128i x, __m128i y,
|
||||
* r = a[127:64] + b[127:64] + c[127:64] + d[127:64] + e[127:64]
|
||||
* + a[63:0] + b[63:0] + c[63:0] + d[63:0] + e[63:0]
|
||||
*/
|
||||
static inline u_int64_t sum5(__m128i a, __m128i b, __m128i c,
|
||||
static inline uint64_t sum5(__m128i a, __m128i b, __m128i c,
|
||||
__m128i d, __m128i e)
|
||||
{
|
||||
u_int64_t r;
|
||||
uint64_t r;
|
||||
|
||||
a = _mm_add_epi64(a, b);
|
||||
c = _mm_add_epi64(c, d);
|
||||
@@ -414,10 +414,10 @@ static inline u_int64_t sum5(__m128i a, __m128i b, __m128i c,
|
||||
static void make_u(private_chapoly_drv_ssse3_t *this)
|
||||
{
|
||||
__m128i r01, r23, r44, x0, x1, y0, y1, z0;
|
||||
u_int32_t r0, r1, r2, r3, r4;
|
||||
u_int32_t u0, u1, u2, u3, u4;
|
||||
u_int32_t s1, s2, s3, s4;
|
||||
u_int64_t d0, d1, d2, d3, d4;
|
||||
uint32_t r0, r1, r2, r3, r4;
|
||||
uint32_t u0, u1, u2, u3, u4;
|
||||
uint32_t s1, s2, s3, s4;
|
||||
uint64_t d0, d1, d2, d3, d4;
|
||||
|
||||
r0 = this->r[0];
|
||||
r1 = this->r[1];
|
||||
@@ -513,12 +513,12 @@ METHOD(chapoly_drv_t, init, bool,
|
||||
*/
|
||||
static void poly2(private_chapoly_drv_ssse3_t *this, u_char *data, u_int dblks)
|
||||
{
|
||||
u_int32_t r0, r1, r2, r3, r4, u0, u1, u2, u3, u4;
|
||||
u_int32_t s1, s2, s3, s4, v1, v2, v3, v4;
|
||||
uint32_t r0, r1, r2, r3, r4, u0, u1, u2, u3, u4;
|
||||
uint32_t s1, s2, s3, s4, v1, v2, v3, v4;
|
||||
__m128i hc0, hc1, hc2, hc3, hc4;
|
||||
u_int32_t h0, h1, h2, h3, h4;
|
||||
u_int32_t c0, c1, c2, c3, c4;
|
||||
u_int64_t d0, d1, d2, d3, d4;
|
||||
uint32_t h0, h1, h2, h3, h4;
|
||||
uint32_t c0, c1, c2, c3, c4;
|
||||
uint64_t d0, d1, d2, d3, d4;
|
||||
u_int i;
|
||||
|
||||
r0 = this->r[0];
|
||||
@@ -622,13 +622,13 @@ static void poly2(private_chapoly_drv_ssse3_t *this, u_char *data, u_int dblks)
|
||||
*/
|
||||
static void poly1(private_chapoly_drv_ssse3_t *this, u_char *data)
|
||||
{
|
||||
u_int32_t r0, r1, r2, r3, r4;
|
||||
u_int32_t s1, s2, s3, s4;
|
||||
u_int32_t h0, h1, h2, h3, h4;
|
||||
u_int64_t d0, d1, d2, d3, d4;
|
||||
uint32_t r0, r1, r2, r3, r4;
|
||||
uint32_t s1, s2, s3, s4;
|
||||
uint32_t h0, h1, h2, h3, h4;
|
||||
uint64_t d0, d1, d2, d3, d4;
|
||||
__m128i h01, h23, h44;
|
||||
__m128i x0, x1, y0, y1, z0;
|
||||
u_int32_t t0, t1;
|
||||
uint32_t t0, t1;
|
||||
|
||||
r0 = this->r[0];
|
||||
r1 = this->r[1];
|
||||
@@ -764,10 +764,10 @@ METHOD(chapoly_drv_t, decrypt, bool,
|
||||
METHOD(chapoly_drv_t, finish, bool,
|
||||
private_chapoly_drv_ssse3_t *this, u_char *mac)
|
||||
{
|
||||
u_int32_t h0, h1, h2, h3, h4;
|
||||
u_int32_t g0, g1, g2, g3, g4;
|
||||
u_int32_t mask;
|
||||
u_int64_t f = 0;
|
||||
uint32_t h0, h1, h2, h3, h4;
|
||||
uint32_t g0, g1, g2, g3, g4;
|
||||
uint32_t mask;
|
||||
uint64_t f = 0;
|
||||
|
||||
/* fully carry h */
|
||||
h0 = this->h[0];
|
||||
@@ -790,7 +790,7 @@ METHOD(chapoly_drv_t, finish, bool,
|
||||
g4 = h4 + (g3 >> 26) - (1 << 26); g3 &= 0x3ffffff;
|
||||
|
||||
/* select h if h < p, or h + -p if h >= p */
|
||||
mask = (g4 >> ((sizeof(u_int32_t) * 8) - 1)) - 1;
|
||||
mask = (g4 >> ((sizeof(uint32_t) * 8) - 1)) - 1;
|
||||
g0 &= mask;
|
||||
g1 &= mask;
|
||||
g2 &= mask;
|
||||
|
||||
@@ -39,7 +39,7 @@ struct private_mac_t {
|
||||
/**
|
||||
* Block size, in bytes
|
||||
*/
|
||||
u_int8_t b;
|
||||
uint8_t b;
|
||||
|
||||
/**
|
||||
* Crypter with key K
|
||||
@@ -49,22 +49,22 @@ struct private_mac_t {
|
||||
/**
|
||||
* K1
|
||||
*/
|
||||
u_int8_t *k1;
|
||||
uint8_t *k1;
|
||||
|
||||
/**
|
||||
* K2
|
||||
*/
|
||||
u_int8_t *k2;
|
||||
uint8_t *k2;
|
||||
|
||||
/**
|
||||
* T
|
||||
*/
|
||||
u_int8_t *t;
|
||||
uint8_t *t;
|
||||
|
||||
/**
|
||||
* remaining, unprocessed bytes in append mode
|
||||
*/
|
||||
u_int8_t *remaining;
|
||||
uint8_t *remaining;
|
||||
|
||||
/**
|
||||
* number of bytes in remaining
|
||||
@@ -127,7 +127,7 @@ static bool update(private_mac_t *this, chunk_t data)
|
||||
/**
|
||||
* process last block M_last
|
||||
*/
|
||||
static bool final(private_mac_t *this, u_int8_t *out)
|
||||
static bool final(private_mac_t *this, uint8_t *out)
|
||||
{
|
||||
chunk_t iv;
|
||||
|
||||
@@ -179,7 +179,7 @@ static bool final(private_mac_t *this, u_int8_t *out)
|
||||
}
|
||||
|
||||
METHOD(mac_t, get_mac, bool,
|
||||
private_mac_t *this, chunk_t data, u_int8_t *out)
|
||||
private_mac_t *this, chunk_t data, uint8_t *out)
|
||||
{
|
||||
/* update T, do not process last block */
|
||||
if (!update(this, data))
|
||||
@@ -316,7 +316,7 @@ mac_t *cmac_create(encryption_algorithm_t algo, size_t key_size)
|
||||
{
|
||||
private_mac_t *this;
|
||||
crypter_t *crypter;
|
||||
u_int8_t b;
|
||||
uint8_t b;
|
||||
|
||||
crypter = lib->crypto->create_crypter(lib->crypto, algo, key_size);
|
||||
if (!crypter)
|
||||
|
||||
@@ -38,7 +38,7 @@ struct private_ctr_ipsec_crypter_t {
|
||||
struct {
|
||||
char nonce[4];
|
||||
char iv[8];
|
||||
u_int32_t counter;
|
||||
uint32_t counter;
|
||||
} __attribute__((packed)) state;
|
||||
};
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ struct private_des_crypter_t {
|
||||
#define DES_ENCRYPT 1
|
||||
#define DES_DECRYPT 0
|
||||
|
||||
#define DES_LONG u_int32_t
|
||||
#define DES_LONG uint32_t
|
||||
|
||||
#if defined(WIN32) || defined(WIN16)
|
||||
#ifndef MSDOS
|
||||
@@ -1420,7 +1420,7 @@ METHOD(crypter_t, decrypt, bool,
|
||||
private_des_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *decrypted)
|
||||
{
|
||||
des_cblock ivb;
|
||||
u_int8_t *out;
|
||||
uint8_t *out;
|
||||
|
||||
out = data.ptr;
|
||||
if (decrypted)
|
||||
@@ -1439,7 +1439,7 @@ METHOD(crypter_t, encrypt, bool,
|
||||
private_des_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *encrypted)
|
||||
{
|
||||
des_cblock ivb;
|
||||
u_int8_t *out;
|
||||
uint8_t *out;
|
||||
|
||||
out = data.ptr;
|
||||
if (encrypted)
|
||||
@@ -1456,7 +1456,7 @@ METHOD(crypter_t, encrypt, bool,
|
||||
METHOD(crypter_t, decrypt_ecb, bool,
|
||||
private_des_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *decrypted)
|
||||
{
|
||||
u_int8_t *out;
|
||||
uint8_t *out;
|
||||
|
||||
out = data.ptr;
|
||||
if (decrypted)
|
||||
@@ -1472,7 +1472,7 @@ METHOD(crypter_t, decrypt_ecb, bool,
|
||||
METHOD(crypter_t, encrypt_ecb, bool,
|
||||
private_des_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *encrypted)
|
||||
{
|
||||
u_int8_t *out;
|
||||
uint8_t *out;
|
||||
|
||||
out = data.ptr;
|
||||
if (encrypted)
|
||||
@@ -1489,7 +1489,7 @@ METHOD(crypter_t, decrypt3, bool,
|
||||
private_des_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *decrypted)
|
||||
{
|
||||
des_cblock ivb;
|
||||
u_int8_t *out;
|
||||
uint8_t *out;
|
||||
|
||||
out = data.ptr;
|
||||
if (decrypted)
|
||||
@@ -1508,7 +1508,7 @@ METHOD(crypter_t, encrypt3, bool,
|
||||
private_des_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *encrypted)
|
||||
{
|
||||
des_cblock ivb;
|
||||
u_int8_t *out;
|
||||
uint8_t *out;
|
||||
|
||||
out = data.ptr;
|
||||
if (encrypted)
|
||||
|
||||
@@ -26,10 +26,10 @@ typedef enum dnskey_algorithm_t dnskey_algorithm_t;
|
||||
* Header of a DNSKEY resource record
|
||||
*/
|
||||
struct dnskey_rr_t {
|
||||
u_int16_t flags;
|
||||
u_int8_t protocol;
|
||||
u_int8_t algorithm;
|
||||
u_int8_t data[];
|
||||
uint16_t flags;
|
||||
uint8_t protocol;
|
||||
uint8_t algorithm;
|
||||
uint8_t data[];
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ struct private_fips_prf_t {
|
||||
/**
|
||||
* key of prf function, "b" long
|
||||
*/
|
||||
u_int8_t *key;
|
||||
uint8_t *key;
|
||||
|
||||
/**
|
||||
* size of "b" in bytes
|
||||
@@ -46,19 +46,19 @@ struct private_fips_prf_t {
|
||||
/**
|
||||
* G function, either SHA1 or DES
|
||||
*/
|
||||
bool (*g)(private_fips_prf_t *this, chunk_t c, u_int8_t res[]);
|
||||
bool (*g)(private_fips_prf_t *this, chunk_t c, uint8_t res[]);
|
||||
};
|
||||
|
||||
/**
|
||||
* sum = (a + b) mod 2 ^ (length * 8)
|
||||
*/
|
||||
static void add_mod(size_t length, u_int8_t a[], u_int8_t b[], u_int8_t sum[])
|
||||
static void add_mod(size_t length, uint8_t a[], uint8_t b[], uint8_t sum[])
|
||||
{
|
||||
int i, c = 0;
|
||||
|
||||
for(i = length - 1; i >= 0; i--)
|
||||
{
|
||||
u_int32_t tmp;
|
||||
uint32_t tmp;
|
||||
|
||||
tmp = a[i] + b[i] + c;
|
||||
sum[i] = 0xff & tmp;
|
||||
@@ -69,7 +69,7 @@ static void add_mod(size_t length, u_int8_t a[], u_int8_t b[], u_int8_t sum[])
|
||||
/**
|
||||
* calculate "chunk mod 2^(length*8)" and save it into buffer
|
||||
*/
|
||||
static void chunk_mod(size_t length, chunk_t chunk, u_int8_t buffer[])
|
||||
static void chunk_mod(size_t length, chunk_t chunk, uint8_t buffer[])
|
||||
{
|
||||
if (chunk.len < length)
|
||||
{
|
||||
@@ -105,14 +105,14 @@ static void chunk_mod(size_t length, chunk_t chunk, u_int8_t buffer[])
|
||||
* 0x8e, 0x20, 0xd7, 0x37, 0xa3, 0x27, 0x51, 0x16
|
||||
*/
|
||||
METHOD(prf_t, get_bytes, bool,
|
||||
private_fips_prf_t *this, chunk_t seed, u_int8_t w[])
|
||||
private_fips_prf_t *this, chunk_t seed, uint8_t w[])
|
||||
{
|
||||
int i;
|
||||
u_int8_t xval[this->b];
|
||||
u_int8_t xseed[this->b];
|
||||
u_int8_t sum[this->b];
|
||||
u_int8_t *xkey = this->key;
|
||||
u_int8_t one[this->b];
|
||||
uint8_t xval[this->b];
|
||||
uint8_t xseed[this->b];
|
||||
uint8_t sum[this->b];
|
||||
uint8_t *xkey = this->key;
|
||||
uint8_t one[this->b];
|
||||
|
||||
if (!w)
|
||||
{
|
||||
@@ -175,9 +175,9 @@ METHOD(prf_t, set_key, bool,
|
||||
/**
|
||||
* Implementation of the G() function based on SHA1
|
||||
*/
|
||||
static bool g_sha1(private_fips_prf_t *this, chunk_t c, u_int8_t res[])
|
||||
static bool g_sha1(private_fips_prf_t *this, chunk_t c, uint8_t res[])
|
||||
{
|
||||
u_int8_t buf[64];
|
||||
uint8_t buf[64];
|
||||
|
||||
if (c.len < sizeof(buf))
|
||||
{
|
||||
|
||||
@@ -67,11 +67,11 @@ struct private_gcm_aead_t {
|
||||
#if ULONG_MAX == 18446744073709551615UL && defined(htobe64)
|
||||
# define htobeword htobe64
|
||||
# define bewordtoh be64toh
|
||||
# define SHIFT_WORD_TYPE u_int64_t
|
||||
# define SHIFT_WORD_TYPE uint64_t
|
||||
#else
|
||||
# define htobeword htonl
|
||||
# define bewordtoh ntohl
|
||||
# define SHIFT_WORD_TYPE u_int32_t
|
||||
# define SHIFT_WORD_TYPE uint32_t
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,7 +52,7 @@ struct private_gcrypt_crypter_t {
|
||||
struct {
|
||||
char nonce[4];
|
||||
char iv[8];
|
||||
u_int32_t counter;
|
||||
uint32_t counter;
|
||||
} __attribute__((packed)) ctr;
|
||||
};
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ METHOD(hasher_t, reset, bool,
|
||||
}
|
||||
|
||||
METHOD(hasher_t, get_hash, bool,
|
||||
private_gcrypt_hasher_t *this, chunk_t chunk, u_int8_t *hash)
|
||||
private_gcrypt_hasher_t *this, chunk_t chunk, uint8_t *hash)
|
||||
{
|
||||
gcry_md_write(this->hd, chunk.ptr, chunk.len);
|
||||
if (hash)
|
||||
|
||||
@@ -36,7 +36,7 @@ struct private_gcrypt_rng_t {
|
||||
};
|
||||
|
||||
METHOD(rng_t, get_bytes, bool,
|
||||
private_gcrypt_rng_t *this, size_t bytes, u_int8_t *buffer)
|
||||
private_gcrypt_rng_t *this, size_t bytes, uint8_t *buffer)
|
||||
{
|
||||
switch (this->quality)
|
||||
{
|
||||
|
||||
@@ -142,7 +142,7 @@ chunk_t gmp_mpz_to_chunk(const mpz_t value)
|
||||
static void mpz_clear_sensitive(mpz_t z)
|
||||
{
|
||||
size_t len = mpz_size(z) * GMP_LIMB_BITS / BITS_PER_BYTE;
|
||||
u_int8_t *zeros = alloca(len);
|
||||
uint8_t *zeros = alloca(len);
|
||||
|
||||
memset(zeros, 0, len);
|
||||
/* overwrite mpz_t with zero bytes before clearing it */
|
||||
|
||||
@@ -38,7 +38,7 @@ struct private_mac_t {
|
||||
/**
|
||||
* Block size, as in RFC.
|
||||
*/
|
||||
u_int8_t b;
|
||||
uint8_t b;
|
||||
|
||||
/**
|
||||
* Hash function.
|
||||
@@ -57,7 +57,7 @@ struct private_mac_t {
|
||||
};
|
||||
|
||||
METHOD(mac_t, get_mac, bool,
|
||||
private_mac_t *this, chunk_t data, u_int8_t *out)
|
||||
private_mac_t *this, chunk_t data, uint8_t *out)
|
||||
{
|
||||
/* H(K XOR opad, H(K XOR ipad, text))
|
||||
*
|
||||
@@ -66,7 +66,7 @@ METHOD(mac_t, get_mac, bool,
|
||||
*
|
||||
*/
|
||||
|
||||
u_int8_t buffer[this->h->get_hash_size(this->h)];
|
||||
uint8_t buffer[this->h->get_hash_size(this->h)];
|
||||
chunk_t inner;
|
||||
|
||||
if (out == NULL)
|
||||
@@ -96,7 +96,7 @@ METHOD(mac_t, set_key, bool,
|
||||
private_mac_t *this, chunk_t key)
|
||||
{
|
||||
int i;
|
||||
u_int8_t buffer[this->b];
|
||||
uint8_t buffer[this->b];
|
||||
|
||||
memset(buffer, 0, this->b);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#define S33 11
|
||||
#define S34 15
|
||||
|
||||
static u_int8_t PADDING[64] = {
|
||||
static uint8_t PADDING[64] = {
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
@@ -65,11 +65,11 @@ static u_int8_t PADDING[64] = {
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
}
|
||||
#define GG(a, b, c, d, x, s) { \
|
||||
(a) += G ((b), (c), (d)) + (x) + (u_int32_t)0x5a827999; \
|
||||
(a) += G ((b), (c), (d)) + (x) + (uint32_t)0x5a827999; \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
}
|
||||
#define HH(a, b, c, d, x, s) { \
|
||||
(a) += H ((b), (c), (d)) + (x) + (u_int32_t)0x6ed9eba1; \
|
||||
(a) += H ((b), (c), (d)) + (x) + (uint32_t)0x6ed9eba1; \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
}
|
||||
|
||||
@@ -87,40 +87,40 @@ struct private_md4_hasher_t {
|
||||
/*
|
||||
* State of the hasher.
|
||||
*/
|
||||
u_int32_t state[4];
|
||||
u_int32_t count[2];
|
||||
u_int8_t buffer[64];
|
||||
uint32_t state[4];
|
||||
uint32_t count[2];
|
||||
uint8_t buffer[64];
|
||||
};
|
||||
|
||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
||||
|
||||
/* Encodes input (u_int32_t) into output (u_int8_t). Assumes len is
|
||||
/* Encodes input (uint32_t) into output (uint8_t). Assumes len is
|
||||
* a multiple of 4.
|
||||
*/
|
||||
static void Encode (u_int8_t *output, u_int32_t *input, size_t len)
|
||||
static void Encode (uint8_t *output, uint32_t *input, size_t len)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||
{
|
||||
output[j] = (u_int8_t)(input[i] & 0xff);
|
||||
output[j+1] = (u_int8_t)((input[i] >> 8) & 0xff);
|
||||
output[j+2] = (u_int8_t)((input[i] >> 16) & 0xff);
|
||||
output[j+3] = (u_int8_t)((input[i] >> 24) & 0xff);
|
||||
output[j] = (uint8_t)(input[i] & 0xff);
|
||||
output[j+1] = (uint8_t)((input[i] >> 8) & 0xff);
|
||||
output[j+2] = (uint8_t)((input[i] >> 16) & 0xff);
|
||||
output[j+3] = (uint8_t)((input[i] >> 24) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
/* Decodes input (u_int8_t) into output (u_int32_t). Assumes len is
|
||||
/* Decodes input (uint8_t) into output (uint32_t). Assumes len is
|
||||
* a multiple of 4.
|
||||
*/
|
||||
static void Decode(u_int32_t *output, u_int8_t *input, size_t len)
|
||||
static void Decode(uint32_t *output, uint8_t *input, size_t len)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||
{
|
||||
output[i] = ((u_int32_t)input[j]) | (((u_int32_t)input[j+1]) << 8) |
|
||||
(((u_int32_t)input[j+2]) << 16) | (((u_int32_t)input[j+3]) << 24);
|
||||
output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) |
|
||||
(((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,9 +132,9 @@ static void Decode(u_int32_t *output, u_int8_t *input, size_t len)
|
||||
/*
|
||||
* MD4 basic transformation. Transforms state based on block.
|
||||
*/
|
||||
static void MD4Transform(u_int32_t state[4], u_int8_t block[64])
|
||||
static void MD4Transform(uint32_t state[4], uint8_t block[64])
|
||||
{
|
||||
u_int32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
||||
uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
||||
|
||||
Decode(x, block, 64);
|
||||
|
||||
@@ -202,13 +202,13 @@ static void MD4Transform(u_int32_t state[4], u_int8_t block[64])
|
||||
* operation, processing another message block, and updating the
|
||||
* context.
|
||||
*/
|
||||
static void MD4Update(private_md4_hasher_t *this, u_int8_t *input, size_t inputLen)
|
||||
static void MD4Update(private_md4_hasher_t *this, uint8_t *input, size_t inputLen)
|
||||
{
|
||||
u_int32_t i;
|
||||
uint32_t i;
|
||||
size_t index, partLen;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
index = (u_int8_t)((this->count[0] >> 3) & 0x3F);
|
||||
index = (uint8_t)((this->count[0] >> 3) & 0x3F);
|
||||
|
||||
/* Update number of bits */
|
||||
if ((this->count[0] += (inputLen << 3)) < (inputLen << 3))
|
||||
@@ -243,9 +243,9 @@ static void MD4Update(private_md4_hasher_t *this, u_int8_t *input, size_t inputL
|
||||
/* MD4 finalization. Ends an MD4 message-digest operation, writing the
|
||||
* the message digest and zeroizing the context.
|
||||
*/
|
||||
static void MD4Final (private_md4_hasher_t *this, u_int8_t digest[16])
|
||||
static void MD4Final (private_md4_hasher_t *this, uint8_t digest[16])
|
||||
{
|
||||
u_int8_t bits[8];
|
||||
uint8_t bits[8];
|
||||
size_t index, padLen;
|
||||
|
||||
/* Save number of bits */
|
||||
@@ -280,7 +280,7 @@ METHOD(hasher_t, reset, bool,
|
||||
}
|
||||
|
||||
METHOD(hasher_t, get_hash, bool,
|
||||
private_md4_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
|
||||
private_md4_hasher_t *this, chunk_t chunk, uint8_t *buffer)
|
||||
{
|
||||
MD4Update(this, chunk.ptr, chunk.len);
|
||||
if (buffer != NULL)
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#define S43 15
|
||||
#define S44 21
|
||||
|
||||
static u_int8_t PADDING[64] = {
|
||||
static uint8_t PADDING[64] = {
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
@@ -66,22 +66,22 @@ static u_int8_t PADDING[64] = {
|
||||
Rotation is separate from addition to prevent recomputation.
|
||||
*/
|
||||
#define FF(a, b, c, d, x, s, ac) { \
|
||||
(a) += F ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
|
||||
(a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define GG(a, b, c, d, x, s, ac) { \
|
||||
(a) += G ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
|
||||
(a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define HH(a, b, c, d, x, s, ac) { \
|
||||
(a) += H ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
|
||||
(a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define II(a, b, c, d, x, s, ac) { \
|
||||
(a) += I ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
|
||||
(a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
@@ -102,41 +102,41 @@ struct private_md5_hasher_t {
|
||||
/*
|
||||
* State of the hasher.
|
||||
*/
|
||||
u_int32_t state[5];
|
||||
u_int32_t count[2];
|
||||
u_int8_t buffer[64];
|
||||
uint32_t state[5];
|
||||
uint32_t count[2];
|
||||
uint8_t buffer[64];
|
||||
};
|
||||
|
||||
|
||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
||||
|
||||
/* Encodes input (u_int32_t) into output (u_int8_t). Assumes len is
|
||||
/* Encodes input (uint32_t) into output (uint8_t). Assumes len is
|
||||
* a multiple of 4.
|
||||
*/
|
||||
static void Encode (u_int8_t *output, u_int32_t *input, size_t len)
|
||||
static void Encode (uint8_t *output, uint32_t *input, size_t len)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||
{
|
||||
output[j] = (u_int8_t)(input[i] & 0xff);
|
||||
output[j+1] = (u_int8_t)((input[i] >> 8) & 0xff);
|
||||
output[j+2] = (u_int8_t)((input[i] >> 16) & 0xff);
|
||||
output[j+3] = (u_int8_t)((input[i] >> 24) & 0xff);
|
||||
output[j] = (uint8_t)(input[i] & 0xff);
|
||||
output[j+1] = (uint8_t)((input[i] >> 8) & 0xff);
|
||||
output[j+2] = (uint8_t)((input[i] >> 16) & 0xff);
|
||||
output[j+3] = (uint8_t)((input[i] >> 24) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
/* Decodes input (u_int8_t) into output (u_int32_t). Assumes len is
|
||||
/* Decodes input (uint8_t) into output (uint32_t). Assumes len is
|
||||
* a multiple of 4.
|
||||
*/
|
||||
static void Decode(u_int32_t *output, u_int8_t *input, size_t len)
|
||||
static void Decode(uint32_t *output, uint8_t *input, size_t len)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||
{
|
||||
output[i] = ((u_int32_t)input[j]) | (((u_int32_t)input[j+1]) << 8) |
|
||||
(((u_int32_t)input[j+2]) << 16) | (((u_int32_t)input[j+3]) << 24);
|
||||
output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) |
|
||||
(((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,9 +147,9 @@ static void Decode(u_int32_t *output, u_int8_t *input, size_t len)
|
||||
|
||||
/* MD5 basic transformation. Transforms state based on block.
|
||||
*/
|
||||
static void MD5Transform(u_int32_t state[4], u_int8_t block[64])
|
||||
static void MD5Transform(uint32_t state[4], uint8_t block[64])
|
||||
{
|
||||
u_int32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
||||
uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
||||
|
||||
Decode(x, block, 64);
|
||||
|
||||
@@ -235,13 +235,13 @@ static void MD5Transform(u_int32_t state[4], u_int8_t block[64])
|
||||
* operation, processing another message block, and updating the
|
||||
* context.
|
||||
*/
|
||||
static void MD5Update(private_md5_hasher_t *this, u_int8_t *input, size_t inputLen)
|
||||
static void MD5Update(private_md5_hasher_t *this, uint8_t *input, size_t inputLen)
|
||||
{
|
||||
u_int32_t i;
|
||||
uint32_t i;
|
||||
size_t index, partLen;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
index = (u_int8_t)((this->count[0] >> 3) & 0x3F);
|
||||
index = (uint8_t)((this->count[0] >> 3) & 0x3F);
|
||||
|
||||
/* Update number of bits */
|
||||
if ((this->count[0] += (inputLen << 3)) < (inputLen << 3))
|
||||
@@ -276,9 +276,9 @@ static void MD5Update(private_md5_hasher_t *this, u_int8_t *input, size_t inputL
|
||||
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
|
||||
* the message digest and zeroizing the context.
|
||||
*/
|
||||
static void MD5Final (private_md5_hasher_t *this, u_int8_t digest[16])
|
||||
static void MD5Final (private_md5_hasher_t *this, uint8_t digest[16])
|
||||
{
|
||||
u_int8_t bits[8];
|
||||
uint8_t bits[8];
|
||||
size_t index, padLen;
|
||||
|
||||
/* Save number of bits */
|
||||
@@ -313,7 +313,7 @@ METHOD(hasher_t, reset, bool,
|
||||
}
|
||||
|
||||
METHOD(hasher_t, get_hash, bool,
|
||||
private_md5_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
|
||||
private_md5_hasher_t *this, chunk_t chunk, uint8_t *buffer)
|
||||
{
|
||||
MD5Update(this, chunk.ptr, chunk.len);
|
||||
if (buffer != NULL)
|
||||
|
||||
@@ -36,7 +36,7 @@ struct private_nonce_nonceg_t {
|
||||
};
|
||||
|
||||
METHOD(nonce_gen_t, get_nonce, bool,
|
||||
private_nonce_nonceg_t *this, size_t size, u_int8_t *buffer)
|
||||
private_nonce_nonceg_t *this, size_t size, uint8_t *buffer)
|
||||
{
|
||||
return this->rng->get_bytes(this->rng, size, buffer);
|
||||
}
|
||||
|
||||
@@ -35,17 +35,17 @@ struct private_ntru_drbg_t {
|
||||
/**
|
||||
* Security strength in bits of the DRBG
|
||||
*/
|
||||
u_int32_t strength;
|
||||
uint32_t strength;
|
||||
|
||||
/**
|
||||
* Number of requests for pseudorandom bits
|
||||
*/
|
||||
u_int32_t reseed_counter;
|
||||
uint32_t reseed_counter;
|
||||
|
||||
/**
|
||||
* Maximum number of requests for pseudorandom bits
|
||||
*/
|
||||
u_int32_t max_requests;
|
||||
uint32_t max_requests;
|
||||
|
||||
/**
|
||||
* True entropy source
|
||||
@@ -111,7 +111,7 @@ static bool update(private_ntru_drbg_t *this, chunk_t data)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(ntru_drbg_t, get_strength, u_int32_t,
|
||||
METHOD(ntru_drbg_t, get_strength, uint32_t,
|
||||
private_ntru_drbg_t *this)
|
||||
{
|
||||
return this->strength;
|
||||
@@ -142,7 +142,7 @@ METHOD(ntru_drbg_t, reseed, bool,
|
||||
}
|
||||
|
||||
METHOD(ntru_drbg_t, generate, bool,
|
||||
private_ntru_drbg_t *this, u_int32_t strength, u_int32_t len, u_int8_t *out)
|
||||
private_ntru_drbg_t *this, uint32_t strength, uint32_t len, uint8_t *out)
|
||||
{
|
||||
size_t delta;
|
||||
chunk_t output;
|
||||
@@ -206,14 +206,14 @@ METHOD(ntru_drbg_t, destroy, void,
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
ntru_drbg_t *ntru_drbg_create(u_int32_t strength, chunk_t pers_str,
|
||||
ntru_drbg_t *ntru_drbg_create(uint32_t strength, chunk_t pers_str,
|
||||
rng_t *entropy)
|
||||
{
|
||||
private_ntru_drbg_t *this;
|
||||
chunk_t seed;
|
||||
signer_t *hmac;
|
||||
size_t entropy_len;
|
||||
u_int32_t max_requests;
|
||||
uint32_t max_requests;
|
||||
|
||||
if (strength > MAX_STRENGTH_BITS)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ struct ntru_drbg_t {
|
||||
*
|
||||
* @return configured security strength in bits
|
||||
*/
|
||||
u_int32_t (*get_strength)(ntru_drbg_t *this);
|
||||
uint32_t (*get_strength)(ntru_drbg_t *this);
|
||||
|
||||
/**
|
||||
* Reseed the instantiated DRBG
|
||||
@@ -54,8 +54,8 @@ struct ntru_drbg_t {
|
||||
* @param out address of output buffer
|
||||
* @return TRUE if successful
|
||||
*/
|
||||
bool (*generate)(ntru_drbg_t *this, u_int32_t strength, u_int32_t len,
|
||||
u_int8_t *out);
|
||||
bool (*generate)(ntru_drbg_t *this, uint32_t strength, uint32_t len,
|
||||
uint8_t *out);
|
||||
|
||||
/**
|
||||
* Get a reference on an ntru_drbg_t object increasing the count by one
|
||||
@@ -77,7 +77,7 @@ struct ntru_drbg_t {
|
||||
* @param pers_str personalization string
|
||||
* @param entropy entropy source to use
|
||||
*/
|
||||
ntru_drbg_t *ntru_drbg_create(u_int32_t strength, chunk_t pers_str,
|
||||
ntru_drbg_t *ntru_drbg_create(uint32_t strength, chunk_t pers_str,
|
||||
rng_t *entropy);
|
||||
|
||||
#endif /** NTRU_DRBG_H_ @}*/
|
||||
|
||||
@@ -66,7 +66,7 @@ struct private_ntru_ke_t {
|
||||
/**
|
||||
* Cryptographical strength in bits of the NTRU Parameter Set
|
||||
*/
|
||||
u_int32_t strength;
|
||||
uint32_t strength;
|
||||
|
||||
/**
|
||||
* NTRU Public Key
|
||||
@@ -247,7 +247,7 @@ ntru_ke_t *ntru_ke_create(diffie_hellman_group_t group, chunk_t g, chunk_t p)
|
||||
rng_t *entropy;
|
||||
ntru_drbg_t *drbg;
|
||||
char *parameter_set;
|
||||
u_int32_t strength;
|
||||
uint32_t strength;
|
||||
|
||||
parameter_set = lib->settings->get_str(lib->settings,
|
||||
"%s.plugins.ntru.parameter_set", "optimum", lib->ns);
|
||||
|
||||
@@ -43,7 +43,7 @@ struct private_openssl_crypter_t {
|
||||
/**
|
||||
* Look up an OpenSSL algorithm name and validate its key size
|
||||
*/
|
||||
static char* lookup_algorithm(u_int16_t ikev2_algo, size_t *key_size)
|
||||
static char* lookup_algorithm(uint16_t ikev2_algo, size_t *key_size)
|
||||
{
|
||||
struct {
|
||||
/* identifier specified in IKEv2 */
|
||||
|
||||
@@ -53,7 +53,7 @@ METHOD(hasher_t, reset, bool,
|
||||
}
|
||||
|
||||
METHOD(hasher_t, get_hash, bool,
|
||||
private_openssl_hasher_t *this, chunk_t chunk, u_int8_t *hash)
|
||||
private_openssl_hasher_t *this, chunk_t chunk, uint8_t *hash)
|
||||
{
|
||||
if (EVP_DigestUpdate(this->ctx, chunk.ptr, chunk.len) != 1)
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ METHOD(mac_t, set_key, bool,
|
||||
}
|
||||
|
||||
METHOD(mac_t, get_mac, bool,
|
||||
private_mac_t *this, chunk_t data, u_int8_t *out)
|
||||
private_mac_t *this, chunk_t data, uint8_t *out)
|
||||
{
|
||||
if (!this->key_set)
|
||||
{
|
||||
|
||||
@@ -47,7 +47,7 @@ struct private_openssl_rng_t {
|
||||
};
|
||||
|
||||
METHOD(rng_t, get_bytes, bool,
|
||||
private_openssl_rng_t *this, size_t bytes, u_int8_t *buffer)
|
||||
private_openssl_rng_t *this, size_t bytes, uint8_t *buffer)
|
||||
{
|
||||
if (this->quality == RNG_WEAK)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ struct private_openssl_sha1_prf_t {
|
||||
};
|
||||
|
||||
METHOD(prf_t, get_bytes, bool,
|
||||
private_openssl_sha1_prf_t *this, chunk_t seed, u_int8_t *bytes)
|
||||
private_openssl_sha1_prf_t *this, chunk_t seed, uint8_t *bytes)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
|
||||
if (!SHA1_Update(&this->ctx, seed.ptr, seed.len))
|
||||
@@ -53,7 +53,7 @@ METHOD(prf_t, get_bytes, bool,
|
||||
|
||||
if (bytes)
|
||||
{
|
||||
u_int32_t *hash = (u_int32_t*)bytes;
|
||||
uint32_t *hash = (uint32_t*)bytes;
|
||||
|
||||
hash[0] = htonl(this->ctx.h0);
|
||||
hash[1] = htonl(this->ctx.h1);
|
||||
|
||||
@@ -81,7 +81,7 @@ METHOD(rng_t, allocate_bytes, bool,
|
||||
}
|
||||
|
||||
METHOD(rng_t, get_bytes, bool,
|
||||
private_padlock_rng_t *this, size_t bytes, u_int8_t *buffer)
|
||||
private_padlock_rng_t *this, size_t bytes, uint8_t *buffer)
|
||||
{
|
||||
chunk_t chunk;
|
||||
|
||||
|
||||
@@ -54,9 +54,9 @@ static void padlock_sha1(int len, u_char *in, u_char *out)
|
||||
/**
|
||||
* sha1() a buffer of data into digest
|
||||
*/
|
||||
static void sha1(chunk_t data, u_int32_t *digest)
|
||||
static void sha1(chunk_t data, uint32_t *digest)
|
||||
{
|
||||
u_int32_t hash[128] PADLOCK_ALIGN;
|
||||
uint32_t hash[128] PADLOCK_ALIGN;
|
||||
|
||||
hash[0] = 0x67452301;
|
||||
hash[1] = 0xefcdab89;
|
||||
@@ -91,18 +91,18 @@ METHOD(hasher_t, reset, bool,
|
||||
}
|
||||
|
||||
METHOD(hasher_t, get_hash, bool,
|
||||
private_padlock_sha1_hasher_t *this, chunk_t chunk, u_int8_t *hash)
|
||||
private_padlock_sha1_hasher_t *this, chunk_t chunk, uint8_t *hash)
|
||||
{
|
||||
if (hash)
|
||||
{
|
||||
if (this->data.len)
|
||||
{
|
||||
append_data(this, chunk);
|
||||
sha1(this->data, (u_int32_t*)hash);
|
||||
sha1(this->data, (uint32_t*)hash);
|
||||
}
|
||||
else
|
||||
{ /* hash directly if no previous data found */
|
||||
sha1(chunk, (u_int32_t*)hash);
|
||||
sha1(chunk, (uint32_t*)hash);
|
||||
}
|
||||
reset(this);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ static status_t pem_decrypt(chunk_t *blob, encryption_algorithm_t alg,
|
||||
chunk_t hash;
|
||||
chunk_t decrypted;
|
||||
chunk_t key = {alloca(key_size), key_size};
|
||||
u_int8_t padding, *last_padding_pos, *first_padding_pos;
|
||||
uint8_t padding, *last_padding_pos, *first_padding_pos;
|
||||
|
||||
/* build key from passphrase and IV */
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_MD5);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
*/
|
||||
static public_key_t *parse_public_key(chunk_t blob)
|
||||
{
|
||||
u_int32_t alg;
|
||||
uint32_t alg;
|
||||
public_key_t *key;
|
||||
|
||||
if (!pgp_read_scalar(&blob, 1, &alg))
|
||||
@@ -74,7 +74,7 @@ static public_key_t *parse_rsa_public_key(chunk_t blob)
|
||||
static private_key_t *parse_rsa_private_key(chunk_t blob)
|
||||
{
|
||||
chunk_t mpi[6];
|
||||
u_int32_t s2k;
|
||||
uint32_t s2k;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
@@ -143,7 +143,7 @@ static private_key_t *parse_private_key(chunk_t blob)
|
||||
{
|
||||
chunk_t packet;
|
||||
pgp_packet_tag_t tag;
|
||||
u_int32_t version, created, days, alg;
|
||||
uint32_t version, created, days, alg;
|
||||
private_key_t *key;
|
||||
|
||||
if (!pgp_read_packet(&blob, &packet, &tag))
|
||||
|
||||
@@ -40,17 +40,17 @@ struct private_pgp_cert_t {
|
||||
/**
|
||||
* version of the public key
|
||||
*/
|
||||
u_int32_t version;
|
||||
uint32_t version;
|
||||
|
||||
/**
|
||||
* creation time
|
||||
*/
|
||||
u_int32_t created;
|
||||
uint32_t created;
|
||||
|
||||
/**
|
||||
* days the certificate is valid
|
||||
*/
|
||||
u_int32_t valid;
|
||||
uint32_t valid;
|
||||
|
||||
/**
|
||||
* userid of the certificate
|
||||
@@ -349,7 +349,7 @@ static bool parse_public_key(private_pgp_cert_t *this, chunk_t packet)
|
||||
*/
|
||||
static bool parse_signature(private_pgp_cert_t *this, chunk_t packet)
|
||||
{
|
||||
u_int32_t version, len, type, created;
|
||||
uint32_t version, len, type, created;
|
||||
|
||||
if (!pgp_read_scalar(&packet, 1, &version))
|
||||
{
|
||||
|
||||
@@ -73,9 +73,9 @@ ENUM_END(pgp_packet_tag_names, PGP_PKT_MOD_DETECT_CODE);
|
||||
/**
|
||||
* Read a PGP scalar of bytes length, advance blob
|
||||
*/
|
||||
bool pgp_read_scalar(chunk_t *blob, size_t bytes, u_int32_t *scalar)
|
||||
bool pgp_read_scalar(chunk_t *blob, size_t bytes, uint32_t *scalar)
|
||||
{
|
||||
u_int32_t res = 0;
|
||||
uint32_t res = 0;
|
||||
|
||||
if (bytes > blob->len)
|
||||
{
|
||||
@@ -96,7 +96,7 @@ bool pgp_read_scalar(chunk_t *blob, size_t bytes, u_int32_t *scalar)
|
||||
*/
|
||||
bool pgp_read_mpi(chunk_t *blob, chunk_t *mpi)
|
||||
{
|
||||
u_int32_t bits, bytes;
|
||||
uint32_t bits, bytes;
|
||||
|
||||
if (!pgp_read_scalar(blob, 2, &bits))
|
||||
{
|
||||
@@ -117,7 +117,7 @@ bool pgp_read_mpi(chunk_t *blob, chunk_t *mpi)
|
||||
/**
|
||||
* Read length of an PGP old packet length encoding
|
||||
*/
|
||||
static bool pgp_old_packet_length(chunk_t *blob, u_int32_t *length)
|
||||
static bool pgp_old_packet_length(chunk_t *blob, uint32_t *length)
|
||||
{
|
||||
/* bits 0 and 1 define the packet length type */
|
||||
u_char type;
|
||||
@@ -141,7 +141,7 @@ static bool pgp_old_packet_length(chunk_t *blob, u_int32_t *length)
|
||||
*/
|
||||
bool pgp_read_packet(chunk_t *blob, chunk_t *data, pgp_packet_tag_t *tag)
|
||||
{
|
||||
u_int32_t len;
|
||||
uint32_t len;
|
||||
u_char t;
|
||||
|
||||
if (!blob->len)
|
||||
|
||||
@@ -115,7 +115,7 @@ bool pgp_read_mpi(chunk_t *blob, chunk_t *mpi);
|
||||
* @param scalar resultin scalar
|
||||
* @return TRUE if scalar parsed successfully
|
||||
*/
|
||||
bool pgp_read_scalar(chunk_t *blob, size_t bytes, u_int32_t *scalar);
|
||||
bool pgp_read_scalar(chunk_t *blob, size_t bytes, uint32_t *scalar);
|
||||
|
||||
/**
|
||||
* Parse a PGP packet.
|
||||
|
||||
@@ -146,7 +146,7 @@ METHOD(hasher_t, reset, bool,
|
||||
}
|
||||
|
||||
METHOD(hasher_t, get_hash, bool,
|
||||
private_pkcs11_hasher_t *this, chunk_t chunk, u_int8_t *hash)
|
||||
private_pkcs11_hasher_t *this, chunk_t chunk, uint8_t *hash)
|
||||
{
|
||||
CK_RV rv;
|
||||
CK_ULONG len;
|
||||
|
||||
@@ -44,7 +44,7 @@ struct private_pkcs11_rng_t {
|
||||
};
|
||||
|
||||
METHOD(rng_t, get_bytes, bool,
|
||||
private_pkcs11_rng_t *this, size_t bytes, u_int8_t *buffer)
|
||||
private_pkcs11_rng_t *this, size_t bytes, uint8_t *buffer)
|
||||
{
|
||||
CK_RV rv;
|
||||
rv = this->lib->f->C_GenerateRandom(this->session, buffer, bytes);
|
||||
|
||||
@@ -324,7 +324,7 @@ end:
|
||||
* Verify the given MAC with available passwords.
|
||||
*/
|
||||
static bool verify_mac(hash_algorithm_t hash, chunk_t salt,
|
||||
u_int64_t iterations, chunk_t data, chunk_t mac)
|
||||
uint64_t iterations, chunk_t data, chunk_t mac)
|
||||
{
|
||||
integrity_algorithm_t integ;
|
||||
enumerator_t *enumerator;
|
||||
@@ -450,7 +450,7 @@ static bool parse_PFX(private_pkcs12_t *this, chunk_t blob)
|
||||
data = chunk_empty;
|
||||
hash_algorithm_t hash = HASH_UNKNOWN;
|
||||
container_t *container = NULL;
|
||||
u_int64_t iterations = 0;
|
||||
uint64_t iterations = 0;
|
||||
bool success = FALSE;
|
||||
|
||||
parser = asn1_parser_create(PFXObjects, blob);
|
||||
|
||||
@@ -57,7 +57,7 @@ ENUM(plugin_feature_names, FEATURE_NONE, FEATURE_CUSTOM,
|
||||
/**
|
||||
* See header.
|
||||
*/
|
||||
u_int32_t plugin_feature_hash(plugin_feature_t *feature)
|
||||
uint32_t plugin_feature_hash(plugin_feature_t *feature)
|
||||
{
|
||||
chunk_t data = chunk_empty;
|
||||
|
||||
|
||||
@@ -362,7 +362,7 @@ static inline void plugin_features_add(plugin_feature_t *features,
|
||||
* @param feature feature to hash
|
||||
* @return hash value of the feature
|
||||
*/
|
||||
u_int32_t plugin_feature_hash(plugin_feature_t *feature);
|
||||
uint32_t plugin_feature_hash(plugin_feature_t *feature);
|
||||
|
||||
/**
|
||||
* Check if feature a matches to feature b.
|
||||
|
||||
@@ -41,7 +41,7 @@ struct private_random_rng_t {
|
||||
};
|
||||
|
||||
METHOD(rng_t, get_bytes, bool,
|
||||
private_random_rng_t *this, size_t bytes, u_int8_t *buffer)
|
||||
private_random_rng_t *this, size_t bytes, uint8_t *buffer)
|
||||
{
|
||||
size_t done;
|
||||
ssize_t got;
|
||||
|
||||
@@ -19,11 +19,11 @@ typedef struct private_rc2_crypter_t private_rc2_crypter_t;
|
||||
|
||||
#define RC2_BLOCK_SIZE 8
|
||||
|
||||
#define ROL16(x, k) ({ u_int16_t _x = (x); (_x << (k)) | (_x >> (16 - (k))); })
|
||||
#define ROR16(x, k) ({ u_int16_t _x = (x); (_x >> (k)) | (_x << (16 - (k))); })
|
||||
#define ROL16(x, k) ({ uint16_t _x = (x); (_x << (k)) | (_x >> (16 - (k))); })
|
||||
#define ROR16(x, k) ({ uint16_t _x = (x); (_x >> (k)) | (_x << (16 - (k))); })
|
||||
|
||||
#define GET16(x) ({ u_char *_x = (x); (u_int16_t)_x[0] | ((u_int16_t)_x[1] << 8); })
|
||||
#define PUT16(x, v) ({ u_char *_x = (x); u_int16_t _v = (v); _x[0] = _v, _x[1] = _v >> 8; })
|
||||
#define GET16(x) ({ u_char *_x = (x); (uint16_t)_x[0] | ((uint16_t)_x[1] << 8); })
|
||||
#define PUT16(x, v) ({ u_char *_x = (x); uint16_t _v = (v); _x[0] = _v, _x[1] = _v >> 8; })
|
||||
|
||||
/**
|
||||
* Private data of rc2_crypter_t
|
||||
@@ -38,7 +38,7 @@ struct private_rc2_crypter_t {
|
||||
/**
|
||||
* The expanded key in 16-bit words
|
||||
*/
|
||||
u_int16_t K[64];
|
||||
uint16_t K[64];
|
||||
|
||||
/**
|
||||
* Key size in bytes
|
||||
@@ -95,7 +95,7 @@ static const u_char PITABLE[256] =
|
||||
*/
|
||||
static void encrypt_block(private_rc2_crypter_t *this, u_char R[])
|
||||
{
|
||||
register u_int16_t R0, R1, R2, R3, *Kj;
|
||||
register uint16_t R0, R1, R2, R3, *Kj;
|
||||
int rounds = 3, mix = 5;
|
||||
|
||||
R0 = GET16(R);
|
||||
@@ -139,7 +139,7 @@ static void encrypt_block(private_rc2_crypter_t *this, u_char R[])
|
||||
*/
|
||||
static void decrypt_block(private_rc2_crypter_t *this, u_char R[])
|
||||
{
|
||||
register u_int16_t R0, R1, R2, R3, *Kj;
|
||||
register uint16_t R0, R1, R2, R3, *Kj;
|
||||
int rounds = 3, mix = 5;
|
||||
|
||||
R0 = GET16(R);
|
||||
@@ -185,7 +185,7 @@ static void decrypt_block(private_rc2_crypter_t *this, u_char R[])
|
||||
METHOD(crypter_t, decrypt, bool,
|
||||
private_rc2_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *decrypted)
|
||||
{
|
||||
u_int8_t *in, *out, *prev;
|
||||
uint8_t *in, *out, *prev;
|
||||
|
||||
if (data.len % RC2_BLOCK_SIZE || iv.len != RC2_BLOCK_SIZE)
|
||||
{
|
||||
@@ -222,7 +222,7 @@ METHOD(crypter_t, decrypt, bool,
|
||||
METHOD(crypter_t, encrypt, bool,
|
||||
private_rc2_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *encrypted)
|
||||
{
|
||||
u_int8_t *in, *out, *end, *prev;
|
||||
uint8_t *in, *out, *end, *prev;
|
||||
|
||||
if (data.len % RC2_BLOCK_SIZE || iv.len != RC2_BLOCK_SIZE)
|
||||
{
|
||||
@@ -273,7 +273,7 @@ METHOD(crypter_t, get_key_size, size_t,
|
||||
METHOD(crypter_t, set_key, bool,
|
||||
private_rc2_crypter_t *this, chunk_t key)
|
||||
{
|
||||
u_int8_t L[128], T8, TM, idx;
|
||||
uint8_t L[128], T8, TM, idx;
|
||||
int i;
|
||||
|
||||
if (key.len != this->T)
|
||||
|
||||
@@ -54,7 +54,7 @@ struct private_rdrand_rng_t {
|
||||
/**
|
||||
* Get a two byte word using RDRAND
|
||||
*/
|
||||
static bool rdrand16(u_int16_t *out)
|
||||
static bool rdrand16(uint16_t *out)
|
||||
{
|
||||
u_char res;
|
||||
int i;
|
||||
@@ -76,7 +76,7 @@ static bool rdrand16(u_int16_t *out)
|
||||
/**
|
||||
* Get a four byte word using RDRAND
|
||||
*/
|
||||
static bool rdrand32(u_int32_t *out)
|
||||
static bool rdrand32(uint32_t *out)
|
||||
{
|
||||
u_char res;
|
||||
int i;
|
||||
@@ -99,7 +99,7 @@ static bool rdrand32(u_int32_t *out)
|
||||
/**
|
||||
* Get a eight byte word using RDRAND
|
||||
*/
|
||||
static bool rdrand64(u_int64_t *out)
|
||||
static bool rdrand64(uint64_t *out)
|
||||
{
|
||||
u_char res;
|
||||
int i;
|
||||
@@ -122,9 +122,9 @@ static bool rdrand64(u_int64_t *out)
|
||||
/**
|
||||
* Get a one byte word using RDRAND
|
||||
*/
|
||||
static bool rdrand8(u_int8_t *out)
|
||||
static bool rdrand8(uint8_t *out)
|
||||
{
|
||||
u_int16_t u16;
|
||||
uint16_t u16;
|
||||
|
||||
if (!rdrand16(&u16))
|
||||
{
|
||||
@@ -141,15 +141,15 @@ static bool rdrand128(void *out)
|
||||
{
|
||||
#ifdef __x86_64__
|
||||
if (!rdrand64(out) ||
|
||||
!rdrand64(out + sizeof(u_int64_t)))
|
||||
!rdrand64(out + sizeof(uint64_t)))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#else /* __i386__ */
|
||||
if (!rdrand32(out) ||
|
||||
!rdrand32(out + 1 * sizeof(u_int32_t)) ||
|
||||
!rdrand32(out + 2 * sizeof(u_int32_t)) ||
|
||||
!rdrand32(out + 3 * sizeof(u_int32_t)))
|
||||
!rdrand32(out + 1 * sizeof(uint32_t)) ||
|
||||
!rdrand32(out + 2 * sizeof(uint32_t)) ||
|
||||
!rdrand32(out + 3 * sizeof(uint32_t)))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -165,9 +165,9 @@ static bool reseed()
|
||||
int i;
|
||||
|
||||
#ifdef __x86_64__
|
||||
u_int64_t tmp;
|
||||
uint64_t tmp;
|
||||
|
||||
for (i = 0; i < 511 * 16 / sizeof(u_int64_t); i++)
|
||||
for (i = 0; i < 511 * 16 / sizeof(uint64_t); i++)
|
||||
{
|
||||
if (!rdrand64(&tmp))
|
||||
{
|
||||
@@ -175,9 +175,9 @@ static bool reseed()
|
||||
}
|
||||
}
|
||||
#else /* __i386__ */
|
||||
u_int32_t tmp;
|
||||
uint32_t tmp;
|
||||
|
||||
for (i = 0; i < 511 * 16 / sizeof(u_int32_t); i++)
|
||||
for (i = 0; i < 511 * 16 / sizeof(uint32_t); i++)
|
||||
{
|
||||
if (!rdrand32(&tmp))
|
||||
{
|
||||
@@ -202,48 +202,48 @@ static bool rdrand_chunk(private_rdrand_rng_t *this, chunk_t chunk)
|
||||
}
|
||||
|
||||
/* align to 2 byte */
|
||||
if (chunk.len >= sizeof(u_int8_t))
|
||||
if (chunk.len >= sizeof(uint8_t))
|
||||
{
|
||||
if ((uintptr_t)chunk.ptr % 2)
|
||||
{
|
||||
if (!rdrand8((u_int8_t*)chunk.ptr))
|
||||
if (!rdrand8((uint8_t*)chunk.ptr))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
chunk = chunk_skip(chunk, sizeof(u_int8_t));
|
||||
chunk = chunk_skip(chunk, sizeof(uint8_t));
|
||||
}
|
||||
}
|
||||
|
||||
/* align to 4 byte */
|
||||
if (chunk.len >= sizeof(u_int16_t))
|
||||
if (chunk.len >= sizeof(uint16_t))
|
||||
{
|
||||
if ((uintptr_t)chunk.ptr % 4)
|
||||
{
|
||||
if (!rdrand16((u_int16_t*)chunk.ptr))
|
||||
if (!rdrand16((uint16_t*)chunk.ptr))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
chunk = chunk_skip(chunk, sizeof(u_int16_t));
|
||||
chunk = chunk_skip(chunk, sizeof(uint16_t));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
/* align to 8 byte */
|
||||
if (chunk.len >= sizeof(u_int32_t))
|
||||
if (chunk.len >= sizeof(uint32_t))
|
||||
{
|
||||
if ((uintptr_t)chunk.ptr % 8)
|
||||
{
|
||||
if (!rdrand32((u_int32_t*)chunk.ptr))
|
||||
if (!rdrand32((uint32_t*)chunk.ptr))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
chunk = chunk_skip(chunk, sizeof(u_int32_t));
|
||||
chunk = chunk_skip(chunk, sizeof(uint32_t));
|
||||
}
|
||||
}
|
||||
|
||||
/* fill with 8 byte words */
|
||||
while (chunk.len >= sizeof(u_int64_t))
|
||||
while (chunk.len >= sizeof(uint64_t))
|
||||
{
|
||||
if (this->quality == RNG_STRONG && chunk.len % FORCE_RESEED == 0)
|
||||
{
|
||||
@@ -252,27 +252,27 @@ static bool rdrand_chunk(private_rdrand_rng_t *this, chunk_t chunk)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (!rdrand64((u_int64_t*)chunk.ptr))
|
||||
if (!rdrand64((uint64_t*)chunk.ptr))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
chunk = chunk_skip(chunk, sizeof(u_int64_t));
|
||||
chunk = chunk_skip(chunk, sizeof(uint64_t));
|
||||
}
|
||||
|
||||
/* append 4 byte word */
|
||||
if (chunk.len >= sizeof(u_int32_t))
|
||||
if (chunk.len >= sizeof(uint32_t))
|
||||
{
|
||||
if (!rdrand32((u_int32_t*)chunk.ptr))
|
||||
if (!rdrand32((uint32_t*)chunk.ptr))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
chunk = chunk_skip(chunk, sizeof(u_int32_t));
|
||||
chunk = chunk_skip(chunk, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
#else /* __i386__ */
|
||||
|
||||
/* fill with 4 byte words */
|
||||
while (chunk.len >= sizeof(u_int32_t))
|
||||
while (chunk.len >= sizeof(uint32_t))
|
||||
{
|
||||
if (this->quality == RNG_STRONG && chunk.len % FORCE_RESEED == 0)
|
||||
{
|
||||
@@ -281,11 +281,11 @@ static bool rdrand_chunk(private_rdrand_rng_t *this, chunk_t chunk)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (!rdrand32((u_int32_t*)chunk.ptr))
|
||||
if (!rdrand32((uint32_t*)chunk.ptr))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
chunk = chunk_skip(chunk, sizeof(u_int32_t));
|
||||
chunk = chunk_skip(chunk, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ / __i386__ */
|
||||
@@ -299,23 +299,23 @@ static bool rdrand_chunk(private_rdrand_rng_t *this, chunk_t chunk)
|
||||
}
|
||||
|
||||
/* append 2 byte word */
|
||||
if (chunk.len >= sizeof(u_int16_t))
|
||||
if (chunk.len >= sizeof(uint16_t))
|
||||
{
|
||||
if (!rdrand16((u_int16_t*)chunk.ptr))
|
||||
if (!rdrand16((uint16_t*)chunk.ptr))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
chunk = chunk_skip(chunk, sizeof(u_int16_t));
|
||||
chunk = chunk_skip(chunk, sizeof(uint16_t));
|
||||
}
|
||||
|
||||
/* append 1 byte word */
|
||||
if (chunk.len >= sizeof(u_int8_t))
|
||||
if (chunk.len >= sizeof(uint8_t))
|
||||
{
|
||||
if (!rdrand8((u_int8_t*)chunk.ptr))
|
||||
if (!rdrand8((uint8_t*)chunk.ptr))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
chunk = chunk_skip(chunk, sizeof(u_int8_t));
|
||||
chunk = chunk_skip(chunk, sizeof(uint8_t));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -378,7 +378,7 @@ static bool rdrand_mixed(private_rdrand_rng_t *this, chunk_t chunk)
|
||||
}
|
||||
|
||||
METHOD(rng_t, get_bytes, bool,
|
||||
private_rdrand_rng_t *this, size_t bytes, u_int8_t *buffer)
|
||||
private_rdrand_rng_t *this, size_t bytes, uint8_t *buffer)
|
||||
{
|
||||
switch (this->quality)
|
||||
{
|
||||
|
||||
@@ -59,20 +59,20 @@ struct private_sha1_hasher_t {
|
||||
/*
|
||||
* State of the hasher. Shared with sha1_prf.c, do not change it!!!
|
||||
*/
|
||||
u_int32_t state[5];
|
||||
u_int32_t count[2];
|
||||
u_int8_t buffer[64];
|
||||
uint32_t state[5];
|
||||
uint32_t count[2];
|
||||
uint8_t buffer[64];
|
||||
};
|
||||
|
||||
/*
|
||||
* Hash a single 512-bit block. This is the core of the algorithm. *
|
||||
*/
|
||||
static void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64])
|
||||
static void SHA1Transform(uint32_t state[5], const unsigned char buffer[64])
|
||||
{
|
||||
u_int32_t a, b, c, d, e;
|
||||
uint32_t a, b, c, d, e;
|
||||
typedef union {
|
||||
u_int8_t c[64];
|
||||
u_int32_t l[16];
|
||||
uint8_t c[64];
|
||||
uint32_t l[16];
|
||||
} CHAR64LONG16;
|
||||
CHAR64LONG16 block[1]; /* use array to appear as a pointer */
|
||||
memcpy(block, buffer, 64);
|
||||
@@ -118,10 +118,10 @@ static void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64])
|
||||
/**
|
||||
* Run your data through this. Also used in sha1_prf.
|
||||
*/
|
||||
void SHA1Update(private_sha1_hasher_t* this, u_int8_t *data, u_int32_t len)
|
||||
void SHA1Update(private_sha1_hasher_t* this, uint8_t *data, uint32_t len)
|
||||
{
|
||||
u_int32_t i;
|
||||
u_int32_t j;
|
||||
uint32_t i;
|
||||
uint32_t j;
|
||||
|
||||
j = this->count[0];
|
||||
if ((this->count[0] += len << 3) < j)
|
||||
@@ -151,15 +151,15 @@ void SHA1Update(private_sha1_hasher_t* this, u_int8_t *data, u_int32_t len)
|
||||
/*
|
||||
* Add padding and return the message digest.
|
||||
*/
|
||||
static void SHA1Final(private_sha1_hasher_t *this, u_int8_t *digest)
|
||||
static void SHA1Final(private_sha1_hasher_t *this, uint8_t *digest)
|
||||
{
|
||||
u_int32_t i;
|
||||
u_int8_t finalcount[8];
|
||||
u_int8_t c;
|
||||
uint32_t i;
|
||||
uint8_t finalcount[8];
|
||||
uint8_t c;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
finalcount[i] = (u_int8_t)((this->count[(i >= 4 ? 0 : 1)]
|
||||
finalcount[i] = (uint8_t)((this->count[(i >= 4 ? 0 : 1)]
|
||||
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
|
||||
}
|
||||
c = 0200;
|
||||
@@ -172,7 +172,7 @@ static void SHA1Final(private_sha1_hasher_t *this, u_int8_t *digest)
|
||||
SHA1Update(this, finalcount, 8); /* Should cause a SHA1Transform() */
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
digest[i] = (u_int8_t)((this->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
|
||||
digest[i] = (uint8_t)((this->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ METHOD(hasher_t, reset, bool,
|
||||
}
|
||||
|
||||
METHOD(hasher_t, get_hash, bool,
|
||||
private_sha1_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
|
||||
private_sha1_hasher_t *this, chunk_t chunk, uint8_t *buffer)
|
||||
{
|
||||
SHA1Update(this, chunk.ptr, chunk.len);
|
||||
if (buffer != NULL)
|
||||
|
||||
@@ -33,9 +33,9 @@ struct private_sha1_hasher_t {
|
||||
/*
|
||||
* State of the hasher. From sha1_hasher.c, do not change it!
|
||||
*/
|
||||
u_int32_t state[5];
|
||||
u_int32_t count[2];
|
||||
u_int8_t buffer[64];
|
||||
uint32_t state[5];
|
||||
uint32_t count[2];
|
||||
uint8_t buffer[64];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -57,12 +57,12 @@ struct private_sha1_prf_t {
|
||||
/**
|
||||
* From sha1_hasher.c
|
||||
*/
|
||||
extern void SHA1Update(private_sha1_hasher_t* this, u_int8_t *data, u_int32_t len);
|
||||
extern void SHA1Update(private_sha1_hasher_t* this, uint8_t *data, uint32_t len);
|
||||
|
||||
METHOD(prf_t, get_bytes, bool,
|
||||
private_sha1_prf_t *this, chunk_t seed, u_int8_t *bytes)
|
||||
private_sha1_prf_t *this, chunk_t seed, uint8_t *bytes)
|
||||
{
|
||||
u_int32_t *hash = (u_int32_t*)bytes;
|
||||
uint32_t *hash = (uint32_t*)bytes;
|
||||
|
||||
SHA1Update(this->hasher, seed.ptr, seed.len);
|
||||
|
||||
@@ -98,14 +98,14 @@ METHOD(prf_t, set_key, bool,
|
||||
private_sha1_prf_t *this, chunk_t key)
|
||||
{
|
||||
int i, rounds;
|
||||
u_int32_t *iv = (u_int32_t*)key.ptr;
|
||||
uint32_t *iv = (uint32_t*)key.ptr;
|
||||
|
||||
if (!this->hasher->public.hasher_interface.reset(
|
||||
&this->hasher->public.hasher_interface))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
rounds = min(key.len/sizeof(u_int32_t), sizeof(this->hasher->state));
|
||||
rounds = min(key.len/sizeof(uint32_t), sizeof(this->hasher->state));
|
||||
for (i = 0; i < rounds; i++)
|
||||
{
|
||||
this->hasher->state[i] ^= htonl(iv[i]);
|
||||
|
||||
@@ -33,9 +33,9 @@ struct private_sha512_hasher_t {
|
||||
sha2_hasher_t public;
|
||||
|
||||
unsigned char sha_out[128]; /* results are here, bytes 0..47/0..63 */
|
||||
u_int64_t sha_H[8];
|
||||
u_int64_t sha_blocks;
|
||||
u_int64_t sha_blocksMSB;
|
||||
uint64_t sha_H[8];
|
||||
uint64_t sha_blocks;
|
||||
uint64_t sha_blocksMSB;
|
||||
int sha_bufCnt;
|
||||
};
|
||||
|
||||
@@ -52,23 +52,23 @@ struct private_sha256_hasher_t {
|
||||
sha2_hasher_t public;
|
||||
|
||||
unsigned char sha_out[64]; /* results are here, bytes 0...31 */
|
||||
u_int32_t sha_H[8];
|
||||
u_int64_t sha_blocks;
|
||||
uint32_t sha_H[8];
|
||||
uint64_t sha_blocks;
|
||||
int sha_bufCnt;
|
||||
};
|
||||
|
||||
|
||||
static const u_int32_t sha224_hashInit[8] = {
|
||||
static const uint32_t sha224_hashInit[8] = {
|
||||
0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511,
|
||||
0x64f98fa7, 0xbefa4fa4
|
||||
};
|
||||
|
||||
static const u_int32_t sha256_hashInit[8] = {
|
||||
static const uint32_t sha256_hashInit[8] = {
|
||||
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c,
|
||||
0x1f83d9ab, 0x5be0cd19
|
||||
};
|
||||
|
||||
static const u_int32_t sha256_K[64] = {
|
||||
static const uint32_t sha256_K[64] = {
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
|
||||
0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
||||
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
|
||||
@@ -82,19 +82,19 @@ static const u_int32_t sha256_K[64] = {
|
||||
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
||||
};
|
||||
|
||||
static const u_int64_t sha512_hashInit[8] = {
|
||||
static const uint64_t sha512_hashInit[8] = {
|
||||
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 0x3c6ef372fe94f82bULL,
|
||||
0xa54ff53a5f1d36f1ULL, 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
|
||||
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
|
||||
};
|
||||
|
||||
static const u_int64_t sha384_hashInit[8] = {
|
||||
static const uint64_t sha384_hashInit[8] = {
|
||||
0xcbbb9d5dc1059ed8ULL, 0x629a292a367cd507ULL, 0x9159015a3070dd17ULL,
|
||||
0x152fecd8f70e5939ULL, 0x67332667ffc00b31ULL, 0x8eb44a8768581511ULL,
|
||||
0xdb0c2e0d64f98fa7ULL, 0x47b5481dbefa4fa4ULL
|
||||
};
|
||||
|
||||
static const u_int64_t sha512_K[80] = {
|
||||
static const uint64_t sha512_K[80] = {
|
||||
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL,
|
||||
0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
|
||||
0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, 0xd807aa98a3030242ULL,
|
||||
@@ -143,14 +143,14 @@ static void sha256_transform(private_sha256_hasher_t *ctx,
|
||||
const unsigned char *datap)
|
||||
{
|
||||
register int j;
|
||||
u_int32_t a, b, c, d, e, f, g, h;
|
||||
u_int32_t T1, T2, W[64], Wm2, Wm15;
|
||||
uint32_t a, b, c, d, e, f, g, h;
|
||||
uint32_t T1, T2, W[64], Wm2, Wm15;
|
||||
|
||||
/* read the data, big endian byte order */
|
||||
j = 0;
|
||||
do {
|
||||
W[j] = (((u_int32_t)(datap[0]))<<24) | (((u_int32_t)(datap[1]))<<16) |
|
||||
(((u_int32_t)(datap[2]))<<8 ) | ((u_int32_t)(datap[3]));
|
||||
W[j] = (((uint32_t)(datap[0]))<<24) | (((uint32_t)(datap[1]))<<16) |
|
||||
(((uint32_t)(datap[2]))<<8 ) | ((uint32_t)(datap[3]));
|
||||
datap += 4;
|
||||
} while(++j < 16);
|
||||
|
||||
@@ -229,8 +229,8 @@ static void sha256_write(private_sha256_hasher_t *ctx,
|
||||
static void sha256_final(private_sha256_hasher_t *ctx)
|
||||
{
|
||||
register int j;
|
||||
u_int64_t bitLength;
|
||||
u_int32_t i;
|
||||
uint64_t bitLength;
|
||||
uint32_t i;
|
||||
unsigned char padByte, *datap;
|
||||
|
||||
bitLength = (ctx->sha_blocks << 9) | (ctx->sha_bufCnt << 3);
|
||||
@@ -287,16 +287,16 @@ static void sha512_transform(private_sha512_hasher_t *ctx,
|
||||
const unsigned char *datap)
|
||||
{
|
||||
register int j;
|
||||
u_int64_t a, b, c, d, e, f, g, h;
|
||||
u_int64_t T1, T2, W[80], Wm2, Wm15;
|
||||
uint64_t a, b, c, d, e, f, g, h;
|
||||
uint64_t T1, T2, W[80], Wm2, Wm15;
|
||||
|
||||
/* read the data, big endian byte order */
|
||||
j = 0;
|
||||
do {
|
||||
W[j] = (((u_int64_t)(datap[0]))<<56) | (((u_int64_t)(datap[1]))<<48) |
|
||||
(((u_int64_t)(datap[2]))<<40) | (((u_int64_t)(datap[3]))<<32) |
|
||||
(((u_int64_t)(datap[4]))<<24) | (((u_int64_t)(datap[5]))<<16) |
|
||||
(((u_int64_t)(datap[6]))<<8 ) | ((u_int64_t)(datap[7]));
|
||||
W[j] = (((uint64_t)(datap[0]))<<56) | (((uint64_t)(datap[1]))<<48) |
|
||||
(((uint64_t)(datap[2]))<<40) | (((uint64_t)(datap[3]))<<32) |
|
||||
(((uint64_t)(datap[4]))<<24) | (((uint64_t)(datap[5]))<<16) |
|
||||
(((uint64_t)(datap[6]))<<8 ) | ((uint64_t)(datap[7]));
|
||||
datap += 8;
|
||||
} while(++j < 16);
|
||||
|
||||
@@ -374,8 +374,8 @@ static void sha512_write(private_sha512_hasher_t *ctx,
|
||||
static void sha512_final(private_sha512_hasher_t *ctx)
|
||||
{
|
||||
register int j;
|
||||
u_int64_t bitLength, bitLengthMSB;
|
||||
u_int64_t i;
|
||||
uint64_t bitLength, bitLengthMSB;
|
||||
uint64_t i;
|
||||
unsigned char padByte, *datap;
|
||||
|
||||
bitLength = (ctx->sha_blocks << 10) | (ctx->sha_bufCnt << 3);
|
||||
@@ -469,7 +469,7 @@ METHOD(hasher_t, reset512, bool,
|
||||
}
|
||||
|
||||
METHOD(hasher_t, get_hash224, bool,
|
||||
private_sha256_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
|
||||
private_sha256_hasher_t *this, chunk_t chunk, uint8_t *buffer)
|
||||
{
|
||||
sha256_write(this, chunk.ptr, chunk.len);
|
||||
if (buffer != NULL)
|
||||
@@ -482,7 +482,7 @@ METHOD(hasher_t, get_hash224, bool,
|
||||
}
|
||||
|
||||
METHOD(hasher_t, get_hash256, bool,
|
||||
private_sha256_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
|
||||
private_sha256_hasher_t *this, chunk_t chunk, uint8_t *buffer)
|
||||
{
|
||||
sha256_write(this, chunk.ptr, chunk.len);
|
||||
if (buffer != NULL)
|
||||
@@ -495,7 +495,7 @@ METHOD(hasher_t, get_hash256, bool,
|
||||
}
|
||||
|
||||
METHOD(hasher_t, get_hash384, bool,
|
||||
private_sha512_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
|
||||
private_sha512_hasher_t *this, chunk_t chunk, uint8_t *buffer)
|
||||
{
|
||||
sha512_write(this, chunk.ptr, chunk.len);
|
||||
if (buffer != NULL)
|
||||
@@ -508,7 +508,7 @@ METHOD(hasher_t, get_hash384, bool,
|
||||
}
|
||||
|
||||
METHOD(hasher_t, get_hash512, bool,
|
||||
private_sha512_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
|
||||
private_sha512_hasher_t *this, chunk_t chunk, uint8_t *buffer)
|
||||
{
|
||||
sha512_write(this, chunk.ptr, chunk.len);
|
||||
if (buffer != NULL)
|
||||
|
||||
@@ -120,7 +120,7 @@ static bool read_result(private_winhttp_fetcher_t *this, HINTERNET request,
|
||||
{
|
||||
DWORD received;
|
||||
char buf[1024];
|
||||
u_int32_t code;
|
||||
uint32_t code;
|
||||
DWORD codelen = sizeof(code);
|
||||
|
||||
if (!WinHttpReceiveResponse(request, NULL))
|
||||
|
||||
@@ -40,7 +40,7 @@ struct private_mac_t {
|
||||
/**
|
||||
* Block size, in bytes
|
||||
*/
|
||||
u_int8_t b;
|
||||
uint8_t b;
|
||||
|
||||
/**
|
||||
* crypter using k1
|
||||
@@ -50,22 +50,22 @@ struct private_mac_t {
|
||||
/**
|
||||
* k2
|
||||
*/
|
||||
u_int8_t *k2;
|
||||
uint8_t *k2;
|
||||
|
||||
/**
|
||||
* k3
|
||||
*/
|
||||
u_int8_t *k3;
|
||||
uint8_t *k3;
|
||||
|
||||
/**
|
||||
* E
|
||||
*/
|
||||
u_int8_t *e;
|
||||
uint8_t *e;
|
||||
|
||||
/**
|
||||
* remaining, unprocessed bytes in append mode
|
||||
*/
|
||||
u_int8_t *remaining;
|
||||
uint8_t *remaining;
|
||||
|
||||
/**
|
||||
* number of bytes in remaining
|
||||
@@ -138,7 +138,7 @@ static bool update(private_mac_t *this, chunk_t data)
|
||||
/**
|
||||
* run last round, data is in this->e
|
||||
*/
|
||||
static bool final(private_mac_t *this, u_int8_t *out)
|
||||
static bool final(private_mac_t *this, uint8_t *out)
|
||||
{
|
||||
chunk_t iv;
|
||||
|
||||
@@ -193,7 +193,7 @@ static bool final(private_mac_t *this, u_int8_t *out)
|
||||
}
|
||||
|
||||
METHOD(mac_t, get_mac, bool,
|
||||
private_mac_t *this, chunk_t data, u_int8_t *out)
|
||||
private_mac_t *this, chunk_t data, uint8_t *out)
|
||||
{
|
||||
/* update E, do not process last block */
|
||||
if (!update(this, data))
|
||||
@@ -294,7 +294,7 @@ static mac_t *xcbc_create(encryption_algorithm_t algo, size_t key_size)
|
||||
{
|
||||
private_mac_t *this;
|
||||
crypter_t *crypter;
|
||||
u_int8_t b;
|
||||
uint8_t b;
|
||||
|
||||
crypter = lib->crypto->create_crypter(lib->crypto, algo, key_size);
|
||||
if (!crypter)
|
||||
|
||||
@@ -96,7 +96,7 @@ struct job_requeue_t {
|
||||
} schedule;
|
||||
/** Time to reschedule the job */
|
||||
union {
|
||||
u_int32_t rel;
|
||||
uint32_t rel;
|
||||
timeval_t abs;
|
||||
} time;
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user