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

Test Improvements for ML-KEM #1947

Merged
merged 17 commits into from
Nov 13, 2024
Merged

Conversation

abhinav-thales
Copy link
Contributor

@abhinav-thales abhinav-thales commented Oct 8, 2024

This PR does the following:
- enable ML-KEM ACVP tests on Windows
Since ML-KEM final specification is released, it would be good to have the tests enabled on Windows
- testcases for ML-KEM rejection key
Add negative testcase as per Algorithm 18 of ML-KEM final specification when the calculated encrypted text does not match the passed ciphertext
- harden checks in vector_kem for RNG lengths and correct error message in decaps

Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
@SWilson4
Copy link
Member

SWilson4 commented Oct 9, 2024

Not sure if you're working on Windows @abhinav-thales, but this script might be helpful to get past the formatting check.

Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
@abhinav-thales abhinav-thales marked this pull request as ready for review October 11, 2024 03:55
@abhinav-thales abhinav-thales marked this pull request as draft October 11, 2024 03:57
@SWilson4
Copy link
Member

@abhinav-thales I triggered CI on the latest commit; please see the minor build failures.

Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
@abhinav-thales abhinav-thales marked this pull request as ready for review October 18, 2024 03:33
Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
@abhinav-thales abhinav-thales marked this pull request as draft October 21, 2024 05:43
@abhinav-thales abhinav-thales marked this pull request as ready for review October 21, 2024 05:43
Copy link
Member

@bhess bhess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this additional test @abhinav-thales !
See the to comments in the code.
The new test is specific to ML-KEM while the existing tests apply to all KEMs. I think it would make sense to structure the code a bit differently, for example moving the new test to separate function.

tests/test_kem.c Outdated Show resolved Hide resolved
tests/test_kem.c Outdated Show resolved Hide resolved
Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
@abhinav-thales
Copy link
Contributor Author

abhinav-thales commented Oct 21, 2024

Thank you for this additional test @abhinav-thales ! See the to comments in the code. The new test is specific to ML-KEM while the existing tests apply to all KEMs. I think it would make sense to structure the code a bit differently, for example moving the new test to separate function.

Thank you @bhess for the review. Have moved the added testcase to a separate function now.

Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
@bhess
Copy link
Member

bhess commented Oct 22, 2024

Thanks for the updates! One more general comment about the test:
The main use case of the rejection key in ML-KEM seems to be if active attackers modify the ciphertext, where the decapsulation should output the rejection key. A test for this would modify the ciphertext and check if the rejection keys match, while your test modifies the secret key. Could you also add a test case that modifies the ciphertext?

Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
@abhinav-thales
Copy link
Contributor Author

Thanks for the updates! One more general comment about the test: The main use case of the rejection key in ML-KEM seems to be if active attackers modify the ciphertext, where the decapsulation should output the rejection key. A test for this would modify the ciphertext and check if the rejection keys match, while your test modifies the secret key. Could you also add a test case that modifies the ciphertext?

added the testcase now.

Copy link
Member

@bhess bhess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @abhinav-thales for adding the additional test! Looks good to me.

Copy link
Member

@baentsch baentsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, @abhinav-thales . Please see the single comments and mark/#ifdef explicitly the algorithm-specific code, e.g., using OQS_ENABLE_KEM_ML_KEM, to allow the system to keep its (admittedly only internal) differentiation in generalized and algorithm-specific code.

Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
@abhinav-thales
Copy link
Contributor Author

Thanks for the contribution, @abhinav-thales . Please see the single comments and mark/#ifdef explicitly the algorithm-specific code, e.g., using OQS_ENABLE_KEM_ML_KEM, to allow the system to keep its (admittedly only internal) differentiation in generalized and algorithm-specific code.

Hi @baentsch , thanks for the review. The ML-KEM tests are now under conditional check of ML-KEM configuration.

@abhinav-thales
Copy link
Contributor Author

@abhinav-thales I triggered CI on the latest commit; please see the minor build failures.

Hi @SWilson4 , can you trigger the workflow on the latest commit as well please ?

tests/test_kem.c Show resolved Hide resolved
tests/test_kem.c Outdated Show resolved Hide resolved
tests/vectors_kem.c Show resolved Hide resolved
tests/test_kem.c Outdated Show resolved Hide resolved
Signed-off-by: Abhinav Saxena <abhinav.saxena@thalesgroup.com>
@abhinav-thales
Copy link
Contributor Author

Hi @SWilson4 @baentsch the review comments are addressed now. Could you please help with triggering CI pipeline if the fixes are fine. Thanks.

@SWilson4
Copy link
Member

SWilson4 commented Nov 4, 2024

Looks good to me. Thanks for making the requested changes!

@abhinav-thales
Copy link
Contributor Author

Hi @baentsch , If the changes meet your expectations, could you please approve them? If there are any additional adjustments needed, kindly let me know. Thank you !

@baentsch
Copy link
Member

Thanks for re-requesting review @abhinav-thales : I was under the mistaken assumption that by marking all comments resolved things turn green, sorry. Now explicitly marked so. Thanks on behalf of the FOSS community for your contributions to improve the library for everyone!

@baentsch baentsch merged commit 507d030 into open-quantum-safe:main Nov 13, 2024
73 checks passed
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

Successfully merging this pull request may close these issues.

4 participants