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

tests/pbkdf2: de-flanky-fy test #18932

Merged
merged 2 commits into from
Nov 18, 2022
Merged

Conversation

maribu
Copy link
Member

@maribu maribu commented Nov 18, 2022

Contribution description

Previously, the test vectors were encoded into the python test scripts, converted to base64, and send over to the device under test via stdio. The application sent back the output after converting it to base64 first, which was read back in by the test script and decoded. Finally, the test script compared the result with the expected result.

This made the test complex, slow and, flanky, as stdio on interfaces such as UART has a high bit error rate and some quirks (e.g. the EDBG UART bridge e.g. in the samr21-xpro dropping bytes when bursts of more than 64 bytes at a time are send).

This basically rewrites the test to embed the test vectors in the firmware and do the comparison on the devices. This fixes test failures on the samr21-xpro, the nRF52840-DK and likely many others. Also, it is now fast.

Beware: This sneaks in a non-API-change-API-change: The password and salt is now passed as const void * rather than as const uint8_t *, as having to cast c-strings to const uint8_t * is a needles pain in the ass.

Testing procedure

make BOARD=nrf52840dk -C tests/pbkdf2 flash test

should pass. Changing one bit in the expected digest in one of the test vectors should result in the test to no longer pass.

Issues/PRs references

None

Having to cast a password provided as `const char *` to
`const uint8_t *` is a needless pain in the ass when using the API.
Hence, fix it by accepting passwords and salts as `const void *`
instead.
Previously, the test vectors were encoded into the python test scripts,
converted to base64, and send over to the device under test via stdio.
The application sent back the output after converting it to base64
first, which was read back in by the test script and decoded. Finally,
the test script compared the result with the expected result.

This made the test complex, slow and, flanky, as stdio on interfaces
such as UART has a high bit error rate and some quirks (e.g. the EDBG
UART bridge e.g. in the samr21-xpro dropping bytes when bursts of more
than 64 bytes at a time are send).

This basically rewrites the test to embed the test vectors in the
firmware and do the comparison on the devices. This fixes test failures
on the samr21-xpro, the nRF52840-DK and likely many others. Also, it
is now fast.
@github-actions github-actions bot added Area: sys Area: System Area: tests Area: tests and testing framework labels Nov 18, 2022
@maribu maribu changed the title sys/hashes/pbkdf2 tests/pbkdf2: de-flanky-fy test Nov 18, 2022
@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: run tests If set, CI server will run tests on hardware for the labeled PR labels Nov 18, 2022
@riot-ci
Copy link

riot-ci commented Nov 18, 2022

Murdock results

✔️ PASSED

176cb9a tests/pbkdf2: de-flanky-fy test

Success Failures Total Runtime
117861 0 117861 02h:31m:14s

Artifacts

@benpicco benpicco merged commit e068899 into RIOT-OS:master Nov 18, 2022
@maribu maribu deleted the sys/hashes/pbkdf2 branch November 19, 2022 09:40
@maribu
Copy link
Member Author

maribu commented Nov 19, 2022

Thx :)

@maribu
Copy link
Member Author

maribu commented Nov 21, 2022

Backport provided in #18941

@kaspar030 kaspar030 added this to the Release 2023.01 milestone Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: run tests If set, CI server will run tests on hardware for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants