Skip to content

Commit d915c39

Browse files
author
gefeili
committed
Bring the KEM release note in line with the SM9 spec validation as reviewed: SM9 does not take the shared KTSParameterSpec validation - its own GM/T 0044.4 KDF sizes the secret to the request, so the satisfiability bound does not apply and a non-whole-byte size stays legal - but the checks that carry over now run in KEM.SM9-KEM itself, rejecting a missing key algorithm name or a non-positive key size at construction with the declared InvalidAlgorithmParameterException rather than a NullPointerException or the key generator's IllegalArgumentException escaping the KEM operations.
1 parent cb227a6 commit d915c39

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎docs/releasenotes.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ <h3>2.1.3 Additional Features and Functionality</h3>
170170
<li>org.bouncycastle.jcajce.provider.util.SecurityExceptions gained an invalidAlgorithmParameterException(String, Throwable) factory, for the same reason as its siblings: java.security.InvalidAlgorithmParameterException only grew a cause-taking constructor in Java 5, so code that has to compile for the legacy Java 4 distributions attaches the cause through initCause instead. Use the factory rather than rolling that call at the throw site.</li>
171171
<li>The BCJSSE provider now treats the ML-KEM based named groups as FIPS approved, and offers the hybrids among them by default. FipsUtils.isFipsNamedGroup answers true for X25519MLKEM768, MLKEM512, MLKEM768 and MLKEM1024 as well as the two SecP hybrids it already accepted - the key establishment in each is ML-KEM (FIPS 203), and in the X25519 hybrid the approved component supplies the shared secret the X25519 half is combined with - so a provider constructed in FIPS mode no longer filters any of them out. NamedGroupInfo's default candidate list, which applies when the jdk.tls.namedGroups property is not set, gains SecP256r1MLKEM768 and SecP384r1MLKEM1024 alongside the X25519MLKEM768 it already carried; they are appended, so the classical groups keep their existing preference and these are additional offers rather than a change of first choice. The pure ML-KEM groups (MLKEM512, MLKEM768, MLKEM1024) are deliberately <b>not</b> in that list, following TLS working group feedback that a key exchange should retain a classical component: they are available in FIPS mode and out of it, but a caller has to ask for one through the jdk.tls.namedGroups property or BCSSLParameters.setNamedGroups rather than getting it by default. curveSM2MLKEM768 remains outside the FIPS set, as do plain x25519 and x448. A new test, org.bouncycastle.jsse.provider.test.TlsFipsTest, drives a TLS 1.3 handshake through the FIPS mode provider for each of the six groups with both ends restricted to the group under test, checks that a pure ML-KEM group does not reach a default configured server while a hybrid does, and also asserts that the FIPS approved GCM cipher suites and the TLSv1.3 protocol preference are present - the complement of the existing FIPS cipher suite suites, which check that nothing outside the FIPS set is exposed.</li>
172172
<li>FrodoKEM and Classic McEliece are now reachable through the javax.crypto.KEM API (JDK 21, JEP 452), which previously only ML-KEM, SM9, NTRU, NTRU Prime and HQC were. The standard BC provider registers KEM.FRODOKEM and KEM.CMCE, plus one parameter-set locked service for each of FrodoKEM's eight and Classic McEliece's sixteen ISO/IEC 18033-2:2006/Amd 2:2026 sets, each with the usual object identifier aliases so a caller dispatching on the OID in a received encoding finds the service. As with the other KEMs the implementations live in the multi-release jar's version 17 tree (org.bouncycastle.jcajce.provider.asymmetric.frodokem.FrodoKEMSpi and .cmce.CMCEKEMSpi with their Encapsulator/Decapsulator peers) and the registrations are gated on SpiUtil.hasKEM(), so on a JDK where javax.crypto.KEM is absent nothing is registered and the existing Cipher, KeyGenerator and KeyFactory services are unaffected. With a null spec the shared secret is the mechanism's own session key - the interoperable form - and a KTSParameterSpec KDF may be layered on top for generic use. Note FrodoKEM differs from ML-KEM in that its session key size follows the parameter set, 192 bits for the 976 sets and 256 for the 1344 sets, so the no-KDF secret size is taken from the key rather than assumed to be 256 bits; Classic McEliece is 256 bits throughout. For the same reason a KDF-less spec asking for more bits than the parameter set produces is refused with an InvalidAlgorithmParameterException naming the set and both sizes, rather than being quietly shortened the way the KTS key-wrapping path does - javax.crypto.KEM validates encapsulate()'s range against secretSize(), so that size has to be honest. The same applies to everything else a KTSParameterSpec can carry that a KEM cannot honour, since the spec validates none of it itself and each otherwise failed as an undeclared unchecked exception out of encapsulate() / decapsulate() rather than as a spec failure the caller can act on: a key size that is not a positive whole number of bytes (one below eight bits yielded a zero-length secret key, one that was not a whole number of bytes silently delivered fewer bits than were asked for, and one within seven of Integer.MAX_VALUE overflowed the rounding up of the byte count), a KDF algorithm identifier naming a KDF or digest the provider cannot service, and an absent key algorithm name. The validation, the algorithm-name reconciliation and the derivation of the secret key itself are shared as new org.bouncycastle.jcajce.provider.asymmetric.util.KdfUtil.resolveKemSpec, resolveAlgorithm and makeSecretKey methods rather than duplicated per KEM. Note makeSecretKey erases the secret it is passed, as the neighbouring makeKeyBytes already did, and validates the requested range before deriving so that an out-of-range request cannot reach SecretKeySpec after the secret has been erased; a caller has to take the encapsulation from the mechanism's output before calling it, and destroy that output afterwards, which is deliberately left at the call site so the ordering stays visible, and every javax.crypto.KEM encapsulator and decapsulator in the provider - ML-KEM, SM9, NTRU, NTRU Prime and HQC as well as the two added here - now reconciles the requested algorithm name through the shared method, which each previously carried its own identical copy of. Behaviour is unchanged, including the exception text for a name the spec does not authorise.</li>
173-
<li>NTRU LPRime, NTRU+ and SMAUG-T are now reachable through the javax.crypto.KEM API as well, which completes the BCPQC KEMs: each already had Cipher, KeyGenerator, KeyFactory and KeyPairGenerator services and only the KEM one was missing. NTRU LPRime gets KEM.NTRULPRIME, a family level service matching the SNTRU Prime counterpart registered beside it in the same class, whose absence was the whole difference between the two. NTRU+ gets KEM.NTRUPLUS and SMAUG-T KEM.SMAUGT, each with one parameter-set locked service per set, mirroring their other services. As elsewhere the implementations are multi-release jar version 17 classes gated on SpiUtil.hasKEM(), and they share KdfUtil.resolveKemSpec and resolveAlgorithm with the other KEMs rather than repeating the spec validation. NTRULPRimeParameters and SmaugTParameters gain a getEncapsulationLength() so the encapsulating side, which holds only a public key, derives the size from the same place the extractor does instead of repeating the expression or reaching for a package-private engine. Note the NTRU+ decapsulator constructs its extractor per call: an NTRUPlusKEMExtractor builds an NTRUPlusEngine, which keeps one SHAKE instance in a field, so sharing one across the concurrent decapsulate calls javax.crypto.KEM permits returned shared secrets that did not match the sender's. NTRU LPRime and SMAUG-T carry no such state and share an extractor. The spec validation added for FrodoKEM and Classic McEliece is now applied by every KEM in the provider except SM9: ML-KEM, HQC, NTRU and SNTRU Prime previously accepted a KDF-less KTSParameterSpec asking for more bits than the mechanism produces and then failed with an ArrayIndexOutOfBoundsException out of encapsulate(), where they now refuse the spec with an InvalidAlgorithmParameterException naming the parameter set and both sizes. SM9 is excluded deliberately, as its own GM/T 0044.4 KDF produces the shared secret at whatever size was requested and so has no fixed session key to bound against.</li>
173+
<li>NTRU LPRime, NTRU+ and SMAUG-T are now reachable through the javax.crypto.KEM API as well, which completes the BCPQC KEMs: each already had Cipher, KeyGenerator, KeyFactory and KeyPairGenerator services and only the KEM one was missing. NTRU LPRime gets KEM.NTRULPRIME, a family level service matching the SNTRU Prime counterpart registered beside it in the same class, whose absence was the whole difference between the two. NTRU+ gets KEM.NTRUPLUS and SMAUG-T KEM.SMAUGT, each with one parameter-set locked service per set, mirroring their other services. As elsewhere the implementations are multi-release jar version 17 classes gated on SpiUtil.hasKEM(), and they share KdfUtil.resolveKemSpec and resolveAlgorithm with the other KEMs rather than repeating the spec validation. NTRULPRimeParameters and SmaugTParameters gain a getEncapsulationLength() so the encapsulating side, which holds only a public key, derives the size from the same place the extractor does instead of repeating the expression or reaching for a package-private engine. Note the NTRU+ decapsulator constructs its extractor per call: an NTRUPlusKEMExtractor builds an NTRUPlusEngine, which keeps one SHAKE instance in a field, so sharing one across the concurrent decapsulate calls javax.crypto.KEM permits returned shared secrets that did not match the sender's. NTRU LPRime and SMAUG-T carry no such state and share an extractor. The spec validation added for FrodoKEM and Classic McEliece is now applied by every KEM in the provider except SM9: ML-KEM, HQC, NTRU and SNTRU Prime previously accepted a KDF-less KTSParameterSpec asking for more bits than the mechanism produces and then failed with an ArrayIndexOutOfBoundsException out of encapsulate(), where they now refuse the spec with an InvalidAlgorithmParameterException naming the parameter set and both sizes. SM9 does not take the shared validation, as its own GM/T 0044.4 KDF produces the shared secret at whatever size was requested - there is no fixed session key to bound a KDF-less request against, and a size that is not a whole number of bytes is a legitimate SM9 request where the other KEMs must refuse it - but the checks that do carry over are applied by KEM.SM9-KEM itself: a spec with no key algorithm name or a non-positive key size is rejected when the encapsulator or decapsulator is created, with the same InvalidAlgorithmParameterException, where the null name previously surfaced as a NullPointerException and the non-positive size as the key generator's own IllegalArgumentException out of the KEM operations.</li>
174174
<li>The new org.bouncycastle.x509.CRLDP_protocols property is an optional whitelist of the protocols a CRL Distribution Point may name, applied by the CrlCache behind both the provider's CertPath validator and X509RevocationChecker before any connection is opened, and ahead of the cache, so an entry already held for a distribution point is no way around it. It is a comma separated list matched without regard to case - "http,https,ldap" refuses a distribution point naming ftp, file, jar or anything else the JVM happens to have a URL handler registered for, with a CRLException naming the protocol. Unset or empty, the default, leaves the protocol unrestricted: RFC 5280 sec. 4.2.1.13 requires a distribution point URI to name a protocol but does not restrict which, and BouncyCastle supports http, https, ftp and ldap here, so this is a policy for deployments that want a narrower set rather than a new default. Note the fetch it governs only happens at all where org.bouncycastle.x509.enableCRLDP is set (see Defects Fixed above).</li>
175175
</ul>
176176

0 commit comments

Comments
 (0)