neuhalje / bouncy-gpg

Make using Bouncy Castle with OpenPGP fun again!
https://neuhalje.github.io/bouncy-gpg/
Other
205 stars 58 forks source link

Command line gpg and this java library produces different results #43

Closed jaas0301 closed 4 years ago

jaas0301 commented 4 years ago

How do I convert following command into the equivalent using this library.

gpg -e -r "recipient" --output output.gpg input.zip

I have tried following options but with no success:

final OutputStream outputStream = BouncyGPG.encryptToStream()
            .withConfig(keyring)
            .withOxAlgorithms()
            //.withDefaultAlgorithms()
                //.withAlgorithms(new PGPAlgorithmSuite(PGPHashAlgorithms.SHA_256 , 
                //   PGPSymmetricEncryptionAlgorithms.AES_256, 
                //   PGPCompressionAlgorithms.ZLIB))
            .toRecipient("recipient")
            .andDoNotSign()
            .binaryOutput()
            .andWriteTo(encrypted);

Every time I encrypt a file using command line and using the code, I get two different results. One with the command line for example if is 300KB, then the one with the code is almost twice the size ~550KB.

Our legacy system is having issues decrypting the gpg file coming from this java library. However, if encrypted using command line GPG GnuPG (2.17.2) version using the command, it is able to decrypt.

Any help will be highly appreciated.

neuhalje commented 4 years ago

Some questions to narrow that down:

jaas0301 commented 4 years ago

I had to use binaryOutput instead of armorAsciiOutput.

This is a non issue, hence should be closed.