Package org.bouncycastle.bcpg
Class PublicKeyEncSessionPacket
- java.lang.Object
-
- org.bouncycastle.bcpg.Packet
-
- org.bouncycastle.bcpg.ContainedPacket
-
- org.bouncycastle.bcpg.PublicKeyEncSessionPacket
-
- All Implemented Interfaces:
PacketTags,PublicKeyAlgorithmTags,org.bouncycastle.util.Encodable
public class PublicKeyEncSessionPacket extends ContainedPacket implements PublicKeyAlgorithmTags
basic packet for a PGP public key
-
-
Field Summary
Fields Modifier and Type Field Description static intVERSION_3Version 3 PKESK packet.static intVERSION_6Version 6 PKESK packet.-
Fields inherited from interface org.bouncycastle.bcpg.PacketTags
AEAD_ENC_DATA, COMPRESSED_DATA, EXPERIMENTAL_1, EXPERIMENTAL_2, EXPERIMENTAL_3, EXPERIMENTAL_4, LITERAL_DATA, MARKER, MOD_DETECTION_CODE, ONE_PASS_SIGNATURE, PADDING, PUBLIC_KEY, PUBLIC_KEY_ENC_SESSION, PUBLIC_SUBKEY, RESERVED, SECRET_KEY, SECRET_SUBKEY, SIGNATURE, SYM_ENC_INTEGRITY_PRO, SYMMETRIC_KEY_ENC, SYMMETRIC_KEY_ENC_SESSION, TRUST, USER_ATTRIBUTE, USER_ID
-
Fields inherited from interface org.bouncycastle.bcpg.PublicKeyAlgorithmTags
DIFFIE_HELLMAN, DSA, EC, ECDH, ECDSA, Ed25519, Ed448, EDDSA, EDDSA_LEGACY, ELGAMAL_ENCRYPT, ELGAMAL_GENERAL, EXPERIMENTAL_1, EXPERIMENTAL_10, EXPERIMENTAL_11, EXPERIMENTAL_2, EXPERIMENTAL_3, EXPERIMENTAL_4, EXPERIMENTAL_5, EXPERIMENTAL_6, EXPERIMENTAL_7, EXPERIMENTAL_8, EXPERIMENTAL_9, RSA_ENCRYPT, RSA_GENERAL, RSA_SIGN, X25519, X448
-
-
Constructor Summary
Constructors Constructor Description PublicKeyEncSessionPacket(int keyVersion, byte[] keyFingerprint, int algorithm, byte[][] data)Create a new V6 PKESK packet.PublicKeyEncSessionPacket(long keyID, int algorithm, byte[][] data)Create a new V3 PKESK packet.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PublicKeyEncSessionPacketcreateV3PKESKPacket(long keyID, int algorithm, byte[][] data)Create a new V3 PKESK packet.static PublicKeyEncSessionPacketcreateV6PKESKPacket(int keyVersion, byte[] keyFingerprint, int algorithm, byte[][] data)Create a new V6 PKESK packet.voidencode(BCPGOutputStream out)intgetAlgorithm()Return the public key algorithm of the recipient key.byte[][]getEncSessionKey()byte[]getKeyFingerprint()Return the fingerprint of the recipient key.longgetKeyID()Return the id of the recipient key.intgetKeyVersion()Return the version number of the recipient key.intgetVersion()Return the version of this PKESK packet.-
Methods inherited from class org.bouncycastle.bcpg.ContainedPacket
getEncoded
-
Methods inherited from class org.bouncycastle.bcpg.Packet
getPacketTag, isCritical
-
-
-
-
Field Detail
-
VERSION_3
public static final int VERSION_3
- See Also:
- Constant Field Values
-
VERSION_6
public static final int VERSION_6
Version 6 PKESK packet. Used only withV2 SEIPDpackets.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PublicKeyEncSessionPacket
public PublicKeyEncSessionPacket(long keyID, int algorithm, byte[][] data)Create a new V3 PKESK packet.- Parameters:
keyID- ID of the recipient key, 0 for anonymousalgorithm- public key algorithmdata- session data
-
PublicKeyEncSessionPacket
public PublicKeyEncSessionPacket(int keyVersion, byte[] keyFingerprint, int algorithm, byte[][] data)Create a new V6 PKESK packet.- Parameters:
keyVersion- version of the keykeyFingerprint- fingerprint of the keyalgorithm- public key algorithmdata- session data
-
-
Method Detail
-
createV3PKESKPacket
public static PublicKeyEncSessionPacket createV3PKESKPacket(long keyID, int algorithm, byte[][] data)
Create a new V3 PKESK packet.- Parameters:
keyID- ID of the recipient key, 0 for anonymousalgorithm- public key algorithmdata- session data
-
createV6PKESKPacket
public static PublicKeyEncSessionPacket createV6PKESKPacket(int keyVersion, byte[] keyFingerprint, int algorithm, byte[][] data)
Create a new V6 PKESK packet.- Parameters:
keyVersion- version of the keykeyFingerprint- fingerprint of the keyalgorithm- public key algorithmdata- session data
-
getVersion
public int getVersion()
Return the version of this PKESK packet.- Returns:
- version
-
getKeyID
public long getKeyID()
Return the id of the recipient key. V3 PKESK only. TODO: Add conversion from fingerprint to key-id for V6 PKESK?- Returns:
- key id
-
getKeyFingerprint
public byte[] getKeyFingerprint()
Return the fingerprint of the recipient key. If the recipient key is anonymous, this method returns an empty array. V6 PKESK packet only.- Returns:
- key fingerprint
-
getKeyVersion
public int getKeyVersion()
Return the version number of the recipient key. If the recipient key is anonymous, this method returns 0. V6 PKESK packet only.- Returns:
- key version
-
getAlgorithm
public int getAlgorithm()
Return the public key algorithm of the recipient key.- Returns:
- public key algorithm
-
getEncSessionKey
public byte[][] getEncSessionKey()
-
encode
public void encode(BCPGOutputStream out) throws java.io.IOException
- Specified by:
encodein classContainedPacket- Throws:
java.io.IOException
-
-