package cryptokit

  1. Overview
  2. Docs

Generic interface of a padding scheme.

method pad : bytes -> int -> unit

pad buf used is called with a byte array buf containing valid input data at positions 0, ..., used-1. The pad method must write padding characters in positions used to Bytes.length str - 1. It is guaranteed that used < Bytes.length str, so that at least one character of padding must be added. The padding scheme must be unambiguous in the following sense: from buf after padding, it must be possible to determine used unambiguously. (This is what method Cryptokit.Padding.scheme.strip does.)

method strip : bytes -> int

This is the converse of the pad operation: from a padded byte array buf as built by method pad, strip buf determines and returns the starting position of the padding data, or equivalently the length of valid, non-padded input data in buf. This method must raise Error Bad_padding if buf does not have the format of a padded block as produced by pad.

OCaml

Innovation. Community. Security.