Top Description Inners Fields Constructors Methods
org.apache.poi.poifs.crypt.agile

public Class AgileDecryptor

extends Decryptor
Class Inheritance
Static Imports
org.apache.poi.poifs.crypt.CryptoFunctions.generateIv, .CryptoFunctions.generateKey, .CryptoFunctions.getBlock0, .CryptoFunctions.getCipher, .CryptoFunctions.getMessageDigest, .CryptoFunctions.hashPassword

Decryptor implementation for Agile Encryption

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
AgileDecryptor.AgileCipherInputStream

2.3.4.15 Data Encryption (Agile Encryption) The EncryptedPackage stream (1) MUST be encrypted in 4096-byte segments to facilitate nearly random access while allowing CBC modes to be used in the encryption process.

Field Summary

Modifier and TypeField and Description
private long
pack-priv static final byte[]
pack-priv static final byte[]
pack-priv static final byte[]
pack-priv static final byte[]
pack-priv static final byte[]
Inherited from org.apache.poi.poifs.crypt.Decryptor:
DEFAULT_PASSWORDDEFAULT_POIFS_ENTRYencryptionInfo

Constructor Summary

AccessConstructor and Description
protected
protected

Method Summary

Modifier and TypeMethod and Description
public AgileDecryptor
public InputStream
getDataStream(DirectoryNode
the node to read from
dir
)

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

Return a stream with decrypted data.

public long
getLength()

Implements abstract org.apache.poi.poifs.crypt.Decryptor.getLength.

Returns the length of the encrypted data that can be safely read with getDataStream(org.apache.poi.poifs.filesystem.DirectoryNode).

protected static int
getNextBlockSize(int inputLen, int blockSize)

pack-priv static byte[]
hashInput(AgileEncryptionVerifier ver, byte[] pwHash, byte[] blockKey, byte[] inputKey, int cipherMode)

protected static Cipher
initCipherForBlock(Cipher existing, int block, boolean lastChunk, EncryptionInfo encryptionInfo, SecretKey skey, int encryptionMode)

private static byte[]
longToBytes(long l)

public boolean
verifyPassword(String password)

Implements abstract org.apache.poi.poifs.crypt.Decryptor.verifyPassword.

set decryption password

Inherited from org.apache.poi.poifs.crypt.Decryptor:
getBlockSizeInBytesgetDataStreamgetDataStreamgetEncryptionInfogetGenericPropertiesgetInstancegetIntegrityHmacKeygetIntegrityHmacValuegetKeySizeInBytesgetSecretKeygetVerifierinitCipherForBlocksetChunkSizesetEncryptionInfosetIntegrityHmacKeysetIntegrityHmacValuesetSecretKeysetVerifier

Field Detail

_lengthback to summary
private long _length
kCryptoKeyBlockback to summary
pack-priv static final byte[] kCryptoKeyBlock
kHashedVerifierBlockback to summary
pack-priv static final byte[] kHashedVerifierBlock
kIntegrityKeyBlockback to summary
pack-priv static final byte[] kIntegrityKeyBlock
kIntegrityValueBlockback to summary
pack-priv static final byte[] kIntegrityValueBlock
kVerifierInputBlockback to summary
pack-priv static final byte[] kVerifierInputBlock

Constructor Detail

AgileDecryptorback to summary
protected AgileDecryptor()
AgileDecryptorback to summary
protected AgileDecryptor(AgileDecryptor other)

Method Detail

copyback to summary
public AgileDecryptor copy()

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

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

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

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

Return a stream with decrypted data.

Use getLength() to get the size of that data that can be safely read from the stream. Just reading to the end of the input stream is not sufficient because there are normally padding bytes that must be discarded

Parameters
dir:DirectoryNode

the node to read from

Returns:InputStream

decrypted stream

Annotations
@SuppressWarnings:java:S2095
@Override
getLengthback to summary
public long getLength()

Implements abstract org.apache.poi.poifs.crypt.Decryptor.getLength.

Doc from org.apache.poi.poifs.crypt.Decryptor.getLength.

Returns the length of the encrypted data that can be safely read with getDataStream(org.apache.poi.poifs.filesystem.DirectoryNode). Just reading to the end of the input stream is not sufficient because there are normally padding bytes that must be discarded

The length variable is initialized in getDataStream(org.apache.poi.poifs.filesystem.DirectoryNode), an attempt to call getLength() prior to getDataStream() will result in IllegalStateException.

Returns:long

length of the encrypted data

Annotations
@Override
getNextBlockSizeback to summary
protected static int getNextBlockSize(int inputLen, int blockSize)
hashInputback to summary
pack-priv static byte[] hashInput(AgileEncryptionVerifier ver, byte[] pwHash, byte[] blockKey, byte[] inputKey, int cipherMode)
initCipherForBlockback to summary
protected static Cipher initCipherForBlock(Cipher existing, int block, boolean lastChunk, EncryptionInfo encryptionInfo, SecretKey skey, int encryptionMode) throws GeneralSecurityException
longToBytesback to summary
private static byte[] longToBytes(long l)
verifyPasswordback to summary
public boolean verifyPassword(String password) throws GeneralSecurityException

Implements abstract org.apache.poi.poifs.crypt.Decryptor.verifyPassword.

set decryption password

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

private Class AgileDecryptor.AgileCipherInputStream

extends ChunkedCipherInputStream
Class Inheritance

2.3.4.15 Data Encryption (Agile Encryption) The EncryptedPackage stream (1) MUST be encrypted in 4096-byte segments to facilitate nearly random access while allowing CBC modes to be used in the encryption process. The initialization vector for the encryption process MUST be obtained by using the zero-based segment number as a blockKey and the binary form of the KeyData.saltValue as specified in section 2.3.4.12. The block number MUST be represented as a 32-bit unsigned integer. Data blocks MUST then be encrypted by using the initialization vector and the intermediate key obtained by decrypting the encryptedKeyValue from a KeyEncryptor contained within the KeyEncryptors sequence as specified in section 2.3.4.10. The final data block MUST be padded to the next integral multiple of the KeyData.blockSize value. Any padding bytes can be used. Note that the StreamSize field of the EncryptedPackage field specifies the number of bytes of unencrypted data as specified in section 2.3.4.4.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Cipher
Inherited from org.apache.poi.poifs.crypt.ChunkedCipherInputStream:
availablegetChunkgetChunkMaskgetPlaingetPosinitCipherForBlockinvokeCiphermarkmarkSupportedreadreadreadPlainresetsetNextRecordSizeskip

Constructor Detail

AgileCipherInputStreamback to summary
public AgileCipherInputStream(DocumentInputStream stream, long size) throws GeneralSecurityException

Method Detail

initCipherForBlockback to summary
protected Cipher initCipherForBlock(Cipher cipher, int block) throws GeneralSecurityException

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

Annotations
@Override