SSS - S3 Toolkit 0.9.6
S3 client library and applications
Loading...
Searching...
No Matches
Hash

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.
 

Detailed Description

Hashing functions.

Function Documentation

◆ hash_to_text() [1/2]

void md5::hash_to_text ( uint32_t  hash[4],
char *  text 
)
inline

Print hash code to text.

Parameters
[in]hashhash code
[out]textnull-terminated out buffer

◆ hash_to_text() [2/2]

void sha256::hash_to_text ( uint32_t  hash[8],
char *  text 
)
inline

Convert SHA256 hash to text.

Parameters
[in]hashSHA256 hash
[out]textnull-terminated output string

◆ hmac256()

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.

Parameters
[in]datapointer to data to sign
[in]lengthsize of data buffer
[in]keykey
[in]key_lengthkey size, if smaller than 64 then a new 64 byte key is generated
[out]hmac_hashcomputed HMAC hash

References alloc_padded(), sha256::init_hash(), sha256::sha256(), sha256::sha256_stream(), and sha256::to_little().

+ Here is the call graph for this function:

◆ init_hash() [1/2]

void md5::init_hash ( uint32_t  h[4])
inline

Initialize MD5 hash.

Parameters
[out]hhash code

◆ init_hash() [2/2]

void sha256::init_hash ( uint32_t  hash[8])
inline

Initialize SHA256 hash.

First 32 bits of the fractional parts of the square roots of the first 8 primes 2..19

Parameters
[out]hashreturned hash code
+ Here is the caller graph for this function:

◆ md5_stream()

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.

Parameters
[in,out]MD5hash updated at each call, initialize with init_hash
[in]datadata to hash
[in]lengthsize of data buffer

◆ print_hash() [1/2]

void md5::print_hash ( uint32_t  hash[4])

Print hash code to stdout.

Parameters
[in]hashhash code

◆ print_hash() [2/2]

void sha256::print_hash ( uint32_t  hash[8])

Print SHA256 hash to standard output.

Parameters
[in]hashSHA256 hash

◆ sha256()

void sha256::sha256 ( const uint8_t  data[],
size_t  length,
uint32_t  hash[8] 
)

Return SHA256 hash.

Parameters
[in]datadata to hash
[in]lengthsize of data buffer
[out]hashreturned hash value

References alloc_padded(), sha256::init_hash(), next_div_by(), sha256::sha256(), sha256::sha256_stream(), and sha256::to_little().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sha256_next()

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.

Parameters
[in]datadata to hash
[in]lengthsize of chunk
[in,out]hashSHA256 hash
[in]total_lengthtotal length of data buffer

References alloc_padded(), and sha256::sha256_stream().

+ Here is the call graph for this function:

◆ 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.

Parameters
[in,out]hashSH256 hash
[in]datadata to hash
[in]lengthsize of data buffer

References lshift(), and right_rotate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ to_little()

void sha256::to_little ( uint32_t  hash[8])
inline

Convert hash value to little endian.

Parameters
[in,out]hashSHA256 hash

References to_little_endian().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: