Package com.bfo.box

Class C2PA_AssertionHashData

All Implemented Interfaces:
C2PA_Assertion

public class C2PA_AssertionHashData extends CborContainerBox implements C2PA_Assertion
A C2PA Assertion for the "c2pa.hash.data" type
Since:
5
  • Constructor Details

    • C2PA_AssertionHashData

      public C2PA_AssertionHashData()
      Create a new assertion
  • Method Details

    • setExclusions

      public void setExclusions(long[] exclusions)
      Set the exclusion range, a sequence of [start, length] pairs determining which bytes from the InputStream read by verify() to read and which to skip. The list must be in order and must not overlap.
      Parameters:
      exclusions - an even-numbered list of longs, which may be zero length or null
    • setHashAlgorithm

      public void setHashAlgorithm(String alg)
      Set the hash algorithm. If not set, defaults to the C2PAClaim.getHashAlgorithm()
      Parameters:
      alg - the algorithm
    • sign

      public List<C2PAStatus> sign() throws IOException
      Calculate the digest during signing. This assertion retrieves the InputStream from C2PAManifest.getInputStream() and calculates the digest based on that, ignoring any ranges specified in the exclusions. This method is called by C2PASignature.sign() and there should be no need to call it manually.
      Returns:
      a list of failure codes, or an empty list on success
      Throws:
      IOException - if an exception was thrown while calculating the digest
    • verify

      public List<C2PAStatus> verify() throws IOException
      Description copied from interface: C2PA_Assertion
      Verify this assertion, returning a list of status codes describing why this assertion failed or an empty list if it succeeded. The default implementation succeeds, and returns an empty list.
      Specified by:
      verify in interface C2PA_Assertion
      Returns:
      a list of status codes, which may be empty on success
      Throws:
      IOException - if the assertion verification involved I/O and the IO layer threw an exception