use of org.apache.poi.poifs.crypt.ChunkedCipherInputStream in project poi by apache.
the class HSLFSlideShowEncrypted method decryptPicBytes.
private void decryptPicBytes(byte[] pictstream, int offset, int len) throws IOException, GeneralSecurityException {
// when reading the picture elements, each time a segment is read, the cipher needs
// to be reset (usually done when calling Cipher.doFinal)
LittleEndianByteArrayInputStream lei = new LittleEndianByteArrayInputStream(pictstream, offset);
ChunkedCipherInputStream ccis = dec.getDataStream(lei, len, 0);
readFully(ccis, pictstream, offset, len);
ccis.close();
lei.close();
}
use of org.apache.poi.poifs.crypt.ChunkedCipherInputStream in project poi by apache.
the class HSLFSlideShowEncrypted method decryptRecord.
protected void decryptRecord(byte[] docstream, int persistId, int offset) {
if (dea == null) {
return;
}
decryptInit();
dec.setChunkSize(-1);
// NOSONAR
LittleEndianByteArrayInputStream lei = new LittleEndianByteArrayInputStream(docstream, offset);
ChunkedCipherInputStream ccis = null;
try {
ccis = dec.getDataStream(lei, docstream.length - offset, 0);
ccis.initCipherForBlock(persistId);
// decrypt header and read length to be decrypted
readFully(ccis, docstream, offset, 8);
// decrypt the rest of the record
int rlen = (int) LittleEndian.getUInt(docstream, offset + 4);
readFully(ccis, docstream, offset + 8, rlen);
} catch (Exception e) {
throw new EncryptedPowerPointFileException(e);
} finally {
IOUtils.closeQuietly(ccis);
IOUtils.closeQuietly(lei);
}
}
Aggregations