SSS - S3 Toolkit 0.9.6
S3 client library and applications
|
Hashing functions. More...
Functions | |
void | hmac256 (const uint8_t *data, size_t length, const uint8_t *key, size_t key_length, uint8_t hmac_hash[32]) |
Implement HMAC algorithm. | |
void | md5::init_hash (uint32_t h[4]) |
Initialize MD5 hash. | |
void | md5::md5_stream (uint32_t hash[4], const uint8_t data[], uint64_t length) |
MD5 hash calculation, streaming version: hash is updated with new hash at each call. | |
void | md5::hash_to_text (uint32_t hash[4], char *text) |
Print hash code to text. | |
void | md5::print_hash (uint32_t hash[4]) |
Print hash code to stdout. | |
void | sha256::init_hash (uint32_t hash[8]) |
Initialize SHA256 hash. | |
void | sha256::sha256 (const uint8_t data[], size_t length, uint32_t hash[8]) |
Return SHA256 hash. | |
void | sha256::sha256_next (const uint8_t data[], uint32_t length, uint32_t hash[8], size_t total_length, uint8_t *tmpbuf) |
Compute SHA256 hash of chunks of data, using preallocated temporary buffer to store padded data. | |
void | sha256::sha256_stream (uint32_t hash[8], const uint8_t data[], uint64_t length) |
Compute SHA256 hash, updating hash value at every invocation. | |
void | sha256::to_little (uint32_t hash[8]) |
Convert hash value to little endian. | |
void | sha256::hash_to_text (uint32_t hash[8], char *text) |
Convert SHA256 hash to text. | |
void | sha256::print_hash (uint32_t hash[8]) |
Print SHA256 hash to standard output. | |
Hashing functions.
|
inline |
Print hash code to text.
[in] | hash | hash code |
[out] | text | null-terminated out buffer |
|
inline |
Convert SHA256 hash to text.
[in] | hash | SHA256 hash |
[out] | text | null-terminated output string |
void hmac256 | ( | const uint8_t * | data, |
size_t | length, | ||
const uint8_t * | key, | ||
size_t | key_length, | ||
uint8_t | hmac_hash[32] | ||
) |
Implement HMAC algorithm.
[in] | data | pointer to data to sign |
[in] | length | size of data buffer |
[in] | key | key |
[in] | key_length | key size, if smaller than 64 then a new 64 byte key is generated |
[out] | hmac_hash | computed HMAC hash |
References alloc_padded(), sha256::init_hash(), sha256::sha256(), sha256::sha256_stream(), and sha256::to_little().
|
inline |
Initialize MD5 hash.
[out] | h | hash code |
|
inline |
Initialize SHA256 hash.
First 32 bits of the fractional parts of the square roots of the first 8 primes 2..19
[out] | hash | returned hash code |
void md5::md5_stream | ( | uint32_t | hash[4], |
const uint8_t | data[], | ||
uint64_t | length | ||
) |
MD5 hash calculation, streaming version: hash is updated with new hash at each call.
[in,out] | MD5 | hash updated at each call, initialize with init_hash |
[in] | data | data to hash |
[in] | length | size of data buffer |
void md5::print_hash | ( | uint32_t | hash[4] | ) |
Print hash code to stdout.
[in] | hash | hash code |
void sha256::print_hash | ( | uint32_t | hash[8] | ) |
Print SHA256 hash to standard output.
[in] | hash | SHA256 hash |
void sha256::sha256 | ( | const uint8_t | data[], |
size_t | length, | ||
uint32_t | hash[8] | ||
) |
Return SHA256 hash.
[in] | data | data to hash |
[in] | length | size of data buffer |
[out] | hash | returned hash value |
References alloc_padded(), sha256::init_hash(), next_div_by(), sha256::sha256(), sha256::sha256_stream(), and sha256::to_little().
void sha256::sha256_next | ( | const uint8_t | data[], |
uint32_t | length, | ||
uint32_t | hash[8], | ||
size_t | total_length, | ||
uint8_t * | tmpbuf | ||
) |
Compute SHA256 hash of chunks of data, using preallocated temporary buffer to store padded data.
The SHA256 algorithm requires the total size of the hashed data to be added to the data itself as the last 8 bytes of the input buffer. When encoding the intermediate chunks length
contains the size of the chunk and total_length
can be either zero or equal to length
. When encoding the last chunk, length
needs to be equal to the chunk size and total_length
equal to the total length of the buffer i.e. the sum of the sizes of the individual chunks.
[in] | data | data to hash |
[in] | length | size of chunk |
[in,out] | hash | SHA256 hash |
[in] | total_length | total length of data buffer |
References alloc_padded(), and sha256::sha256_stream().
void sha256::sha256_stream | ( | uint32_t | hash[8], |
const uint8_t | data[], | ||
uint64_t | length | ||
) |
Compute SHA256 hash, updating hash value at every invocation.
[in,out] | hash | SH256 hash |
[in] | data | data to hash |
[in] | length | size of data buffer |
References lshift(), and right_rotate().
|
inline |
Convert hash value to little endian.
[in,out] | hash | SHA256 hash |
References to_little_endian().