Repository navigation
Add ML-DSA context and hedging (CK_SIGN_ADDITIONAL_CONTEXT) - #250
Open
afchine1337 wants to merge 1 commit into
Open
afchine1337 wants to merge 1 commit into
afchine1337 wants to merge 1 commit into
Conversation
Mechanism.ML_DSA takes an optional CK_SIGN_ADDITIONAL_CONTEXT in PKCS#11 v3.2: the FIPS 204 context string and the hedging variant. Until now the only way to pass it was the raw bytes parameter, which means packing the struct by hand with a CK_ULONG whose size depends on the platform. SignAdditionalContext carries the context and a HedgeType, following GCMParams and CTRParams. It is accepted for signing and for verification. ML_DSA without a parameter still passes a NULL parameter, and raw bytes still take precedence, so existing code does not change. Refs pyauth#249
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of the PRs planned in #249.
Mechanism.ML_DSAtakes an optionalCK_SIGN_ADDITIONAL_CONTEXTin PKCS#11 v3.2: the FIPS 204 context string and the hedging variant. Until now the only way to pass it was a rawbytesparameter, which means packing the struct by hand, with aCK_ULONGwhose size depends on the platform.What this adds
HedgeType, anIntEnumof the threeCKH_*values:PREFERRED,REQUIRED,DETERMINISTIC_REQUIRED.SignAdditionalContext(context=None, hedge=HedgeType.PREFERRED)inpkcs11.mechanisms, modelled onGCMParamsandCTRParams. The context is at most 255 bytes, as FIPS 204 allows.Mechanism.ML_DSAaccepts it asmechanism_paramfor signing and for verification. Hedging only matters for signing; a token ignores it on verification.As discussed in #249,
ML_DSAwithout a parameter still passes a NULL parameter, and a rawbytesparameter still takes precedence, so existing code behaves as before.Tests
tests/test_ml_dsa.pygains seven cases:HedgeType.The whole file passes against FreeHSM, a PKCS#11 v3.2 software token. I have not run it against the SoftHSMv2 and opencryptoki builds in CI, and I don't know whether they implement the context and the hedging variants. I will look at what CI reports here and mark the cases for whichever token lacks them, the way existing tests use
NotandFIXME.