public class XORDecryptor extends Decryptor
DEFAULT_PASSWORD, DEFAULT_POIFS_ENTRY, encryptionInfo
Modifier | Constructor and Description |
---|---|
protected |
XORDecryptor() |
protected |
XORDecryptor(XORDecryptor other) |
Modifier and Type | Method and Description |
---|---|
XORDecryptor |
copy() |
ChunkedCipherInputStream |
getDataStream(DirectoryNode dir)
Return a stream with decrypted data.
(返回带有解密数据的流。)
|
java.io.InputStream |
getDataStream(java.io.InputStream stream, int size, int initialPos)
Wraps a stream for decryption
(包装用于解密的流)
|
long |
getLength()
Returns the length of the encrypted data that can be safely read with
Decryptor.getDataStream(org.apache.poi.poifs.filesystem.DirectoryNode) .
(返回可以使用 Decryptor.getDataStream(org.apache.poi.poifs.filesystem.DirectoryNode) 安全读取的加密数据的长度。)
|
javax.crypto.Cipher |
initCipherForBlock(javax.crypto.Cipher cipher, int block)
Initializes a cipher object for a given block index for encryption
(为给定的块索引初始化密码对象以进行加密)
|
protected static javax.crypto.Cipher |
initCipherForBlock(javax.crypto.Cipher cipher, int block, EncryptionInfo encryptionInfo, javax.crypto.SecretKey skey, int encryptMode) |
void |
setChunkSize(int chunkSize)
Sets the chunk size of the data stream.
(设置数据流的块大小。)
|
boolean |
verifyPassword(java.lang.String password) |
getBlockSizeInBytes, getDataStream, getEncryptionInfo, getGenericProperties, getInstance, getIntegrityHmacKey, getIntegrityHmacValue, getKeySizeInBytes, getSecretKey, getVerifier, setEncryptionInfo, setIntegrityHmacKey, setIntegrityHmacValue, setSecretKey, setVerifier
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getGenericChildren, getGenericRecordType
protected XORDecryptor()
protected XORDecryptor(XORDecryptor other)
public boolean verifyPassword(java.lang.String password)
verifyPassword
in class
Decryptor
(类 Decryptor 中的 verifyPassword)
public javax.crypto.Cipher initCipherForBlock(javax.crypto.Cipher cipher, int block) throws java.security.GeneralSecurityException
Decryptor
initCipherForBlock
in class
Decryptor
cipher
- may be null, otherwise the given instance is reset to the new block index
(cipher - 可以为空,否则给定的实例被重置为新的块索引)
block
- the block index, e.g. the persist/slide id (hslf)
(block - 块索引,例如持久化/幻灯片 id (hslf))
java.security.GeneralSecurityException
- if the cipher can't be initialized
(java.security.GeneralSecurityException - 如果密码无法初始化)
protected static javax.crypto.Cipher initCipherForBlock(javax.crypto.Cipher cipher, int block, EncryptionInfo encryptionInfo, javax.crypto.SecretKey skey, int encryptMode) throws java.security.GeneralSecurityException
java.security.GeneralSecurityException
(java.security.GeneralSecurityException)
public ChunkedCipherInputStream getDataStream(DirectoryNode dir) throws java.io.IOException, java.security.GeneralSecurityException
Decryptor
Use Decryptor.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
getDataStream
in class
Decryptor
(类 Decryptor 中的 getDataStream)
dir
- the node to read from
(dir - 要读取的节点)
java.io.IOException
(java.io.IOException)
java.security.GeneralSecurityException
(java.security.GeneralSecurityException)
public java.io.InputStream getDataStream(java.io.InputStream stream, int size, int initialPos) throws java.io.IOException, java.security.GeneralSecurityException
Decryptor
As we are handling streams and don't know the total length beforehand, it's the callers duty to care for the length of the entries.
(包装用于解密的流由于我们正在处理流并且事先不知道总长度,因此调用者有责任关心条目的长度。)getDataStream
in class
Decryptor
stream
- the stream to be wrapped
(stream - 要包装的流)
initialPos
- initial/current byte position within the stream
(initialPos - 流中的初始/当前字节位置)
java.io.IOException
(java.io.IOException)
java.security.GeneralSecurityException
(java.security.GeneralSecurityException)
public long getLength()
Decryptor
Decryptor.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 Decryptor.getDataStream(org.apache.poi.poifs.filesystem.DirectoryNode)
, an attempt to call getLength() prior to getDataStream() will result in IllegalStateException.
public void setChunkSize(int chunkSize)
Decryptor
setChunkSize
in class
Decryptor
chunkSize
- the chunk size, i.e. the block size with the same encryption key
(chunkSize - 块大小,即具有相同加密密钥的块大小)
public XORDecryptor copy()
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.