Interface DigestContext

All Superinterfaces:
AutoCloseable, Closeable, CryptoContext, TagEngine<byte[]>
All Known Implementing Classes:
JcaDigestContext

public non-sealed interface DigestContext extends TagEngine<byte[]>, CryptoContext
Context for computing unkeyed message digests and extendable-output functions (XOFs) in streaming pipelines.

A DigestContext combines digest/XOF state with the TagEngine contract: the wrapped input stream passes bytes through while updating the computation; at end-of-file, a fixed-length tag is appended (produce mode) or compared with an expected tag (verify mode).

Operation

Usage

Digest trailer


TagEngine<byte[]> eng = TagEngineBuilder.digest(DigestSpec.sha256()).get();
try (java.io.InputStream in = eng.wrap(upstream)) {
    in.transferTo(out);
}

Detached verification


TagEngine<byte[]> eng = TagEngineBuilder.digest(DigestSpec.sha256()).get();
eng.setExpectedTag(expectedDigest);
try (java.io.InputStream in = eng.wrap(bodyWithoutTrailer)) {
    in.transferTo(java.io.OutputStream.nullOutputStream());
}

Security considerations

  • Unkeyed digests do not provide authenticity; use MacContext or SignatureContext for that.
  • For XOFs, choose an output length appropriate for your security level.
  • Implementations are stateful and not guaranteed to be thread-safe.
Since:
1.0