Skip to content

Replace ring with aws-lc-rs#24

Merged
zonyitoo merged 1 commit into
shadowsocks:mainfrom
mullvad:replace-ring-with-aws-lc-rs
Apr 25, 2026
Merged

Replace ring with aws-lc-rs#24
zonyitoo merged 1 commit into
shadowsocks:mainfrom
mullvad:replace-ring-with-aws-lc-rs

Conversation

@faern
Copy link
Copy Markdown
Contributor

@faern faern commented Apr 16, 2026

This fixes #22.

I have not actually tested this on Windows since I don't currently have access to a Windows machine. But the CI seem to pass.

MSRV is bumped from 1.63 to 1.71 to match aws-lc-rs 1.16. The Windows CI job also needs NASM preinstalled because aws-lc-sys assembles its x86_64 kernels with it; the clippy job already did this, so the build and test job gets the same ilammy/setup-nasm@v1 step.

This branch builds on top of the cleanup branch in #23. I wanted to make sure the entire CI passed before I was confident in this cryptographic change. So I fixed everything the CI errored on. But I also submitted that as a separate PR in case you want to merge them separately (easier to read the diff if we can make this PR only focus on the ring migration)

@faern faern changed the title Replace ring with aws lc rs Replace ring with aws-lc-rs Apr 16, 2026
@faern
Copy link
Copy Markdown
Contributor Author

faern commented Apr 16, 2026

Since the cargo feature ring is being renamed to faster-crypto, this is a breaking change. Even if we did not do any API breaking change like this, it would maybe be fair to users to do a breaking version bump following the replacement of such a key component in the library. So it would probably make sense to release this as 0.7.0

Swap the optional `ring`/`ring-compat` dependency for `aws-lc-rs`, which
wraps the actively maintained AWS-LC C library and delivers comparable
(or better) AEAD/HKDF throughput without pulling in `ring`.

The cargo feature is renamed from `ring` to `faster-crypto` so downstream
users express intent (a faster crypto backend) rather than the specific
implementation. Platforms not covered by aws-lc-rs (e.g. WASM, exotic
targets) must leave the feature off and fall back to the pure-Rust path.

The AEAD code under the feature gate now calls aws-lc-rs natively via
`LessSafeKey` / `UnboundKey` / `Nonce` / `Aad` / `seal_in_place_separate_tag`
/ `open_in_place`. The HKDF-SHA1 path switches from `ring_compat::ring::hkdf`
to `aws_lc_rs::hkdf`, which exposes the same `Salt` / `Prk` / `Okm` /
`KeyType` surface, so that block is a near-verbatim import swap. The
pure-Rust `else` branches are untouched apart from moving the struct +
impl blocks inside the `cfg_if!` so each backend is self-contained.

MSRV is bumped from 1.63 to 1.71 to match aws-lc-rs 1.16. The Windows
CI job also needs NASM preinstalled because aws-lc-sys assembles its
x86_64 kernels with it; the clippy job already did this, so the build
and test job gets the same `ilammy/setup-nasm@v1` step.
@faern faern force-pushed the replace-ring-with-aws-lc-rs branch from 5ac29b7 to 52add5f Compare April 20, 2026 21:54
@faern
Copy link
Copy Markdown
Contributor Author

faern commented Apr 20, 2026

Thanks for merging the cleanup PR. This has now been rebased on top of main again, and ready for review.

@faern
Copy link
Copy Markdown
Contributor Author

faern commented Apr 23, 2026

I built this on a Windows 10 machine and both cargo build and cargo test passed fine. I also were able to build the shadowsocks binaries based off of this branch. However, I have not really tried running them.

@zonyitoo
Copy link
Copy Markdown
Collaborator

I would prefer to use aws-lc as the feature name instead of faster-crypto.

@zonyitoo zonyitoo merged commit 11203ab into shadowsocks:main Apr 25, 2026
6 checks passed
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.

Replace ring with aws-lc-rs?

2 participants