Class AbstractPublicKeyDataDecryptorFactory
java.lang.Object
org.bouncycastle.openpgp.operator.AbstractPublicKeyDataDecryptorFactory
- All Implemented Interfaces:
PGPDataDecryptorFactory, PublicKeyDataDecryptorFactory
- Direct Known Subclasses:
AbstractExternalPublicKeyDataDecryptorFactory, BcPublicKeyDataDecryptorFactory
public abstract class AbstractPublicKeyDataDecryptorFactory
extends Object
implements PublicKeyDataDecryptorFactory
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidcheckRange(int pLen, byte[] enc) protected booleancontainsSKAlg(int pkeskVersion) protected static byte[][]parseECDHEncSessionKey(byte[] enc) Parse the encrypted-session-key field of an ECDH (RFC 6637) PKESK packet into the sender's MPI-encoded ephemeral point and the wrapped session key, applying all length checks.protected static byte[][]parseXDHEncSessionKey(byte[] enc, int pLen, boolean containsSKAlg) Parse the algorithm-specific encrypted-session-key field of an X25519 or X448 PKESK packet into the sender's ephemeral public key and the wrapped session key, applying all length checks.protected byte[]prependSKAlgorithmToSessionData(PublicKeyEncSessionPacket pkesk, InputStreamPacket encData, byte[] decryptedSessionData) byte[]recoverSessionData(int keyAlgorithm, byte[][] secKeyData) Recover the plain session info by decrypting the encrypted session key.final byte[]recoverSessionData(PublicKeyEncSessionPacket pkesk, InputStreamPacket encData) Recover the plain session info by decrypting the encrypted session key.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PGPDataDecryptorFactory
createDataDecryptor, createDataDecryptor, createDataDecryptorMethods inherited from interface PublicKeyDataDecryptorFactory
recoverSessionData
-
Constructor Details
-
AbstractPublicKeyDataDecryptorFactory
public AbstractPublicKeyDataDecryptorFactory()
-
-
Method Details
-
recoverSessionData
public final byte[] recoverSessionData(PublicKeyEncSessionPacket pkesk, InputStreamPacket encData) throws PGPException Description copied from interface:PublicKeyDataDecryptorFactoryRecover the plain session info by decrypting the encrypted session key. The session info ALWAYS has the symmetric algorithm ID prefixed, so the return value is:[sym-alg][session-key][checksum]?
- Specified by:
recoverSessionDatain interfacePublicKeyDataDecryptorFactory- Parameters:
pkesk- public-key encrypted session-key packetencData- encrypted data (sed/seipd/oed) packet- Returns:
- decrypted session info
- Throws:
PGPException
-
recoverSessionData
Description copied from interface:PublicKeyDataDecryptorFactoryRecover the plain session info by decrypting the encrypted session key. This method returns the decrypted session info as-is (without prefixing missing cipher algorithm), so the return value is:[sym-alg]?[session-key][checksum]?
- Specified by:
recoverSessionDatain interfacePublicKeyDataDecryptorFactory- Parameters:
keyAlgorithm- public key algorithmsecKeyData- encrypted session key data- Returns:
- decrypted session info
- Throws:
PGPException
-
prependSKAlgorithmToSessionData
protected byte[] prependSKAlgorithmToSessionData(PublicKeyEncSessionPacket pkesk, InputStreamPacket encData, byte[] decryptedSessionData) throws PGPException - Throws:
PGPException
-
containsSKAlg
protected boolean containsSKAlg(int pkeskVersion) -
checkRange
- Throws:
PGPException
-
parseXDHEncSessionKey
protected static byte[][] parseXDHEncSessionKey(byte[] enc, int pLen, boolean containsSKAlg) throws PGPException Parse the algorithm-specific encrypted-session-key field of an X25519 or X448 PKESK packet into the sender's ephemeral public key and the wrapped session key, applying all length checks. Shared so every decryptor factory applies exactly the same checks.- Parameters:
enc- the PKESK's encrypted session key datapLen- length in octets of the ephemeral public key (32 for X25519, 56 for X448)containsSKAlg- whether the packet version carries the symmetric-key algorithm octet (v3)- Returns:
- a two-element array of the ephemeral public key and the wrapped session key
- Throws:
PGPException- if the data is shorter than its declared lengths require
-
parseECDHEncSessionKey
Parse the encrypted-session-key field of an ECDH (RFC 6637) PKESK packet into the sender's MPI-encoded ephemeral point and the wrapped session key, applying all length checks. Shared so every decryptor factory applies exactly the same checks.- Parameters:
enc- the PKESK's encrypted session key data- Returns:
- a two-element array of the encoded ephemeral point and the wrapped session key
- Throws:
PGPException- if the data is shorter than its declared lengths require
-