diff options
Diffstat (limited to 'libgo/go/crypto/tls/handshake_client.go')
-rw-r--r-- | libgo/go/crypto/tls/handshake_client.go | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/libgo/go/crypto/tls/handshake_client.go b/libgo/go/crypto/tls/handshake_client.go index e760fbf..ed000eb 100644 --- a/libgo/go/crypto/tls/handshake_client.go +++ b/libgo/go/crypto/tls/handshake_client.go @@ -8,6 +8,7 @@ import ( "bytes" "crypto" "crypto/ecdsa" + "crypto/ed25519" "crypto/rsa" "crypto/subtle" "crypto/x509" @@ -85,7 +86,6 @@ func (c *Conn) makeClientHello() (*clientHelloMsg, ecdheParameters, error) { possibleCipherSuites := config.cipherSuites() hello.cipherSuites = make([]uint16, 0, len(possibleCipherSuites)) -NextCipherSuite: for _, suiteId := range possibleCipherSuites { for _, suite := range cipherSuites { if suite.id != suiteId { @@ -94,10 +94,10 @@ NextCipherSuite: // Don't advertise TLS 1.2-only cipher suites unless // we're attempting TLS 1.2. if hello.vers < VersionTLS12 && suite.flags&suiteTLS12 != 0 { - continue + break } hello.cipherSuites = append(hello.cipherSuites, suiteId) - continue NextCipherSuite + break } } @@ -582,7 +582,7 @@ func (hs *clientHandshakeState) doFullHandshake() error { if certVerify.hasSignatureAlgorithm { certVerify.signatureAlgorithm = signatureAlgorithm } - digest, err := hs.finishedHash.hashForClientCertificate(sigType, hashFunc, hs.masterSecret) + signed, err := hs.finishedHash.hashForClientCertificate(sigType, hashFunc, hs.masterSecret) if err != nil { c.sendAlert(alertInternalError) return err @@ -591,7 +591,7 @@ func (hs *clientHandshakeState) doFullHandshake() error { if sigType == signatureRSAPSS { signOpts = &rsa.PSSOptions{SaltLength: rsa.PSSSaltLengthEqualsHash, Hash: hashFunc} } - certVerify.signature, err = key.Sign(c.config.rand(), digest, signOpts) + certVerify.signature, err = key.Sign(c.config.rand(), signed, signOpts) if err != nil { c.sendAlert(alertInternalError) return err @@ -827,11 +827,7 @@ func (c *Conn) verifyServerCertificate(certificates [][]byte) error { DNSName: c.config.ServerName, Intermediates: x509.NewCertPool(), } - - for i, cert := range certs { - if i == 0 { - continue - } + for _, cert := range certs[1:] { opts.Intermediates.AddCert(cert) } var err error @@ -850,7 +846,7 @@ func (c *Conn) verifyServerCertificate(certificates [][]byte) error { } switch certs[0].PublicKey.(type) { - case *rsa.PublicKey, *ecdsa.PublicKey: + case *rsa.PublicKey, *ecdsa.PublicKey, ed25519.PublicKey: break default: c.sendAlert(alertUnsupportedCertificate) @@ -873,13 +869,13 @@ var ( // certificateRequestInfoFromMsg generates a CertificateRequestInfo from a TLS // <= 1.2 CertificateRequest, making an effort to fill in missing information. func certificateRequestInfoFromMsg(certReq *certificateRequestMsg) *CertificateRequestInfo { - var rsaAvail, ecdsaAvail bool + var rsaAvail, ecAvail bool for _, certType := range certReq.certificateTypes { switch certType { case certTypeRSASign: rsaAvail = true case certTypeECDSASign: - ecdsaAvail = true + ecAvail = true } } @@ -893,25 +889,23 @@ func certificateRequestInfoFromMsg(certReq *certificateRequestMsg) *CertificateR // case we use a plausible list based on the acceptable // certificate types. switch { - case rsaAvail && ecdsaAvail: + case rsaAvail && ecAvail: cri.SignatureSchemes = tls11SignatureSchemes case rsaAvail: cri.SignatureSchemes = tls11SignatureSchemesRSA - case ecdsaAvail: + case ecAvail: cri.SignatureSchemes = tls11SignatureSchemesECDSA } return cri } - // In TLS 1.2, the signature schemes apply to both the certificate chain and - // the leaf key, while the certificate types only apply to the leaf key. + // Filter the signature schemes based on the certificate types. // See RFC 5246, Section 7.4.4 (where it calls this "somewhat complicated"). - // Filter the signature schemes based on the certificate type. cri.SignatureSchemes = make([]SignatureScheme, 0, len(certReq.supportedSignatureAlgorithms)) for _, sigScheme := range certReq.supportedSignatureAlgorithms { switch signatureFromSignatureScheme(sigScheme) { - case signatureECDSA: - if ecdsaAvail { + case signatureECDSA, signatureEd25519: + if ecAvail { cri.SignatureSchemes = append(cri.SignatureSchemes, sigScheme) } case signatureRSAPSS, signaturePKCS1v15: |