aboutsummaryrefslogtreecommitdiff
path: root/scrypt/scrypt.go
diff options
context:
space:
mode:
Diffstat (limited to 'scrypt/scrypt.go')
-rw-r--r--scrypt/scrypt.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/scrypt/scrypt.go b/scrypt/scrypt.go
index 76fa40f..b422b7d 100644
--- a/scrypt/scrypt.go
+++ b/scrypt/scrypt.go
@@ -196,6 +196,9 @@ func Key(password, salt []byte, N, r, p, keyLen int) ([]byte, error) {
if N <= 1 || N&(N-1) != 0 {
return nil, errors.New("scrypt: N must be > 1 and a power of 2")
}
+ if r <= 0 || p <= 0 {
+ return nil, errors.New("scrypt: parameters must be > 0")
+ }
if uint64(r)*uint64(p) >= 1<<30 || r > maxInt/128/p || r > maxInt/256 || N > maxInt/128/r {
return nil, errors.New("scrypt: parameters are too large")
}