mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-15 21:29:38 +02:00
Apply fix for session key decryption of messages without ESKs
Requires BC 172
This commit is contained in:
parent
8dfabf1842
commit
4132644cc6
1 changed files with 5 additions and 16 deletions
|
@ -34,6 +34,7 @@ import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKey;
|
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPSessionKey;
|
import org.bouncycastle.openpgp.PGPSessionKey;
|
||||||
|
import org.bouncycastle.openpgp.PGPSessionKeyEncryptedData;
|
||||||
import org.bouncycastle.openpgp.PGPSignature;
|
import org.bouncycastle.openpgp.PGPSignature;
|
||||||
import org.bouncycastle.openpgp.PGPSignatureList;
|
import org.bouncycastle.openpgp.PGPSignatureList;
|
||||||
import org.bouncycastle.openpgp.PGPUtil;
|
import org.bouncycastle.openpgp.PGPUtil;
|
||||||
|
@ -259,25 +260,13 @@ public final class DecryptionStreamFactory {
|
||||||
PGPSessionKey pgpSessionKey = new PGPSessionKey(sessionKey.getAlgorithm().getAlgorithmId(), sessionKey.getKey());
|
PGPSessionKey pgpSessionKey = new PGPSessionKey(sessionKey.getAlgorithm().getAlgorithmId(), sessionKey.getKey());
|
||||||
SessionKeyDataDecryptorFactory decryptorFactory =
|
SessionKeyDataDecryptorFactory decryptorFactory =
|
||||||
ImplementationFactory.getInstance().provideSessionKeyDataDecryptorFactory(pgpSessionKey);
|
ImplementationFactory.getInstance().provideSessionKeyDataDecryptorFactory(pgpSessionKey);
|
||||||
InputStream decryptedDataStream = null;
|
|
||||||
PGPEncryptedData encryptedData = null;
|
PGPSessionKeyEncryptedData encryptedData = pgpEncryptedDataList.addSessionKeyDecryptionMethod(pgpSessionKey);
|
||||||
for (PGPEncryptedData pgpEncryptedData : pgpEncryptedDataList) {
|
|
||||||
encryptedData = pgpEncryptedData;
|
|
||||||
if (!options.isIgnoreMDCErrors() && !encryptedData.isIntegrityProtected()) {
|
if (!options.isIgnoreMDCErrors() && !encryptedData.isIntegrityProtected()) {
|
||||||
throw new MessageNotIntegrityProtectedException();
|
throw new MessageNotIntegrityProtectedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encryptedData instanceof PGPPBEEncryptedData) {
|
InputStream decryptedDataStream = encryptedData.getDataStream(decryptorFactory);
|
||||||
PGPPBEEncryptedData pbeEncrypted = (PGPPBEEncryptedData) encryptedData;
|
|
||||||
decryptedDataStream = pbeEncrypted.getDataStream(decryptorFactory);
|
|
||||||
break;
|
|
||||||
} else if (encryptedData instanceof PGPPublicKeyEncryptedData) {
|
|
||||||
PGPPublicKeyEncryptedData pkEncrypted = (PGPPublicKeyEncryptedData) encryptedData;
|
|
||||||
decryptedDataStream = pkEncrypted.getDataStream(decryptorFactory);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (decryptedDataStream == null) {
|
if (decryptedDataStream == null) {
|
||||||
throw new PGPException("No valid PGP data encountered.");
|
throw new PGPException("No valid PGP data encountered.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue