|
Bouncy Castle Cryptography Library 1.77.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.InputStream | +--java.io.FilterInputStream | +--org.bouncycastle.crypto.io.CipherInputStream
A CipherInputStream is composed of an InputStream and a cipher so that read() methods return data that are read in from the underlying InputStream but have been additionally processed by the Cipher. The cipher must be fully initialized before being used by a CipherInputStream.
For example, if the Cipher is initialized for decryption, the CipherInputStream will attempt to read in data and decrypt them, before returning the decrypted data.
Fields inherited from class java.io.FilterInputStream |
in |
Constructor Summary | |
CipherInputStream(java.io.InputStream is,
AEADBlockCipher cipher)
Constructs a CipherInputStream from an InputStream and an AEADBlockCipher. |
|
CipherInputStream(java.io.InputStream is,
AEADBlockCipher cipher,
int bufSize)
Constructs a CipherInputStream from an InputStream, an AEADBlockCipher, and a specified internal buffer size. |
|
CipherInputStream(java.io.InputStream is,
BufferedBlockCipher cipher)
Constructs a CipherInputStream from an InputStream and a BufferedBlockCipher. |
|
CipherInputStream(java.io.InputStream is,
BufferedBlockCipher cipher,
int bufSize)
Constructs a CipherInputStream from an InputStream, a BufferedBlockCipher, and a specified internal buffer size. |
|
CipherInputStream(java.io.InputStream is,
StreamCipher cipher)
Constructs a CipherInputStream from an InputStream and a StreamCipher. |
|
CipherInputStream(java.io.InputStream is,
StreamCipher cipher,
int bufSize)
Constructs a CipherInputStream from an InputStream, a StreamCipher, and a specified internal buffer size. |
Method Summary | |
int |
available()
|
void |
close()
Closes the underlying input stream and finalises the processing of the data by the cipher. |
void |
mark(int readlimit)
Mark the current position. |
boolean |
markSupported()
Return true if mark(readlimit) is supported. |
int |
read()
Reads data from the underlying stream and processes it with the cipher until the cipher outputs data, and returns the next available byte. |
int |
read(byte[] b)
Reads data from the underlying stream and processes it with the cipher until the cipher outputs data, and then returns up to b.length bytes in the provided array. |
int |
read(byte[] b,
int off,
int len)
Reads data from the underlying stream and processes it with the cipher until the cipher outputs data, and then returns up to len bytes in the provided array. |
void |
reset()
Reset to the last marked position, if supported. |
long |
skip(long n)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CipherInputStream(java.io.InputStream is, BufferedBlockCipher cipher)
public CipherInputStream(java.io.InputStream is, StreamCipher cipher)
public CipherInputStream(java.io.InputStream is, AEADBlockCipher cipher)
public CipherInputStream(java.io.InputStream is, BufferedBlockCipher cipher, int bufSize)
public CipherInputStream(java.io.InputStream is, StreamCipher cipher, int bufSize)
public CipherInputStream(java.io.InputStream is, AEADBlockCipher cipher, int bufSize)
Method Detail |
public int read() throws java.io.IOException
If the underlying stream is exhausted by this call, the cipher will be finalised.
read
in class java.io.FilterInputStream
java.io.IOException
- if there was an error closing the input stream.InvalidCipherTextIOException
- if the data read from the stream was invalid ciphertext
(e.g. the cipher is an AEAD cipher and the ciphertext tag check fails).public int read(byte[] b) throws java.io.IOException
If the underlying stream is exhausted by this call, the cipher will be finalised.
read
in class java.io.FilterInputStream
b
- the buffer into which the data is read.java.io.IOException
- if there was an error closing the input stream.InvalidCipherTextIOException
- if the data read from the stream was invalid ciphertext
(e.g. the cipher is an AEAD cipher and the ciphertext tag check fails).public int read(byte[] b, int off, int len) throws java.io.IOException
If the underlying stream is exhausted by this call, the cipher will be finalised.
read
in class java.io.FilterInputStream
b
- the buffer into which the data is read.off
- the start offset in the destination array blen
- the maximum number of bytes read.java.io.IOException
- if there was an error closing the input stream.InvalidCipherTextIOException
- if the data read from the stream was invalid ciphertext
(e.g. the cipher is an AEAD cipher and the ciphertext tag check fails).public long skip(long n) throws java.io.IOException
skip
in class java.io.FilterInputStream
public int available() throws java.io.IOException
available
in class java.io.FilterInputStream
public void close() throws java.io.IOException
close
in class java.io.FilterInputStream
java.io.IOException
- if there was an error closing the input stream.InvalidCipherTextIOException
- if the data read from the stream was invalid ciphertext
(e.g. the cipher is an AEAD cipher and the ciphertext tag check fails).public void mark(int readlimit)
This method only works if markSupported() returns true - which means the underlying stream supports marking, and the cipher passed in to this stream's constructor is a SkippingCipher (so capable of being reset to an arbitrary point easily).
mark
in class java.io.FilterInputStream
readlimit
- the maximum read ahead required before a reset() may be called.public void reset() throws java.io.IOException
reset
in class java.io.FilterInputStream
java.io.IOException
- if marking not supported by the cipher used, or the underlying stream.public boolean markSupported()
markSupported
in class java.io.FilterInputStream
|
Bouncy Castle Cryptography Library 1.77.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |