To make argon2rs #![no_std], we'd have to be able to replace all use std::*; with use core::*;. In theory, this would be as simple as doing something like this:
#[cfg( feature = "core" )] use core::*;
#[cfg(not(feature = "core"))] use std::*;
However, as core doesn't know about threading, we'd have to do something about the lanes parameter for Argon2::new and argon2::defaults::LANES. I can think of three sensible ways to solve the parallelism issue.
- The simplest and possibly most sensible solution would be to return
ParamErr::TooManyLanes for lanes != 1. This might, however, be absolutely not what a user wants.
- Add an extra parameter for
feature = "core", which is a V-table struct for a target OS's threading API. Instead of expanding Argon2::new, however, one might just add a second Argon2::with_thread_api function. This can be combined with (1.) by returning an error if api.is_none() and lanes > 1.
- Just ignore threading and calculate the lanes sequentially. This would, however, increase the calculation time for secure hashes by a freakin' lot. E.g., with
lanes = 8 and the recommended hashing duration of half a second, doing (3.) would take four seconds for the same hash strength. This might result in feature = "core" people choosing very weak parameters.
To make argon2rs
#![no_std], we'd have to be able to replace alluse std::*;withuse core::*;. In theory, this would be as simple as doing something like this:However, as
coredoesn't know about threading, we'd have to do something about thelanesparameter forArgon2::newandargon2::defaults::LANES. I can think of three sensible ways to solve the parallelism issue.ParamErr::TooManyLanesforlanes != 1. This might, however, be absolutely not what a user wants.feature = "core", which is a V-table struct for a target OS's threading API. Instead of expandingArgon2::new, however, one might just add a secondArgon2::with_thread_apifunction. This can be combined with (1.) by returning an error ifapi.is_none()andlanes > 1.lanes = 8and the recommended hashing duration of half a second, doing (3.) would take four seconds for the same hash strength. This might result infeature = "core"people choosing very weak parameters.