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

Update SHA module #18

Merged
merged 9 commits into from
Feb 24, 2025
Merged

Update SHA module #18

merged 9 commits into from
Feb 24, 2025

Conversation

JulioLoayzaM
Copy link
Collaborator

  • Update the SHA test vectors to the new format, merging the different CAVP files into one ShaVectors instance.
  • Remove bit-oriented tests. The current protocol did not account for non-aligned sizes, meaning they could not be used properly, and there does not seem that many implementations support this mode.
  • Update the SHA wrapper to be harness-like, add the example to the documentation.
  • Add a test for the harness mode, include it in the docs.

Remove the bit-oriented test vectors. The current protocol only passes
the message to hash without indication of its length in bits, making it
impossible to test bit-oriented implementations. Furthermore, it seems
that not many implementations are bit-oriented [1], which is anecdotally
confirmed by the absence of bug reports on this mode.

In a first time, the main user-visible change is the fact that `test`
raises ValueError if the given orientation is BIT. The next step is to
remove the orientation completely. If there are users of this mode, we
may add them back. In that case, we should create separate test vectors
with an additional `len` field, as well as a separate test function.

For users of the test vectors, the ShaVectors class from `vectors.SHA`
is replaced by the protobuf class `vectors._sha.sha_pb2.ShaVectors`. The
test vectors themselves are simplified, as we did with the SHAKE
vectors. The tests from the LongMsg and ShortMsg files are combined into
a single instance of ShaVectors, along with a new mc_test field for
Monte Carlo tests. This means that only a single Results is returned per
test vectors file.

[1]: https://csrc.nist.rip/groups/STM/cavp/documents/shs/shaval.html
Following the update of the SHA test vectors, remove the Orientation
parameter, as crypto-condor does not properly test bit-oriented
implementations.
Wrong indentation from previous version meant that only the last test
was actually counted.
It was not needed as we only have compliance test vectors for now, but
better to start including the option in all primitives.
Move the Python wrapper to the new format with naming convention. Update
the example to test this format, and add the corresponding doc page. The
page includes the wrapper example, instead of only examples of function
names.
Add a harness test using OpenSSL and include it in the documentation as
an usage example. crypto-condor now passes the size of the output
buffer, mainly in case implementations need to copy the output from
another buffer.
Replaces the `test` function to explicitely add the name of the
operation being tested to the function name.
Continuing with a standardisation of the function names, add
`test_output_digest` to replace `verify_file`. The latter is deprecated
but not yet removed to maintain compatibility.
@JulioLoayzaM JulioLoayzaM merged commit dbccd26 into main Feb 24, 2025
9 checks passed
@JulioLoayzaM JulioLoayzaM deleted the feat/sha-update branch February 24, 2025 10: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.

1 participant