private boolean tryReadHeader() throws IOException {
    ciphertextChannel.position(header.position() + firstSegmentOffset);
    ciphertextChannel.read(header);
    if (header.remaining() > 0) {
      return false;
    } else {
      header.flip();
      try {
        decrypter.init(header, aad);
        headerRead = true;
      } catch (GeneralSecurityException ex) {
        // TODO(bleichen): Define the state of this.
        throw new IOException(ex);
      }
      return true;
    }
  }
Tries to read the header of the ciphertext and derive the key used for the ciphertext from the
information in the header.

@return true if the header was fully read and has a correct format. Returns false if the header
    could not be read.
@throws IOException if the header was incorrectly formatted or if there was an exception during
    the key derivation.
java_src/src/main/java/com/google/crypto/tink/subtle/StreamingAeadSeekableDecryptingChannel.java