All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.io.InputStream | +----java.io.FilterInputStream | +----Acme.Crypto.EncryptedInputStream
This class encapsulates a StreamCipher or BlockCipher as an InputStream. You set up your cipher, pass it and the underlying stream to the EncryptedInputStream constructor, and then read your cleartext from this stream. It gets read from the underlying stream and decrypted. Encryption is done by an EncryptedOutputStream.
When used with a StreamCipher, no input protocol is necessary, each byte of ciphertext turns into one byte of cleartext. When used with a BlockCipher it's more complicated. First, the raw BlockCipher gets encapsulated into a CbcBlockCipher, which needs an initialization vector; so each encrypted stream automatically starts off with such a vector. After that, the stream is a series of (block,bytecount) pairs. Each block of ciphertext is read from the stream, decrypted into a block of cleartext, and then one more byte is read that says how many bytes in the block are valid. Generally the bytecount will be equal to the block size, but it can be less if the stream gets flushed or closed on a partial block.
Fetch the software.
Fetch the entire Acme package.
public EncryptedInputStream(BlockCipher blockCipher, InputStream in)
public EncryptedInputStream(StreamCipher streamCipher, InputStream in)
public void setKey(String keyStr)
public void setDecrypting(boolean decrypting) throws IOException
public int read() throws IOException
public int read(byte b[], int off, int len) throws IOException
All Packages Class Hierarchy This Package Previous Next Index
ACME Java ACME Labs