Skip to content
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

proposal: x/crypto/argon2: Check if the parameters and the key length are valid #65717

Open
sorairolake opened this issue Feb 15, 2024 · 1 comment
Labels
Proposal Proposal-Crypto Proposal related to crypto packages or other security issues
Milestone

Comments

@sorairolake
Copy link

sorairolake commented Feb 15, 2024

Proposal Details

According to RFC 9106, the valid values for the parameters and the key length are:

  • $1 \leq t \leq 2^{32} - 1$ (number of passes, time)
  • $8p \leq m \leq 2^{32} - 1$ (memory size, memory)
  • $1 \leq p \leq 2^{24} - 1$ (degree of parallelism, threads)
  • $4 \leq T \leq 2^{32} - 1$ (tag length, keyLen)

No need to check maximum values of time, memory and keyLen, since these are math.MaxUint32. Also, since threads is uint8, there is no need to check the maximum value.

The minimum values of time and threads are already checked. However, the minimum values of memory and keyLen seem not to be checked. So, I would suggest checking for these minimum values and either panic or return an error if they are invalid.

Examples

import "golang.org/x/crypto/argon2"

// `memory` is invalid
idKey := argon2.IDKey([]byte("passphrase"), salt, 3, 24, 4, 4)

// `keyLen` is invalid
key := argon2.Key([]byte("passphrase"), salt, 3, 32, 4, 3)
@gopherbot gopherbot added this to the Proposal milestone Feb 15, 2024
@ianlancetaylor
Copy link
Contributor

CC @golang/security

@ianlancetaylor ianlancetaylor added the Proposal-Crypto Proposal related to crypto packages or other security issues label Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Proposal Proposal-Crypto Proposal related to crypto packages or other security issues
Projects
Status: Incoming
Development

No branches or pull requests

3 participants