Skip to content

Commit

Permalink
Implement recoverSessionKey(pkesk, encData) in AbstractPublicKeyDataD…
Browse files Browse the repository at this point in the history
…ecryptorFactory
  • Loading branch information
vanitasvitae committed Sep 10, 2024
1 parent 8ffaaba commit 398c845
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ public abstract class AbstractPublicKeyDataDecryptorFactory
implements PublicKeyDataDecryptorFactory
{

@Override
public final byte[] recoverSessionData(PublicKeyEncSessionPacket pkesk, InputStreamPacket encData)
throws PGPException
{
byte[] sessionData = recoverSessionData(pkesk.getAlgorithm(), pkesk.getEncSessionKey(), pkesk.getVersion());
return prependSKAlgorithmToSessionData(pkesk, encData, sessionData);
}


protected byte[] prependSKAlgorithmToSessionData(PublicKeyEncSessionPacket pkesk,
InputStreamPacket encData,
byte[] decryptedSessionData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ public BcPublicKeyDataDecryptorFactory(PGPPrivateKey pgpPrivKey)
this.pgpPrivKey = pgpPrivKey;
}

public byte[] recoverSessionData(PublicKeyEncSessionPacket pkesk, InputStreamPacket encData)
throws PGPException
{
byte[] sessionData = recoverSessionData(pkesk.getAlgorithm(), pkesk.getEncSessionKey(), pkesk.getVersion());
return prependSKAlgorithmToSessionData(pkesk, encData, sessionData);
}

@Override
public byte[] recoverSessionData(int keyAlgorithm, byte[][] secKeyData, int pkeskVersion)
throws PGPException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
import org.bouncycastle.asn1.x9.X9ECParametersHolder;
import org.bouncycastle.bcpg.AEADEncDataPacket;
import org.bouncycastle.bcpg.ECDHPublicBCPGKey;
import org.bouncycastle.bcpg.InputStreamPacket;
import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
import org.bouncycastle.bcpg.PublicKeyEncSessionPacket;
import org.bouncycastle.bcpg.PublicKeyPacket;
import org.bouncycastle.bcpg.SymmetricEncIntegrityPacket;
import org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags;
Expand Down Expand Up @@ -134,14 +132,6 @@ public PublicKeyDataDecryptorFactory build(final PrivateKey privKey)
{
final int expectedPayLoadSize = getExpectedPayloadSize(privKey);

@Override
public byte[] recoverSessionData(PublicKeyEncSessionPacket pkesk, InputStreamPacket encData)
throws PGPException
{
byte[] sessionData = recoverSessionData(pkesk.getAlgorithm(), pkesk.getEncSessionKey(), pkesk.getVersion());
return prependSKAlgorithmToSessionData(pkesk, encData, sessionData);
}

@Override
public byte[] recoverSessionData(int keyAlgorithm, byte[][] secKeyData, int pkeskVersion)
throws PGPException
Expand Down Expand Up @@ -183,14 +173,6 @@ public PublicKeyDataDecryptorFactory build(final PGPPrivateKey privKey)
{
return new AbstractPublicKeyDataDecryptorFactory()
{
@Override
public byte[] recoverSessionData(PublicKeyEncSessionPacket pkesk, InputStreamPacket encData)
throws PGPException
{
byte[] sessionData = recoverSessionData(pkesk.getAlgorithm(), pkesk.getEncSessionKey(), pkesk.getVersion());
return prependSKAlgorithmToSessionData(pkesk, encData, sessionData);
}

@Override
public byte[] recoverSessionData(int keyAlgorithm, byte[][] secKeyData, int pkeskVersion)
throws PGPException
Expand Down

0 comments on commit 398c845

Please sign in to comment.