Add missing secret key coefficient validation#807
Add missing secret key coefficient validation#807sgmenda wants to merge 1 commit intopq-code-package:mainfrom
Conversation
d93c482 to
649b860
Compare
|
Thank you @sgmenda for raising this! I see that in aws/aws-lc#2874 you added the check to It seems to depend on the assumptions we make on the input. If we assume a valid SK, then the check is not needed. If we don't assume a valid SK, then why do we only surface the validity issue in a Does the spec say something about this check? EDIT: Oh well, I should have read our own documentation first. It clearly says that |
|
@hanno-becker yep, exactly. mldsa-native/mldsa/mldsa_native.h Lines 672 to 685 in b7e9a26 |
d025ad6 to
90c2778
Compare
|
Thank you for this! In my mind, my first thought was to modify the function In my mind, the fundamental issue is this function: https://github.com/pq-code-package/mldsa-native/blob/main/mldsa/src/polyvec.h#L666-L685 Should not be bound to Essentially, what I feel the crux of this PR is getting at, is changing the above decision for The current approach in this PR solves the issue in a way I hadn't first considered, and I just want to know the pros/cons of this over allowing This all came to me when creating the CBMC contract for the |
Altenative to #807 This commit adds validation of the s1 and s2 components of the secret key to the pk_from_sk function. It checks if coefficients are within the valid bound [-MLDSA_ETA, MLDSA_ETA] by using the chknorm function that is already present in the code. Documentation and CBMC proofs are adjusted accordingly. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
|
@mkannwischer nope, that's a better fix. I hadn't thought of that. Thanks for the suggestion. |
|
@initsecret General Q: The standard does not seem to designate a list of recommended validity checks, does it? |
Altenative to #807 This commit adds validation of the s1 and s2 components of the secret key to the pk_from_sk function. It checks if coefficients are within the valid bound [-MLDSA_ETA, MLDSA_ETA] by using the chknorm function that is already present in the code. Documentation and CBMC proofs are adjusted accordingly. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
|
There's a bunch of validity checks on the public key, but it is less strict about the secret key because it assumes it's honestly generated. (/im afk rn, so I made a note to provide a detailed response when im back at work in ~11hrs.) |
This paragraph on secret key validity is the only thing that I can find: |
Altenative to #807 This commit adds validation of the s1 and s2 components of the secret key to the pk_from_sk function. It checks if coefficients are within the valid bound [-MLDSA_ETA, MLDSA_ETA] by using the chknorm function that is already present in the code. Documentation and CBMC proofs are adjusted accordingly. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
Altenative to pq-code-package#807 This commit adds validation of the s1 and s2 components of the secret key to the pk_from_sk function. It checks if coefficients are within the valid bound [-MLDSA_ETA, MLDSA_ETA] by using the chknorm function that is already present in the code. Documentation and CBMC proofs are adjusted accordingly. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
|
I rebased my test on top of @mkannwischer 's excellent a8738b1, and verified that |
Altenative to pq-code-package#807 This commit adds validation of the s1 and s2 components of the secret key to the pk_from_sk function. It checks if coefficients are within the valid bound [-MLDSA_ETA, MLDSA_ETA] by using the chknorm function that is already present in the code. Documentation and CBMC proofs are adjusted accordingly. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
933d699 to
518bb84
Compare
Altenative to #807 This commit adds validation of the s1 and s2 components of the secret key to the pk_from_sk function. It checks if coefficients are within the valid bound [-MLDSA_ETA, MLDSA_ETA] by using the chknorm function that is already present in the code. Documentation and CBMC proofs are adjusted accordingly. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
Altenative to #807 This commit adds validation of the s1 and s2 components of the secret key to the pk_from_sk function. It checks if coefficients are within the valid bound [-MLDSA_ETA, MLDSA_ETA] by using the chknorm function that is already present in the code. Documentation and CBMC proofs are adjusted accordingly. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
Altenative to #807 This commit adds validation of the s1 and s2 components of the secret key to the pk_from_sk function. It checks if coefficients are within the valid bound [-MLDSA_ETA, MLDSA_ETA] by using the chknorm function that is already present in the code. Documentation and CBMC proofs are adjusted accordingly. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
Signed-off-by: sanketh <sgmenda@amazon.com>
518bb84 to
426ba6e
Compare

Issues:
crypto_sign_pk_from_skwas not verifying that s1 and s2 polynomial coefficients were within the valid range [-η, η].Description of changes:
Implements missing validation in
crypto_sign_pk_from_skto verify that s1 and s2 polynomial coefficients are within the valid range [-η, η].Motivated by aws/aws-lc#2874 where we discovered, via a Wycheproof test vector, that AWS-LC's MLDSA implementation was accepting secret keys with out-of-bounds s1/s2 coefficients.
Call-outs:
Testing:
The new functional tests and the existing tests all pass.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.