-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feature Request: Allow specifying Argon2 parameters #119
Comments
I created a Pull Request with the proposed solution. |
hey @TylerWanta, sorry for the late reply. If the recommended parameters are too low, I think we should focus on fixing the defaults than allowing different parameters. My current assessment: The defaults in https://docs.rs/argon2/0.5.3/argon2/struct.Params.html#associatedconstant.DEFAULT_M_COST are
Spec currently recommends:
https://datatracker.ietf.org/doc/draft-irtf-cfrg-opaque/ Conclusion: P (paralellism) cost is 1, but should be 4 Is this correct? If so I think we should update the defaults in the library to match the spec. Or do you have any good reasons to use other parameters? |
Admittedly, I was only thinking about the low parallelism cost when originally looking at the parameters. Now, seeing the jump in memory Doing some research, it seems like 2GBs is quite a high cost. Testing this locally, it takes 14.71s to fun the algorithm with the recommended parameters
Considering this is an OPAQUE package, updating the parameters to the recommended still seems like a good idea to me, but, with the memory cost as high as it is, allowing developers to tone it done a bit would be needed. Otherwise, forcing the defaults could easily prevent developers from being able to utilize the package due to the abnormally high resource usage. FWIW, the default argon2 parameters take me ~250ms to run, which is a bit low. Usually the sweet spot is ~1s from my understanding. Another argument for allowing to specify argon2 parameters is that hardware advances. What may take ~1s today, could take ~250ms in a couple years. In that case, the parameters would want to be increased. From my knowledge, monitoring algorithm times and adjusting parameters is a fairly common thing. I guess to flip the question, did you have a specific reason for not allowing parameters to be specified? The parameters are still going through validation, so it should be easy to tell to someone if they are trying to use parameters that are incompatible. |
To answer your question: From my experience sane defaults and less options is usually better. Especially when it comes to cryptography. I think us exploring this is a good example how complex it is and how is to screw it up. We could still make it flexible, but the most important thing should be to have good defaults. The 2GB memory is indeed concerning. Will see if I can check with other people who use OPAQUE in production and what's their experience. |
Hey @TylerWanta, sorry for the delay Got some feedback: the initial discussion on the parameters happened here: cfrg/draft-irtf-cfrg-opaque#376 I think you are right in making on configurable after reading more into the topic. There are two ways forward for default configurations that sound sensible:
Why this setting? It's the second recommended option in the RFC draft https://www.rfc-editor.org/rfc/rfc9106.html#name-recommendations
What are your thoughts? |
Hey @nikgraf. Good catch on the second set of parameter recommendations in the paper. My vote would be for using those parameters for Argon2id. Do you still plan on allowing users of the package to specify their own parameters on top of this change? |
@TylerWanta good question, not sure. We could offer predefined sets of parameters? I'm worried that exposing the full parameter-set causes more harm than does good. Very tricky API decision |
@nikgraf offering predefined sets of parameters would be useful. We could do
We could then default them to the first set of recommended parameters but allow switching between any of the 3. We could also allow slight tweaking of the predefined ones, but only with options from a curated list. So if someone wanted something slightly more secure than the second option, they could pick from a memory cost of |
I am interested in this as well. I would like to let the user select the parameters during registration. For this it would be really nice if the user can choose the parameters to their liking, e.g. in the UI the user can choose how many seconds or how much memory it would take to stretch their password on their machine. Btw. once the KDF parameters are selected how are their retrieved from the server? Are they encoded in the loginResponse? or do they need to be transferred separately? |
@nikgraf FWIW, it looks like Bitwarden (password manager) allows users to specify the parameters used for Argon2id |
yeah, I think we probably want to allow a union of pre-defined defaults or a custom object @czeidler no the KDF parameters are currently not encoded in the loginResponse. Especially since the handling of these might vary a lot from application to application I think they should be handled by the application developer. What do you think? sorry for being so unresponsive, busy times |
@nikgraf Did you want me to tweak my current pull request to support both pre-defined defaults and custom params, or do you have a plan and want to tackle it yourself? |
@TylerWanta In case you have time and are motived, would be great if you could do it! I'm super busy for 2 more weeks. As a first step we should define the API. I was thinking to have an optional parameter:
e.g. type KeyStrechingFunction = {
name: "argon2-custom";
iterations: number;
memory: number;
parallelism: number
} | {
name: "argon2-recommended"
}; This would be a minimal version. argon2 recommended is the default in case In addition we could add a What do you think? Feedback is very welcome |
@TylerWanta @czeidler I created a PR: #127 - feedback would be much appreciated |
@nikgraf Sorry, was very busy for a while there and wasn't tracking this as closely. Thanks for getting this done, it looks great so far! I left just a few comments on the pull request |
I noticed that the default parameters are being used for the argon2 package, which seem to be a bit below the recommended parameters outlined in the protocol.
Could an update be made to support specifying different parameters for argon2?
The text was updated successfully, but these errors were encountered: