summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-09-28 06:35:25 -0300
committerEuAndreh <eu@euandre.org>2024-09-28 06:35:25 -0300
commit64beccc9b279a87dc6c4688a6e3e51489d909e3a (patch)
tree0829a413cac37a8002066d3045b133b92f07654b
parentMakefile: "var version" -> "const Version" (diff)
downloadscrypt-64beccc9b279a87dc6c4688a6e3e51489d909e3a.tar.gz
scrypt-64beccc9b279a87dc6c4688a6e3e51489d909e3a.tar.xz
src/scrypt.go: Remove "scrypt" prefix from consts
-rw-r--r--src/scrypt.go26
-rw-r--r--tests/scrypt.go4
2 files changed, 14 insertions, 16 deletions
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
diff --git a/tests/scrypt.go b/tests/scrypt.go
index d6d59c3..b7d87f1 100644
--- a/tests/scrypt.go
+++ b/tests/scrypt.go
@@ -431,9 +431,9 @@ func test_Salt() {
testing("we generate a random salt of a fixed size", func() {
salt := Salt()
- assertEq(len(salt), scryptSaltMinLength)
+ assertEq(len(salt), saltMinLength)
- var buffer [scryptSaltMinLength * 2]byte
+ var buffer [saltMinLength * 2]byte
hex.Encode(buffer[:], salt)
fmt.Fprintf(os.Stderr, "%s ", string(buffer[:]))
})