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 Summary
Modifier and TypeMethodDescriptionreadHeader(InputStream in, CryptoAlgorithm algorithm, CtxInterface ctx) Read header fromin, populate params inctx, and return an InputStream positioned immediately after the header.voidwriteHeader(OutputStream out, CryptoAlgorithm algorithm, CtxInterface ctx) Writes a header toout, using or recording parameters fromctx.
-
Method Details
-
writeHeader
Writes a header toout, using or recording parameters fromctx.- Parameters:
out- destination stream; remains owned by the calleralgorithm- exact symmetric algorithm whose runtime parameters are encodedctx- 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 fromin, populate params inctx, and return an InputStream positioned immediately after the header.- Parameters:
in- source stream positioned at the encoded headeralgorithm- exact symmetric algorithm expected by the operationctx- 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
-