Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Argon2 native CPU module selection #2

Open
riptl opened this issue Dec 14, 2018 · 2 comments
Open

Argon2 native CPU module selection #2

riptl opened this issue Dec 14, 2018 · 2 comments
Labels
crate:libargon2-sys Concerns libargon2-sys sub-crate enhancement New feature or request

Comments

@riptl
Copy link
Contributor

riptl commented Dec 14, 2018

Like in nimiq/core-js#440 of core-js, I think it's useful to have a native module selection for packaged builds, and I'd like to take on this.

My idea is to statically link the different versions of libargon2 into the same binary, giving the function names a suffix of the target via a C macro.
We'd then have argon2d_hash_raw_avx2, argon2d_hash_raw_sse2 and so on built from the same source.

Like in nimiq/core-js#456, a $PACKAGING environment variable should be introduced, that will trigger a native build if it's false instead of the avx2, sse2… versions.

On startup, Rust then would set up function pointers to the native module and use rust-cupid to initialize them with the correct implementations.

I also filed #1 to reduce the number of functions so the module is easier to work with.

The alternative would be to dynamically load the implementations like the .node libraries in Node.js but that'd be more difficult and inconvenient, in my opinion.

@riptl
Copy link
Contributor Author

riptl commented Dec 15, 2018

If we use function multiversioning instead, no changes are required in Rust.

@paberr
Copy link
Member

paberr commented Jan 15, 2019

Function multi versioning looks like a nice way to tackle that.

@paberr paberr added enhancement New feature or request crate:libargon2-sys Concerns libargon2-sys sub-crate labels Feb 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crate:libargon2-sys Concerns libargon2-sys sub-crate enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants