Skip to content

Commit

Permalink
crypto/rsa: explain random parameter for GenerateKey and GenerateMult…
Browse files Browse the repository at this point in the history
…iPrimeKey.

Fixes #6850.

LGTM=agl
R=golang-codereviews, agl
CC=golang-codereviews
https://golang.org/cl/60500046
  • Loading branch information
minux committed Feb 13, 2014
1 parent c36dd4a commit 9abe6d9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/pkg/crypto/rsa/rsa.go
Expand Up @@ -120,16 +120,18 @@ func (priv *PrivateKey) Validate() error {
return nil
}

// GenerateKey generates an RSA keypair of the given bit size.
// GenerateKey generates an RSA keypair of the given bit size using the
// random source random (for example, crypto/rand.Reader).
func GenerateKey(random io.Reader, bits int) (priv *PrivateKey, err error) {
return GenerateMultiPrimeKey(random, 2, bits)
}

// GenerateMultiPrimeKey generates a multi-prime RSA keypair of the given bit
// size, as suggested in [1]. Although the public keys are compatible
// (actually, indistinguishable) from the 2-prime case, the private keys are
// not. Thus it may not be possible to export multi-prime private keys in
// certain formats or to subsequently import them into other code.
// size and the given random source, as suggested in [1]. Although the public
// keys are compatible (actually, indistinguishable) from the 2-prime case,
// the private keys are not. Thus it may not be possible to export multi-prime
// private keys in certain formats or to subsequently import them into other
// code.
//
// Table 1 in [2] suggests maximum numbers of primes for a given size.
//
Expand Down

0 comments on commit 9abe6d9

Please sign in to comment.