Class type Padding.scheme
Generic interface of a padding scheme.
method pad : bytes -> int -> unit
pad buf used
is called with a byte arraybuf
containing valid input data at positions0, ..., used-1
. Thepad
method must write padding characters in positionsused
toBytes.length str - 1
. It is guaranteed thatused < Bytes.length str
, so that at least one character of padding must be added. The padding scheme must be unambiguous in the following sense: frombuf
after padding, it must be possible to determineused
unambiguously. (This is what methodCryptokit.Padding.scheme.strip
does.)
method strip : bytes -> int
This is the converse of the
pad
operation: from a padded byte arraybuf
as built by methodpad
,strip buf
determines and returns the starting position of the padding data, or equivalently the length of valid, non-padded input data inbuf
. This method must raiseError Bad_padding
ifbuf
does not have the format of a padded block as produced bypad
.