diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-13 05:11:45 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-13 05:11:45 +0000 |
commit | df4aa89a5e7acb315655f193e7f549e8d32367e2 (patch) | |
tree | eb5eccc07097c5fcf940967f33ab84a7d47c96fe /libgo/go/crypto | |
parent | f83fa0bf8f411697ec908cfa86ee6faf4cd9c476 (diff) | |
download | gcc-df4aa89a5e7acb315655f193e7f549e8d32367e2.zip gcc-df4aa89a5e7acb315655f193e7f549e8d32367e2.tar.gz gcc-df4aa89a5e7acb315655f193e7f549e8d32367e2.tar.bz2 |
libgo: Update to weekly.2011-12-22.
From-SVN: r183150
Diffstat (limited to 'libgo/go/crypto')
-rw-r--r-- | libgo/go/crypto/aes/aes_test.go | 2 | ||||
-rw-r--r-- | libgo/go/crypto/crypto.go | 3 | ||||
-rw-r--r-- | libgo/go/crypto/openpgp/keys.go | 1 | ||||
-rw-r--r-- | libgo/go/crypto/rand/rand_unix.go | 2 | ||||
-rw-r--r-- | libgo/go/crypto/tls/common.go | 4 | ||||
-rw-r--r-- | libgo/go/crypto/tls/handshake_client.go | 2 | ||||
-rw-r--r-- | libgo/go/crypto/tls/key_agreement.go | 4 | ||||
-rw-r--r-- | libgo/go/crypto/tls/root_darwin.go | 2 | ||||
-rw-r--r-- | libgo/go/crypto/tls/root_stub.go | 2 | ||||
-rw-r--r-- | libgo/go/crypto/x509/cert_pool.go | 3 | ||||
-rw-r--r-- | libgo/go/crypto/x509/verify_test.go | 12 | ||||
-rw-r--r-- | libgo/go/crypto/x509/x509.go | 1 |
12 files changed, 29 insertions, 9 deletions
diff --git a/libgo/go/crypto/aes/aes_test.go b/libgo/go/crypto/aes/aes_test.go index aa1d0df..e500c66 100644 --- a/libgo/go/crypto/aes/aes_test.go +++ b/libgo/go/crypto/aes/aes_test.go @@ -356,7 +356,7 @@ func BenchmarkEncrypt(b *testing.B) { tt := encryptTests[0] c, err := NewCipher(tt.key) if err != nil { - panic("NewCipher") + b.Fatal("NewCipher:", err) } out := make([]byte, len(tt.in)) b.StartTimer() diff --git a/libgo/go/crypto/crypto.go b/libgo/go/crypto/crypto.go index 53672a4..c913494 100644 --- a/libgo/go/crypto/crypto.go +++ b/libgo/go/crypto/crypto.go @@ -71,3 +71,6 @@ func RegisterHash(h Hash, f func() hash.Hash) { } hashes[h] = f } + +// PrivateKey represents a private key using an unspecified algorithm. +type PrivateKey interface{} diff --git a/libgo/go/crypto/openpgp/keys.go b/libgo/go/crypto/openpgp/keys.go index df39970..74e7d23 100644 --- a/libgo/go/crypto/openpgp/keys.go +++ b/libgo/go/crypto/openpgp/keys.go @@ -16,6 +16,7 @@ import ( // PublicKeyType is the armor type for a PGP public key. var PublicKeyType = "PGP PUBLIC KEY BLOCK" + // PrivateKeyType is the armor type for a PGP private key. var PrivateKeyType = "PGP PRIVATE KEY BLOCK" diff --git a/libgo/go/crypto/rand/rand_unix.go b/libgo/go/crypto/rand/rand_unix.go index d9cddf6..5d4fc81 100644 --- a/libgo/go/crypto/rand/rand_unix.go +++ b/libgo/go/crypto/rand/rand_unix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin freebsd linux openbsd +// +build darwin freebsd linux netbsd openbsd // Unix cryptographically secure pseudorandom number // generator. diff --git a/libgo/go/crypto/tls/common.go b/libgo/go/crypto/tls/common.go index f57d932..a461ad9 100644 --- a/libgo/go/crypto/tls/common.go +++ b/libgo/go/crypto/tls/common.go @@ -5,8 +5,8 @@ package tls import ( + "crypto" "crypto/rand" - "crypto/rsa" "crypto/x509" "io" "strings" @@ -255,7 +255,7 @@ func (c *Config) BuildNameToCertificate() { // A Certificate is a chain of one or more certificates, leaf first. type Certificate struct { Certificate [][]byte - PrivateKey *rsa.PrivateKey + PrivateKey crypto.PrivateKey // supported types: *rsa.PrivateKey // OCSPStaple contains an optional OCSP response which will be served // to clients that request it. OCSPStaple []byte diff --git a/libgo/go/crypto/tls/handshake_client.go b/libgo/go/crypto/tls/handshake_client.go index e39e59c..7364800 100644 --- a/libgo/go/crypto/tls/handshake_client.go +++ b/libgo/go/crypto/tls/handshake_client.go @@ -234,7 +234,7 @@ func (c *Conn) clientHandshake() error { digest := make([]byte, 0, 36) digest = finishedHash.serverMD5.Sum(digest) digest = finishedHash.serverSHA1.Sum(digest) - signed, err := rsa.SignPKCS1v15(c.config.rand(), c.config.Certificates[0].PrivateKey, crypto.MD5SHA1, digest) + signed, err := rsa.SignPKCS1v15(c.config.rand(), c.config.Certificates[0].PrivateKey.(*rsa.PrivateKey), crypto.MD5SHA1, digest) if err != nil { return c.sendAlert(alertInternalError) } diff --git a/libgo/go/crypto/tls/key_agreement.go b/libgo/go/crypto/tls/key_agreement.go index b531717..c3c1664 100644 --- a/libgo/go/crypto/tls/key_agreement.go +++ b/libgo/go/crypto/tls/key_agreement.go @@ -44,7 +44,7 @@ func (ka rsaKeyAgreement) processClientKeyExchange(config *Config, ckx *clientKe ciphertext = ckx.ciphertext[2:] } - err = rsa.DecryptPKCS1v15SessionKey(config.rand(), config.Certificates[0].PrivateKey, ciphertext, preMasterSecret) + err = rsa.DecryptPKCS1v15SessionKey(config.rand(), config.Certificates[0].PrivateKey.(*rsa.PrivateKey), ciphertext, preMasterSecret) if err != nil { return nil, err } @@ -147,7 +147,7 @@ Curve: copy(serverECDHParams[4:], ecdhePublic) md5sha1 := md5SHA1Hash(clientHello.random, hello.random, serverECDHParams) - sig, err := rsa.SignPKCS1v15(config.rand(), config.Certificates[0].PrivateKey, crypto.MD5SHA1, md5sha1) + sig, err := rsa.SignPKCS1v15(config.rand(), config.Certificates[0].PrivateKey.(*rsa.PrivateKey), crypto.MD5SHA1, md5sha1) if err != nil { return nil, errors.New("failed to sign ECDHE parameters: " + err.Error()) } diff --git a/libgo/go/crypto/tls/root_darwin.go b/libgo/go/crypto/tls/root_darwin.go index 1512241..db1b18b 100644 --- a/libgo/go/crypto/tls/root_darwin.go +++ b/libgo/go/crypto/tls/root_darwin.go @@ -8,7 +8,7 @@ package tls // Note: We disable -Werror here because the code in this file uses a deprecated API to stay // compatible with both Mac OS X 10.6 and 10.7. Using a deprecated function on Darwin generates // a warning. -#cgo CFLAGS: -Wno-error +#cgo CFLAGS: -Wno-error -Wno-deprecated-declarations #cgo LDFLAGS: -framework CoreFoundation -framework Security #include <CoreFoundation/CoreFoundation.h> #include <Security/Security.h> diff --git a/libgo/go/crypto/tls/root_stub.go b/libgo/go/crypto/tls/root_stub.go index 18dcb02..d00493a 100644 --- a/libgo/go/crypto/tls/root_stub.go +++ b/libgo/go/crypto/tls/root_stub.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build plan9 +// +build plan9 darwin/nocgo package tls diff --git a/libgo/go/crypto/x509/cert_pool.go b/libgo/go/crypto/x509/cert_pool.go index adc7f9b..5a0a876 100644 --- a/libgo/go/crypto/x509/cert_pool.go +++ b/libgo/go/crypto/x509/cert_pool.go @@ -28,6 +28,9 @@ func NewCertPool() *CertPool { // given certificate. If no such certificate can be found or the signature // doesn't match, it returns nil. func (s *CertPool) findVerifiedParents(cert *Certificate) (parents []int) { + if s == nil { + return + } var candidates []int if len(cert.AuthorityKeyId) > 0 { diff --git a/libgo/go/crypto/x509/verify_test.go b/libgo/go/crypto/x509/verify_test.go index df54430..2016858 100644 --- a/libgo/go/crypto/x509/verify_test.go +++ b/libgo/go/crypto/x509/verify_test.go @@ -19,6 +19,7 @@ type verifyTest struct { roots []string currentTime int64 dnsName string + nilRoots bool errorCallback func(*testing.T, int, error) bool expectedChains [][]string @@ -48,6 +49,14 @@ var verifyTests = []verifyTest{ { leaf: googleLeaf, intermediates: []string{thawteIntermediate}, + nilRoots: true, // verifies that we don't crash + currentTime: 1302726541, + dnsName: "www.google.com", + errorCallback: expectAuthorityUnknown, + }, + { + leaf: googleLeaf, + intermediates: []string{thawteIntermediate}, roots: []string{verisignRoot}, currentTime: 1, dnsName: "www.example.com", @@ -136,6 +145,9 @@ func TestVerify(t *testing.T) { DNSName: test.dnsName, CurrentTime: time.Unix(test.currentTime, 0), } + if test.nilRoots { + opts.Roots = nil + } for j, root := range test.roots { ok := opts.Roots.AppendCertsFromPEM([]byte(root)) diff --git a/libgo/go/crypto/x509/x509.go b/libgo/go/crypto/x509/x509.go index 65ca315..28c7880 100644 --- a/libgo/go/crypto/x509/x509.go +++ b/libgo/go/crypto/x509/x509.go @@ -981,6 +981,7 @@ func CreateCertificate(rand io.Reader, template, parent *Certificate, pub *rsa.P // pemCRLPrefix is the magic string that indicates that we have a PEM encoded // CRL. var pemCRLPrefix = []byte("-----BEGIN X509 CRL") + // pemType is the type of a PEM encoded CRL. var pemType = "X509 CRL" |