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

chacha20: Add full NEON backend. #310

Merged
merged 4 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/chacha20.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ jobs:
rust: stable

# ARM64 with NEON backend
#- target: aarch64-unknown-linux-gnu
# rust: nightly
# features: --features neon
- target: aarch64-unknown-linux-gnu
rust: stable
features: --features neon

# PPC32
- target: powerpc-unknown-linux-gnu
Expand Down
1 change: 1 addition & 0 deletions chacha20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ hex-literal = "0.3.3"
[features]
std = ["cipher/std"]
zeroize = ["cipher/zeroize"]
neon = []
Copy link
Member

Choose a reason for hiding this comment

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

It might be worth considering using a cfg! attribute here /cc @newpavlov

I think the only reason to have a gated implementation at all is MSRV compatibility. We can bump to MSRV 1.61 in the next release (bumping to 1.60 has some nice additions like weak feature activation).

Semi-related issue: RustCrypto/sponges#24 (comment)

FWIW, we use cfg! attributes to gate aes and pmull intrinsics on ARMv8


[package.metadata.docs.rs]
all-features = true
Expand Down
6 changes: 4 additions & 2 deletions chacha20/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ work on stable Rust with the following `RUSTFLAGS`:
- `x86` / `x86_64`
- `avx2`: (~1.4cpb) `-Ctarget-cpu=haswell -Ctarget-feature=+avx2`
- `sse2`: (~2.5cpb) `-Ctarget-feature=+sse2` (on by default on x86 CPUs)
- `aarch64`
- `neon` (~2-3x faster than `soft`) requires Rust 1.61+ and the `neon` feature enabled
- Portable
- `soft`: (~5 cpb on x86/x86_64)

Expand Down Expand Up @@ -76,8 +78,8 @@ done with a minor version bump.

Licensed under either of:

* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
* [MIT license](http://opensource.org/licenses/MIT)
- [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
- [MIT license](http://opensource.org/licenses/MIT)

at your option.

Expand Down
2 changes: 2 additions & 0 deletions chacha20/src/backends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ cfg_if! {
pub(crate) mod sse2;
}
}
} else if #[cfg(all(feature = "neon", target_arch = "aarch64", target_feature = "neon"))] {
pub(crate) mod neon;
} else {
pub(crate) mod soft;
}
Expand Down