golang/go

x/crypto/argon2: docs on thread parameter might make users inadvertently create non-portable hashes

Open

#42.605 aperta il 14 nov 2020

Vedi su GitHub
 (6 commenti) (0 reazioni) (0 assegnatari)Go (19.008 fork)batch import
DocumentationNeedsFixhelp wanted

Metriche repository

Star
 (133.883 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Both IDKey and Key from golang.org/x/crypto/argon2 take a threads parameter which is documented as following:

The number of threads can be adjusted to the numbers of available CPUs.

While it's obviously wrong in hindsight, this sentence lead me to pass the (dynamic) value of runtime.NumCPU() as the value for threads when hashing passwords, which means the hashes Argon2 would create are different (i.e. stop matching) on hosts with different numbers of CPUs.

Would it make sense to extend the comments here to point out that threads is not purely performance related, but also has an effect on the hash output (e.g. by stating it needs to be a fixed value and you can use the number of CPUs as a guideline)?

Guida contributor