If anyone is still facing the same problem, this may help. I was trying to decrypt a file without passphrase (it was an empty String), but I was getting an error in the class org.bouncycastle.openpgp.PGPSecretKey, in the method
public PGPPrivateKey extractPrivateKey(
PBESecretKeyDecryptor decryptorFactory)
The exception was the following one:
Exception in thread "main" java.lang.NoSuchMethodError: org.bouncycastle.util.BigIntegers.modOddInverse(Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger;
at org.bouncycastle.bcpg.RSASecretBCPGKey.<init>(Unknown Source)
at org.bouncycastle.openpgp.PGPSecretKey.extractPrivateKey(Unknown Source)
at com.hp.etl.pipeline.utils.pgptool.KeyFilesOperationsPgpImpl.getPrivateKey(KeyFilesOperationsPgpImpl.java:318)
at com.hp.etl.pipeline.utils.pgptool.PGPDecryptor.decrypt(PGPDecryptor.java:134)
at com.hp.etl.pipeline.utils.PGPUtils.decryptRoutine(PGPUtils.java:107)
at com.hp.etl.pipeline.utils.PGPUtils.decryptPGPFile(PGPUtils.java:56)
at com.hp.etl.pipeline.connectors.sftp.SFTPConnector.getPGPDecryptedFiles(SFTPConnector.java:392)
at com.hp.etl.pipeline.connectors.sftp.SFTPConnector.downloadFiles(SFTPConnector.java:292)
at com.hp.etl.pipeline.connectors.sftp.SFTPConnector.retrieveS3FileNames(SFTPConnector.java:235)
at bmttest.BMTTest.main(BMTTest.java:90)
I was using the Maven artifact org.bouncycastle » bcpg-jdk15on version 1.68 and after downgrading the Maven artifact to the version 1.63, the file could be decrypted without problem, with an empty passphrase.