Class CryptoAPIDecryptor
java.lang.Object
org.docx4j.org.apache.poi.poifs.crypt.Decryptor
org.docx4j.org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIDecryptor
-
Field Summary
Fields inherited from class org.docx4j.org.apache.poi.poifs.crypt.Decryptor
builder, DEFAULT_PASSWORD, DEFAULT_POIFS_ENTRY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptionprotected static SecretKeygenerateSecretKey(String password, EncryptionVerifier ver) Decrypt the Document-/SummaryInformation and other optionally streams.longReturns the length of the encrypted data that can be safely read withDecryptor.getDataStream(org.docx4j.org.apache.poi.poifs.filesystem.DirectoryNode).initCipherForBlock(Cipher cipher, int block) Initializes a cipher object for a given block index for decryptionprotected static CipherinitCipherForBlock(Cipher cipher, int block, EncryptionInfoBuilder builder, SecretKey skey, int encryptMode) booleanverifyPassword(String password) Methods inherited from class org.docx4j.org.apache.poi.poifs.crypt.Decryptor
getBlockSizeInBytes, getDataStream, getDataStream, getDataStream, getInstance, getIntegrityHmacKey, getIntegrityHmacValue, getKeySizeInBytes, getSecretKey, getVerifier, setIntegrityHmacKey, setIntegrityHmacValue, setSecretKey, setVerifier
-
Constructor Details
-
CryptoAPIDecryptor
-
-
Method Details
-
verifyPassword
- Specified by:
verifyPasswordin classDecryptor
-
initCipherForBlock
Initializes a cipher object for a given block index for decryption- Parameters:
cipher- may be null, otherwise the given instance is reset to the new block indexblock- the block index, e.g. the persist/slide id (hslf)- Returns:
- a new cipher object, if cipher was null, otherwise the reinitialized cipher
- Throws:
GeneralSecurityException
-
initCipherForBlock
protected static Cipher initCipherForBlock(Cipher cipher, int block, EncryptionInfoBuilder builder, SecretKey skey, int encryptMode) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
generateSecretKey
-
getDataStream
Decrypt the Document-/SummaryInformation and other optionally streams. Opposed to other crypto modes, cryptoapi is record based and can't be used to stream-decrypt a whole file- Specified by:
getDataStreamin classDecryptor- Parameters:
dir- the node to read from- Returns:
- decrypted stream
- Throws:
IOExceptionGeneralSecurityException- See Also:
-
getLength
public long getLength()Description copied from class:DecryptorReturns the length of the encrypted data that can be safely read withDecryptor.getDataStream(org.docx4j.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 discardedThe length variable is initialized in
Decryptor.getDataStream(org.docx4j.org.apache.poi.poifs.filesystem.DirectoryNode), an attempt to call getLength() prior to getDataStream() will result in IllegalStateException.- Specified by:
getLengthin classDecryptor- Returns:
- the length of the stream returned by
getDataStream(DirectoryNode)
-