block-buffer and block-padding improvements #113
Merged
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.
This PR modifies
block-buffer
andblock-padding
APIs to reduce their surface and to make them mostly panic-free. Lack of panics inblock-buffer
was checked using godbolt. The relevantunsafe
code line relies on the following invariant:pos
is always strictly smaller than block size.Because of this invariant I had to remove the
input_lazy
method, which was initially added for Skein. I think it will be better to later introduce a separate "lazy" buffer type. As a consequence it means that Skein will not be compatible with the core API introduced in RustCrypto/traits#380 (I think it could be eventually fixed with specialization). For most users it will be a barely noticeable implementation detail (i.e. Skein will simply implement the mid-level traits directly, without relying on the core wrapper), so considering relative unpopularity of hashes reliant on "lazy" buffers, I think it's a reasonable sacrifice.Ideally we would use an Ada-like range type for
pos
(both theblock-buffer
field and theblock-padding
method argument), but without const generics such type probably will be quite unergonomic.Closes #79