Update and API revision
HASHLIB's API got a bit of a facelift recently with the function set changing nomenclature depending on what function is being served by the group of functions. No longer are hashlib functions prefixed with hashlib_, they are prefixed with a class-esque namespace indicating what they do. Like so:
Invocations of the Secure RNG within HASHLIB look like this:
The latest update is available here.
The header has some slight issues in the documentation... stay tuned for a 9.1 update for a fix, but everything works as of v9.
https://github.com/acagliano/hashlib/releases/latest
I am also opening the floor if anyone wants to contribute hashing algorithms. Fast hashes like sha512, sha1 welcome, as well as slower hashes like argon.
HASHLIB's API got a bit of a facelift recently with the function set changing nomenclature depending on what function is being served by the group of functions. No longer are hashlib functions prefixed with hashlib_, they are prefixed with a class-esque namespace indicating what they do. Like so:
Invocations of the Secure RNG within HASHLIB look like this:
Code Select
csrand_init(); initializes the entropy source internally
csrand_get(); returns a random 32-bit unsigned int
csrand_fill(); fills a buffer to a size with random bytes
Invocations of Hashing look like this:Code Select
hash_ctx hash;
uint8_t out[32];
hash_init(&hash, ALG_NAME) initializes a context of type ALG_NAME
hash_update(&hash, data, len)
hash_final(&hash, out)
hash_mgf1(..., ALG_NAME)
/* Due to the structure of the hash context, the following are
viable alternatives to hash_update and hash_final:
uint8_t out[32];
hash_ctx hash;
hash_init(&hash, SHA256);
hash.update(&hash.Hash, data, len);
hash.final(&hash.Hash, out);
Invocations of HMAC are set up and have the same alternatives as hashing:Code Select
hmac_init()
hmac_update()
hmac_final()
hmac_pbkdf2(..., ALG_NAME)
The AES cipher is invoked like so:Code Select
aes_loadkey()
aes_encrypt()
aes_decrypt()
The RSA cipher is invoked like so:Code Select
rsa_encrypt()
// The RSA encryptor takes a hash ID specifier so that, if other hashes
// are added at some point, they can be used with OAEP internal to RSA.
Digest operations look like this:Code Select
digest_tostring()
digest_compare()
The latest update is available here.
The header has some slight issues in the documentation... stay tuned for a 9.1 update for a fix, but everything works as of v9.
https://github.com/acagliano/hashlib/releases/latest
I am also opening the floor if anyone wants to contribute hashing algorithms. Fast hashes like sha512, sha1 welcome, as well as slower hashes like argon.