File tree Expand file tree Collapse file tree
main/java/org/bouncycastle/openpgp/api
test/java/org/bouncycastle/openpgp/api/test Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments