@@ -150,7 +150,7 @@ private void verifyBcPublicKeyDecryptorFactoryFromSessionKeyCanDecryptDataSucces
150150 ArmoredInputStream msgArmorIn = new ArmoredInputStream (msgIn );
151151 PGPObjectFactory objectFactory = new BcPGPObjectFactory (msgArmorIn );
152152 PGPEncryptedDataList encryptedDataList = (PGPEncryptedDataList )objectFactory .nextObject ();
153- PGPPublicKeyEncryptedData encryptedData = ( PGPPublicKeyEncryptedData ) encryptedDataList .iterator (). next ();
153+ PGPSessionKeyEncryptedData encryptedData = encryptedDataList .extractSessionKeyEncryptedData ();
154154
155155 SessionKeyDataDecryptorFactory decryptorFactory = new BcSessionKeyDataDecryptorFactory (new PGPSessionKey (PK_ENC_SESSIONKEY_ALG , Hex .decode (PK_ENC_SESSIONKEY )));
156156 InputStream decrypted = encryptedData .getDataStream (decryptorFactory );
@@ -172,7 +172,7 @@ private void verifyJcePublicKeyDecryptorFactoryFromSessionKeyCanDecryptDataSucce
172172 ArmoredInputStream msgArmorIn = new ArmoredInputStream (msgIn );
173173 PGPObjectFactory objectFactory = new BcPGPObjectFactory (msgArmorIn );
174174 PGPEncryptedDataList encryptedDataList = (PGPEncryptedDataList )objectFactory .nextObject ();
175- PGPPublicKeyEncryptedData encryptedData = ( PGPPublicKeyEncryptedData ) encryptedDataList .iterator (). next ();
175+ PGPSessionKeyEncryptedData encryptedData = encryptedDataList .extractSessionKeyEncryptedData ();
176176
177177 SessionKeyDataDecryptorFactory decryptorFactory =
178178 new JceSessionKeyDataDecryptorFactoryBuilder ().build (new PGPSessionKey (PK_ENC_SESSIONKEY_ALG , Hex .decode (PK_ENC_SESSIONKEY )));
@@ -240,7 +240,7 @@ private void verifyBcPBEDecryptorFactoryFromSessionKeyCanDecryptDataSuccessfully
240240
241241 PGPObjectFactory objectFactory = new BcPGPObjectFactory (msgArmorIn );
242242 PGPEncryptedDataList encryptedDataList = (PGPEncryptedDataList )objectFactory .nextObject ();
243- PGPPBEEncryptedData encryptedData = ( PGPPBEEncryptedData ) encryptedDataList .iterator (). next ();
243+ PGPSessionKeyEncryptedData encryptedData = encryptedDataList .extractSessionKeyEncryptedData ();
244244
245245 SessionKeyDataDecryptorFactory decryptorFactory = new BcSessionKeyDataDecryptorFactory (new PGPSessionKey (PBE_ENC_SESSIONKEY_ALG , Hex .decode (PBE_ENC_SESSIONKEY )));
246246 InputStream decrypted = encryptedData .getDataStream (decryptorFactory );
0 commit comments