← Back to section · Open Source Projects

Bouncy Castle's Post-Quantum Support: The PQC Gateway for Java and C#

One of the most widely deployed cryptographic libraries in the Java and C# worlds, Bouncy Castle shipped ML-KEM, ML-DSA and SLH-DSA early, and offers both a lightweight low-level API and a standard JCE provider path.

Published 22 November 2026 · 7 min read · PQ Frontier

Bouncy Castle's Post-Quantum Support: The PQC Gateway for Java and C#
AI-generated illustration by PQ Frontier
Video explainer · Cryptography Libraries: key exchange, maintained in public

Why Bouncy Castle Comes First

Whenever the question is “does algorithm X have a usable implementation?”, Bouncy Castle (BC) is one of the first names to check. The open-source library, originally from Australia, maintains both Java and C#/.NET product lines and sits quietly inside a large share of enterprise middleware, government systems and financial back offices. Its importance is the installed base: in countless systems, the provider behind today’s java.security calls is BC. When an organization inventories how its systems will migrate to PQC, BC’s support status often decides how hard that migration will be.

Supported Algorithms

BC tracked the NIST process early, shipping Kyber, Dilithium and SPHINCS+ with draft parameters before the standards were final, then updating to the standardized ML-KEM, ML-DSA and SLH-DSA after FIPS 203/204/205 were published in August 2024. Its PQC catalogue also includes:

  • Hash-based signatures: SPHINCS+ (the scheme standardized as SLH-DSA) and the stateful LMS and XMSS families;
  • Lattice signatures: Falcon, on its way to standardization as FN-DSA;
  • Code-based KEMs: Classic McEliece, BIKE, HQC and other candidates or alternates;
  • Composite constructions: utilities for composite keys and signatures aimed at protocol integration.

The exact algorithm and parameter list moves quickly between releases, so verify against the official release notes of the version you plan to deploy rather than locking a version based on secondary articles.

Two Ways In: Low-Level API and JCE

Path Entry point Best for
Low-level API KEM and signature classes in org.bouncycastle.crypto Fine-grained control over parameters and encodings, or non-JCE environments such as embedded or trimmed Android runtimes
JCE provider Register BouncyCastleProvider, then use standard KeyPairGenerator, KeyFactory, Signature APIs Existing enterprise systems: business code barely changes; algorithms and providers switch by configuration

The JCE path is what makes enterprise adoption realistic. Registering the provider at application start-up is typically the only structural change; key generation and signature verification continue through standard JCA calls, with new algorithm names such as ML-KEM and ML-DSA passed as strings. Migration can therefore start as “pilot services first, dual-running” instead of a flag-day replacement of the whole cryptographic stack. The C# line (BouncyCastle.Cryptography) mirrors this API shape closely, so .NET teams can reuse the same mental model.

Version Discipline

One practical warning applies to BC more than to most libraries: its PQC surface has evolved quickly, and pre-standard drafts differ from the final FIPS parameter sets and encodings. Keys or signatures produced with an early draft implementation of Kyber or Dilithium are not interoperable with standardized ML-KEM or ML-DSA, even though the names look similar. Estates that experimented early should therefore treat draft-era artefacts as disposable: regenerate keys under the standardized algorithms, record the exact library version alongside any test vectors, and never let a draft-parameter deployment drift into production by inertia. This is a general PQC lesson, but BC’s head start means its users are the ones most likely to hold draft-era material.

An Enterprise Adoption Path

  1. Inventory. Find every place BC is actually called — direct dependencies and indirect ones through middleware — and classify uses into signatures, key establishment and certificates.
  2. Pilot. Enable ML-KEM/ML-DSA via the JCE path on a non-critical service and check compatibility with your PKI, HSMs and audit logging. Pay special attention to whether field lengths and message-size limits downstream can absorb the much larger PQC keys and signatures.
  3. Roll out. Write the chosen algorithms and parameter sets into your internal cryptographic standard, pin an evaluated BC release line, and follow its security-update cadence.

One caveat: BC is a general-purpose library, not a certified product. Whether a deployment satisfies a regulated industry’s certification requirements (such as a FIPS 140-3 validated module) must be assessed separately — “the algorithms are standardized” does not by itself imply “the deployment is compliant”.

Certificates and TLS

Two adjacent areas matter for adopters. On the certificate side, BC’s PKIX layer handles X.509 structures carrying the new algorithms, which is what internal CAs and tooling need before they can issue ML-DSA or composite certificates at all; expect encoding details (algorithm identifiers, subject-public-key formats) to track the relevant IETF LAMPS working-group documents as they finalize, and verify them against your target release. On the transport side, BC’s own TLS/JSSE implementation has been adding post-quantum hybrid key-exchange support in recent releases, which matters for Java estates that terminate TLS with BC rather than the JDK’s built-in provider. In both areas the release notes of the exact version you deploy are the authoritative source — the surface is moving faster than most secondary documentation.

Stateful Signatures: The State-Management Problem You Cannot Dodge

One family in BC’s PQC catalogue demands special care: stateful hash-based signatures such as LMS and XMSS. Their security rests on each one-time key being used exactly once — if the same state ever signs two different messages, the private key can be reconstructed. BC models this state explicitly in its API: key objects carry mutable signature-counter state, and the caller must persist the new state after every signature and guarantee it never rolls back to a used value.

In a single application that is merely a discipline problem; in distributed and virtualized environments it becomes an architecture problem. VM snapshot rollbacks, database failovers, container-image cloning and disaster-recovery restores can all silently rewind signature state while everything looks normal on the surface. The industry’s standard answers are to concentrate stateful signing inside an HSM or a dedicated signing service that issues signatures serially, or — where the protocol allows — to prefer stateless ML-DSA or SLH-DSA. BC gives you the algorithms, but responsibility for state management sits squarely with the deployer: the layer most often missed when assessing what “a library supports algorithm X” really means.

Sizes and Performance: The Real Bill for Migration

After switching algorithms to PQC, the first wall you hit is usually not compute but size. An ML-KEM-768 public key or ciphertext is on the order of a kilobyte, ML-DSA signatures run to several kilobytes, and SLH-DSA signatures can reach tens of kilobytes — against a few dozen bytes for an ECDSA signature. Routed through BC, those increments amplify along the call chain: certificate chains grow, tokens and tickets swell, database fields holding keys and signatures need widening, and fixed-length assumptions in older protocol messages break outright — typically surfacing during integration testing as mysterious truncations.

The performance bill splits differently: lattice operations (key generation, encapsulation, decapsulation) are usually fast, while the pain concentrates in hash-based signature generation speeds and the sheer key sizes of code-based schemes. The pragmatic approach is to benchmark with BC on a pilot service first — measuring not just raw algorithm time but the end-to-end cost of serialization, storage and network transport — and only then write parameter-set choices into the internal standard. Substituting “the algorithm is standardized” for measurement is one of the most common ways PQC migration projects come unstuck; BC’s value is precisely that it lets you take the measure of that bill inside your real call stack, early.

The Supply-Chain View: Why BC’s Release Cadence Matters Too

Finally, the supply chain deserves a mention of its own. BC sits deep in the dependency trees of a vast number of systems, so each of its security updates propagates layer by layer through middleware, application servers and industry software. In the PQC era that propagation carries something new: algorithm implementations themselves must keep tracking standards errata and side-channel research, and optimization code written against draft parameters can become historical baggage once the standard is final. For deployers, following BC’s stable release line, subscribing to its security announcements, and recording the exact BC version and algorithms in use in the dependency inventory is the cheapest way to keep this supply-chain risk inside controlled bounds.

References

  1. The Legion of the Bouncy Castle. https://www.bouncycastle.org
  2. Bouncy Castle Java repository. https://github.com/bcgit/bc-java
  3. Bouncy Castle C# repository. https://github.com/bcgit/bc-csharp
  4. NIST, FIPS 203 / 204 / 205, 2024-08-13. https://csrc.nist.gov/publications/fips

Tags: Bouncy CastleJavaML-KEMcrypto libraries