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

block-buffer and block-padding improvements #113

Merged
merged 3 commits into from
Jan 18, 2021
Merged

block-buffer and block-padding improvements #113

merged 3 commits into from
Jan 18, 2021

Conversation

newpavlov
Copy link
Member

@newpavlov newpavlov commented Dec 6, 2020

This PR modifies block-buffer and block-padding APIs to reduce their surface and to make them mostly panic-free. Lack of panics in block-buffer was checked using godbolt. The relevant unsafe 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 the block-buffer field and the block-padding method argument), but without const generics such type probably will be quite unergonomic.

Closes #79

@newpavlov
Copy link
Member Author

I have added the xor_data method, which should be useful for RustCrypto/stream-ciphers#95. I am not 100% sure it will be universal enough to unify buffering logic for one-pass AE and AEAD implementations, but it should be a good enough starting point.

block-buffer/src/lib.rs Outdated Show resolved Hide resolved
@newpavlov newpavlov merged commit ffd2524 into master Jan 18, 2021
@newpavlov newpavlov deleted the block_utils branch January 18, 2021 13:17
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.

block-padding: add NAME associated constant to the Padding trait
2 participants