Package org.bouncycastle.openpgp
Class PGPEncryptedDataList
java.lang.Object
org.bouncycastle.openpgp.PGPEncryptedDataList
- All Implemented Interfaces:
Iterable<PGPEncryptedData>,org.bouncycastle.util.Iterable<PGPEncryptedData>
public class PGPEncryptedDataList
extends Object
implements org.bouncycastle.util.Iterable<PGPEncryptedData>
A holder for a list of PGP encryption method packets and the encrypted data associated with them.
This holder supports reading a sequence of the following encryption methods, followed by an encrypted data packet:
PacketTags.SYMMETRIC_KEY_ENC_SESSION- produces aPGPPBEEncryptedDataPacketTags.PUBLIC_KEY_ENC_SESSION- produces aPGPPublicKeyEncryptedData
All of the objects returned from this holder share a reference to the same encrypted data input stream, which can only be consumed once.
-
Constructor Summary
ConstructorsConstructorDescriptionPGPEncryptedDataList(byte[] encData) Construct an encrypted data packet holder, reading PGP encrypted method packets and an encrypted data packet from a stream.PGPEncryptedDataList(InputStream inStream) Construct an encrypted data packet holder, reading PGP encrypted method packets and an encrypted data packet from a stream.Construct an encrypted data packet holder, reading PGP encrypted method packets and an encrypted data packet from the stream. -
Method Summary
Modifier and TypeMethodDescriptionCreate a decryption method using aPGPSessionKey.get(int index) Gets the encryption method object at the specified index.Returns an iterator over the encryption method objects held in this list, in the order they appeared in the stream they are read from.booleanisEmpty()Returnstrueiff there are 0 encryption methods in this list.booleanChecks whether the packet is integrity protected.iterator()Support method for Iterable where available.intsize()Gets the number of encryption methods in this list.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
PGPEncryptedDataList
Construct an encrypted data packet holder, reading PGP encrypted method packets and an encrypted data packet from a stream.The first packet in the stream should be one of
PacketTags.SYMMETRIC_KEY_ENC_SESSIONorPacketTags.PUBLIC_KEY_ENC_SESSION.- Parameters:
encData- a byte array containing an encrypted stream.- Throws:
IOException- if an error occurs reading from the PGP input.
-
PGPEncryptedDataList
Construct an encrypted data packet holder, reading PGP encrypted method packets and an encrypted data packet from a stream.The first packet in the stream should be one of
PacketTags.SYMMETRIC_KEY_ENC_SESSIONorPacketTags.PUBLIC_KEY_ENC_SESSION.- Parameters:
inStream- the input stream being read.- Throws:
IOException- if an error occurs reading from the PGP input.
-
PGPEncryptedDataList
Construct an encrypted data packet holder, reading PGP encrypted method packets and an encrypted data packet from the stream.The next packet in the stream should be one of
PacketTags.SYMMETRIC_KEY_ENC_SESSIONorPacketTags.PUBLIC_KEY_ENC_SESSION.- Parameters:
pIn- the PGP object stream being read.- Throws:
IOException- if an error occurs reading from the PGP input.
-
-
Method Details
-
isIntegrityProtected
public boolean isIntegrityProtected()Checks whether the packet is integrity protected.- Returns:
trueif there is a modification detection code package associated with this stream
-
get
Gets the encryption method object at the specified index.- Parameters:
index- the encryption method to obtain (0 based).
-
size
public int size()Gets the number of encryption methods in this list. -
isEmpty
public boolean isEmpty()Returnstrueiff there are 0 encryption methods in this list. -
getEncryptedDataObjects
Returns an iterator over the encryption method objects held in this list, in the order they appeared in the stream they are read from. -
iterator
Support method for Iterable where available.- Specified by:
iteratorin interfaceIterable<PGPEncryptedData>- Specified by:
iteratorin interfaceorg.bouncycastle.util.Iterable<PGPEncryptedData>
-
extractSessionKeyEncryptedData
Create a decryption method using aPGPSessionKey. This method can be used to decrypt messages which do not contain a SKESK or PKESK packet using a session key.- Returns:
- session key encrypted data
-