upstream: github.com/robur-coop/kdf
1(** {{:https://tools.ietf.org/html/rfc7914} The scrypt Password-Based Key
2 Derivation Function} specifies the password-based key derivation function
3 scrypt. The function derives one or more secret keys from a secret string.
4 It is based on memory-hard functions which offer added protection against
5 attacks using custom hardware. *)
6
7val derive :
8 password:string ->
9 salt:string ->
10 n:int ->
11 r:int ->
12 p:int ->
13 dk_len:int32 ->
14 string
15(** [derive ~password ~salt ~n ~r ~p ~dk_len] is [dk], the derived key of
16 [dk_len] octets. [n], the cost parameter, must be larger than 1 and a power
17 of 2. [p], the parallelization parameter, must be a possitive integer and
18 less than or equal to 2^32 - 1 / (4 * r)
19 @raise Invalid_argument when either [n], [p] or [dk_len] are not valid. *)