jedisct1 / rust-aegis

AEGIS high performance ciphers for Rust.
MIT License
23 stars 4 forks source link

pure-rust via `cfg("aegis_backend" = "..")` vs `cfg(feature = "..")` #5

Open pinkforest opened 1 month ago

pinkforest commented 1 month ago

Hey thanks for working on this! Great stuff

Would you be open to moving the cfg(feature = "pure-rust") into as:

cfg("aegis_backend" = "libaegis" | "rust" | ..)

Happy to send a PR - ideally the selection is automatic but we provide "overrides" in curve25519_dalek f.ex.

We had extensive discussion over here re: features vs cfg when we bumped to curve25519 to v4:

I would recommend having this mutual exclusive override as cfg due to;

The compiler now supports validating cfg (requires high MSRV though so we've ignored it until MSRV is high enough)

Ref:

jedisct1 commented 1 month ago

Hi!

I'm not fluent enough in Rust to understand the difference

However, unless it removes a bug that can't be addressed otherwise, or makes things faster, or adds a feature, what I really care about is avoiding breaking changes. People should be able to update the library version without having to change anything to their code. This includes compiling to WebAssembly without requiring any special tweaks. Maybe what you propose is just some internal changes that wouldn't change any user-facing feature. In that case why not. Rust has so many completely different ways to do the same thing.

The pure Rust implementation was added for people wanting to compile it to WebAssembly, that don't necessarily have a WebAssembly C compiler installed. But it's incomplete and maintaining two implementations in the same project is not fun. So, the plan is rather to precompile libaegis as a webasssembly module, and just link it on that platform, as done by other projects. So that all platforms can share the same code.

If you need to cross-compile to a target that isn't supported by cargo-zigbuild, or don't have a C compiler for some reason, crypto-rust has all the AEGIS variants implemented in pure Rust. It's better than the Rust code we have here.