Top Inners Fields Constructors Methods
org.apache.poi.poifs.crypt.xor

public Class XOREncryptor

extends Encryptor
Class Inheritance
Imports
java.io.File, .IOException, .OutputStream, java.security.GeneralSecurityException, javax.crypto.Cipher, javax.crypto.spec.SecretKeySpec, com.zaxxer.sparsebits.SparseBitSet, org.apache.poi.EncryptedDocumentException, org.apache.poi.poifs.crypt.ChunkedCipherOutputStream, .CryptoFunctions, .Encryptor, org.apache.poi.poifs.filesystem.DirectoryNode, org.apache.poi.util.LittleEndian

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Inherited from org.apache.poi.poifs.crypt.Encryptor:
DEFAULT_POIFS_ENTRY

Constructor Summary

AccessConstructor and Description
protected
protected

Method Summary

Modifier and TypeMethod and Description
public void
public void
confirmPassword(String password, byte[] keySpec, byte[] keySalt, byte[] verifier, byte[] verifierSalt, byte[] integritySalt)

Implements abstract org.apache.poi.poifs.crypt.Encryptor.confirmPassword.

public XOREncryptor
public OutputStream
getDataStream(DirectoryNode
the node to write to
dir
)

Implements abstract org.apache.poi.poifs.crypt.Encryptor.getDataStream.

Return an output stream for encrypted data.

public XOREncryptor.XORCipherOutputStream
protected int
public void
setChunkSize(int
the chunk size, i.e. the block size with the same encryption key
chunkSize
)

Overrides org.apache.poi.poifs.crypt.Encryptor.setChunkSize.

Sets the chunk size of the data stream.

Inherited from org.apache.poi.poifs.crypt.Encryptor:
getDataStreamgetEncryptionInfogetGenericPropertiesgetInstancegetSecretKeysetEncryptionInfosetSecretKey

Constructor Detail

XOREncryptorback to summary
protected XOREncryptor()
XOREncryptorback to summary
protected XOREncryptor(XOREncryptor other)

Method Detail

confirmPasswordback to summary
public void confirmPassword(String password)

Implements abstract org.apache.poi.poifs.crypt.Encryptor.confirmPassword.

Annotations
@Override
confirmPasswordback to summary
public void confirmPassword(String password, byte[] keySpec, byte[] keySalt, byte[] verifier, byte[] verifierSalt, byte[] integritySalt)

Implements abstract org.apache.poi.poifs.crypt.Encryptor.confirmPassword.

Annotations
@Override
copyback to summary
public XOREncryptor copy()

Implements abstract org.apache.poi.poifs.crypt.Encryptor.copy.

Annotations
@Override
getDataStreamback to summary
public OutputStream getDataStream(DirectoryNode dir) throws IOException, GeneralSecurityException

Implements abstract org.apache.poi.poifs.crypt.Encryptor.getDataStream.

Doc from org.apache.poi.poifs.crypt.Encryptor.getDataStream.

Return an output stream for encrypted data.

Parameters
dir:DirectoryNode

the node to write to

Returns:OutputStream

encrypted stream

Annotations
@Override
getDataStreamback to summary
public XOREncryptor.XORCipherOutputStream getDataStream(OutputStream stream, int initialOffset) throws IOException, GeneralSecurityException

Overrides org.apache.poi.poifs.crypt.Encryptor.getDataStream.

Annotations
@Override
getKeySizeInBytesback to summary
protected int getKeySizeInBytes()
setChunkSizeback to summary
public void setChunkSize(int chunkSize)

Overrides org.apache.poi.poifs.crypt.Encryptor.setChunkSize.

Doc from org.apache.poi.poifs.crypt.Encryptor.setChunkSize.

Sets the chunk size of the data stream. Needs to be set before the data stream is requested. When not set, the implementation uses method specific default values

Parameters
chunkSize:int

the chunk size, i.e. the block size with the same encryption key

Annotations
@Override
org.apache.poi.poifs.crypt.xor back to summary

private Class XOREncryptor.XORCipherOutputStream

extends ChunkedCipherOutputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private int
private int

Constructor Summary

AccessConstructor and Description
public
XORCipherOutputStream(OutputStream stream, int initialPos)

public

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
public void
flush()

Overrides java.io.FilterOutputStream.flush.

Implements java.io.Flushable.flush.

Flushes this output stream and forces any buffered output bytes to be written out to the stream.

protected Cipher
protected int
invokeCipher(int posInChunk, boolean doFinal)

Overrides org.apache.poi.poifs.crypt.ChunkedCipherOutputStream.invokeCipher.

Helper function for overriding the cipher invocation, i.e. XOR doesn't use a cipher and uses its own implementation

private byte
rotateLeft(byte bits, int shift)

public void
setNextRecordSize(int
the size of the next record
recordSize
,
boolean
true if the record is unencrypted
isPlain
)

Overrides org.apache.poi.poifs.crypt.ChunkedCipherOutputStream.setNextRecordSize.

Some ciphers (actually just XOR) are based on the record size, which needs to be set before encryption

Inherited from org.apache.poi.poifs.crypt.ChunkedCipherOutputStream:
closegetChunkgetChunkMaskgetPlainByteFlagsgetPosgetTotalPosinitCipherForBlockinitCipherForBlockNoFlushwritewritewritewritewriteChunkwritePlain

Field Detail

recordEndback to summary
private int recordEnd
recordStartback to summary
private int recordStart

Constructor Detail

XORCipherOutputStreamback to summary
public XORCipherOutputStream(OutputStream stream, int initialPos) throws IOException, GeneralSecurityException
XORCipherOutputStreamback to summary
public XORCipherOutputStream(DirectoryNode dir) throws IOException, GeneralSecurityException

Method Detail

calculateChecksumback to summary
protected void calculateChecksum(File file, int i)

Implements abstract org.apache.poi.poifs.crypt.ChunkedCipherOutputStream.calculateChecksum.

Annotations
@Override
createEncryptionInfoEntryback to summary
protected void createEncryptionInfoEntry(DirectoryNode dir, File tmpFile)

Implements abstract org.apache.poi.poifs.crypt.ChunkedCipherOutputStream.createEncryptionInfoEntry.

Annotations
@Override
flushback to summary
public void flush() throws IOException

Overrides java.io.FilterOutputStream.flush.

Implements java.io.Flushable.flush.

Doc from java.io.FilterOutputStream.flush.

Flushes this output stream and forces any buffered output bytes to be written out to the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
initCipherForBlockback to summary
protected Cipher initCipherForBlock(Cipher cipher, int block, boolean lastChunk) throws GeneralSecurityException

Implements abstract org.apache.poi.poifs.crypt.ChunkedCipherOutputStream.initCipherForBlock.

Annotations
@Override
invokeCipherback to summary
protected int invokeCipher(int posInChunk, boolean doFinal)

Overrides org.apache.poi.poifs.crypt.ChunkedCipherOutputStream.invokeCipher.

Doc from org.apache.poi.poifs.crypt.ChunkedCipherOutputStream.invokeCipher.

Helper function for overriding the cipher invocation, i.e. XOR doesn't use a cipher and uses its own implementation

Annotations
@Override
rotateLeftback to summary
private byte rotateLeft(byte bits, int shift)
setNextRecordSizeback to summary
public void setNextRecordSize(int recordSize, boolean isPlain)

Overrides org.apache.poi.poifs.crypt.ChunkedCipherOutputStream.setNextRecordSize.

Doc from org.apache.poi.poifs.crypt.ChunkedCipherOutputStream.setNextRecordSize.

Some ciphers (actually just XOR) are based on the record size, which needs to be set before encryption

Parameters
recordSize:int

the size of the next record

isPlain:boolean

true if the record is unencrypted

Annotations
@Override