aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/crypto/rand/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/crypto/rand/util.go')
-rw-r--r--libgo/go/crypto/rand/util.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/libgo/go/crypto/rand/util.go b/libgo/go/crypto/rand/util.go
index 50e5b16..0cd5e0e 100644
--- a/libgo/go/crypto/rand/util.go
+++ b/libgo/go/crypto/rand/util.go
@@ -98,12 +98,13 @@ func Prime(rand io.Reader, bits int) (p *big.Int, err error) {
return
}
}
-
- return
}
-// Int returns a uniform random value in [0, max).
+// Int returns a uniform random value in [0, max). It panics if max <= 0.
func Int(rand io.Reader, max *big.Int) (n *big.Int, err error) {
+ if max.Sign() <= 0 {
+ panic("crypto/rand: argument to Int is <= 0")
+ }
k := (max.BitLen() + 7) / 8
// b is the number of bits in the most significant byte of max.
@@ -130,6 +131,4 @@ func Int(rand io.Reader, max *big.Int) (n *big.Int, err error) {
return
}
}
-
- return
}