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

public Class CryptoAPIEncryptor

extends Encryptor
Class Inheritance
Imports
java.io.File, .IOException, .OutputStream, java.security.GeneralSecurityException, .MessageDigest, .SecureRandom, java.util.ArrayList, .List, javax.crypto.Cipher, .SecretKey, org.apache.poi.EncryptedDocumentException, org.apache.poi.poifs.crypt.ChunkedCipherOutputStream, .CryptoFunctions, .EncryptionInfo, .Encryptor, .HashAlgorithm, org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIDecryptor.StreamDescriptorEntry, org.apache.poi.poifs.filesystem.DirectoryNode, .DocumentInputStream, .Entry, .POIFSFileSystem, org.apache.poi.util.IOUtils, .LittleEndian, .RandomSingleton, .StringUtil

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class

Field Summary

Modifier and TypeField and Description
private int
Inherited from org.apache.poi.poifs.crypt.Encryptor:
DEFAULT_POIFS_ENTRY

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

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 CryptoAPIEncryptor
public ChunkedCipherOutputStream
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 CryptoAPIEncryptor.CryptoAPICipherOutputStream
public Cipher

Returns:

a new cipher object, if cipher was null, otherwise the reinitialized cipher
initCipherForBlock
(Cipher
may be null, otherwise the given instance is reset to the new block index
cipher
,
int
the block index, e.g. the persist/slide id (hslf)
block
)

Initializes a cipher object for a given block index for encryption

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.

public void
setSummaryEntries(DirectoryNode dir, String encryptedStream, POIFSFileSystem entries)

Encrypt the Document-/SummaryInformation and other optionally streams.

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

Field Detail

chunkSizeback to summary
private int chunkSize

Constructor Detail

CryptoAPIEncryptorback to summary
pack-priv CryptoAPIEncryptor()
CryptoAPIEncryptorback to summary
pack-priv CryptoAPIEncryptor(CryptoAPIEncryptor 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 CryptoAPIEncryptor copy()

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

Annotations
@Override
getDataStreamback to summary
public ChunkedCipherOutputStream getDataStream(DirectoryNode dir) throws IOException

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:ChunkedCipherOutputStream

encrypted stream

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

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

Annotations
@Override
initCipherForBlockback to summary
public Cipher initCipherForBlock(Cipher cipher, int block) throws GeneralSecurityException

Initializes a cipher object for a given block index for encryption

Parameters
cipher:Cipher

may be null, otherwise the given instance is reset to the new block index

block:int

the block index, e.g. the persist/slide id (hslf)

Returns:Cipher

a new cipher object, if cipher was null, otherwise the reinitialized cipher

Exceptions
GeneralSecurityException:
when the cipher can't be initialized
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
setSummaryEntriesback to summary
public void setSummaryEntries(DirectoryNode dir, String encryptedStream, POIFSFileSystem entries) throws IOException, GeneralSecurityException

Encrypt the Document-/SummaryInformation and other optionally streams. Opposed to other crypto modes, cryptoapi is record based and can't be used to stream-encrypt a whole file

See Also
2.3.5.4 RC4 CryptoAPI Encrypted Summary Stream
org.apache.poi.poifs.crypt.cryptoapi back to summary

protected Class CryptoAPIEncryptor.CryptoAPICipherOutputStream

extends ChunkedCipherOutputStream
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv

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 Cipher
Inherited from org.apache.poi.poifs.crypt.ChunkedCipherOutputStream:
closegetChunkgetChunkMaskgetPlainByteFlagsgetPosgetTotalPosinitCipherForBlockinvokeCiphersetNextRecordSizewritewritewritewritewriteChunkwritePlain

Constructor Detail

CryptoAPICipherOutputStreamback to summary
pack-priv CryptoAPICipherOutputStream(OutputStream stream) 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 IOException, GeneralSecurityException

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

Annotations
@Override
initCipherForBlockNoFlushback to summary
protected Cipher initCipherForBlockNoFlush(Cipher existing, int block, boolean lastChunk) throws GeneralSecurityException

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

Annotations
@Override