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 against all 100 KAT values #1560

Merged
merged 39 commits into from
Jan 30, 2024
Merged

Test against all 100 KAT values #1560

merged 39 commits into from
Jan 30, 2024

Conversation

SWilson4
Copy link
Member

@SWilson4 SWilson4 commented Sep 26, 2023

Add functionality to test against all 100 NIST KAT values.

  • Extend the kat_kem and kat_sig programs to generate all 100 KAT values
  • Collect SHA256 hashes for the extended KAT values
  • Create a Python script analogous to test_nistkat.py to run all 100 tests
  • Integrate the tests into a CI workflow

Fixes #1418

  • [No] Does this PR change the input/output behaviour of a cryptographic algorithm (i.e., does it change known answer test values)? (If so, a version bump will be required from x.y.z to x.(y+1).0.)
  • [No] Does this PR change the list of algorithms available -- either adding, removing, or renaming? Does this PR otherwise change an API? (If so, PRs in oqs-provider, OQS-OpenSSL, OQS-BoringSSL, and OQS-OpenSSH will also need to be ready for review and merge by the time this is merged.)

@SWilson4
Copy link
Member Author

SWilson4 commented Sep 26, 2023

While working on this, I noticed that our implementation of Falcon-1024 differs from the upstream on a single KAT, number 82. I put together a demonstration here: https://github.com/SWilson4/falcon-diff

This seems to be explained by the signature buffer size used for the KATs: our implementation uses the signature size of 1280 bytes while the upstream code passes a larger buffer of 1330 bytes (even though the signature size upstream is still defined to be 1280 bytes). I'm not sure yet why this is done, but redefining the signature size to be 1330 in liboqs does make all 100 KATs pass.

.circleci/config.yml Outdated Show resolved Hide resolved
.circleci/config.yml Outdated Show resolved Hide resolved
@baentsch
Copy link
Member

baentsch commented Nov 5, 2023

redefining the signature size to be 1330 in liboqs does make all 100 KATs pass.

This also speaks for your option 3 in #1561 (comment). Yes, @dstebila this may be a deviation from the "sig size" number given in the Falcon spec, but a) that number seems to be an "arbitrary choice" and b) aren't KATs there to "tie down" any spec ambiguities?

@dstebila dstebila added this to the 0.10.0 milestone Dec 7, 2023
@SWilson4 SWilson4 force-pushed the sw-full-kat branch 2 times, most recently from 5e35f96 to 8883e71 Compare December 15, 2023 19:31
@SWilson4
Copy link
Member Author

Now that Falcon updates are (hopefully) coming soon, I think it's time to get this merged. I would rather it not be held up by the (apparently buggy) CircleCI ARM environment, so for now the full KATs only run on GitHub Actions once a week, using the same configuration as the constant-time tests. They will fail for Falcon-1024 until the new code for that algorithm lands.

@SWilson4 SWilson4 marked this pull request as ready for review December 18, 2023 14:05
@SWilson4 SWilson4 requested review from baentsch, bhess and dstebila and removed request for bhess and dstebila December 18, 2023 14:05
src/common/rand/rand.h Outdated Show resolved Hide resolved
tests/kat_kem.c Outdated Show resolved Hide resolved
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.

Conceptually LGTM. I'd approve if there'd be a good rationale for the API (or a change to "externalize" the state :)

The environment says Thanks for your diligent exclusion of this long-running test from the standard CI suite. I just wonder whether there'd be a more future-proof way to do this, e.g., some sort of "weekly_only" test list that can be summarily excluded from all PR and push Ci tests (?) Or should we create a separate issue for this? Something separating the .py files into "WEEKLY_TESTS", "PR_ONLY_TESTS" and "ALWAYS_TESTS"...

@SWilson4 SWilson4 force-pushed the sw-full-kat branch 2 times, most recently from 92a49d1 to c0e4c2b Compare December 22, 2023 19:58
@SWilson4 SWilson4 marked this pull request as draft January 8, 2024 16:31
@SWilson4
Copy link
Member Author

SWilson4 commented Jan 8, 2024

I'm going to mark this PR as draft while I tinker with the internal API configuration. Will reopen for review when I'm ready for feedback.

@SWilson4
Copy link
Member Author

Once (if) #1667 lands, I'll rebase this branch and reopen this PR.

@SWilson4 SWilson4 marked this pull request as ready for review January 22, 2024 19:46
@SWilson4
Copy link
Member Author

This has been rebased to use the new internal API and is once again ready for review. Pardon the long and messy commit history.

@SWilson4 SWilson4 requested review from baentsch, dstebila, praveksharma and bhess and removed request for dstebila and bhess January 22, 2024 19:47
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.

Pardon the long and messy commit history.

No reason to apologize. Sorry in turn for the questions triggering some of the work. Didn't read single commits but only reviewed the final files changes and those basically LGTM (2 separate nits for which there's probably easy answers). The merge indeed should be a thorough "Squash" with presumably most commit messages trimmed. I also presume you tested the weekly job using act or so?!

@SWilson4 SWilson4 merged commit 7c56bcb into main Jan 30, 2024
56 checks passed
@SWilson4 SWilson4 deleted the sw-full-kat branch January 30, 2024 21:01
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.

Expand test coverage to all 100 NIST KAT values
3 participants