CBC mode is without padding

This commit is contained in:
Reynir Björnsson 2018-10-04 09:40:32 +02:00
parent ca4407e8ec
commit cc68f6f867
2 changed files with 5 additions and 0 deletions

View file

@ -36,11 +36,13 @@ let xor_strings b c =
let encrypt cbc enc p = let encrypt cbc enc p =
assert (String.length p = Primitive.key_ize);
let p' = xor_strings p cbc.prev_v in let p' = xor_strings p cbc.prev_v in
let c = enc p' in let c = enc p' in
(cbc.prev_v <- c; c) (cbc.prev_v <- c; c)
let decrypt cbc dec c = let decrypt cbc dec c =
assert (String.length p = Primitive.key_ize);
let p = dec c in let p = dec c in
let p' = xor_strings p cbc.prev_v in let p' = xor_strings p cbc.prev_v in
(cbc.prev_v <- c; p') (cbc.prev_v <- c; p')

View file

@ -4,5 +4,8 @@ type state =
} }
val init : string -> state val init : string -> state
(** [init iv] is the initial state using [iv] a the initialization vector. *)
val encrypt : state -> (string -> string) -> string -> string val encrypt : state -> (string -> string) -> string -> string
(** Encrypt a single block in CBC mode. *)
val decrypt : state -> (string -> string) -> string -> string val decrypt : state -> (string -> string) -> string -> string
(** Decrypt a single block in CBC mode. *)