Package org.apache.poi.poifs.crypt
Class ChunkedCipherInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.apache.poi.util.LittleEndianInputStream
-
- org.apache.poi.poifs.crypt.ChunkedCipherInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,LittleEndianInput
@Internal public abstract class ChunkedCipherInputStream extends LittleEndianInputStream
-
-
Constructor Summary
Constructors Constructor Description ChunkedCipherInputStream(java.io.InputStream stream, long size, int chunkSize)
ChunkedCipherInputStream(java.io.InputStream stream, long size, int chunkSize, int initialPos)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
long
getPos()
javax.crypto.Cipher
initCipherForBlock(int block)
void
mark(int readlimit)
boolean
markSupported()
int
read()
int
read(byte[] b, int off, int len)
void
readPlain(byte[] b, int off, int len)
Used when BIFF header fields (sid, size) are being read.void
reset()
void
setNextRecordSize(int recordSize)
Some ciphers (actually just XOR) are based on the record size, which needs to be set before decryptionlong
skip(long n)
-
Methods inherited from class org.apache.poi.util.LittleEndianInputStream
readByte, readDouble, readFully, readFully, readInt, readLong, readShort, readUByte, readUInt, readUShort
-
-
-
-
Constructor Detail
-
ChunkedCipherInputStream
public ChunkedCipherInputStream(java.io.InputStream stream, long size, int chunkSize) throws java.security.GeneralSecurityException
- Throws:
java.security.GeneralSecurityException
-
ChunkedCipherInputStream
public ChunkedCipherInputStream(java.io.InputStream stream, long size, int chunkSize, int initialPos) throws java.security.GeneralSecurityException
- Throws:
java.security.GeneralSecurityException
-
-
Method Detail
-
initCipherForBlock
public final javax.crypto.Cipher initCipherForBlock(int block) throws java.io.IOException, java.security.GeneralSecurityException
- Throws:
java.io.IOException
java.security.GeneralSecurityException
-
read
public int read() throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
skip
public long skip(long n)
- Overrides:
skip
in classjava.io.FilterInputStream
-
available
public int available()
- Specified by:
available
in interfaceLittleEndianInput
- Overrides:
available
in classLittleEndianInputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.FilterInputStream
-
mark
public void mark(int readlimit)
- Overrides:
mark
in classjava.io.FilterInputStream
-
reset
public void reset()
- Overrides:
reset
in classjava.io.FilterInputStream
-
readPlain
public void readPlain(byte[] b, int off, int len)
Used when BIFF header fields (sid, size) are being read. The internalCipher
instance must step even when unencrypted bytes are read- Specified by:
readPlain
in interfaceLittleEndianInput
- Overrides:
readPlain
in classLittleEndianInputStream
- Parameters:
b
- the byte array to receive the bytesoff
- the start offset into the byte arraylen
- the amount of bytes to fill
-
setNextRecordSize
public void setNextRecordSize(int recordSize)
Some ciphers (actually just XOR) are based on the record size, which needs to be set before decryption- Parameters:
recordSize
- the size of the next record
-
getPos
public long getPos()
- Returns:
- the absolute position in the stream
-
-