-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: x/crypto: yescrypt support #49898
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
Comments
cc @FiloSottile |
Although this is for x/crypto, I believe the stdlib FAQ applies here: https://go.dev/doc/faq#x_in_std |
I have no idea of the golang internals, so I don't know where this should be implemented. It would be nice if someone could help. |
Thanks for tagging me on this, @gustavosbarreto. I'm also not familiar with Go and where this would need to be. Would this require yescrypt implementation written in Go or would it use the existing C+SIMD code under the hood? I'd prefer the latter, for performance and future maintenance reasons. Also, this should possibly use shared code with scrypt from go.crypto, as yescrypt can also compute classic scrypt from the same codebase, and not only the password hashing but also the KDF functionality (both classic scrypt and yescrypt) should be exposed (unlike in libxcrypt, which only exposes a subset of the password hashing functionality). Maybe @dchest wants to comment? |
@solardiz Go libraries don't use C, so it would need to be reimplemented in Go, but can use assembly for performance sensitive parts. Indeed, it makes sense to share code with existing x/crypto/scrypt implementation, especially if there's SIMD implementation (current scrypt is not SIMD). Personally, I would like to see yescrypt in x/crypto, and can help review it. I think the best first step would be to have a nice third-party package outside of x/crypto first, that people can use, and then propose it for inclusion once it reaches some level of acceptance. From what I see, the linked initial implementation has some room for improvement with regards to code style. |
As an option, https://github.com/golang/crypto/blob/master/scrypt/scrypt.go can be enhanced to also compute yescrypt when that is requested by the caller. This file can then be renamed to |
What would the API be if we extended package scrypt? |
This proposal has been added to the active column of the proposals project |
Some initial thoughts on API: For yescrypt, there are new arguments in addition to N, r, p: t, g, and NROM:
The current signature of scrypt is: func Key(password, salt []byte, N, r, p, keyLen int) ([]byte, error) For yescrypt it would be a lot of arguments for a single function. It also needs an optional ROM buffer to be passed. Perhaps, it should use a struct for parameters, which would also be useful for serialization. Additionally, yescrypt defines a password hash format, just like bcrypt, so we can define Yescrypt also defines a way to encrypt/decrypt/re-encrypt hashes with a secret key. Those would be separate functions. |
@dchest so it sounds like yescrypt really wouldn't reuse any of the bcrypt API? Given that it's not just a tweak to x/crypto/bcrypt, should it really be in x? Is there a reason it shouldn't be a package maintained by someone else? Thoughts, @FiloSottile? |
@rsc it wouldn't use the API (of x/crypto/scrypt), but the internals of implementations can be shared. In fact, it might make sense to implement yescrypt, and then switch x/crypto/scrypt to call it.
I think this should be at least the first step. It would be nice to have a fast Go/assembly implementation of yescrypt as a package. Once there is such implementation, contributing it into x/crypto would benefit the performance of x/crypto/scrypt by switching it to call yescrypt with some configuration flags set to zero. (BTW, x/crypto/scrypt also began its life as a third-party package.) |
/cc @golang/security |
The average Go application is probably fine with x/crypto/argon2 for generic password hashing, and providing multiple choices for the same job is not a goal of the standard library (or of x/crypto). Compatibility with Debian and Fedora is something that can be addressed through a third-party module. The strongest argument for inclusion would be centralizing improvements in the shared backend with scrypt. On balance, that does not feel worth the extra maintenance burden of a new package. FYI, there is an approved proposal for adding a high-level API to x/crypto/scrypt, which might be of interest to anyone implementing the yescrypt package. #16971 |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
Can you provide the source code of golang to implement yescrypt? |
I've been asked to share this link in case others search for yescrypt support on the Go issue tracker: |
With
yescrypt
being the default password hashing scheme on recent ALT Linux, Debian 11, Fedora 35+, and Kali Linux 2021.1+. It is also supported in Fedora 29+ and Ubuntu 20.04+, and is recommended for new passwords in Fedora CoreOS. it might be desirable to supportyescript
in golang.Yescrypt is a notable algorithm:
Where used:
Tech details:
The text was updated successfully, but these errors were encountered: