View Source Tezex.Crypto.HMACDRBG (tezex v3.0.1)
Pure Elixir implementation of HMAC-DRBG
Usage:
entropy = "totally random0123456789"
nonce = "some secret nonce"
pers = "my drbg"
drbg = HMACDRBG.init(entropy, nonce, pers)
{_result, drbg} = HMACDRBG.generate(drbg, 32)
{_result, drbg} = HMACDRBG.generate(drbg, 32)
{result, drbg} = HMACDRBG.generate(drbg, 32)
Base16.encode(result, case: :lower) == "a00cb0982eec3917b4b48abccfd460366d98b887943ff402bb7147cda174a46f"
Implementation inspired by both:
https://github.com/indutny/hmac-drbg/blob/master/package.json
MIT / (c) Fedor Indutny fedor@indutny.com
https://github.com/sorpaas/rust-hmac-drbg/blob/master/src/lib.rs
Apache License, Version 2.0, January 2004 / Copyright {yyyy} {name of copyright owner}
Summary
Functions
Generate size
bytes, returning the generated bytes and the updated DRBG
Initialize a DRBG
Reseed a DRBG
Types
@type hash_algo() ::
:sha
| :sha224
| :sha256
| :sha384
| :sha512
| :sha3_224
| :sha3_256
| :sha3_384
| :sha3_512
@type t() :: %Tezex.Crypto.HMACDRBG{ algo: hash_algo(), count: non_neg_integer(), k: binary(), v: binary() }
Functions
@spec generate(t(), pos_integer(), binary() | nil) :: {binary(), t()}
Generate size
bytes, returning the generated bytes and the updated DRBG
Initialize a DRBG
Reseed a DRBG