Description
Important
Nov 20, 2024: The latest version of the proposal is here.
Proposal Details
I propose to move the golang.org/x/crypto/pbkdf2 package into the standard library with the name crypto/pbkdf2
. This proposal is a #65269 spin off, as requested by the following comment from @rsc:
I agree with this in principle but there should be review of individual packages rather than a blank check to usher significant amounts of never-reviewed API into the standard library.
#65269 (comment)
pbkdf2
is a low-hanging fruit here as it only exports a single function. I propose to move it to the standard library as is, just adding an error return parameter in case we want to implement some additional parameter validation in the future (e.g. minimum salt length or minimum iterations). The proposed API looks like this:
// Key derives a key from the password, salt and iteration count,
// returning a []byte of length keyLen that can be used as cryptographic key.
// The key is derived based on the method described as PBKDF2 with the
// HMAC variant using the supplied hash function.
func Key(password, salt []byte, iter, keyLen int, h func() hash.Hash) ([]byte, error)
The pbkdf2.Key
function is enough to cover most pbkdf2 use cases. As a data point, OpenSSL exports the PKCS5_PBKDF2_HMAC function, accepting the same inputs as pbkdf2.Key
.
@golang/security
Metadata
Metadata
Assignees
Type
Projects
Status