You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ae14c98
Browse filesBrowse the repository at this point in the historyBrowse files
Report the algorithm when a KEM has no registered encapsulation length rather than dereferencing a null table entry, and enable Classic McEliece as a CMS RFC 9629 KEMRecipientInfo recipient by registering the encapsulation lengths for its sixteen ISO/IEC 18033-2 parameter sets, relates to github #2398.
Copy file name to clipboardExpand all lines: docs/releasenotes.html
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -133,6 +133,7 @@ <h3>2.1.2 Defects Fixed</h3>
133
133
<li>The KEM KeyGenerator services had the same missing key-size check as the javax.crypto.KEM ones described under Additional Features below, and are corrected here for the older API too: a KEMGenerateSpec or KEMExtractSpec built withNoKdf() and given a key size larger than the mechanism's session key overran the shared secret and threw ArrayIndexOutOfBoundsException out of KeyGenerator.generateKey(), which has no way to describe such a failure. The conventional 256-bit request failed that way for FrodoKEM's 976 parameter sets, whose session key is 192 bits, as did any request above 256 bits for ML-KEM, Classic McEliece and the composite KEMs, whose session keys are 256 bits. These services take a KEMKDFSpec rather than a KTSParameterSpec and so never pass through KdfUtil.resolveKemSpec, where the KEM services now have their spec validated up front; the check therefore sits in KdfUtil.makeKeyBytes itself, which covers them and any future caller of it. The request is refused with an IllegalArgumentException naming both sizes rather than quietly met at the shorter length, since a caller that asked for a 256-bit AES key and was handed a 192-bit one has no way of telling. A request the session key can satisfy is unaffected and produces exactly the key material it did before, and the Cipher and KTS key-wrapping paths were never affected - there the requested size is only an upper bound on a wrapping key both parties derive the same way from the same secret, so WrapUtil clamps it to the secret it has.</li>
134
134
<li>The BCJSSE provider now only computes active early key share groups for clients offering TLS 1.3+. Previously it was computed for all connections, which was mostly harmless, but could generate misleading log messages (at WARNING level) for servers or pre-TLS1.3 clients where the logged condition was irrelevant (github #2392).</li>
135
135
<li>Initialising a BC signature, cipher or key-agreement service with a private key from another provider whose key material is not accessible - a hardware-backed key whose getModulus() / getX() / getS() / getParams() throws, as an IBM CCA RSAPrivateHWKey does with "Hardware error, function getModulus has no meaning in hardware" - let that provider-specific unchecked UnsupportedOperationException escape a method declared to throw only InvalidKeyException, so an mTLS handshake failed with a raw hardware error rather than the documented type. The key-parameter helpers that examine a key through a java.security.interfaces or javax.crypto.interfaces type a foreign provider may implement - RSAUtil, DSAUtil, ECUtil (its java.security.interfaces.ECPrivateKey branch), both DHUtil copies and ElGamalUtil - now catch a failure to read the key's parameters and raise InvalidKeyException with the original exception chained as its cause. A caller, or a JSSE layer that keys its provider fallback on InvalidKeyException, sees the declared type and a clear message. This does not let BC sign or decrypt with a non-exportable hardware key, which is not possible; it makes the refusal in contract. BC's own keys and any exportable key are unaffected (github #1440).</li>
136
+
<li>org.bouncycastle.operator.DefaultKemEncapsulationLengthProvider.getEncapsulationLength() looked its argument up in a table of the KEMs whose encapsulation lengths are registered - ML-KEM, NTRU, HQC, FrodoKEM and composite ML-KEM - and dereferenced the result without checking it. A CMS RFC 9629 KEMRecipientInfo recipient using any other KEM which does register a key wrapping cipher, BIKE, NTRU+ or SMAUG-T, got as far as the wrap and then failed with a NullPointerException carrying no indication of which algorithm was at fault. The lookup now throws IllegalArgumentException naming the KEM's OID, as the sibling DefaultKemAlgorithmIdentifierFinder does, and the contract is documented on the KemEncapsulationLengthProvider interface (github #2398).</li>
136
137
</ul>
137
138
138
139
<h3>2.1.3 Additional Features and Functionality</h3>
@@ -179,6 +180,7 @@ <h3>2.1.3 Additional Features and Functionality</h3>
179
180
<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>
180
181
<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>
181
182
<li>The Gradle build now checks Android compatibility with AnimalSniffer: each published module's base (Java 8) classes are verified against the Android API level 26 (Android 8.0) platform signature, so a reference to a java.* / javax.* API absent from that platform - the class of regression behind the org.bouncycastle.util.BigIntegers.intValueExact NoSuchMethodError seen on older Android (see Defects Fixed above, github #2369) - fails the build rather than reaching a consumer's device as a runtime error. Only the base classes are checked, not the multi-release overlays, since those are selected by JDK version at runtime and never load on Android. A small allow-list covers the references that are intentionally platform-absent: the optional JNDI-based fetchers (javax.naming - the LDAP CRL and certificate stores in bcprov and bcpkix, and the DANE fetcher), which are inert on Android as it ships no JNDI, and the legacy bcmail S/MIME content handlers' java.awt.datatransfer.DataFlavor reference, which cannot be dropped while javax.activation 1.x's ActivationDataFlavor extends it - Android consumers should use bcjmail, which carries no such reference (github #242). Based on the initial implementation in github #336.</li>
183
+
<li>Classic McEliece can now be used as a recipient KEM in CMS EnvelopedData / AuthEnvelopedData via the RFC 9629 KEMRecipientInfo structure. DefaultKemEncapsulationLengthProvider now knows the encapsulation (ciphertext) lengths for all sixteen parameter sets standardised under the ISO/IEC 18033-2 arc (mceliece460896 156, mceliece6688128 208, mceliece6960119 194, mceliece8192128 208, each of the plaintext-confirmation "pc" sets adding a 32 byte confirmation hash, and the semi-systematic key generation "f" variants leaving the ciphertext unchanged), which JceKEMRecipientInfoGenerator previously lacked - a Classic McEliece recipient failed the wrap. DefaultAlgorithmNameFinder and DefaultKemAlgorithmIdentifierFinder already carried the parameter set names. Unlike ML-KEM and FrodoKEM there is no CMS profile for Classic McEliece, so the key-wrap algorithm is the caller's choice; the round-trip tests pair mceliece460896 (level 3) with AES-Wrap-192 and the level 5 sets with AES-Wrap-256, keying the wrap with HKDF-SHA256.</li>
0 commit comments