Skip to content

Commit 555685e

Browse files
committed
crypto/rsa: support > 3 primes.
With full multi-prime support we can support version 1 PKCS#1 private keys. This means exporting all the members of rsa.PrivateKey, thus making the API a little messy. However there has already been another request to export this so it seems to be something that's needed. Over time, rsa.GenerateMultiPrimeKey will replace rsa.GenerateKey, but I need to work on the prime balance first because we're no longer generating primes which are a multiples of 8 bits. Fixes #987. R=rsc CC=golang-dev https://golang.org/cl/4378046
1 parent 781df13 commit 555685e

6 files changed

Lines changed: 275 additions & 187 deletions

File tree

src/pkg/crypto/openpgp/packet/private_key.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,10 @@ func (pk *PrivateKey) parseRSAPrivateKey(data []byte) (err os.Error) {
164164
}
165165

166166
rsaPriv.D = new(big.Int).SetBytes(d)
167-
rsaPriv.P = new(big.Int).SetBytes(p)
168-
rsaPriv.Q = new(big.Int).SetBytes(q)
167+
rsaPriv.Primes = make([]*big.Int, 2)
168+
rsaPriv.Primes[0] = new(big.Int).SetBytes(p)
169+
rsaPriv.Primes[1] = new(big.Int).SetBytes(q)
170+
rsaPriv.Precompute()
169171
pk.PrivateKey = rsaPriv
170172
pk.Encrypted = false
171173
pk.encryptedData = nil

0 commit comments

Comments
 (0)