Skip to content

Add tests for variable-length signatures#541

Merged
thomwiggers merged 9 commits intomasterfrom
sw-variable-len-sig-tests
Feb 5, 2024
Merged

Add tests for variable-length signatures#541
thomwiggers merged 9 commits intomasterfrom
sw-variable-len-sig-tests

Conversation

@SWilson4
Copy link
Copy Markdown
Collaborator

@SWilson4 SWilson4 commented Jan 25, 2024

This PR adds tests for variable-length signatures, as discussed in #530.

There are two tests:

  1. Fill the signature buffer with random bytes before calling the signing operation. Check to see that the "tail" of the buffer (beyond the returned siglen is unmodified.
  2. Mark the signature buffer as "undefined" and use Valgrind to check that the signing operation does not depend on the value of this buffer. This, combined with the previous test, ensures that the signing operation does not read past the end of the buffer in any meaningful way.

The commit history contains a number of reverted commits which deliberately trigger test failures. This is to demonstrate that the new tests do indeed catch undesired behaviour. If you want to double-check this, just checkout one of the "TO BE REVERTED" commits and run either
pytest -v -n=auto -k "falcon-512 and clean" test_functest.py::test_functest or pytest -v -n=auto -k "falcon-512 and clean" test_valgrind.py. I'll squash these commits at merge.

Will mark as ready for review once I see that CI has passed.

@SWilson4 SWilson4 changed the title Sw variable len sig tests Add tests for variable-length signatures Jan 25, 2024
Copy link
Copy Markdown
Member

@thomwiggers thomwiggers left a comment

Choose a reason for hiding this comment

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

One minor suggestion for a change, and one discussion point.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <valgrind/memcheck.h>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we hide the Valgrind tests behind a #define? I think PQCLEAN_USE_VALGRIND or something along those lines sounds good.

Then we can pass this define in test_valgrind.py.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done! Also rebased on the latest master, so hopefully CI will be green(er).

@SWilson4 SWilson4 force-pushed the sw-variable-len-sig-tests branch from ef149dc to 5b10369 Compare January 26, 2024 17:01
@SWilson4 SWilson4 mentioned this pull request Jan 26, 2024
@SWilson4 SWilson4 requested a review from thomwiggers January 26, 2024 17:49
@SWilson4 SWilson4 marked this pull request as ready for review January 26, 2024 17:49
@thomwiggers
Copy link
Copy Markdown
Member

I'm on vacation, so I'm afraid it'll be a little bit

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.

2 participants