Skip to content

Commit c574aa7

Browse files
committed
Merge branch 'pgpainless-fixMessageEncryptionMechanism'
2 parents dd99b4a + 73578e9 commit c574aa7

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎pg/src/main/java/org/bouncycastle/openpgp/api/MessageEncryptionMechanism.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public int getAeadAlgorithm()
5353
public static MessageEncryptionMechanism unencrypted()
5454
{
5555
int none = 0;
56-
return new MessageEncryptionMechanism(EncryptedDataPacketType.SEIPDv1,
56+
return new MessageEncryptionMechanism(null,
5757
SymmetricKeyAlgorithmTags.NULL, none);
5858
}
5959

‎pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPMessageProcessorTest.java‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ protected void performTestWith(OpenPGPApi api)
8686

8787
verifyMessageByRevokedKey(api);
8888
incompleteMessageProcessing(api);
89+
processUnencryptedMessage(api);
8990
}
9091

9192
private void roundtripUnarmoredPlaintextMessage(OpenPGPApi api)
@@ -712,6 +713,26 @@ private void incompleteMessageProcessing(OpenPGPApi api)
712713
isFalse(sig.isValid());
713714
}
714715

716+
private void processUnencryptedMessage(OpenPGPApi api)
717+
throws PGPException, IOException
718+
{
719+
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
720+
OpenPGPMessageOutputStream mOut = api.signAndOrEncryptMessage()
721+
.open(bOut);
722+
mOut.write(PLAINTEXT);
723+
mOut.close();
724+
725+
ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());
726+
OpenPGPMessageInputStream mIn = api.decryptAndOrVerifyMessage().process(bIn);
727+
byte[] plain = Streams.readAll(mIn);
728+
mIn.close();
729+
isEncodingEqual(PLAINTEXT, plain);
730+
731+
OpenPGPMessageInputStream.Result result = mIn.getResult();
732+
isTrue(result.getEncryptionMethod().equals(MessageEncryptionMechanism.unencrypted()));
733+
isNull(result.getEncryptionMethod().getMode());
734+
}
735+
715736
private void testVerificationOfSEIPD1MessageWithTamperedCiphertext(OpenPGPApi api)
716737
throws IOException, PGPException
717738
{

0 commit comments

Comments
 (0)