-
Notifications
You must be signed in to change notification settings - Fork 19
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
Making argon2rs #![no_std] - lanes configuration? #19
Comments
The main use case I see for
I suggest using I don't know much about Argon2 but I think support for multiple lanes can also be added by using SIMD, right? Maybe it makes sense to use the futures API to abstract out any use of threading? I'm not sure. |
without std::vec, what would block::Matrix look like? |
Does it need to be resizable? Can't remember seing any
This is a good idea with a good raison d'être.
If I understood that correctly, making We could as well do a whole different and crazy thing: In case of |
how else to deal with adjustable memory cost at runtime? |
Well, doesn't the amount of memory to allocate solely depend on the configuration parameters for Argon2? Just allocate a big enough buffer in advance. After all, your API does not allow to change a hasher's configuration, once created. I.e. And if I'd need two different memory cost configurations at runtime, I'd just create two different Argon2 hashers. |
precisely how would this allocation take place?
|
Okay, so, the first step would be to link against Rust's allocator API, i.e. against After allocating memory, you'd have to initialise it before use. Your array is let block_array_ptr: *mut Block = ...;
for i in 0..(lanes * lanelen) {
unsafe { ptr::write(block_array_ptr.offset(i), zero()) }; // Your `zero` function.
} You might as well just Then, you can use this raw block of memory like any other 2D array, by converting 2D coordinates to 1D ones like this: Depending on how paranoid we are, you'd want to Finally, if you'd want a more fancy API instead of raw allocate/deallocate, you could The good thing is that Edit: There is also |
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
core
doesn't know about threading, we'd have to do something about thelanes
parameter forArgon2::new
andargon2::defaults::LANES
. I can think of three sensible ways to solve the parallelism issue.ParamErr::TooManyLanes
forlanes != 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_api
function. This can be combined with (1.) by returning an error ifapi.is_none()
andlanes > 1
.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 infeature = "core"
people choosing very weak parameters.The text was updated successfully, but these errors were encountered: