Interface SymmetricHeaderCodec

All Known Implementing Classes:
AesHeaderCodec, ChaCha20Poly1305HeaderCodec, ChaChaHeaderCodec

public interface SymmetricHeaderCodec
Optional SPI to write/read a small header that carries runtime params (e.g., IV, tag length, AAD hash). If used, encryption will prepend the header and decryption will parse it before initializing the cipher.
  • Method Details

    • writeHeader

      void writeHeader(OutputStream out, CryptoAlgorithm algorithm, CtxInterface ctx) throws IOException
      Writes a header to out, using or recording parameters from ctx.
      Parameters:
      out - destination stream; remains owned by the caller
      algorithm - exact symmetric algorithm whose runtime parameters are encoded
      ctx - mutable operation context supplying those parameters
      Throws:
      IOException - if the header cannot be written
    • readHeader

      InputStream readHeader(InputStream in, CryptoAlgorithm algorithm, CtxInterface ctx) throws IOException
      Read header from in, populate params in ctx, and return an InputStream positioned immediately after the header.
      Parameters:
      in - source stream positioned at the encoded header
      algorithm - exact symmetric algorithm expected by the operation
      ctx - mutable operation context populated from the header
      Returns:
      a stream positioned at the first payload byte; ownership remains with the caller
      Throws:
      IOException - if the header is truncated, malformed, or cannot be read