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-cipher: add BlockCipherMut #179

Merged
merged 1 commit into from
Jun 9, 2020
Merged

block-cipher: add BlockCipherMut #179

merged 1 commit into from
Jun 9, 2020

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Jun 9, 2020

Adds a stateful equivalent to BlockCipher that permits &mut self access to the underlying type.

The main use case for this trait is hardware cryptographic accelerators which need to e.g. communitate with a peripheral device via an underlying &mut reference.

While it's possible to use some underlying logic to use the existing BlockCipher trait in such a scenario, the solutions are somewhat ugly. Here is a real-world example:

https://github.com/iqlusioninc/usbarmory.rs/blob/develop/firmware/usbarmory/src/dcp/aes128.rs#L198-L236

The idea with BlockCipherMut would be to alternatively provide AeadMut/AeadMutInPlace for AEAD modes with an underlying BlockCipherMut (when possible).

Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit hesitant about ParBlocks. Does it make sense for hardware cryptographic accelerators? IIUC they either work on per-block basis or process the whole message (multiple of block sizes) at once with a given mode (e.g. ECB or CBC).

@tarcieri
Copy link
Member Author

tarcieri commented Jun 9, 2020

I’d agree: I just did it for feature parity, but these use cases are always ParBlocks=U1, so it might be nice to omit it for simplicity.

Adds a stateful equivalent to `BlockCipher` that permits `&mut self`
access to the underlying type.

The main use case for this trait is hardware cryptographic accelerators
which need to e.g. communitate with a peripheral device via an
underlying `&mut` reference.

While it's possible to use some underlying logic to use the existing
`BlockCipher` trait in such a scenario, the solutions are somewhat ugly.
Here is a real-world example:

https://github.com/iqlusioninc/usbarmory.rs/blob/develop/firmware/usbarmory/src/dcp/aes128.rs#L198-L236

The idea with `BlockCipherMut` would be to alternatively provide
`AeadMut`/`AeadMutInPlace` for AEAD modes with an underlying
`BlockCipherMut` (when possible).
@tarcieri
Copy link
Member Author

tarcieri commented Jun 9, 2020

Updated to remove ParBlocks

@tarcieri tarcieri merged commit e312a03 into master Jun 9, 2020
@tarcieri tarcieri deleted the block-cipher-mut branch June 9, 2020 04:30
@tarcieri tarcieri mentioned this pull request Jun 11, 2020
dns2utf8 pushed a commit to dns2utf8/traits that referenced this pull request Jan 24, 2023
…ustCrypto#182)

Closes RustCrypto#179.

This commit makes the `Params` struct always available regardless of
enabled crate features, adding on functionality when the `password-hash`
feature is enabled.

Per the added TODOs in this commit, it really seems like in the next
breaking release, `Argon2::new` should accept `Params` as an argument
rather than duplicating all of the individual parameter fields and
passing them in as arguments. After that, they can be validated and
stored within the `Argon2` struct itself. But that would be a breaking
change, so for now they're stored piecemeal.

Additionally, this commit now ensures enough context is available in the
`Argon2` struct in order to implement `hash_password_simple` that uses
the configured params rather than the defaults, which addresses the
aforementioned issue.
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.

None yet

2 participants