Hi Simon (and hi debian-devel),

I maintain gnoMint, a small GTK Certificate Authority manager built on
top of GnuTLS, and this week I sat down to add ML-DSA keys to it. It
didn't get very far: on Debian (and on Ubuntu, which is what I happen to
run) GnuTLS happily declares GNUTLS_PK_MLDSA87 in its headers, but at
runtime certtool answers "The signature algorithm is not supported".
Which, after a bit of digging, makes perfect sense... and led me to this
ITP.

Just to put the pieces together (please correct me if I got any of them
wrong):

 * Since GnuTLS 3.8.10, PQC in GnuTLS is only provided through
   leancrypto, and --with-leancrypto is off by default. Not even
   gnutls28 3.8.14-2 in sid can enable it, since leancrypto is not in
   the archive.

 * In the liboqs ITP thread last year, Andreas mentioned that GnuTLS
   uses leancrypto "temporarily, until nettle has PQ in a released
   version". As far as I can see that is still far away for signatures:
   nettle 4.0 has SLH-DSA but no ML-DSA, and current nettle master adds
   ML-KEM and sntrup761 but still no ML-DSA. And sid is still at nettle
   3.10.2 anyway.

 * Fedora already ships leancrypto bundled inside its gnutls package.

 * And then there's yesterday's NSA advisory, which I think we should
   take at face value. It asks everybody running national security
   systems to "immediately accelerate" the move to PQC: stand up
   PQC-capable CAs, reissue X.509 certificates and re-sign firmware now,
   with CNSA 2.0 (ML-DSA-87, ML-KEM-1024) required for new acquisitions
   from January 2027. What triggered it, according to the NSA itself,
   were recent discoveries responsibly disclosed by frontier AI labs
   that "impact the security of some cryptographic systems currently in
   use". They haven't said which ones, and I'm not going to speculate,
   but when the people with the most first-hand information on the
   matter change their wording from "plan for" to "immediately", I'd
   rather treat it as a real risk today. And even in the best case, the
   timing argument stands on its own: anything signed or encrypted today
   with RSA or ECC can be collected now and attacked later, and
   migrating a PKI takes months or years. The tooling has to be in the
   archive before it is needed, not after.

So I'd like to help get leancrypto over the line, if you're OK with it.
I didn't want to come empty-handed, so I picked up your packaging from
salsa and pushed an updated branch, with a merge request against
yours:

  https://salsa.debian.org/davefx/leancrypto/-/tree/debian/latest
  https://salsa.debian.org/debian/leancrypto/-/merge_requests/1

What changed:

 * New upstream version 1.9.1 (salsa was at 1.5.1), repacked as
   1.9.1+dfsg. Every component in the tarball has a doc/ directory with
   reference material: copies of 20-odd IETF RFCs and drafts (BCP 78,
   so non-free for us), but also ISO and ITU-T standards, papers and
   vendor documents, several of them with no license at all. None of it
   is needed for the build, so it all goes through Files-Excluded,
   together with the test data that comes from the IETF (the IETF
   Hackathon PQC certificates and the RFC 9882 examples) and a prebuilt
   EFI binary only used by the Secure Boot tool tests, which aren't
   built. A small patch makes the four tests that use the IETF data
   skip when it's missing, instead of failing.

 * debian/watch: the previous one downloaded GitHub's auto-generated
   tarball (gzip) and renamed it to .tar.xz, which made pristine-tar
   very unhappy. It now tracks the official release tarballs from
   leancrypto.org and verifies their OpenPGP signature. The key
   (342C 4E3A 39EA 5F19 909B E38A AE5D 0DA3 FD09 2353, Stephan Müller)
   is not on the keyservers, but it is one of the keys registered on
   upstream's GitHub account, and GitHub also reports the v1.9.1 tag as
   verified. That's the best chain of trust I could find; if someone
   knows a better one, I'm all ears.

 * The library package is now libleancrypto1.9, following the SONAME
   (more on that below), and the new lc_x509_generator and
   lc_pkcs7_generator tools go into the leancrypto package, with man
   pages.

 * The upstream test suite now runs during the build (it was disabled
   in d/rules): 424 OK, 15 expected failures (negative tests), 4
   skipped (the IETF data ones) and 0 failures on amd64, in a minimal
   sid container. That needed jq and openssl in Build-Depends: without
   them, 27 tests (most of them OpenSSL interoperability checks) were
   silently skipped. I excluded the "performance" suite, which
   benchmarks throughput for several minutes per test and makes no
   sense on a buildd. The salsa CI pipeline on my fork is green too,
   i386 build included.

 * New autopkgtest: builds a small program against libleancrypto-dev
   and checks an ML-DSA-87 sign/verify round trip, including rejection
   of a tampered message and a tampered signature.

 * debian/copyright: a complete DEP-5 file. This was the part you were
   stuck on last year, and I understand why... The upstream LICENSE file
   turned out not to be reliable enough to write it from (about 20
   stale paths, a few files missing from it, and per-file licensing it
   doesn't reflect), so I generated it from the per-file headers with
   a script that knows the third-party origins, and then reviewed it.
   Files derived from third-party code list both copyright holders
   and both licenses. licenserecon reports no significant
   differences, with a d/lrc.config that only covers the
   "derived from" combinations that licensecheck can't express (there's
   no alias for the main license, so nothing can hide under Files: *).

 * lintian --pedantic: no errors or warnings left, only a handful of
   informational and pedantic tags (no symbols file yet, debhelper
   compat 13, watch file version 4).

There are a few things I'd like your opinion on before going further:

 1. The SONAME is major.minor (libleancrypto.so.1.9), so every minor
    upstream release would mean a library transition, and upstream
    releases fairly often (1.7.x, 1.8.0, 1.9.0 and 1.9.1 in the last
    nine months). Upstream's 1.9.0 changelog says this is on purpose,
    because minor releases may change the ABI. I've asked Stephan
    whether a stable SONAME with versioned symbols could be an option
    later on (https://github.com/smuellerDD/leancrypto/issues/102).
    Until then it means a small transition with every minor release.

 2. Most of internal/api/ext_x86_*.h say they are "derived in parts
    from GCC (GPLv3) and the LLVM project", while being distributed
    under leancrypto's BSD-3-Clause or GPL-2 license. Upstream argues in
    LICENSE that these are only inline wrappers around compiler
    built-ins and don't affect the library's license. It sounds
    reasonable to me, but I'm no lawyer, so I documented it with a
    Comment in d/copyright rather than sweeping it under the carpet.
    Better to discuss it now than to have ftp-master find it in NEW.
    I've also asked upstream about it:
    https://github.com/smuellerDD/leancrypto/issues/103

 3. Looking further ahead: once GnuTLS links against leancrypto, some
    Apache-2.0 code ends up in the picture (OpenSSL's Curve448, the
    BIKE code from Amazon) for programs that use GnuTLS, including
    GPL-2-only ones. Andreas, you surely know better than me how this
    was handled for OpenSSL 3, so I'd love to hear whether you see a
    problem there.

The other upstream issues I found along the way are already reported
to Stephan: the LICENSE paths, a BSD-2 vs BSD-3 mismatch between the
spec file and LICENSE.bsd and a mangled SPDX identifier (#100), the
RFCs and the .efi in the release tarball (#101) and a bashism in a test
script (#104), all at https://github.com/smuellerDD/leancrypto/issues

How would you like to proceed? I'm happy to do the grunt work and
co-maintain it under the pkg-security team (I took the liberty of adding
myself to Uploaders in the branch, but that's entirely up to you). I'm
not a DD or DM, so I'd need you, or someone, to sponsor the upload.
Experimental first, as you originally planned, sounds right to me.

On the GnuTLS side I've already tested the next step on top of these
packages: Debian's gnutls28 3.8.14-2 rebuilt --with-leancrypto passes
its whole test suite (955 tests: 856 pass, 99 skipped, 0 failures;
mldsa.sh and pqc-hybrid-kx.sh now actually run), and certtool can
create an ML-DSA-87 CA, issue a certificate with it, verify the chain
and reject a tampered certificate. The patch is two lines, plus one
more that I only found thanks to a test: gnutls.pc lists leancrypto in
Requires.private, so libgnutls28-dev must depend on libleancrypto-dev,
or `pkg-config gnutls` breaks for every package building against
GnuTLS. Once leancrypto is in the archive, I'll file a wishlist bug
against gnutls28 with that debdiff.

Full disclosure, in the spirit of the recent GR: I did this work with
the help of an AI coding assistant, and also used it for a separate
review pass over the result. The numbers above come from real builds
and test runs in a clean sid container (Docker). In any case I'm the
one answering for it, so any mistake in there is mine.

Any comments are more than welcome.

Cheers,

David

-- 
David Marín Carreño <[email protected]>
gnoMint: https://davefx.github.io/gnoMint/

Reply via email to