PGP Cryptography With The Legion of the Bouncy Castle – Part 4

Posted on

Before starting I would like to thank all the people who have viewed my posts on using Bouncy Castle. I have been monitoring the hits on my blog and I’ve noticed that my series on encryption with Bouncy Castle has been getting a lot of attention. I did promise to make Part 4 about encrypting and signing a single file all in one, but from lack of time I do not think it will make it to Part 4.

One of the main reasons is that Bouncy Castle is largely undocumented and what little documentation there exists on the net is not enough. The way I have created my posts where by reading the unit test cases from the Bouncy Castle source package and doing some trial and error and testing with PGP Desktop and GPG. So there isn’t enough time for me to continue to do that. So for Part 4 I have decided to show how we add Bouncy Castle support to Android!

When it comes to Android the Legion of The Bouncy Castle is not so bouncy. In fact it becomes rather spongy! Adding the standard Bouncy Castle library in an Android project will not work so nice. That is because Android already uses Bouncy Castle built in. Ah, but not so fast to rejoice. It comes with a watered down version of Bouncy Castle as stated here. Though it seems that in Android 4.0+ that the issue has been … somewhat resolved. Either way why take chance ?

Spony Castle has been created in order to help Android developers with this problem. It the entire Bouncy Castle library just re-packaged and re-named so that it does not cause any conflicts with the Bouncy Castle version that ships with Android.

  • org.bouncycastle.* changed to org.spongycastle.*
  • Provider name BC changed to SC

When writing your code, the place where you would normally call the Bouncy Castle provider; you would just replace it with the Spongy Castle provider name.

static {
      Security.addProvider(new org.spongycastle.jce.provider.BouncyCastleProvider());

So you can visit the Spogny Castle website at and download the Android libraries and include them into your Android project.


2 thoughts on “PGP Cryptography With The Legion of the Bouncy Castle – Part 4

    aononapotimus said:
    August 6, 2013 at 11:07 pm

    please make the part 4 you intended, this is an immensely helpful blog series. Either way, thank you.

    […] in Part 4 I apologized that I did not have a lot of time and just showed how to integrate Bouncy Castle with […]

Leave a Comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s