pgpainless icon indicating copy to clipboard operation
pgpainless copied to clipboard

How do you configure this to not use BouncyCastle?

Open DarthHater opened this issue 1 year ago • 2 comments

Describe the bug

This isn't really a bug, just a request for an example.

Expected behavior

I am interested in using this library in the absence of bouncy castle. The README states it can be configured to be used with JCE or BouncyCastle, but I can't seem to find any documentation on this, and perusing the source of both sop and core, bouncy castle seems to be pretty embedded.

Additional context

Thanks in advance!

DarthHater avatar Apr 22 '24 18:04 DarthHater

Hey! Bouncycastles bcpg provides two different implementations of the OpenPGP protocol, one based on BCs lightweight crypto implementation and one relying on JCE instead.

Currently, BCs lightweight OpenPGP implementation is the default in PGPainless. However, you can at runtime swap the use of these classes out for their JCA/JCE counterparts by calling:

ImplementationFactory.setFactoryImplementation(new JceImplementationFactory());

This will result in JCE classes to be used instead. Note though, that this does not mean that you can use PGPainless without having Bouncycastle in your classpath, as BC is providing the classes which use JCE in the first place. PGPainless still depends on bcpg (BCs OpenPGP implementation).

It is also possible to replace BouncyCastleProvider (from bcprov) with a different SecurityProvider by calling

ProviderFactory.factory = new MySecurityProviderFactory(); // extends ProviderFactory

but I still haven't found a suitable alternative SecurityProvider that provides all the necessary algorithms and ciphers needed for OpenPGP.

Hope that helps you :)

vanitasvitae avatar Apr 23 '24 12:04 vanitasvitae

Bouncy Castle seems to be the only game in town for PGP in Java, and while it's great it exists, it's just nice to know if alternatives exist, thank you for the thorough answer!

DarthHater avatar Apr 23 '24 19:04 DarthHater