Verified Commit a224c804 authored by Vincent Bernardoff's avatar Vincent Bernardoff Committed by Grégoire Henry

Hacl: refactoring

parent 928ee9d3
......@@ -32,7 +32,7 @@ module Rand = struct
end
module Hash = struct
module type S = sig
module type HASH = sig
val init : Bigstring.t -> unit
val update : Bigstring.t -> Bigstring.t -> unit
val update_last : Bigstring.t -> Bigstring.t -> int -> unit
......@@ -43,7 +43,7 @@ module Hash = struct
val statebytes : int
end
module Make(S: S) = struct
module Make(S: HASH) = struct
type state = {
state : Bigstring.t ;
buf : Bigstring.t ;
......@@ -87,6 +87,33 @@ module Hash = struct
finish st
end
module type S = sig
type state
val bytes : int
val blockbytes : int
val statebytes : int
(** Incremental Interface *)
val init : unit -> state
val update : state -> Bigstring.t -> unit
val finish : state -> Bigstring.t
(** Direct Interface *)
val digest : Bigstring.t -> Bigstring.t
module HMAC : sig
val write :
key:Bigstring.t -> msg:Bigstring.t -> Bigstring.t -> unit
(** @raise [Invalid_argument] if argument is less than 32 bytes long *)
val digest :
key:Bigstring.t -> msg:Bigstring.t -> Bigstring.t
end
end
module SHA256 = struct
module H = Make(struct
(* state -> unit *)
......
......@@ -28,7 +28,7 @@ module Rand : sig
end
module Hash : sig
module SHA256 : sig
module type S = sig
type state
val bytes : int
......@@ -55,32 +55,8 @@ module Hash : sig
end
end
module SHA512 : sig
type state
val bytes : int
val blockbytes : int
val statebytes : int
(** Incremental Interface *)
val init : unit -> state
val update : state -> Bigstring.t -> unit
val finish : state -> Bigstring.t
(** Direct Interface *)
val digest : Bigstring.t -> Bigstring.t
module HMAC : sig
val write :
key:Bigstring.t -> msg:Bigstring.t -> Bigstring.t -> unit
(** @raise [Invalid_argument] if argument is less than 32 bytes long *)
val digest :
key:Bigstring.t -> msg:Bigstring.t -> Bigstring.t
end
end
module SHA256 : S
module SHA512 : S
end
module Nonce : sig
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment