Class CipherOutputStreamImpl
java.lang.Object
java.io.OutputStream
org.bouncycastle.crypto.UpdateOutputStream
org.bouncycastle.crypto.CipherOutputStream
org.bouncycastle.crypto.internal.io.CipherOutputStreamImpl
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
A CipherOutputStream is composed of an OutputStream and a cipher so that write() methods process
the written data with the cipher, and the output of the cipher is in turn written to the
underlying OutputStream. The cipher must be fully initialized before being used by a
CipherInputStream.
For example, if the cipher is initialized for encryption, the CipherOutputStream will encrypt the data before writing the encrypted data to the underlying stream.
Note: this class does not close the underlying stream on a close.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stringprotected final booleanprotected final byte[]protected OutputStream -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCipherOutputStreamImpl(String algorithmName, OutputStream out) -
Method Summary
Modifier and TypeMethodDescriptionvoidflush()Flushes this output stream by forcing any buffered output bytes that have already been processed by the encapsulated cipher object to be written out.static CipherOutputStreamgetInstance(OutputStream out, BufferedBlockCipher cipher) static CipherOutputStreamgetInstance(OutputStream out, AEADCipher cipher) static CipherOutputStreamgetInstance(OutputStream out, StreamCipher cipher) voidwrite(byte[] b) Writesb.lengthbytes from the specified byte array to this output stream.voidwrite(int b) Writes the specified byte to this output stream.Methods inherited from class CipherOutputStream
closeMethods inherited from class UpdateOutputStream
finished, update, update, updateMethods inherited from class OutputStream
nullOutputStream, write
-
Field Details
-
algorithmName
-
isApprovedMode
protected final boolean isApprovedMode -
out
-
oneByte
protected final byte[] oneByte
-
-
Constructor Details
-
CipherOutputStreamImpl
-
-
Method Details
-
write
Writes the specified byte to this output stream.- Specified by:
writein classOutputStream- Parameters:
b- thebyte.- Throws:
IOException- if an I/O error occurs.
-
write
Writesb.lengthbytes from the specified byte array to this output stream.The
writemethod ofCipherOutputStreamcalls thewritemethod of three arguments with the three argumentsb,0, andb.length.- Overrides:
writein classOutputStream- Parameters:
b- the data.- Throws:
IOException- if an I/O error occurs.- See Also:
-
flush
Flushes this output stream by forcing any buffered output bytes that have already been processed by the encapsulated cipher object to be written out.Any bytes buffered by the encapsulated cipher and waiting to be processed by it will not be written out. For example, if the encapsulated cipher is a block cipher, and the total number of bytes written using one of the
writemethods is less than the cipher's block size, no bytes will be written out.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- if an I/O error occurs.
-
getInstance
-
getInstance
-
getInstance
-