public Biff8DecryptingStream(InputStream in, int initialOffset, EncryptionInfo info) throws RecordFormatException { try { byte initialBuf[] = IOUtils.safelyAllocate(initialOffset, MAX_RECORD_LENGTH); InputStream stream; if (initialOffset == 0) { stream = in; } else { stream = new PushbackInputStream(in, initialOffset); ((PushbackInputStream)stream).unread(initialBuf); } Decryptor dec = info.getDecryptor(); dec.setChunkSize(RC4_REKEYING_INTERVAL); ccis = (ChunkedCipherInputStream)dec.getDataStream(stream, Integer.MAX_VALUE, 0); if (initialOffset > 0) { ccis.readFully(initialBuf); } } catch (Exception e) { throw new RecordFormatException(e); } }
public Biff8DecryptingStream(InputStream in, int initialOffset, EncryptionInfo info) throws RecordFormatException { try { byte initialBuf[] = IOUtils.safelyAllocate(initialOffset, MAX_RECORD_LENGTH); InputStream stream; if (initialOffset == 0) { stream = in; } else { stream = new PushbackInputStream(in, initialOffset); ((PushbackInputStream)stream).unread(initialBuf); } Decryptor dec = info.getDecryptor(); dec.setChunkSize(RC4_REKEYING_INTERVAL); ccis = (ChunkedCipherInputStream)dec.getDataStream(stream, Integer.MAX_VALUE, 0); if (initialOffset > 0) { ccis.readFully(initialBuf); } } catch (Exception e) { throw new RecordFormatException(e); } }
protected void decryptRecord(byte[] docstream, int persistId, int offset) { if (dea == null) { return; } Decryptor dec = getEncryptionInfo().getDecryptor(); dec.setChunkSize(-1); try (LittleEndianByteArrayInputStream lei = new LittleEndianByteArrayInputStream(docstream, offset); ChunkedCipherInputStream ccis = (ChunkedCipherInputStream)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); } }
EncryptionInfo ei = new EncryptionInfo(leis, em); Decryptor dec = ei.getDecryptor(); dec.setChunkSize(RC4_REKEYING_INTERVAL); try { String pass = Biff8EncryptionKey.getCurrentUserPassword();