@Test public void testFlushDoesNotWriteTagIfNull() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamEncrypterImpl s = new StreamEncrypterImpl(out, cipher, streamNumber, null, streamHeaderNonce, streamHeaderKey, frameKey); s.flush(); ByteArrayOutputStream expected = new ByteArrayOutputStream(); expected.write(streamHeaderNonce); expected.write(protocolVersionBytes); expected.write(streamNumberBytes); expected.write(frameKey.getBytes()); expected.write(new byte[MAC_LENGTH]); assertArrayEquals(expected.toByteArray(), out.toByteArray()); }
@Override public void flush() throws IOException { if (writeTag) writeTag(); if (writeStreamHeader) writeStreamHeader(); out.flush(); }
StreamEncrypterImpl implements StreamEncrypter { @Override public void flush() throws IOException { if (writeTag) writeTag(); if (writeStreamHeader) writeStreamHeader(); out.flush(); } }
StreamEncrypterImpl implements StreamEncrypter { @Override public void flush() throws IOException { if (writeTag) writeTag(); if (writeStreamHeader) writeStreamHeader(); out.flush(); } StreamEncrypterImpl(OutputStream out, AuthenticatedCipher cipher,
			long streamNumber, @Nullable byte[] tag, byte[] streamHeaderNonce,
			SecretKey streamHeaderKey, SecretKey frameKey); }
StreamEncrypterImpl implements StreamEncrypter { @Override public void flush() throws IOException { if (writeTag) writeTag(); if (writeStreamHeader) writeStreamHeader(); out.flush(); } StreamEncrypterImpl(OutputStream out, AuthenticatedCipher cipher,
			long streamNumber, @Nullable byte[] tag, byte[] streamHeaderNonce,
			SecretKey streamHeaderKey, SecretKey frameKey); @Override void writeFrame(byte[] payload, int payloadLength,
			int paddingLength, boolean finalFrame); @Override void flush(); }
StreamEncrypterImpl implements StreamEncrypter { @Override public void flush() throws IOException { if (writeTag) writeTag(); if (writeStreamHeader) writeStreamHeader(); out.flush(); } StreamEncrypterImpl(OutputStream out, AuthenticatedCipher cipher,
			long streamNumber, @Nullable byte[] tag, byte[] streamHeaderNonce,
			SecretKey streamHeaderKey, SecretKey frameKey); @Override void writeFrame(byte[] payload, int payloadLength,
			int paddingLength, boolean finalFrame); @Override void flush();  }