Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we use the context string? #24

Closed
bwesterb opened this issue Oct 1, 2024 · 16 comments
Closed

Should we use the context string? #24

bwesterb opened this issue Oct 1, 2024 · 16 comments

Comments

@bwesterb
Copy link
Collaborator

bwesterb commented Oct 1, 2024

Mike asks which context string to use. At the moment we don't set any.

This question is not specific to ML-DSA. Context strings have been discussed in general in this LAMPS thread.

@ounsworth
Copy link
Contributor

ounsworth commented Oct 1, 2024

The correct answer is probably to use the empty string. One good reason for this is backwards-compatibility with signature primitives that do not have ctx params (ie if we want to use the same context string across all signature schemes, then this is the only option), and even compatibility with crypto libraries that offer ML-DSA but no not have a .Sign() interface that accepts a ctx parameter.

Empty string is already the default in FIPS 204, so in theory nothing needs to be said in draft-dilithium-certificates, but it would probably be polite to put in a sentence.

@bwesterb
Copy link
Collaborator Author

bwesterb commented Oct 1, 2024

There is an argument to be made to set a context string. Over time, the signature algorithms used will all have context. Also, requiring it here forces libraries to adopt it, which is very helpful to protocols where a context string is more useful but don't have the reach of X509. The clear downside is more work and added complexity. I have not made up my mind.

@jakemas
Copy link
Collaborator

jakemas commented Oct 2, 2024

I think we should probably include the context string, as any FIPS implementation of ML-DSA will have it included. However, I do agree that minimizing complexity is important. The use of the empty string seems the most reasonable solution here.

@csosto-pk
Copy link
Contributor

I vote for empty string. It does not add anything in the X.509 context.

If folks insist, a simple context like the ASCII characters of "X.509 ML-DSA" would suffice imo.

@ounsworth
Copy link
Contributor

ounsworth commented Dec 11, 2024

After thinking a bit more, here is a more refined opinion:

What should be in draft-ietf-lamps-dilithium-certificates-05 is a statement that ML-DSA signatures produced by CA certificates (basicConstraints.cA=true) MUST use ctx=””, while signatures produced by end entity certificates MAY use any ctx value as appropriate for its application context.

The rationale here is that LAMPS owns the "protocol" that is X.509 Certificates and CRLs, but we do not own arbitrary things that an X.509 cert can sign, so we can and should be prescriptive about the former, but not about the latter.

Alternatively, maybe it makes sense to set ctx=”rfc5280certificate”, ctx=”rfc5280csr”, ctx=”rfc5280crl”, etc to prevent type confusion attacks. I don’t have a strong preference, but we should be prescriptive one way or another.

@OR13
Copy link

OR13 commented Dec 11, 2024

Sorry for hitting the list before seeing this.

For some context regarding JOSE / COSE.

The both already have their own application layer context constructions, so I don't plan to expose ctx directly in the specifications, unless there is clear justification for doing it the same way as this draft.

FWIW, I am in favor of "empty string".

@ounsworth
Copy link
Contributor

For some context regarding JOSE / COSE.

The both already have their own application layer context constructions, so I don't plan to expose ctx directly in the specifications, unless there is clear justification for doing it the same way as this draft.

FWIW, I am in favor of "empty string".

Orie,

Another thought. CMS is actually the closer parallel between COSE and “LAMPS-things”.

https://datatracker.ietf.org/doc/html/draft-ietf-lamps-cms-ml-dsa-01

It says:

ML-DSA has a context string input that can be used to ensure that different signatures are generated for different application contexts. When using ML-DSA as described in this document, the context string is not used.

So ctx=”” everywhere within CMS, mainly because it already has plenty of context binding at the application layer.

@csosto-pk
Copy link
Contributor

Context had some value when HashML-DSA was going to be used. I think, now that HashML-DSA is becoming irrelevant there is no point in using ctx. Empty string makes sense to me.

@csosto-pk
Copy link
Contributor

Need to close this one, I think we converged to empty ctx.

@danvangeest
Copy link
Contributor

Context had some value when HashML-DSA was going to be used.

@csosto-pk can you expand on this? Does it also apply to HashSLH-DSA? HashSLH-DSA is being defined for public keys in end-entity certificates, so x509-slhdsa doesn't really have any say about how the context would be use there, but I'm curious why you say the context had some use with HashML-DSA.

@bwesterb
Copy link
Collaborator Author

bwesterb commented Dec 12, 2024

Need to close this one, I think we converged to empty ctx.

We might still want to add some words to that effect to the I-D.

@csosto-pk
Copy link
Contributor

csosto-pk commented Dec 12, 2024

Need to close this one, I think we converged to empty ctx.

We might still want to add some words to that effect to the I-D.

@bwesterb , please check #62

@csosto-pk
Copy link
Contributor

Context had some value when HashML-DSA was going to be used.

@csosto-pk can you expand on this? Does it also apply to HashSLH-DSA? HashSLH-DSA is being defined for public keys in end-entity certificates, so x509-slhdsa doesn't really have any say about how the context would be use there, but I'm curious why you say the context had some use with HashML-DSA.

Hi @danvangeest

Indeed about HashML-DSA, you can't control the ctx. You can only control it for PureXX-DSA.

I meant that ctx did not exist in Dilithium. It was introduced for the M' calculation when NIST added the HashML-DSA option. I think the idea for ctx and domain separation came from Markku when discussing the EUF-CMA property of the newly introduced HashML-DSA and PureML-DSA. I am fuzzy on the details. Now that we will basically not be using HashML-DSA, I don't think we should care about the option.

I think Sophie had made a few good points against the necessity of ctx in ML-DSA as well, but there are too many things to track and I forget the details.

I don't have any strong feelings about ctx in SLH-DSA. Given that you will need Pure and Hash there (you can't do external my like ML-DSA), maybe you want to use ctx as PR-PKIX and DG-PKIX and call it a day. Or maybe you can use empty string for the Pure and specify HashSL-DSA-PKIX only for the external generation of M' in the HashSLH-DSA. I really don't have strong feelings, but it seems to me of HashXX-DSA is really used, adding the context makes sense.

@danvangeest
Copy link
Contributor

@csosto-pk, M` is already constructed differently depending if you're using Hash*-DSA or (pure) *-DSA. So the context won't add any additional differentiation between pure and Hash signatures. The value in using the context is if you're signing different content types with the same key and signature algorithm. Then using different contexts for different content types avoids a potential issue if there are encoding collisions between the content types.

Given that everything that is signed by a CA key is ASN.1 encoded, there shouldn't be any encoding collisions for this draft.

@csosto-pk
Copy link
Contributor

csosto-pk commented Dec 12, 2024

ACK, you are right. The OID is in the M' of HashXX-DSA already. Fine by me if you also use empty everywhere.

@csosto-pk
Copy link
Contributor

csosto-pk commented Dec 19, 2024

Ready to be closed @bwesterb. The change made it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants