Closed Bug 2068282 Opened 2 months ago Closed 5 days ago

Add ML-DSA support to moz::pkix

Categories

(NSS :: Libraries, enhancement, P2)

enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jschanck, Unassigned)

References

Details

Attachments

(4 external files)

No description provided.
  • Added MLDSA to the PublicKeyAlgorithm enum in pkixder.h.
  • Implemented VerifyMLDSASignedDataNSS for verifying raw ML-DSA signatures.
  • Extended the TrustDomain interface with a virtual method VerifyMLDSASignedData().
  • Integrated ML-DSA support into:
    • pkixverify.cpp (verification dispatch)
    • pkixcheck.cpp (OID recognition and public key checks)
    • pkixder.cpp (signature algorithm decoding)
    • pkixnss.cpp (signature mechanism handling)
  • Defined and matched the ML-DSA OIDs.
  • Enforced the DER encoding rule that ML-DSA AlgorithmIdentifier must omit parameters.

Signed-off-by: Francesco Rollo <eferollo@gmail.com>

mozilla::pkix's ML-DSA support uses std::optional. Firefox already builds
NSS as C++17 or later; this does the same for standalone builds:

  • GCC and Clang: -std=c++17 in config.gypi and command.mk.
  • Xcode/macOS: CLANG_CXX_LANGUAGE_STANDARD is now c++17.
  • MSVC and clang-cl, make: CXXSTD is -std:c++17.
  • MSVC and clang-cl, gyp: gyp cannot pass C++-only flags to MSVC, so the
    mozpkix targets, which have no C sources, add /std:c++17 themselves and
    pass it to the targets that depend on them.

Keeping the parameter set lets mozilla::pkix check that it is used
consistently:

  • der::PublicKeyAlgorithm::MLDSA is now MLDSA_44, MLDSA_65 and MLDSA_87,
    so CheckSignatureAlgorithm rejects certificates whose two signature
    algorithm fields name different parameter sets (RFC 5280 4.1.1.2).
  • TrustDomain::VerifyMLDSASignedData and VerifyMLDSASignedDataNSS take the
    parameter set named by the signature algorithm, and
    VerifyMLDSASignedDataNSS rejects keys that are not ML-DSA keys or that
    are for a different parameter set.
  • New MLDSAParameterSet enum and TrustDomain::CheckMLDSAParameterSetIsAcceptable
    hook, called from CheckSubjectPublicKeyInfo, so that applications can
    refuse ML-DSA keys by parameter set.
  • CheckSubjectPublicKeyInfo checks that an ML-DSA public key has the
    length that FIPS 204 gives for its parameter set.
  • ML-DSA AlgorithmIdentifiers must not have parameters, not even NULL
    (RFC 9881 Section 2).
  • New Result::ERROR_BAD_KEY, mapped to SEC_ERROR_BAD_KEY.
  • pkixmldsa_tests.cpp: VerifyMLDSASignedDataNSS, CheckSubjectPublicKeyInfo,
    VerifySignedData dispatch, path building with ML-DSA (and mixed ML-DSA
    and RSA) chains, VerifyCodeSigningCertificateChain, and the Wycheproof
    ML-DSA verification vectors.
  • ML-DSA cases in the CheckSignatureAlgorithm and SignatureAlgorithmIdentifierValue
    tests.
  • ML-DSA key generation and signing in the mozilla::pkix test library.
See Also: → 2091629

Pushed by jschanck@mozilla.com:
https://hg.mozilla.org/projects/nss/rev/f2b434543111
build C++ code as C++17. r=nss-reviewers,keeler
https://hg.mozilla.org/projects/nss/rev/82de509c57df
Enable ML-DSA signature verification for certificate chain validation r=keeler
https://hg.mozilla.org/projects/nss/rev/6544be58d4b5
split PublicKeyAlgorithm::MLDSA into one algorithm per parameter set. r=nss-reviewers,keeler
https://hg.mozilla.org/projects/nss/rev/46a64f316965
add ML-DSA tests for mozilla::pkix. r=nss-reviewers,goutam,keeler

Status: NEW → RESOLVED
Closed: 5 days ago
Resolution: --- → FIXED
Blocks: 2092696
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: