Possible incorrect sha256 values for 64 bytes buffers #156
Labels
No labels
announcement
bug
duplicate
enhancement
help wanted
invalid
Next release
question
sighting
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-intel/isa-l_crypto#156
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi,
There seem to be a bug that leads to incorrect sha256 values for 64 bytes buffers.
The broken sequence:
submit(64 bytes, ISAL_HASH_FIRST)->submit(0 bytes, ISAL_HASH_LAST)->flush()->Wrong HashThe working one:
submit(0 bytes, ISAL_HASH_FIRST)->submit(64 bytes, ISAL_HASH_LAST)->flush()->Correct HashI'd expect the value to be the same and correct regardless of the permutation.
Environment:
Minimal reproducible example:
Hi @wlou. Thanks for the detailed explanation of this sighting. In order to make it work, regardless the order, you need to flush after each submit call, unless the submit function returns the ctx ('out' in your case).
Check out the explanation in sha256_mb.h (at the top).
Thanks for quick reply @pablodelara ! Got it, please feel free to close the issue.
Tested the following and it works as expected:
submit(0 bytes, ISAL_HASH_FIRST)->flush()->submit(64 bytes, ISAL_HASH_LAST)->flush()-> Correctsubmit(64 bytes, ISAL_HASH_FIRST)->flush()->submit(0 bytes, ISAL_HASH_LAST)->flush()-> CorrectJust to clarify, is it correct to assume that redundant
flush()calls are safe?Yes, redundant
flush()s are safe. "Worse" case, nothing gets out and ctx is always NULL.