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

Unify the aes, aesni, aes-ctr, and aes-soft crates #200

Merged
merged 6 commits into from
Nov 18, 2020
Merged

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Nov 16, 2020

Combines all four crates into a single aes crate.

The optional ctr feature exposes a consistent set of Aes*Ctr types.

cc @peterdettman

aes/Cargo.toml Outdated Show resolved Hide resolved
@tarcieri tarcieri force-pushed the aes/unify-crates branch 6 times, most recently from 2d71c31 to 4479823 Compare November 16, 2020 22:27
aes/Cargo.toml Outdated Show resolved Hide resolved
@tarcieri tarcieri force-pushed the aes/unify-crates branch 2 times, most recently from e79b4b6 to ec205ca Compare November 16, 2020 22:39
Combines all three crates into a single `aes` crate.

The optional `ctr` feature exposes a consistent set of `Aes*Ctr` types
as well.
@tarcieri tarcieri changed the title [WIP] Unify the aes, aesni, and aes-soft crates Unify the aes, aesni, and aes-soft crates Nov 16, 2020
@tarcieri tarcieri marked this pull request as ready for review November 16, 2020 22:53
@tarcieri
Copy link
Member Author

I was a bit torn on whether to call this a breaking change (i.e. bumping the version to 0.7.0-pre).

It seems like the only breaking case would be treating the types exported from aes as the same as either aesni or aes-soft, which would be breaking if ever AES-NI were/weren't used (depending on what you're expecting).

Given that, I think it's safe to call it backwards compatible. We could potentially release this as v0.6.1, and yank the previous v0.6.0 to prevent any shenanigans.

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 thought that unification is worth only with added runtime detection. Otherwise AES-NI support will be hard to find for users who do not use the aes crate directly. In other words most users will use the software implementation, while with the current implementation they may notice aes-soft in their build log. I think I've seen projects which use aesni directly to motivate users to enable the aes target feature.

But I guess if we'll add the runtime detection before the next minor cipher version, merging crate now should not be a problem.

aes/src/lib.rs Outdated Show resolved Hide resolved
aes/src/lib.rs Show resolved Hide resolved
aes/src/ni.rs Outdated Show resolved Hide resolved
aes/src/ni/aes192.rs Outdated Show resolved Hide resolved
@tarcieri
Copy link
Member Author

I thought that unification is worth only with added runtime detection.

We definitely need it for that. The current target-based gating of aesni vs aes-soft crate dependencies makes adding it impossible.

But also it's unclear how to add things like ARM acceleration (#10), which is especially important given the recent launch of the Apple M1. Would that otherwise go into aesni? But then we need to gate on two different targets, and things get quite complicated. Add yet another crate? I think as we add more hardware accelerated backends, converging on a single crate makes things a lot easier.

aes/src/ni.rs Show resolved Hide resolved
@newpavlov
Copy link
Member

newpavlov commented Nov 18, 2020

it's unclear how to add things like ARM acceleration

AFAIK the ideal solution is blocked on rust-lang/rfcs#2725. Meanwhile we would have to either write platform-specific code to extract available features, continue to rely on RUSTFLAGS, or add a feature for forcing hardware-accelerated implementation (assuming M1 uses the AArch64 crypto extension). Considering that ARM intrinsics are still unstable, I think the latter option will be fine for now.

@tarcieri
Copy link
Member Author

tarcieri commented Nov 18, 2020

Think I addressed all of the outstanding comments.

Re: cfg-if-based gating in lib.rs I mentioned earlier, I think I'd like to explore that as part of a separate PR.

An additional remaining question is still whether if this is merged, whether it could be published as v0.6.1, or if we should hold off and do a cipher crate upgrade and/or runtime detection first.

@newpavlov
Copy link
Member

I think we can merge but do not publish just yet.

@tarcieri tarcieri merged commit cd5a34f into master Nov 18, 2020
@tarcieri tarcieri deleted the aes/unify-crates branch November 18, 2020 15:21
tarcieri added a commit that referenced this pull request Nov 18, 2020
Bumps the `aes` crate version to indicate we'll be making breaking
changes before the next release (i.e. `cipher` crate upgrade).

Also removes the `aesni` and `aes-soft` crates from the README.md table
now that they've been unified into the `aes` crate (#200)
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.

2 participants