liveBook · Manning

Bouncy Castle

As explained in Software Security for Developers

Bouncy Castle is a cryptographic software library that provides Java Cryptography Extension providers and implementations of many cryptographic algorithms.

Bouncy Castle is a Java Cryptography Extension provider: it supplies implementations of cryptographic algorithms behind Java’s standard JCA and JCE APIs. It supports strong cryptography, includes more algorithms than the default SunJCE provider, and was optimized for embedded devices with limited CPU resources. section 4.3

Use Bouncy Castle when an application needs:

  • An algorithm or implementation not available from the default Java provider. section 4.3
  • ECC encryption through the ECIES transformation, selected explicitly with the provider name BC. section 7.2.1
  • A straightforward Java implementation while keeping application code on standard cryptography APIs. section 4.3 section 7.2.1

Encrypting refunds with ECIES

An encrypting application registers the provider when needed, obtains an ECIES cipher from BC, and initializes it with the recipient’s public key. The receiving application uses the same transformation with the matching private key. Decryption fails with a different private key or modified ciphertext, demonstrating key dependence and content integrity. section 7.2.1

Figure 4.6 Application code calls the standard JCA and JCE APIs, making the code independent of the crypto algorithm implementation. The JCA and JCE layer routes calls to a provider’s implementation. Java 11-based OpenJDK ships with 13 providers out of the box.
figure

The provider architecture shows how application code remains independent of the underlying cryptographic implementation. section 4.3

How Software Security for Developers covers it

How deep it goes
Explains provider routing and demonstrates ECC encryption and decryption, but does not develop cryptographic internals.
Examples
Uses Java code to register BC, encrypt refunds.json with ECIES, decrypt it with a private key, and test altered ciphertext.
What it assumes
Assumes familiarity with Java APIs and public-private key pairs while demonstrating provider registration and key use.
What you can do after
Apply it via Java’s security APIs to implement ECC encryption and decryption with the Bouncy Castle provider.
How it connects
Connects Java Cryptography Architecture, Java Cryptography Extension, cryptographic algorithms, ECC, ECIES, and public-key encryption.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Security for Developers. The section links point to the parts of the book it draws on.