diff options
| author | Adam Langley <agl@golang.org> | 2009-11-05 16:44:02 -0800 |
|---|---|---|
| committer | Adam Langley <agl@golang.org> | 2009-11-05 16:44:02 -0800 |
| commit | d9a2726adce31cd6d1c23f33949a07537b16a0a9 (patch) | |
| tree | 5e697a8aaec75d7a2d8c5ed1ebe5941a01bb4e89 /src/pkg/crypto/rsa | |
| parent | b0af6c8cdc22eb04696e0008fe02313e5b380274 (diff) | |
| download | golang-d9a2726adce31cd6d1c23f33949a07537b16a0a9.tar.gz | |
crypto/tls (part 5/5)
Make RSA and X509 build by using big. (This involves commenting out
key generation for now since I haven't written Miller-Rabin in big
yet.)
Add entries to the Makefile.
R=rsc
CC=go-dev
http://go/go-review/1022005
Diffstat (limited to 'src/pkg/crypto/rsa')
| -rw-r--r-- | src/pkg/crypto/rsa/pkcs1v15.go | 2 | ||||
| -rw-r--r-- | src/pkg/crypto/rsa/pkcs1v15_test.go | 2 | ||||
| -rw-r--r-- | src/pkg/crypto/rsa/rsa.go | 16 | ||||
| -rw-r--r-- | src/pkg/crypto/rsa/rsa_test.go | 8 |
4 files changed, 24 insertions, 4 deletions
diff --git a/src/pkg/crypto/rsa/pkcs1v15.go b/src/pkg/crypto/rsa/pkcs1v15.go index 2583f1911..58f860fac 100644 --- a/src/pkg/crypto/rsa/pkcs1v15.go +++ b/src/pkg/crypto/rsa/pkcs1v15.go @@ -5,9 +5,9 @@ package rsa import ( + "big"; "bytes"; "crypto/subtle"; - big "gmp"; "io"; "os"; ) diff --git a/src/pkg/crypto/rsa/pkcs1v15_test.go b/src/pkg/crypto/rsa/pkcs1v15_test.go index b2cdc2660..1f5cf463a 100644 --- a/src/pkg/crypto/rsa/pkcs1v15_test.go +++ b/src/pkg/crypto/rsa/pkcs1v15_test.go @@ -5,9 +5,9 @@ package rsa import ( + "big"; "bytes"; "encoding/base64"; - big "gmp"; "os"; "io"; "strings"; diff --git a/src/pkg/crypto/rsa/rsa.go b/src/pkg/crypto/rsa/rsa.go index 65258781b..701c4cd4f 100644 --- a/src/pkg/crypto/rsa/rsa.go +++ b/src/pkg/crypto/rsa/rsa.go @@ -8,9 +8,9 @@ package rsa // TODO(agl): Add support for PSS padding. import ( + "big"; "bytes"; "crypto/subtle"; - big "gmp"; "hash"; "io"; "os"; @@ -19,6 +19,10 @@ import ( var bigZero = big.NewInt(0) var bigOne = big.NewInt(1) +/* + +TODO(agl): Enable once big implements ProbablyPrime. + // randomSafePrime returns a number, p, of the given size, such that p and // (p-1)/2 are both prime with high probability. func randomSafePrime(rand io.Reader, bits int) (p *big.Int, err os.Error) { @@ -53,6 +57,8 @@ func randomSafePrime(rand io.Reader, bits int) (p *big.Int, err os.Error) { return; } +*/ + // randomNumber returns a uniform random value in [0, max). func randomNumber(rand io.Reader, max *big.Int) (n *big.Int, err os.Error) { k := (max.Len() + 7)/8; @@ -103,6 +109,9 @@ type PrivateKey struct { // It returns nil if the key is valid, or else an os.Error describing a problem. func (priv PrivateKey) Validate() os.Error { + /* + TODO(agl): Enable once big implements ProbablyPrime. + // Check that p and q are prime. if !priv.P.ProbablyPrime(20) { return os.ErrorString("P is composite"); @@ -110,6 +119,7 @@ func (priv PrivateKey) Validate() os.Error { if !priv.Q.ProbablyPrime(20) { return os.ErrorString("Q is composite"); } + */ // Check that p*q == n. modulus := new(big.Int).Mul(priv.P, priv.Q); if big.CmpInt(modulus, priv.N) != 0 { @@ -136,6 +146,8 @@ func (priv PrivateKey) Validate() os.Error { return nil; } +/* + // GenerateKeyPair generates an RSA keypair of the given bit size. func GenerateKey(rand io.Reader, bits int) (priv *PrivateKey, err os.Error) { priv = new(PrivateKey); @@ -192,6 +204,8 @@ func GenerateKey(rand io.Reader, bits int) (priv *PrivateKey, err os.Error) { return; } +*/ + // incCounter increments a four byte, big-endian counter. func incCounter(c *[4]byte) { if c[3]++; c[3] != 0 { diff --git a/src/pkg/crypto/rsa/rsa_test.go b/src/pkg/crypto/rsa/rsa_test.go index 3bdfc66a7..7070a8ba8 100644 --- a/src/pkg/crypto/rsa/rsa_test.go +++ b/src/pkg/crypto/rsa/rsa_test.go @@ -5,13 +5,17 @@ package rsa import ( + "big"; "bytes"; "crypto/sha1"; - big "gmp"; "os"; "testing"; ) +/* + +TODO(agl): Enable once big implements ProbablyPrime. + func TestKeyGeneration(t *testing.T) { urandom, err := os.Open("/dev/urandom", os.O_RDONLY, 0); if err != nil { @@ -42,6 +46,8 @@ func TestKeyGeneration(t *testing.T) { } } +*/ + type testEncryptOAEPMessage struct { in []byte; seed []byte; |
