Skip to content

Commit

Permalink
Use argon2 as more memory efficient key derivation algorithm
Browse files Browse the repository at this point in the history
scrypt uses too much memory especially with that config that we had used
  • Loading branch information
bumi committed Jan 30, 2024
1 parent b4d409b commit cf3c45d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions aesgcm.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"encoding/hex"
"strings"

"golang.org/x/crypto/scrypt"
"golang.org/x/crypto/argon2"
)

func DeriveKey(password string, salt []byte) ([]byte, []byte, error) {
Expand All @@ -18,10 +18,7 @@ func DeriveKey(password string, salt []byte) ([]byte, []byte, error) {
}
}

key, err := scrypt.Key([]byte(password), salt, 131072, 8, 1, 32)
if err != nil {
return nil, nil, err
}
key := argon2.Key([]byte(password), salt, 3, 32*1024, 1, 32)

return key, salt, nil
}
Expand Down

0 comments on commit cf3c45d

Please sign in to comment.