mirror of
https://github.com/muety/wakapi.git
synced 2025-12-06 06:22:41 -08:00
fix: set default parallelism if argon2id.DefaultParams overflows to 0
This commit is contained in:
@@ -79,7 +79,13 @@ func CompareArgon2Id(hashed, plain, pepper string) bool {
|
||||
|
||||
func HashArgon2Id(plain, pepper string) (string, error) {
|
||||
plainPepperedPassword := strings.TrimSpace(plain) + pepper
|
||||
hash, err := argon2id.CreateHash(plainPepperedPassword, argon2id.DefaultParams)
|
||||
params := *argon2id.DefaultParams
|
||||
// Check for the uint8 overflow bug on high-core-count CPUs.
|
||||
if params.Parallelism == 0 {
|
||||
// If the overflow is detected, set parallelism to a safe default.
|
||||
params.Parallelism = 2
|
||||
}
|
||||
hash, err := argon2id.CreateHash(plainPepperedPassword, ¶ms)
|
||||
if err == nil {
|
||||
return hash, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user