Construct the encryption key corresponding to secret
.
- raises Invalid_argument
if the length of
secret
is not inkey_sizes
.
encrypt ~key ~iv msg
is msg
encrypted under key
, using iv
as the CBC initialization vector.
- raises Invalid_argument
if
iv
is notblock_size
, ormsg
is notk * block_size
long.
decrypt ~key ~iv msg
is the inverse of encrypt
.
- raises Invalid_argument
if
iv
is notblock_size
, ormsg
is notk * block_size
long.
next_iv ~iv ciphertext
is the first iv
following the encryption that used iv
to produce ciphertext
.
For protocols which perform inter-message chaining, this is the iv
for the next message.
It is either iv
, when len ciphertext = 0
, or the last block of ciphertext
. Note that
encrypt ~iv msg1 || encrypt ~iv:(next_iv ~iv (encrypt ~iv msg1)) msg2
== encrypt ~iv (msg1 || msg2)
- raises Invalid_argument
if the length of
iv
is notblock_size
, or the length ofciphertext
is notk * block_size
for somek
.