Hi Stephan,
I have been part of some discussion of this. My understanding is that the hashing at the CMS level is completely disjoint from any hashing done as part of the algorithm. For example, today you would perform a message digest according to the algorithm set in the SignerInfo, and then you would separately perform the pre-hashing step of sha256withRSA. These are two separate hash steps and are not combined. Two historical reasons for this:
1. sha256withRSA is often implemented (and FIPS / CC certified) as an atomic operation. Pulling the hash step entirely into the CMS library would be a weird abstraction layer violation of the crypto module. Said a different way: most crypto libraries and hardware will expose an interface for sha256withRSA, and not an interface for RSA by itself.
2. The bit with signed attributes, as you say, means that this is really part of the protocol and not part of the signature primitive.
You should also be aware that for ML-DSA in particular, we are leaning towards completely forbidding HashML-DSA within X.509 and instead standardizing what we are calling “ExternalMu-ML-DSA” which is allowed by the inline comment in FIPS 204 Alg 7 line 6. See this work-in-progress draft for the full idea. Feedback is most welcome.
---
Mike Ounsworth
From: 'Stephan Mueller' via pqc-forum <pqc-...@list.nist.gov>
Sent: Thursday, November 21, 2024 2:51 AM
To: pqc-forum <pqc-...@list.nist.gov>
Subject: [EXTERNAL] [pqc-forum] PKCS#7 / CMS signed data content and PQC algorithms
Hi, during the implementation of a PKCS#7/CMS message generator for PQC algorithms (see [1]), I would like to ask the collective brain about the following: RFC5652 section 5. 4 ([2]) outlines that the data to be protected shall be hashed an then
Hi, during the implementation of a PKCS#7/CMS message generator for PQC algorithms (see [1]), I would like to ask the collective brain about the following: RFC5652 section 5.4 ([2]) outlines that the data to be protected shall be hashed an then later be signed. Together with the mandatory field "digestAlgorithms" in the SignerInfo ([3]) which defines the used digest algorithm, I infer that: 1. the message digest must be applied to the data to be signed 2. as we have a message digest, the PQC algorithms seemingly must always be used in their pre-hashed variant. The reason for confirming this suspicion is the following: it is certainly technically possible to use the non-pre-hashed variants of PQC when performing the signature operation. But in this case: * the message digest algorithm specification is not used at all when not having authenticate attributes * when having authenticated attributes which mandate the hashing of the original data and then signing the authenticated attributes, the message digest algorithm is only applied to the original message hashing, but not to the signature operation of the authenticated message itself. [1] https://urldefense.com/v3/__https://github.com/smuellerDD/leancrypto/tree/master/asn1/src*pkcs7-message-generator__;Iw!!FJ-Y8qCqXTj2!d9Z3DoHLpDFwAltmxuXkTR48ndth8OH4fU46lvtvLEC8rhBA5ww3VWkwPYg-33MVsRAcWbG15w46zndpPicpGD42iwzR$ [2] https://urldefense.com/v3/__https://www.rfc-editor.org/rfc/rfc5652*section-5.4__;Iw!!FJ-Y8qCqXTj2!d9Z3DoHLpDFwAltmxuXkTR48ndth8OH4fU46lvtvLEC8rhBA5ww3VWkwPYg-33MVsRAcWbG15w46zndpPicpGDoai_Tb$ [3] https://urldefense.com/v3/__https://www.rfc-editor.org/rfc/rfc5652*section-12.1__;Iw!!FJ-Y8qCqXTj2!d9Z3DoHLpDFwAltmxuXkTR48ndth8OH4fU46lvtvLEC8rhBA5ww3VWkwPYg-33MVsRAcWbG15w46zndpPicpGBb1xejB$ Thanks a lotStephan -- You received this message because you are subscribed to the Google Groups "pqc-forum" group.To unsubscribe from this group and stop receiving emails from it, send an email to pqc-forum+...@list.nist.gov.> Just to clarify: in case of not having signed attributes, the
digestAlgorithm set with the signer is to be ignored?
I believe not. I believe that the hashing done as part of CMS SignerInfo, and any hashing done as part of the signature primitive are always separate and un-related. This is well-established behaviour of CMS, which underpins all sorts of things (S/MIME, signed PDF, Windows code signing, etc). I’m sure there are samples around somewhere (but I don’t have them on-hand, so maybe not a helpful comment).
---
Mike Ounsworth
From: 'Stephan Mueller' via pqc-forum <pqc-...@list.nist.gov>
Sent: Thursday, November 21, 2024 11:52 AM
To: pqc-...@list.nist.gov; Kampanakis, Panos <kpa...@amazon.com>
Subject: [EXTERNAL] Re: [pqc-forum] PKCS#7 / CMS signed data content and PQC algorithms
Am Donnerstag, 21. November 2024, 18: 05: 30 Mitteleuropäische Normalzeit schrieb 'Kampanakis, Panos' via pqc-forum: Hi Panos' via pqc-forum, > Hi Stephan, > > Please check Section 4 of draft-ietf-lamps-cms-sphincs-plus > https: //urldefense. com/v3/__https: //datatracker. ietf. org/doc/html/draft-ietf-lamps-cms-sphincs-plus*nam__;Iw!!FJ-Y8qCqXTj2!eMZriYnD4hKo0Jzct_iPa2KKjb-3sLy02fB9PdJERj3a95XaybSX-j5lGGJq9z3xEfb43YBGIvGhd5ISx535el51QQmH$
Am Donnerstag, 21. November 2024, 18:05:30 Mitteleuropäische Normalzeit schrieb 'Kampanakis, Panos' via pqc-forum: Hi Panos' via pqc-forum, > Hi Stephan,> > Please check Section 4 of draft-ietf-lamps-cms-sphincs-plus> e-signed-data-conventions CMS always uses pure mode. When signed attributes> are present the data is digested "using the same hash function that is used> in the SLH-DSA tree".> -pure-mode-vs-pre-hash-mode says something similar for ML-DSA in CMS.> > In other words CMS already supports optional predigesting and thus we don't> need the HashSLH-DSA. That is more straightforward and aligns with what CMS> implementations do today. Thank you. Just to clarify: in case of not having signed attributes, the digestAlgorithm set with the signer is to be ignored? Thanks CiaoStephan -- You received this message because you are subscribed to the Google Groups "pqc-forum" group.To unsubscribe from this group and stop receiving emails from it, send an email to pqc-forum+...@list.nist.gov.> ---
> Mike Ounsworth
> Apostle of the church of ExternalMu-ML-DSA
>
> Pardon me,
but is all the trade-off based on saving one small round of hashing?
No, that matters almost not at all. I did not even mention that in my email below.
The main problem is the absolute disaster that’s gonna happen at the operational level when you start having to commit at key-gen time to whether your ML-DSA key will do pure or pre-hashed signatures, and also the absolute disaster that’s gonna happen at the protocol level when we need to carry in the message whether to use ML-DSA.Verify() or HashML-DSA.Verify(), and if the client gets it wrong, then you have a security vulnerability, which means this data needs to be protected inside the signed data, which most protocols today don’t do, it’s a nasty chicken-and-egg problem.
ExternalMu-ML-DSA does not have either of these problems because the .Verify() function is identical or both ML-DSA and ExternalMu-ML-DSA.
> I am not sure I understand why HashML-DSA would be step down in terms
of security, at the core the signature binds the public key just likeML-DSA does
No, it doesn’t, not if you put a pre-hash in front of it.
Let’s assume an attack model where the hash function used for the HashML-DSA prehash is broken like SHA-1 so that it’s easy to find collision pairs where H(m1) = H(m2). Then I trivially have a signature collision in HashML-DSA.
The same is only true for ML-DSA if the collision was computed against that public key, ie H(tr || m1) = H(tr | m2). In other words, it needs to be a per-public-key collision search. This is not quite as robust as SLH-DSA which rolls in a completely unpredictable nonce, but it’s something.
So while HashML-DSA is not worse that RSA, it’s not taking advantage of modern crypto design techniques. Insisting that we MUST maintain the behaviour from the ‘90’s is impeding both the immediate signature security improvements in FIPS 204 and 205, and also any future innovations. In my opinion, we need to treat the signature primitives as a black box and stop interfering with their internal security properties. You may argue that separating out mu is also doing this, but I argue that it is not; it is separating the work between two collaborating crypto modules, but it is not altering the behaviour of the algorithm.
> Additionally allowing bare mu trading can lead to people simply
unbinding pk.tr and writing protocols that pass in an arbitrary hash(and hash mechanism) into the ExternalMu-ML-DSA generating a completelynon compliant signature.
Again, I’m proposing that ExternalMu-ML-DSA.Prehash() and ExternalMu-ML-DSA.Sign() can be split across a P11 driver and its backing HSM; not that we should be exposing ExternalMu-ML.Sign() to the application. I fully agree that allowing protocol designers to get creative with how they construct mu is a complete and total violation of the ML-DSA algorithm. Also, a signature generated this way would fail to validate against a standard .Verify() function, since that independently computes mu. In addition to that failing test vectors, I suspect that CMVP would not certify that anyhow because FIPS 204 makes it clear that the ExternalMu prehash step still has to be done in a certified crypto module, just not necessarily *the same* crypto module.
(Alg 7 line 6):
“> message representative that may optionally be computed in a different cryptographic module”
This is excellent discussion. It’s really unfortunate that we didn’t get to have this discussion *before* FIPS 204 was published because now I’m afraid that we are fighting against inertia that people have already sunk investment into their ML-DSA implementations. I think it’s very clear that ML-DSA and ExternalMu-ML-DSA is WAY LESS MESSY at the X.509 layer than ML-DSA and HashML-DSA since the latter requires a complete duplicate set of OIDs, and a complete duplicate set of .Verify() implementations.
---
Mike Ounsworth
To view this discussion visit https://groups.google.com/a/list.nist.gov/d/msgid/pqc-forum/17085cae888c6d61c1fad174c645a9873b5429c7.camel%40redhat.com.
On Fri, 2024-11-22 at 11:01 -0800, Watson Ladd wrote:
> On Fri, Nov 22, 2024 at 10:58 AM Simo Sorce <si...@redhat.com> wrote:
> >
> > On Fri, 2024-11-22 at 10:53 -0800, Watson Ladd wrote:
> > > I don't understand why the PKCS 11 driver or whatever API cannot
> > > handle what it takes to work with external mu internally, while the
> > > hardware HSM exposes the mu.
> >
> > It totally can, but the driver, or the HSM, can verify nothing about
> > the passed in mu except its length.
> >
> > What this means is
> >
> > External-mu-ML-DSA == Raw RSA
> >
> > Handle with care!! And ... thank you?
>
> I think you misunderstand. The PKCS11 driver would expose ML-DSA. The
> use of external mu is purely an implementation detail between the HSM
> and the driver to avoid sending the entire message to the HSM.
I am not sure why people fixate on PKCS11 here.
Once OpenSSL or other popular Open Source cryptography library provides
access to sign with External-mu-ML-DSA the damage is done.
I agree with Watson here.
Whether or not openssl would need to expose an API for ExternalMu-ML-DSA is sortof orthogonal to this discussion. I can imagine that openssl would need to implement the ExternalMu.Prehash() function, and would need to know how to chain that into underlying cryptographic hardware that exposes a .Sign(mu). If you are doing a signature entirely in local software, then there is no reason to split this into Prehash() and then Sign() – just do straight “one-shot” normal ML-DSA. It’s hard to imagine what use case would require openssl to implement and expose a .Sign(mu) function in software. That would be cases where a a single signature produced across two collaborating openssl modules separated by a network connection? If openssl does have a use case for that, I trust them to suitably document it. As Sophie has nicely laid out, there’s no security risk here: if you hand in a broken mu, then you have a broken signature that will not verify, which is probably not what you wanted, but is not a security problem.
---
Mike Ounsworth
From: Watson Ladd <watso...@gmail.com>
Sent: Friday, November 22, 2024 1:34 PM
To: Simo Sorce <si...@redhat.com>
Cc: Sophie Schmieg <ssch...@google.com>; John Gray <jogr...@gmail.com>; Mike Ounsworth <Mike.Ou...@entrust.com>; Tim Hollebeek <tim.ho...@digicert.com>; Stephan Mueller <smue...@chronox.de>; pqc-forum <pqc-...@list.nist.gov>
Subject: Re: [EXTERNAL] [pqc-forum] HashML-DSA vs ExternalMu-ML-DSA
On Fri, Nov 22, 2024, 11: 28 AM Simo Sorce <simo@ redhat. com> wrote: On Fri, 2024-11-22 at 11: 01 -0800, Watson Ladd wrote: > On Fri, Nov 22, 2024 at 10: 58 AM Simo Sorce <simo@ redhat. com> wrote: > > > > On Fri, 2024-11-22
Hi Simo,
Right, so the question is whether and how to support cases where Prehash() --> mu is computed by one crypto module (ex.: openssl), which then hands off to a Sign(mu) in another crypto module (ex.: a P11 driver for an HSM). As a PKI person myself this is all “crypto module internal detail” to me, but this is a thing that needs to be sorted out.
I think the open question is whether PKCS#11 should expose a .Sign(mu) ? I think it probably does. Again, the exact wording of FIPS 204 is:
“> message representative that may optionally be computed in a different cryptographic module”
So it’s totally within the FIPS guidelines for Prehash() to be done in Module A, and Sign(mu) to be done in Module B. There probably are valid use cases that will require this.
---
Mike Ounsworth
From: Simo Sorce <si...@redhat.com>
Sent: Friday, November 22, 2024 3:25 PM
To: Mike Ounsworth <Mike.Ou...@entrust.com>; Watson Ladd <watso...@gmail.com>
Cc: Sophie Schmieg <ssch...@google.com>; John Gray <jogr...@gmail.com>; Tim Hollebeek <tim.ho...@digicert.com>; Stephan Mueller <smue...@chronox.de>; pqc-forum <pqc-...@list.nist.gov>
Subject: Re: [EXTERNAL] [pqc-forum] HashML-DSA vs ExternalMu-ML-DSA
I was under the impression you were advocating for a public API to allow external parties (it's in the name) to pass mu directly to the cryptographic module. If all you are discussing is how to internally organize calls between the software
Waston, but that’s an entirely separate use case, right?
If openssl is linked against and calling into a P11 driver, that is a different usecase from a P11 driver being linked against and calling into openssl. One requires the PKCS#11 specification to expose a .Sign(mu) and the other does not.
Other than sunk costs on the part of HSM vendors who may have already shipped their ML-DSA implementation, is there any downside to putting a .Sign(mu) API into the P11 spec in order to allow the prehash step to be done by the application prior to invoking the HSM’s driver?
PS – I may be contradicting my own earlier comments here. Oops.
---
Mike Ounsworth
From: Watson Ladd <watso...@gmail.com>
Sent: Friday, November 22, 2024 4:46 PM
To: Mike Ounsworth <Mike.Ou...@entrust.com>
Cc: Simo Sorce <si...@redhat.com>; Sophie Schmieg <ssch...@google.com>; John Gray <jogr...@gmail.com>; Tim Hollebeek <tim.ho...@digicert.com>; Stephan Mueller <smue...@chronox.de>; pqc-forum <pqc-...@list.nist.gov>
Subject: Re: [EXTERNAL] [pqc-forum] HashML-DSA vs ExternalMu-ML-DSA
On Fri, Nov 22, 2024 at 2: 41 PM Mike Ounsworth <Mike. Ounsworth@ entrust. com> wrote: > > Hi Simo, > > > > Right, so the question is whether and how to support cases where Prehash() --> mu is computed by one crypto module
The 2nd paragraph of the section 6 in FIPS 204 explicitly disallows offering Algorithm 7 (and the others in this section, including Algorithm 8, ‘Verify_internal’) to applications. So the needed change is to remove this ‘should not’:
“Other than for testing purposes, the interfaces for key generation and signature generation specified in this section should not be made available to applications, as any random values required for key generation and signature generation shall be generated by the cryptographic module. ”
Yes, there is a huge difference between ‘should not’ and ‘shall not’, and optimistic folks have been reading ‘should not’ as ‘do what you want’ as long as we have had standards. However, I strongly disagree with an optimistic interpretation on these grounds:
I think there very much needs to be a change to FIPS 204 before embracing the IETF-LAMPS proposed plan.
Please also note: my own feelings are a very strong preference for ExternalMu-ML-DSA. I very much like the compatibility / simplicity and I think a lot of the security goal is met by moving line 5 of Algorithm 4 into Algorithm 7, although I am not a cryptographer.
Note that in my non-cryptographer opinion, I think FIPS 205 has a similar problem, even though section 9.4 explicitly allows pre-hash. This is because the remedy in section 9.4 is to pass hash(M) as the M input to the sign operation (algorithm 18), meaning that pre-hash SLH-DSA will also result in a different signature of M versus ‘Pure’ SLH-DSA. I do not understand FIPS 205 well enough to know if the preceding algorithms allow an equivalent construction to ExternalMu-ML-DSA, resulting in the same signature for pre-hash and ‘pure’ SLH-DSA.
--
You received this message because you are subscribed to the Google Groups "pqc-forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pqc-forum+...@list.nist.gov.
THALES GROUP LIMITED DISTRIBUTION to email recipients
Hi Richard,
We received confirmation on the NIST PQC forums that supporting an interface that accepts Mu as input is allowed. Here is one of the more recent (and more direct) threads on that topic.
https://groups.google.com/a/list.nist.gov/g/pqc-forum/c/GPtJRsk67TY
As for “should not” vs “shall”, I don’t believe there is any confusion there either. As part of a certification, we are required to provide documentation/evidence as to how we meet all of the SHALL statements in the various FIPS specification. And “should not” is a recommendation, not a requirement we are required to meet.
The FIPS specifications also provide definitions that support this.
shall: used to indicate a requirement of this standard
should: used to indicate a strong recommendation but not a requirement of this standard. Ignoring the recommendation could lead to undesirable results.
Thanks
Darren