File: hkdf.mli

package info (click to toggle)
ocaml-kdf 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 160 kB
  • sloc: ml: 610; ansic: 56; makefile: 3
file content (27 lines) | stat: -rw-r--r-- 1,164 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

(** {{:https://tools.ietf.org/html/rfc5869}RFC 5869} specifies a HMAC-based
    Extract-and-Expand Key Derivation Function (HKDF), which is abstracted over
    a specific hash function. *)

module type S = sig

  (** [extract salt ikm] is [prk], the pseudorandom key of hash length octets.
      The [salt] is an optional non-secret random value, [ikm] the input key
      material. *)
  val extract : ?salt:string -> string -> string

  (** [extract prk info length] is [okm], the output keying material.  Given the
  pseudorandom key of hash length (usually output of [!extract] step), and an
  optional context and application specific information [info], the [okm] is
  generated. *)
  val expand : prk:string -> ?info:string -> int -> string
end

(** Given a Hash function, get the HKDF *)
module Make (H : Digestif.S) : S

(** convenience [extract hash salt ikm] where the [hash] has to be provided explicitly *)
val extract : hash:Digestif.hash' -> ?salt:string -> string -> string

(** convenience [expand hash prk info len] where the [hash] has to be provided explicitly *)
val expand : hash:Digestif.hash' -> prk:string -> ?info:string -> int -> string