@Override
    public synchronized void encryptSegment(
        ByteBuffer plaintext, boolean isLastSegment, ByteBuffer ciphertext)
        throws GeneralSecurityException {
      cipher.init(
          Cipher.ENCRYPT_MODE,
          keySpec,
          paramsForSegment(noncePrefix, encryptedSegments, isLastSegment));
      encryptedSegments++;
      cipher.doFinal(plaintext, ciphertext);
    }
Encrypts the next plaintext segment. This uses encryptedSegments as the segment number for
the encryption.
java_src/src/main/java/com/google/crypto/tink/subtle/AesGcmHkdfStreaming.java