Skip to content

Expose "detached" in-place encryption/decryption APIs #21

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

Merged
merged 1 commit into from
Oct 4, 2019

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Oct 4, 2019

Exposes an encrypt_in_place_detached() and decrypt_in_place_detached() API on all AEAD implementations in this repository.

Until we figure out what the upstream API looks like, this commit at least makes an in-place mode an option for those who don't want to allocate a buffer for every encryption/decryption operation.

Exposes an `encrypt_in_place_detached()` and
`decrypt_in_place_detached()` API on all AEAD implementations in this
repository.

Until we figure out what the upstream API looks like, this commit at
least makes an in-place mode an option for those who don't want to
allocate a buffer for every encryption/decryption operation.
@tarcieri tarcieri requested a review from newpavlov October 4, 2019 18:16
@tarcieri
Copy link
Member Author

tarcieri commented Oct 4, 2019

I will open a separate PR proposing to add these methods to the Aead and AeadMut traits. I don't think they need to be the only in-place API, or even the preferred one for end users, but in terms of AEAD implementations, I hope this PR makes clear that they all benefit as I have used this pattern in all of the implementations.

@tarcieri
Copy link
Member Author

tarcieri commented Oct 4, 2019

PR to add encrypt_in_place_detached() and decrypt_in_place_detached() to the Aead and AeadMut traits open here: RustCrypto/traits#58

@tarcieri
Copy link
Member Author

tarcieri commented Oct 4, 2019

Going to go ahead and land this, but I'll hold off on another release of any of these crates until I hear back on RustCrypto/traits#58 and RustCrypto/traits#59

@tarcieri tarcieri merged commit 05d4181 into master Oct 4, 2019
@tarcieri tarcieri deleted the expose-detached-apis branch October 4, 2019 20:32
newpavlov pushed a commit to RustCrypto/traits that referenced this pull request Nov 17, 2019
This commit adds `encrypt_in_place_detached()` and
`decrypt_in_place_detached()` methods to `Aead` and `AeadMut`, along
with default implementations of `encrypt()` and `decrypt()` which assume
a postfix authentication tag.

Presently all of the AEAD implementations in `RustCrypto/AEADs` use this
pattern. This PR exposes the detached interface as a public API:

RustCrypto/AEADs#21

Note that this need not be the only in-place API (hence the long name
with `_detached` on the end. I plan on doing a follow-up PR for adding
an in-place API which does not depend on `alloc` but also handles
ciphertext message assembly/parsing, which would be more useful for end
users.

That said, this API isn't just useful for AEAD implementers: there are
genuine use cases for a detached API from an end user perspective, e.g
encrypted filesystems.

With the addition of this API, we can also make `alloc` an optional (but
enabled-by-default) feature, allowing use of AEADs on truly `#![no_std]`
targets.
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.

1 participant