Some documentation

This commit is contained in:
Reynir Björnsson 2018-09-09 17:24:43 +02:00
parent 3deea9a0e1
commit ca4407e8ec
2 changed files with 14 additions and 2 deletions

View file

@ -351,10 +351,15 @@ let mds_rem a b =
in in
mds_rem_ab ((Int64.of_int32 a) & 0xFFFFFFFFL) ((Int64.of_int32 b) & 0xFFFFFFFFL) 0 mds_rem_ab ((Int64.of_int32 a) & 0xFFFFFFFFL) ((Int64.of_int32 b) & 0xFFFFFFFFL) 0
let key_size = 32
let init key = let init key =
let keylength = String.length key in let keylength = String.length key in
if keylength != 32 then if keylength != key_size then
failwith ("init: key length must be 32, got key length "^string_of_int (keylength)) failwith (Printf.sprintf
"init: key length must be %d, got key length %d"
key_size
(string_of_int keylength))
else else
let le_longs = unpack_longs key 8 in let le_longs = unpack_longs key 8 in

View file

@ -1,4 +1,11 @@
type ctx type ctx
(** Some context? *)
(* XXX: Is this stateful?? *)
val key_size : int
(** [key_size] is the size of twofish keys. *)
val init : string -> ctx val init : string -> ctx
(** [init key] is the context / state initialized from secret key [key]. *)
val encrypt : ctx -> string -> string val encrypt : ctx -> string -> string
(** [encrypt ctx plain_text] is a single block encrypted with [ctx]. *)
val decrypt : ctx -> string -> string val decrypt : ctx -> string -> string
(** [encrypt ctx cipher_text] is a single block decrypted with [ctx]. *)