Utility function called from hashing functions.
More...
|
| uint64_t | to_big_endian (uint64_t n) |
| | Convert number from little endian to big endian.
|
| |
| uint32_t | to_little_endian (uint32_t n) |
| | Convert from big endian to little endian.
|
| |
| uint64_t | next_div_by (uint64_t n, uint64_t d) |
| | Return next number evenly divisible by specified number.
|
| |
| uint32_t | right_rotate (uint32_t x, uint32_t n) |
| | Right rotate bits of 32 bit integer numbers.
|
| |
| uint32_t | left_rotate (uint32_t x, uint32_t n) |
| | Left rotate bits of 32 bit integer numbers.
|
| |
| uint32_t | lshift (uint8_t n, uint8_t nshifts) |
| | Left shift of unsigned 8 bit int and conversion to 32 bit.
|
| |
| uint8_t * | alloc_padded (uint64_t size, uint64_t buffer_size, size_t *sz, uint8_t *tmpbuf) |
| | Allocate buffer of correct size for computing hash code.
|
| |
Utility function called from hashing functions.
◆ alloc_padded()
| uint8_t * alloc_padded |
( |
uint64_t |
size, |
|
|
uint64_t |
buffer_size, |
|
|
size_t * |
sz, |
|
|
uint8_t * |
tmpbuf |
|
) |
| |
Allocate buffer of correct size for computing hash code.
The input buffer needs to be padded with a 1 bit and 8 bytes containing the buffer size in big endian format. The total size of the buffer size must therefore be greater or equal to:
buffer size + 1 (1...) + 8 (length) = buffer size + 9 bytes
References next_div_by(), and to_big_endian().
◆ left_rotate()
| uint32_t left_rotate |
( |
uint32_t |
x, |
|
|
uint32_t |
n |
|
) |
| |
|
inline |
Left rotate bits of 32 bit integer numbers.
- Parameters
-
| [in] | x | number to rotate. |
| [in] | n | number of bitshifts. |
◆ lshift()
| uint32_t lshift |
( |
uint8_t |
n, |
|
|
uint8_t |
nshifts |
|
) |
| |
|
inline |
Left shift of unsigned 8 bit int and conversion to 32 bit.
- Parameters
-
| [in] | n | number to shift. |
| [in] | nshifts | number of shifts. |
- Returns
- left shifted 32 bit number.
◆ next_div_by()
| uint64_t next_div_by |
( |
uint64_t |
n, |
|
|
uint64_t |
d |
|
) |
| |
|
inline |
Return next number evenly divisible by specified number.
- Parameters
-
| [in] | n | input number. |
| [in] | d | divisor |
- Returns
- number evenly divisible by
d.
◆ right_rotate()
| uint32_t right_rotate |
( |
uint32_t |
x, |
|
|
uint32_t |
n |
|
) |
| |
|
inline |
Right rotate bits of 32 bit integer numbers.
- Parameters
-
| [in] | x | number to rotate. |
| [in] | n | number of right shifts. |
- Returns
- right rotated number.
◆ to_big_endian()
| uint64_t to_big_endian |
( |
uint64_t |
n | ) |
|
|
inline |
Convert number from little endian to big endian.
- Parameters
-
| [in] | n | number to convert in little endian format. |
- Returns
- number in big endian format.
◆ to_little_endian()
| uint32_t to_little_endian |
( |
uint32_t |
n | ) |
|
|
inline |
Convert from big endian to little endian.
- Parameters
-
| [in] | n | number in big endian format. |
- Returns
- number in little endian format.