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.
It's still rough around edges, but I think it's sufficient to demonstrate main ideas:
BlockEncryptMut
/BlockDecryptMut
traits now used for both block modes and hardware accelerators.BlockCipher
marker trait is introduced to distinguish between them.crypto_common::BlockProcessing
trait is now used for all traits which work over bytes. In future I think we may add aligment information to it (i.e.Block
no longer will be a simple byte array).proc
closures allow us to add "hooks" which can access pre- and post-encryption data, not only it's quite useful for block modes, but also should allow us to support both EtM and MtE modes. Users will not deal with these closures directly, later I will add convenience blanket methods.See the block-ciphers PR to see how these changes work in dependent crates.
Open questions:
impl InOutVal<Block<Self>>
withimpl Into<InOutVal<'_, '_, Block<Self>>>
, where in the latter caseInOutVal
is a struct containing two potentially equal pointers (i.e. it's essentiallyInOutBuf
, but withlen
equal to 1)? In the former case, due to inlining compiler may generate two separate variants of a cipher (in-place and buffer-to-buffer), while in the former it may result in some optimizations being omitted (i.e. in the in-place case program may pass two pointers instead of one and perform the same pointer arithmetic twice).