summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/scrypt.go26
1 files changed, 12 insertions, 14 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