From 64beccc9b279a87dc6c4688a6e3e51489d909e3a Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 28 Sep 2024 06:35:25 -0300 Subject: src/scrypt.go: Remove "scrypt" prefix from consts --- src/scrypt.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/scrypt.go') diff --git a/src/scrypt.go b/src/scrypt.go index 103ae66..267cb08 100644 --- a/src/scrypt.go +++ b/src/scrypt.go @@ -18,16 +18,14 @@ import ( const ( + saltMinLength = 32 + desiredLength = 32 maxInt = int((^uint(0)) >> 1) MinimumPasswordLength = 16 -) -const ( - scrypt_N = 1 << 15 - scrypt_r = 8 - scrypt_p = 1 - scryptSaltMinLength = 32 - scryptDesiredLength = 32 + _N = 1 << 15 + r = 8 + p = 1 ) @@ -346,8 +344,8 @@ func scrypt( } func SaltFrom(r io.Reader) ([]byte, error) { - buffer := make([]byte, scryptSaltMinLength) - _, err := io.ReadFull(rand.Reader, buffer) + buffer := make([]byte, saltMinLength) + _, err := io.ReadFull(r, buffer) if err != nil { return nil, err } @@ -355,17 +353,17 @@ func SaltFrom(r io.Reader) ([]byte, error) { } func HashFrom(password []byte, salt []byte) ([]byte, error) { - if len(salt) < scryptSaltMinLength { + if len(salt) < saltMinLength { return nil, SaltTooSmallError } hash, err := scrypt( password, salt, - scrypt_N, - scrypt_r, - scrypt_p, - scryptDesiredLength, + _N, + r, + p, + desiredLength, ) if err != nil { return nil, err -- cgit v1.2.3