Skip to content

Commit

Permalink
math/big: add security warning to (*Int).Rand
Browse files Browse the repository at this point in the history
Change-Id: I22a67733aa2d07298e124077654c9b1473802100
Reviewed-on: https://go-review.googlesource.com/76012
Reviewed-by: Aliaksandr Valialkin <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
FiloSottile committed Nov 6, 2017
1 parent b4c84a1 commit ef0e2af
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/math/big/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,9 @@ func (z *Int) lehmerGCD(a, b *Int) *Int {
}

// Rand sets z to a pseudo-random number in [0, n) and returns z.
//
// As this uses the math/rand package, it must not be used for
// security-sensitive work. Use crypto/rand.Int instead.
func (z *Int) Rand(rnd *rand.Rand, n *Int) *Int {
z.neg = false
if n.neg || len(n.abs) == 0 {
Expand Down

0 comments on commit ef0e2af

Please sign in to comment.