Add tests for the cryptographic primitives - #266
Merged
Merged
Conversation
test/cryptotest.c checks AES-CBC (NIST SP 800-38A), ChaCha20 and Poly1305 (RFC 8439) for all implementations available on the target, compares the implementations on pseudo-random input, and checks the Poly1305 tag comparison. The program is built like the shell by "make check" or "make cryptotest" and runs in the host_unix CI job after the existing tests.
Owner
|
Hi Markus, thank very much for this great contribution! 🥇 |
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.
Hi Ulrich,
as discussed in #262, this adds a test program for the cryptographic primitives and runs it in CI.
Type: Feature / Enhancement (tests)
What it checks
test/cryptotest.cincludes the amalgamation, so it can call the internal functions directly:Without selectable implementations (currently
main), only the default implementations are checked. The program returns 1 if a check fails.Because the program calls internal functions such as
sse2_poly1305()directly, it has to be adjusted when these functions are renamed or removed.Why
The existing CI tests only exercise the implementations a runner selects by default. A hardware-specific implementation that computes wrong results, or results that differ from the other implementations, would not be noticed.
Build and CI
Makefile.amaddscryptotestas acheck_PROGRAMStarget with the flags ofsqlite3shell, so a normalmakedoesn't build it. Thehost_unixjob builds and runs it after the existing tests.Tested
main(a393e13): the CI recipe (autoreconf,./configure,make, then the new step) on Linux x86_64 and arm64 with GCC and Clang, plus direct builds on macOS arm64, the iOS simulator, Android (NDK r28) and WebAssembly. All checks pass.hwaccel(8794b10): all 6669 checks pass on ARM64, including NEON, and all 9123 checks pass on x86_64, including SSSE3, AVX2 and SSE2.The test vectors were cross-checked with OpenSSL.
Best regards,
Markus