upstream: https://github.com/mirage/mirage-crypto
at main 46 lines 1.3 kB view raw
1(** Poly1305 message authentication code. *) 2 3(** The signature of a Poly1305 MAC. *) 4module type S = sig 5 type 'a iter = 'a Uncommon.iter 6 (** An iterator. *) 7 8 type t 9 (** MAC computation state. *) 10 11 val mac_size : int 12 (** The MAC output size in bytes. *) 13 14 val empty : key:string -> t 15 (** [empty ~key] is a fresh MAC state keyed with [key]. 16 17 @raise Invalid_argument if [key] is not 32 bytes. *) 18 19 val feed : t -> string -> t 20 (** [feed t data] feeds [data] into [t]. *) 21 22 val feedi : t -> string iter -> t 23 (** [feedi t iter] feeds an iterator of strings into [t]. *) 24 25 val get : t -> string 26 (** [get t] finalises and returns the MAC. *) 27 28 val mac : key:string -> string -> string 29 (** [mac ~key data] is the MAC of [data] under [key]. *) 30 31 val maci : key:string -> string iter -> string 32 (** [maci ~key iter] is the MAC of the concatenation of strings from [iter]. 33 *) 34 35 val mac_into : 36 key:string -> (string * int * int) list -> bytes -> dst_off:int -> unit 37 (** [mac_into ~key datas dst ~dst_off] computes the MAC of [datas] into [dst] 38 at [dst_off] with bounds checking. *) 39 40 val unsafe_mac_into : 41 key:string -> (string * int * int) list -> bytes -> dst_off:int -> unit 42 (** Like {!mac_into} without bounds checking. *) 43end 44 45module It : S 46(** Poly1305 MAC using the C implementation. *)