This does not include AES-GCM yet. Also, it assumes that the handshake and certificate signature hash are always SHA-256, which is true of the ciphersuites that we currently support. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/10762044tls13
@@ -42,7 +42,7 @@ type cipherSuite struct { | |||
keyLen int | |||
macLen int | |||
ivLen int | |||
ka func() keyAgreement | |||
ka func(version uint16) keyAgreement | |||
// If elliptic is set, a server will only consider this ciphersuite if | |||
// the ClientHello indicated that the client supports an elliptic curve | |||
// and point format that we can handle. | |||
@@ -157,12 +157,14 @@ func (s tls10MAC) MAC(digestBuf, seq, header, data []byte) []byte { | |||
return s.h.Sum(digestBuf[:0]) | |||
} | |||
func rsaKA() keyAgreement { | |||
func rsaKA(version uint16) keyAgreement { | |||
return rsaKeyAgreement{} | |||
} | |||
func ecdheRSAKA() keyAgreement { | |||
return new(ecdheRSAKeyAgreement) | |||
func ecdheRSAKA(version uint16) keyAgreement { | |||
return &ecdheRSAKeyAgreement{ | |||
version: version, | |||
} | |||
} | |||
// mutualCipherSuite returns a cipherSuite given a list of supported | |||
@@ -18,6 +18,7 @@ const ( | |||
VersionSSL30 = 0x0300 | |||
VersionTLS10 = 0x0301 | |||
VersionTLS11 = 0x0302 | |||
VersionTLS12 = 0x0303 | |||
) | |||
const ( | |||
@@ -27,7 +28,7 @@ const ( | |||
maxHandshake = 65536 // maximum handshake we support (protocol max is 16 MB) | |||
minVersion = VersionSSL30 | |||
maxVersion = VersionTLS11 | |||
maxVersion = VersionTLS12 | |||
) | |||
// TLS record types. | |||
@@ -63,12 +64,13 @@ const ( | |||
// TLS extension numbers | |||
var ( | |||
extensionServerName uint16 = 0 | |||
extensionStatusRequest uint16 = 5 | |||
extensionSupportedCurves uint16 = 10 | |||
extensionSupportedPoints uint16 = 11 | |||
extensionSessionTicket uint16 = 35 | |||
extensionNextProtoNeg uint16 = 13172 // not IANA assigned | |||
extensionServerName uint16 = 0 | |||
extensionStatusRequest uint16 = 5 | |||
extensionSupportedCurves uint16 = 10 | |||
extensionSupportedPoints uint16 = 11 | |||
extensionSignatureAlgorithms uint16 = 13 | |||
extensionSessionTicket uint16 = 35 | |||
extensionNextProtoNeg uint16 = 13172 // not IANA assigned | |||
) | |||
// TLS Elliptic Curves | |||
@@ -99,6 +101,31 @@ const ( | |||
// Rest of these are reserved by the TLS spec | |||
) | |||
// Hash functions for TLS 1.2 (See RFC 5246, section A.4.1) | |||
const ( | |||
hashSHA1 uint8 = 2 | |||
hashSHA256 uint8 = 4 | |||
) | |||
// Signature algorithms for TLS 1.2 (See RFC 5246, section A.4.1) | |||
const ( | |||
signatureRSA uint8 = 1 | |||
signatureECDSA uint8 = 3 | |||
) | |||
// signatureAndHash mirrors the TLS 1.2, SignatureAndHashAlgorithm struct. See | |||
// RFC 5246, section A.4.1. | |||
type signatureAndHash struct { | |||
hash, signature uint8 | |||
} | |||
// supportedSignatureAlgorithms contains the signature and hash algorithms that | |||
// the code will adverse as supported both in a TLS 1.2 ClientHello and | |||
// CertificateRequest. | |||
var supportedSignatureAlgorithms = []signatureAndHash{ | |||
{hashSHA256, signatureRSA}, | |||
} | |||
// ConnectionState records basic TLS details about the connection. | |||
type ConnectionState struct { | |||
HandshakeComplete bool | |||
@@ -748,7 +748,9 @@ func (c *Conn) readHandshake() (interface{}, error) { | |||
case typeCertificate: | |||
m = new(certificateMsg) | |||
case typeCertificateRequest: | |||
m = new(certificateRequestMsg) | |||
m = &certificateRequestMsg{ | |||
hasSignatureAndHash: c.vers >= VersionTLS12, | |||
} | |||
case typeCertificateStatus: | |||
m = new(certificateStatusMsg) | |||
case typeServerKeyExchange: | |||
@@ -758,7 +760,9 @@ func (c *Conn) readHandshake() (interface{}, error) { | |||
case typeClientKeyExchange: | |||
m = new(clientKeyExchangeMsg) | |||
case typeCertificateVerify: | |||
m = new(certificateVerifyMsg) | |||
m = &certificateVerifyMsg{ | |||
hasSignatureAndHash: c.vers >= VersionTLS12, | |||
} | |||
case typeNextProtocol: | |||
m = new(nextProtoMsg) | |||
case typeFinished: | |||
@@ -6,7 +6,6 @@ package tls | |||
import ( | |||
"bytes" | |||
"crypto" | |||
"crypto/rsa" | |||
"crypto/subtle" | |||
"crypto/x509" | |||
@@ -16,8 +15,6 @@ import ( | |||
) | |||
func (c *Conn) clientHandshake() error { | |||
finishedHash := newFinishedHash(VersionTLS10) | |||
if c.config == nil { | |||
c.config = defaultConfig() | |||
} | |||
@@ -45,7 +42,10 @@ func (c *Conn) clientHandshake() error { | |||
return errors.New("short read from Rand") | |||
} | |||
finishedHash.Write(hello.marshal()) | |||
if hello.vers >= VersionTLS12 { | |||
hello.signatureAndHashes = supportedSignatureAlgorithms | |||
} | |||
c.writeRecord(recordTypeHandshake, hello.marshal()) | |||
msg, err := c.readHandshake() | |||
@@ -56,7 +56,6 @@ func (c *Conn) clientHandshake() error { | |||
if !ok { | |||
return c.sendAlert(alertUnexpectedMessage) | |||
} | |||
finishedHash.Write(serverHello.marshal()) | |||
vers, ok := c.config.mutualVersion(serverHello.vers) | |||
if !ok || vers < VersionTLS10 { | |||
@@ -66,6 +65,10 @@ func (c *Conn) clientHandshake() error { | |||
c.vers = vers | |||
c.haveVers = true | |||
finishedHash := newFinishedHash(c.vers) | |||
finishedHash.Write(hello.marshal()) | |||
finishedHash.Write(serverHello.marshal()) | |||
if serverHello.compressionMethod != compressionNone { | |||
return c.sendAlert(alertUnexpectedMessage) | |||
} | |||
@@ -148,7 +151,7 @@ func (c *Conn) clientHandshake() error { | |||
return err | |||
} | |||
keyAgreement := suite.ka() | |||
keyAgreement := suite.ka(c.vers) | |||
skx, ok := msg.(*serverKeyExchangeMsg) | |||
if ok { | |||
@@ -269,10 +272,8 @@ func (c *Conn) clientHandshake() error { | |||
if chainToSend != nil { | |||
certVerify := new(certificateVerifyMsg) | |||
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.(*rsa.PrivateKey), crypto.MD5SHA1, digest) | |||
digest, hashFunc := finishedHash.hashForClientCertificate() | |||
signed, err := rsa.SignPKCS1v15(c.config.rand(), c.config.Certificates[0].PrivateKey.(*rsa.PrivateKey), hashFunc, digest) | |||
if err != nil { | |||
return c.sendAlert(alertInternalError) | |||
} | |||
@@ -65,6 +65,15 @@ func TestHandshakeClientTLS11(t *testing.T) { | |||
testClientScript(t, "TLS11-ECDHE-AES", tls11ECDHEAESClientScript, &config) | |||
} | |||
func TestHandshakeClientTLS12(t *testing.T) { | |||
config := *testConfig | |||
config.MaxVersion = VersionTLS12 | |||
config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA} | |||
cert, _ := X509KeyPair(testClientChainCertificate, testClientChainCertificate) | |||
config.Certificates = []Certificate{cert} | |||
testClientScript(t, "TLS12", clientTLS12Script, &config) | |||
} | |||
var connect = flag.Bool("connect", false, "connect to a TLS server on :10443") | |||
func TestRunClient(t *testing.T) { | |||
@@ -1802,6 +1811,268 @@ var clientChainCertificateScript = [][]byte{ | |||
}, | |||
} | |||
var clientTLS12Script = [][]byte{ | |||
{ | |||
0x16, 0x03, 0x01, 0x00, 0x52, 0x01, 0x00, 0x00, | |||
0x4e, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x13, | |||
0x01, 0x00, 0x00, 0x23, 0x00, 0x05, 0x00, 0x05, | |||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, | |||
0x08, 0x00, 0x06, 0x00, 0x17, 0x00, 0x18, 0x00, | |||
0x19, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, 0x00, | |||
0x0d, 0x00, 0x04, 0x00, 0x02, 0x04, 0x01, | |||
}, | |||
{ | |||
0x16, 0x03, 0x03, 0x00, 0x54, 0x02, 0x00, 0x00, | |||
0x50, 0x03, 0x03, 0x51, 0xcd, 0xe6, 0x5e, 0x4c, | |||
0x36, 0x2f, 0xe1, 0x38, 0x6c, 0xff, 0x9c, 0xe2, | |||
0x0f, 0xbb, 0x04, 0x6d, 0x82, 0xa6, 0x1a, 0x85, | |||
0xfa, 0x8c, 0x04, 0xb7, 0xcb, 0xcc, 0x39, 0x02, | |||
0xb3, 0x24, 0xff, 0x20, 0xaa, 0x79, 0xb0, 0x04, | |||
0x70, 0x39, 0x7a, 0x3b, 0xd7, 0xe0, 0x16, 0x43, | |||
0x63, 0xd2, 0x04, 0xc9, 0x4a, 0x49, 0x08, 0xf8, | |||
0x1c, 0xf6, 0xba, 0x5f, 0xe2, 0x61, 0x8c, 0xa4, | |||
0x3d, 0x81, 0x6a, 0x79, 0xc0, 0x13, 0x00, 0x00, | |||
0x08, 0x00, 0x0b, 0x00, 0x04, 0x03, 0x00, 0x01, | |||
0x02, 0x16, 0x03, 0x03, 0x03, 0xf5, 0x0b, 0x00, | |||
0x03, 0xf1, 0x00, 0x03, 0xee, 0x00, 0x03, 0xeb, | |||
0x30, 0x82, 0x03, 0xe7, 0x30, 0x82, 0x02, 0xcf, | |||
0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, | |||
0xb9, 0xee, 0xd4, 0xd9, 0x55, 0xa5, 0x9e, 0xb3, | |||
0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, | |||
0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, | |||
0x70, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, | |||
0x04, 0x06, 0x13, 0x02, 0x55, 0x4b, 0x31, 0x16, | |||
0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, | |||
0x0d, 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, 0x4c, | |||
0x20, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x31, 0x22, | |||
0x30, 0x20, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, | |||
0x19, 0x46, 0x4f, 0x52, 0x20, 0x54, 0x45, 0x53, | |||
0x54, 0x49, 0x4e, 0x47, 0x20, 0x50, 0x55, 0x52, | |||
0x50, 0x4f, 0x53, 0x45, 0x53, 0x20, 0x4f, 0x4e, | |||
0x4c, 0x59, 0x31, 0x25, 0x30, 0x23, 0x06, 0x03, | |||
0x55, 0x04, 0x03, 0x0c, 0x1c, 0x4f, 0x70, 0x65, | |||
0x6e, 0x53, 0x53, 0x4c, 0x20, 0x54, 0x65, 0x73, | |||
0x74, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, | |||
0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x20, 0x43, | |||
0x41, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x31, 0x31, | |||
0x32, 0x30, 0x38, 0x31, 0x34, 0x30, 0x31, 0x34, | |||
0x38, 0x5a, 0x17, 0x0d, 0x32, 0x31, 0x31, 0x30, | |||
0x31, 0x36, 0x31, 0x34, 0x30, 0x31, 0x34, 0x38, | |||
0x5a, 0x30, 0x64, 0x31, 0x0b, 0x30, 0x09, 0x06, | |||
0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x4b, | |||
0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, | |||
0x0a, 0x0c, 0x0d, 0x4f, 0x70, 0x65, 0x6e, 0x53, | |||
0x53, 0x4c, 0x20, 0x47, 0x72, 0x6f, 0x75, 0x70, | |||
0x31, 0x22, 0x30, 0x20, 0x06, 0x03, 0x55, 0x04, | |||
0x0b, 0x0c, 0x19, 0x46, 0x4f, 0x52, 0x20, 0x54, | |||
0x45, 0x53, 0x54, 0x49, 0x4e, 0x47, 0x20, 0x50, | |||
0x55, 0x52, 0x50, 0x4f, 0x53, 0x45, 0x53, 0x20, | |||
0x4f, 0x4e, 0x4c, 0x59, 0x31, 0x19, 0x30, 0x17, | |||
0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x10, 0x54, | |||
0x65, 0x73, 0x74, 0x20, 0x53, 0x65, 0x72, 0x76, | |||
0x65, 0x72, 0x20, 0x43, 0x65, 0x72, 0x74, 0x30, | |||
0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, | |||
0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, | |||
0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, | |||
0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, | |||
0xf3, 0x84, 0xf3, 0x92, 0x36, 0xdc, 0xb2, 0x46, | |||
0xca, 0x66, 0x7a, 0xe5, 0x29, 0xc5, 0xf3, 0x49, | |||
0x28, 0x22, 0xd3, 0xb9, 0xfe, 0xe0, 0xde, 0xe4, | |||
0x38, 0xce, 0xee, 0x22, 0x1c, 0xe9, 0x91, 0x3b, | |||
0x94, 0xd0, 0x72, 0x2f, 0x87, 0x85, 0x59, 0x4b, | |||
0x66, 0xb1, 0xc5, 0xf5, 0x7a, 0x85, 0x5d, 0xc2, | |||
0x0f, 0xd3, 0x2e, 0x29, 0x58, 0x36, 0xcc, 0x48, | |||
0x6b, 0xa2, 0xa2, 0xb5, 0x26, 0xce, 0x67, 0xe2, | |||
0x47, 0xb6, 0xdf, 0x49, 0xd2, 0x3f, 0xfa, 0xa2, | |||
0x10, 0xb7, 0xc2, 0x97, 0x44, 0x7e, 0x87, 0x34, | |||
0x6d, 0x6d, 0xf2, 0x8b, 0xb4, 0x55, 0x2b, 0xd6, | |||
0x21, 0xde, 0x53, 0x4b, 0x90, 0xea, 0xfd, 0xea, | |||
0xf9, 0x38, 0x35, 0x2b, 0xf4, 0xe6, 0x9a, 0x0e, | |||
0xf6, 0xbb, 0x12, 0xab, 0x87, 0x21, 0xc3, 0x2f, | |||
0xbc, 0xf4, 0x06, 0xb8, 0x8f, 0x8e, 0x10, 0x07, | |||
0x27, 0x95, 0xe5, 0x42, 0xcb, 0xd1, 0xd5, 0x10, | |||
0x8c, 0x92, 0xac, 0xee, 0x0f, 0xdc, 0x23, 0x48, | |||
0x89, 0xc9, 0xc6, 0x93, 0x0c, 0x22, 0x02, 0xe7, | |||
0x74, 0xe7, 0x25, 0x00, 0xab, 0xf8, 0x0f, 0x5c, | |||
0x10, 0xb5, 0x85, 0x3b, 0x66, 0x94, 0xf0, 0xfb, | |||
0x4d, 0x57, 0x06, 0x55, 0x21, 0x22, 0x25, 0xdb, | |||
0xf3, 0xaa, 0xa9, 0x60, 0xbf, 0x4d, 0xaa, 0x79, | |||
0xd1, 0xab, 0x92, 0x48, 0xba, 0x19, 0x8e, 0x12, | |||
0xec, 0x68, 0xd9, 0xc6, 0xba, 0xdf, 0xec, 0x5a, | |||
0x1c, 0xd8, 0x43, 0xfe, 0xe7, 0x52, 0xc9, 0xcf, | |||
0x02, 0xd0, 0xc7, 0x7f, 0xc9, 0x7e, 0xb0, 0x94, | |||
0xe3, 0x53, 0x44, 0x58, 0x0b, 0x2e, 0xfd, 0x29, | |||
0x74, 0xb5, 0x06, 0x9b, 0x5c, 0x44, 0x8d, 0xfb, | |||
0x32, 0x75, 0xa4, 0x3a, 0xa8, 0x67, 0x7b, 0x87, | |||
0x32, 0x0a, 0x50, 0x8d, 0xe1, 0xa2, 0x13, 0x4a, | |||
0x25, 0xaf, 0xe6, 0x1c, 0xb1, 0x25, 0xbf, 0xb4, | |||
0x99, 0xa2, 0x53, 0xd3, 0xa2, 0x02, 0xbf, 0x11, | |||
0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x81, 0x8f, | |||
0x30, 0x81, 0x8c, 0x30, 0x0c, 0x06, 0x03, 0x55, | |||
0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x02, 0x30, | |||
0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, | |||
0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x05, | |||
0xe0, 0x30, 0x2c, 0x06, 0x09, 0x60, 0x86, 0x48, | |||
0x01, 0x86, 0xf8, 0x42, 0x01, 0x0d, 0x04, 0x1f, | |||
0x16, 0x1d, 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, | |||
0x4c, 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, | |||
0x74, 0x65, 0x64, 0x20, 0x43, 0x65, 0x72, 0x74, | |||
0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x30, | |||
0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, | |||
0x04, 0x14, 0x82, 0xbc, 0xcf, 0x00, 0x00, 0x13, | |||
0xd1, 0xf7, 0x39, 0x25, 0x9a, 0x27, 0xe7, 0xaf, | |||
0xd2, 0xef, 0x20, 0x1b, 0x6e, 0xac, 0x30, 0x1f, | |||
0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, | |||
0x16, 0x80, 0x14, 0x36, 0xc3, 0x6c, 0x88, 0xe7, | |||
0x95, 0xfe, 0xb0, 0xbd, 0xec, 0xce, 0x3e, 0x3d, | |||
0x86, 0xab, 0x21, 0x81, 0x87, 0xda, 0xda, 0x30, | |||
0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, | |||
0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x82, | |||
0x01, 0x01, 0x00, 0xa9, 0xbd, 0x4d, 0x57, 0x40, | |||
0x74, 0xfe, 0x96, 0xe9, 0x2b, 0xd6, 0x78, 0xfd, | |||
0xb3, 0x63, 0xcc, 0xf4, 0x0b, 0x4d, 0x12, 0xca, | |||
0x5a, 0x74, 0x8d, 0x9b, 0xf2, 0x61, 0xe6, 0xfd, | |||
0x06, 0x11, 0x43, 0x84, 0xfc, 0x17, 0xa0, 0xec, | |||
0x63, 0x63, 0x36, 0xb9, 0x9e, 0x36, 0x6a, 0xb1, | |||
0x02, 0x5a, 0x6a, 0x5b, 0x3f, 0x6a, 0xa1, 0xea, | |||
0x05, 0x65, 0xac, 0x7e, 0x40, 0x1a, 0x48, 0x65, | |||
0x88, 0xd1, 0x39, 0x4d, 0xd3, 0x4b, 0x77, 0xe9, | |||
0xc8, 0xbb, 0x2b, 0x9e, 0x5a, 0xf4, 0x08, 0x34, | |||
0x39, 0x47, 0xb9, 0x02, 0x08, 0x31, 0x9a, 0xf1, | |||
0xd9, 0x17, 0xc5, 0xe9, 0xa6, 0xa5, 0x96, 0x4b, | |||
0x6d, 0x40, 0xa9, 0x5b, 0x65, 0x28, 0xcb, 0xcb, | |||
0x00, 0x03, 0x82, 0x63, 0x37, 0xd3, 0xad, 0xb1, | |||
0x96, 0x3b, 0x76, 0xf5, 0x17, 0x16, 0x02, 0x7b, | |||
0xbd, 0x53, 0x53, 0x46, 0x72, 0x34, 0xd6, 0x08, | |||
0x64, 0x9d, 0xbb, 0x43, 0xfb, 0x64, 0xb1, 0x49, | |||
0x07, 0x77, 0x09, 0x61, 0x7a, 0x42, 0x17, 0x11, | |||
0x30, 0x0c, 0xd9, 0x27, 0x5c, 0xf5, 0x71, 0xb6, | |||
0xf0, 0x18, 0x30, 0xf3, 0x7e, 0xf1, 0x85, 0x3f, | |||
0x32, 0x7e, 0x4a, 0xaf, 0xb3, 0x10, 0xf7, 0x6c, | |||
0xc6, 0x85, 0x4b, 0x2d, 0x27, 0xad, 0x0a, 0x20, | |||
0x5c, 0xfb, 0x8d, 0x19, 0x70, 0x34, 0xb9, 0x75, | |||
0x5f, 0x7c, 0x87, 0xd5, 0xc3, 0xec, 0x93, 0x13, | |||
0x41, 0xfc, 0x73, 0x03, 0xb9, 0x8d, 0x1a, 0xfe, | |||
0xf7, 0x26, 0x86, 0x49, 0x03, 0xa9, 0xc5, 0x82, | |||
0x3f, 0x80, 0x0d, 0x29, 0x49, 0xb1, 0x8f, 0xed, | |||
0x24, 0x1b, 0xfe, 0xcf, 0x58, 0x90, 0x46, 0xe7, | |||
0xa8, 0x87, 0xd4, 0x1e, 0x79, 0xef, 0x99, 0x6d, | |||
0x18, 0x9f, 0x3e, 0x8b, 0x82, 0x07, 0xc1, 0x43, | |||
0xc7, 0xe0, 0x25, 0xb6, 0xf1, 0xd3, 0x00, 0xd7, | |||
0x40, 0xab, 0x4b, 0x7f, 0x2b, 0x7a, 0x3e, 0xa6, | |||
0x99, 0x4c, 0x54, 0x16, 0x03, 0x03, 0x01, 0x4d, | |||
0x0c, 0x00, 0x01, 0x49, 0x03, 0x00, 0x17, 0x41, | |||
0x04, 0x8f, 0x92, 0xa0, 0x20, 0xdc, 0x70, 0xce, | |||
0xaf, 0x50, 0x44, 0xa8, 0x53, 0x15, 0xbf, 0x74, | |||
0x0c, 0xed, 0x60, 0x26, 0xac, 0xb0, 0x07, 0x17, | |||
0x59, 0x02, 0x6d, 0x9f, 0x45, 0x57, 0x3b, 0x9c, | |||
0x67, 0xae, 0xb8, 0xa6, 0x70, 0xa9, 0x03, 0xb4, | |||
0x37, 0x7b, 0xe4, 0x2f, 0x7c, 0x42, 0x4f, 0xaa, | |||
0x9a, 0x5d, 0x10, 0x65, 0xc1, 0xa5, 0x33, 0xff, | |||
0xc5, 0xdf, 0x24, 0xdb, 0x8f, 0xe2, 0x14, 0xee, | |||
0x00, 0x04, 0x01, 0x01, 0x00, 0x76, 0xcf, 0xe6, | |||
0x47, 0xcf, 0xc1, 0x58, 0xf5, 0x5d, 0x3a, 0x0b, | |||
0xd5, 0x4e, 0xb1, 0x08, 0xa6, 0x03, 0x8b, 0xa3, | |||
0x7b, 0x9c, 0xa2, 0x3b, 0x99, 0x7e, 0x42, 0x0d, | |||
0x38, 0x6e, 0x9a, 0x5e, 0xf7, 0x45, 0x7f, 0xf3, | |||
0x51, 0xa2, 0xe6, 0xae, 0x1c, 0x55, 0x2a, 0x58, | |||
0x13, 0x55, 0xa9, 0x93, 0xac, 0x6a, 0x1e, 0xd6, | |||
0xd9, 0x98, 0x89, 0x93, 0x16, 0x8f, 0xab, 0xc5, | |||
0x65, 0x65, 0x62, 0x68, 0xd8, 0xbf, 0xbd, 0x4e, | |||
0x1a, 0x17, 0x24, 0x9c, 0x3c, 0x56, 0xf5, 0x8f, | |||
0xda, 0x6e, 0x03, 0xe7, 0xe9, 0xce, 0xe5, 0xb1, | |||
0x68, 0xd8, 0x88, 0xdb, 0xde, 0xfe, 0x98, 0xbe, | |||
0x9d, 0x1f, 0x86, 0xbf, 0x36, 0xe5, 0xe9, 0x77, | |||
0xc3, 0xa6, 0xa3, 0x30, 0x60, 0x9f, 0x36, 0x65, | |||
0x4c, 0xe5, 0xb6, 0x3f, 0xf8, 0x15, 0x76, 0xac, | |||
0x4f, 0xb5, 0x8a, 0x98, 0xe3, 0xc2, 0xbd, 0x13, | |||
0xff, 0x59, 0xfd, 0x22, 0xbf, 0xb3, 0x02, 0xab, | |||
0xf1, 0x82, 0xff, 0x4c, 0x41, 0x81, 0x15, 0xa5, | |||
0xc7, 0x56, 0x93, 0xc3, 0xb0, 0xd2, 0x70, 0x84, | |||
0xb6, 0x27, 0x43, 0x47, 0x38, 0x3a, 0xcf, 0x20, | |||
0xa4, 0x97, 0x61, 0xc7, 0xf9, 0xb2, 0x01, 0xea, | |||
0x83, 0x72, 0x00, 0x74, 0x3e, 0x41, 0xd0, 0x24, | |||
0x32, 0xf7, 0xe1, 0x68, 0xae, 0x06, 0xcb, 0x70, | |||
0x06, 0x3a, 0x3a, 0xd3, 0x97, 0x7e, 0xaa, 0x27, | |||
0xb7, 0xcc, 0xd3, 0x7f, 0xb2, 0x07, 0x9e, 0x85, | |||
0x16, 0x25, 0x28, 0xee, 0xc7, 0x29, 0x09, 0x56, | |||
0x94, 0x6c, 0x7e, 0xe4, 0x61, 0x7b, 0xc2, 0xd5, | |||
0x03, 0x46, 0x71, 0x69, 0xc0, 0x90, 0x0e, 0x58, | |||
0xc6, 0xef, 0xf5, 0x23, 0x03, 0x42, 0x92, 0x1a, | |||
0x2f, 0x4b, 0x0a, 0x5d, 0x74, 0x71, 0x28, 0x5a, | |||
0x83, 0xf2, 0x00, 0x79, 0x65, 0x89, 0x61, 0x87, | |||
0x31, 0xf0, 0x09, 0x89, 0x6a, 0xc4, 0x48, 0xee, | |||
0x78, 0xf1, 0x65, 0x3f, 0xe1, 0x16, 0x03, 0x03, | |||
0x00, 0x5a, 0x0d, 0x00, 0x00, 0x52, 0x03, 0x01, | |||
0x02, 0x40, 0x00, 0x20, 0x06, 0x01, 0x06, 0x02, | |||
0x06, 0x03, 0x05, 0x01, 0x05, 0x02, 0x05, 0x03, | |||
0x04, 0x01, 0x04, 0x02, 0x04, 0x03, 0x03, 0x01, | |||
0x03, 0x02, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, | |||
0x02, 0x03, 0x01, 0x01, 0x00, 0x2a, 0x00, 0x28, | |||
0x30, 0x26, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, | |||
0x55, 0x04, 0x0a, 0x13, 0x07, 0x41, 0x63, 0x6d, | |||
0x65, 0x20, 0x43, 0x6f, 0x31, 0x12, 0x30, 0x10, | |||
0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x09, 0x31, | |||
0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, | |||
0x0e, 0x00, 0x00, 0x00, | |||
}, | |||
{ | |||
0x16, 0x03, 0x03, 0x00, 0x07, 0x0b, 0x00, 0x00, | |||
0x03, 0x00, 0x00, 0x00, 0x16, 0x03, 0x03, 0x00, | |||
0x46, 0x10, 0x00, 0x00, 0x42, 0x41, 0x04, 0x1e, | |||
0x18, 0x37, 0xef, 0x0d, 0x19, 0x51, 0x88, 0x35, | |||
0x75, 0x71, 0xb5, 0xe5, 0x54, 0x5b, 0x12, 0x2e, | |||
0x8f, 0x09, 0x67, 0xfd, 0xa7, 0x24, 0x20, 0x3e, | |||
0xb2, 0x56, 0x1c, 0xce, 0x97, 0x28, 0x5e, 0xf8, | |||
0x2b, 0x2d, 0x4f, 0x9e, 0xf1, 0x07, 0x9f, 0x6c, | |||
0x4b, 0x5b, 0x83, 0x56, 0xe2, 0x32, 0x42, 0xe9, | |||
0x58, 0xb6, 0xd7, 0x49, 0xa6, 0xb5, 0x68, 0x1a, | |||
0x41, 0x03, 0x56, 0x6b, 0xdc, 0x5a, 0x89, 0x14, | |||
0x03, 0x03, 0x00, 0x01, 0x01, 0x16, 0x03, 0x03, | |||
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x1f, 0xb8, 0x47, 0xfb, 0xd2, 0xba, | |||
0x62, 0x74, 0x63, 0x54, 0xb8, 0x03, 0x7b, 0xb9, | |||
0x05, 0x87, 0x60, 0x6f, 0xb9, 0xfc, 0x79, 0x96, | |||
0xce, 0xf0, 0x84, 0x77, 0x23, 0x1b, 0x44, 0x3f, | |||
0x33, 0xe8, 0x71, 0x97, 0x9d, 0xd3, 0x7d, 0x43, | |||
0x40, 0xd3, 0x95, 0x65, 0x1f, 0x2c, 0x30, 0xfd, | |||
0x7f, 0xac, | |||
}, | |||
{ | |||
0x14, 0x03, 0x03, 0x00, 0x01, 0x01, 0x16, 0x03, | |||
0x03, 0x00, 0x40, 0x64, 0x09, 0x6c, 0x06, 0x5a, | |||
0x01, 0x24, 0x10, 0xd9, 0x92, 0x66, 0xe6, 0x28, | |||
0x43, 0x2f, 0xba, 0x0b, 0x17, 0x61, 0x55, 0x42, | |||
0x9d, 0xc3, 0x59, 0xba, 0x57, 0x19, 0x1b, 0x74, | |||
0x22, 0x40, 0xc7, 0x13, 0x95, 0x83, 0xe6, 0xf3, | |||
0x11, 0x62, 0xe6, 0xde, 0xfc, 0xf3, 0x1a, 0xd1, | |||
0x3d, 0xce, 0xd1, 0xf9, 0xeb, 0x2e, 0x13, 0x39, | |||
0xa6, 0xdb, 0x04, 0x79, 0xaa, 0x2d, 0xe1, 0xa4, | |||
0xd0, 0xf9, 0x36, | |||
}, | |||
{ | |||
0x17, 0x03, 0x03, 0x00, 0x30, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x88, 0x3d, | |||
0xcb, 0x65, 0xc1, 0xac, 0x94, 0xc5, 0x1d, 0x4d, | |||
0xc5, 0x1e, 0xd4, 0x17, 0xe3, 0x83, 0xac, 0x14, | |||
0x80, 0x92, 0x2d, 0x5b, 0x42, 0x19, 0xcb, 0x51, | |||
0xc9, 0x48, 0xdf, 0xf6, 0x27, 0x15, 0x03, 0x03, | |||
0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0xf7, 0xc2, 0xed, 0x1a, 0x88, 0xb6, | |||
0xb8, 0x26, 0x04, 0x31, 0x89, 0xab, 0x29, 0x34, | |||
0xce, 0x84, 0x81, 0x33, 0x64, 0x8e, 0x53, 0xa3, | |||
0xaf, 0x8b, 0x5a, 0x50, 0x43, 0xab, 0x77, 0x77, | |||
0xa3, 0xc7, | |||
}, | |||
} | |||
var testClientChainCertificate = fromHex( | |||
"2d2d2d2d2d424547494e2050524956415445204b" + | |||
"45592d2d2d2d2d0a4d494945766749424144414e" + | |||
@@ -20,6 +20,7 @@ type clientHelloMsg struct { | |||
supportedPoints []uint8 | |||
ticketSupported bool | |||
sessionTicket []uint8 | |||
signatureAndHashes []signatureAndHash | |||
} | |||
func (m *clientHelloMsg) equal(i interface{}) bool { | |||
@@ -40,7 +41,8 @@ func (m *clientHelloMsg) equal(i interface{}) bool { | |||
eqUint16s(m.supportedCurves, m1.supportedCurves) && | |||
bytes.Equal(m.supportedPoints, m1.supportedPoints) && | |||
m.ticketSupported == m1.ticketSupported && | |||
bytes.Equal(m.sessionTicket, m1.sessionTicket) | |||
bytes.Equal(m.sessionTicket, m1.sessionTicket) && | |||
eqSignatureAndHashes(m.signatureAndHashes, m1.signatureAndHashes) | |||
} | |||
func (m *clientHelloMsg) marshal() []byte { | |||
@@ -74,6 +76,10 @@ func (m *clientHelloMsg) marshal() []byte { | |||
extensionsLength += len(m.sessionTicket) | |||
numExtensions++ | |||
} | |||
if len(m.signatureAndHashes) > 0 { | |||
extensionsLength += 2 + 2*len(m.signatureAndHashes) | |||
numExtensions++ | |||
} | |||
if numExtensions > 0 { | |||
extensionsLength += 4 * numExtensions | |||
length += 2 + extensionsLength | |||
@@ -199,6 +205,25 @@ func (m *clientHelloMsg) marshal() []byte { | |||
copy(z, m.sessionTicket) | |||
z = z[len(m.sessionTicket):] | |||
} | |||
if len(m.signatureAndHashes) > 0 { | |||
// https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1 | |||
z[0] = byte(extensionSignatureAlgorithms >> 8) | |||
z[1] = byte(extensionSignatureAlgorithms) | |||
l := 2 + 2*len(m.signatureAndHashes) | |||
z[2] = byte(l >> 8) | |||
z[3] = byte(l) | |||
z = z[4:] | |||
l -= 2 | |||
z[0] = byte(l >> 8) | |||
z[1] = byte(l) | |||
z = z[2:] | |||
for _, sigAndHash := range m.signatureAndHashes { | |||
z[0] = sigAndHash.hash | |||
z[1] = sigAndHash.signature | |||
z = z[2:] | |||
} | |||
} | |||
m.raw = x | |||
@@ -249,6 +274,7 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool { | |||
m.ocspStapling = false | |||
m.ticketSupported = false | |||
m.sessionTicket = nil | |||
m.signatureAndHashes = nil | |||
if len(data) == 0 { | |||
// ClientHello is optionally followed by extension data | |||
@@ -336,6 +362,23 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool { | |||
// http://tools.ietf.org/html/rfc5077#section-3.2 | |||
m.ticketSupported = true | |||
m.sessionTicket = data[:length] | |||
case extensionSignatureAlgorithms: | |||
// https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1 | |||
if length < 2 || length&1 != 0 { | |||
return false | |||
} | |||
l := int(data[0])<<8 | int(data[1]) | |||
if l != length-2 { | |||
return false | |||
} | |||
n := l / 2 | |||
d := data[2:] | |||
m.signatureAndHashes = make([]signatureAndHash, n) | |||
for i := range m.signatureAndHashes { | |||
m.signatureAndHashes[i].hash = d[0] | |||
m.signatureAndHashes[i].signature = d[1] | |||
d = d[2:] | |||
} | |||
} | |||
data = data[length:] | |||
} | |||
@@ -899,8 +942,14 @@ func (m *nextProtoMsg) unmarshal(data []byte) bool { | |||
} | |||
type certificateRequestMsg struct { | |||
raw []byte | |||
raw []byte | |||
// hasSignatureAndHash indicates whether this message includes a list | |||
// of signature and hash functions. This change was introduced with TLS | |||
// 1.2. | |||
hasSignatureAndHash bool | |||
certificateTypes []byte | |||
signatureAndHashes []signatureAndHash | |||
certificateAuthorities [][]byte | |||
} | |||
@@ -912,7 +961,8 @@ func (m *certificateRequestMsg) equal(i interface{}) bool { | |||
return bytes.Equal(m.raw, m1.raw) && | |||
bytes.Equal(m.certificateTypes, m1.certificateTypes) && | |||
eqByteSlices(m.certificateAuthorities, m1.certificateAuthorities) | |||
eqByteSlices(m.certificateAuthorities, m1.certificateAuthorities) && | |||
eqSignatureAndHashes(m.signatureAndHashes, m1.signatureAndHashes) | |||
} | |||
func (m *certificateRequestMsg) marshal() (x []byte) { | |||
@@ -928,6 +978,10 @@ func (m *certificateRequestMsg) marshal() (x []byte) { | |||
} | |||
length += casLength | |||
if m.hasSignatureAndHash { | |||
length += 2 + 2*len(m.signatureAndHashes) | |||
} | |||
x = make([]byte, 4+length) | |||
x[0] = typeCertificateRequest | |||
x[1] = uint8(length >> 16) | |||
@@ -938,6 +992,19 @@ func (m *certificateRequestMsg) marshal() (x []byte) { | |||
copy(x[5:], m.certificateTypes) | |||
y := x[5+len(m.certificateTypes):] | |||
if m.hasSignatureAndHash { | |||
n := len(m.signatureAndHashes) * 2 | |||
y[0] = uint8(n >> 8) | |||
y[1] = uint8(n) | |||
y = y[2:] | |||
for _, sigAndHash := range m.signatureAndHashes { | |||
y[0] = sigAndHash.hash | |||
y[1] = sigAndHash.signature | |||
y = y[2:] | |||
} | |||
} | |||
y[0] = uint8(casLength >> 8) | |||
y[1] = uint8(casLength) | |||
y = y[2:] | |||
@@ -978,6 +1045,27 @@ func (m *certificateRequestMsg) unmarshal(data []byte) bool { | |||
data = data[numCertTypes:] | |||
if m.hasSignatureAndHash { | |||
if len(data) < 2 { | |||
return false | |||
} | |||
sigAndHashLen := uint16(data[0])<<8 | uint16(data[1]) | |||
data = data[2:] | |||
if sigAndHashLen&1 != 0 { | |||
return false | |||
} | |||
if len(data) < int(sigAndHashLen) { | |||
return false | |||
} | |||
numSigAndHash := sigAndHashLen / 2 | |||
m.signatureAndHashes = make([]signatureAndHash, numSigAndHash) | |||
for i := range m.signatureAndHashes { | |||
m.signatureAndHashes[i].hash = data[0] | |||
m.signatureAndHashes[i].signature = data[1] | |||
data = data[2:] | |||
} | |||
} | |||
if len(data) < 2 { | |||
return false | |||
} | |||
@@ -1013,8 +1101,10 @@ func (m *certificateRequestMsg) unmarshal(data []byte) bool { | |||
} | |||
type certificateVerifyMsg struct { | |||
raw []byte | |||
signature []byte | |||
raw []byte | |||
hasSignatureAndHash bool | |||
signatureAndHash signatureAndHash | |||
signature []byte | |||
} | |||
func (m *certificateVerifyMsg) equal(i interface{}) bool { | |||
@@ -1024,6 +1114,9 @@ func (m *certificateVerifyMsg) equal(i interface{}) bool { | |||
} | |||
return bytes.Equal(m.raw, m1.raw) && | |||
m.hasSignatureAndHash == m1.hasSignatureAndHash && | |||
m.signatureAndHash.hash == m1.signatureAndHash.hash && | |||
m.signatureAndHash.signature == m1.signatureAndHash.signature && | |||
bytes.Equal(m.signature, m1.signature) | |||
} | |||
@@ -1035,14 +1128,23 @@ func (m *certificateVerifyMsg) marshal() (x []byte) { | |||
// See http://tools.ietf.org/html/rfc4346#section-7.4.8 | |||
siglength := len(m.signature) | |||
length := 2 + siglength | |||
if m.hasSignatureAndHash { | |||
length += 2 | |||
} | |||
x = make([]byte, 4+length) | |||
x[0] = typeCertificateVerify | |||
x[1] = uint8(length >> 16) | |||
x[2] = uint8(length >> 8) | |||
x[3] = uint8(length) | |||
x[4] = uint8(siglength >> 8) | |||
x[5] = uint8(siglength) | |||
copy(x[6:], m.signature) | |||
y := x[4:] | |||
if m.hasSignatureAndHash { | |||
y[0] = m.signatureAndHash.hash | |||
y[1] = m.signatureAndHash.signature | |||
y = y[2:] | |||
} | |||
y[0] = uint8(siglength >> 8) | |||
y[1] = uint8(siglength) | |||
copy(y[2:], m.signature) | |||
m.raw = x | |||
@@ -1061,12 +1163,23 @@ func (m *certificateVerifyMsg) unmarshal(data []byte) bool { | |||
return false | |||
} | |||
siglength := int(data[4])<<8 + int(data[5]) | |||
if len(data)-6 != siglength { | |||
data = data[4:] | |||
if m.hasSignatureAndHash { | |||
m.signatureAndHash.hash = data[0] | |||
m.signatureAndHash.signature = data[1] | |||
data = data[2:] | |||
} | |||
if len(data) < 2 { | |||
return false | |||
} | |||
siglength := int(data[0])<<8 + int(data[1]) | |||
data = data[2:] | |||
if len(data) != siglength { | |||
return false | |||
} | |||
m.signature = data[6:] | |||
m.signature = data | |||
return true | |||
} | |||
@@ -1165,3 +1278,16 @@ func eqByteSlices(x, y [][]byte) bool { | |||
} | |||
return true | |||
} | |||
func eqSignatureAndHashes(x, y []signatureAndHash) bool { | |||
if len(x) != len(y) { | |||
return false | |||
} | |||
for i, v := range x { | |||
v2 := y[i] | |||
if v.hash != v2.hash || v.signature != v2.signature { | |||
return false | |||
} | |||
} | |||
return true | |||
} |
@@ -135,6 +135,9 @@ func (*clientHelloMsg) Generate(rand *rand.Rand, size int) reflect.Value { | |||
m.sessionTicket = randomBytes(rand.Intn(300), rand) | |||
} | |||
} | |||
if rand.Intn(10) > 5 { | |||
m.signatureAndHashes = supportedSignatureAlgorithms | |||
} | |||
return reflect.ValueOf(m) | |||
} | |||
@@ -5,7 +5,6 @@ | |||
package tls | |||
import ( | |||
"crypto" | |||
"crypto/rsa" | |||
"crypto/subtle" | |||
"crypto/x509" | |||
@@ -292,7 +291,7 @@ func (hs *serverHandshakeState) doFullHandshake() error { | |||
c.writeRecord(recordTypeHandshake, certStatus.marshal()) | |||
} | |||
keyAgreement := hs.suite.ka() | |||
keyAgreement := hs.suite.ka(c.vers) | |||
skx, err := keyAgreement.generateServerKeyExchange(config, cert, hs.clientHello, hs.hello) | |||
if err != nil { | |||
c.sendAlert(alertHandshakeFailure) | |||
@@ -307,6 +306,10 @@ func (hs *serverHandshakeState) doFullHandshake() error { | |||
// Request a client certificate | |||
certReq := new(certificateRequestMsg) | |||
certReq.certificateTypes = []byte{certTypeRSASign} | |||
if c.vers >= VersionTLS12 { | |||
certReq.hasSignatureAndHash = true | |||
certReq.signatureAndHashes = supportedSignatureAlgorithms | |||
} | |||
// An empty list of certificateAuthorities signals to | |||
// the client that it may send any certificate in response | |||
@@ -383,10 +386,8 @@ func (hs *serverHandshakeState) doFullHandshake() error { | |||
return c.sendAlert(alertUnexpectedMessage) | |||
} | |||
digest := make([]byte, 0, 36) | |||
digest = hs.finishedHash.serverMD5.Sum(digest) | |||
digest = hs.finishedHash.serverSHA1.Sum(digest) | |||
err = rsa.VerifyPKCS1v15(pub, crypto.MD5SHA1, digest, certVerify.signature) | |||
digest, hashFunc := hs.finishedHash.hashForClientCertificate() | |||
err = rsa.VerifyPKCS1v15(pub, hashFunc, digest, certVerify.signature) | |||
if err != nil { | |||
c.sendAlert(alertBadCertificate) | |||
return errors.New("could not validate signature of connection nonces: " + err.Error()) | |||
@@ -112,7 +112,7 @@ func TestAlertForwarding(t *testing.T) { | |||
err := Server(s, testConfig).Handshake() | |||
s.Close() | |||
if e, ok := err.(*net.OpError); !ok || e.Err != error(alertUnknownCA) { | |||
t.Errorf("Got error: %s; expected: %s", err, alertUnknownCA) | |||
t.Errorf("Got error: %s; expected: %s", err, error(alertUnknownCA)) | |||
} | |||
} | |||
@@ -147,6 +147,7 @@ func TestCipherSuitePreference(t *testing.T) { | |||
serverConfig := &Config{ | |||
CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_RC4_128_SHA}, | |||
Certificates: testConfig.Certificates, | |||
MaxVersion: VersionTLS11, | |||
} | |||
clientConfig := &Config{ | |||
CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_RC4_128_SHA}, | |||
@@ -247,6 +248,15 @@ func TestResumption(t *testing.T) { | |||
testServerScript(t, "Resume", serverResumeTest, testConfig, nil) | |||
} | |||
func TestTLS12ClientCertServer(t *testing.T) { | |||
config := *testConfig | |||
config.MaxVersion = VersionTLS12 | |||
config.ClientAuth = RequireAnyClientCert | |||
config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_RC4_128_SHA} | |||
testServerScript(t, "TLS12", tls12ServerScript, &config, nil) | |||
} | |||
type clientauthTest struct { | |||
name string | |||
clientauth ClientAuthType | |||
@@ -2223,6 +2233,532 @@ var tls11ECDHEAESServerScript = [][]byte{ | |||
}, | |||
} | |||
var tls12ServerScript = [][]byte{ | |||
{ | |||
0x16, 0x03, 0x01, 0x01, 0x46, 0x01, 0x00, 0x01, | |||
0x42, 0x03, 0x03, 0x51, 0xcd, 0xe6, 0xe3, 0xe1, | |||
0xb7, 0xb8, 0xf9, 0x20, 0xea, 0xc5, 0x8a, 0xe2, | |||
0x8b, 0x07, 0x5a, 0x11, 0x0e, 0x54, 0x3c, 0x4f, | |||
0x36, 0x06, 0x64, 0x7b, 0x0e, 0xc4, 0xf8, 0x75, | |||
0x99, 0x9d, 0x5a, 0x00, 0x00, 0xd0, 0xc0, 0x30, | |||
0xc0, 0x2c, 0xc0, 0x28, 0xc0, 0x24, 0xc0, 0x14, | |||
0xc0, 0x0a, 0xc0, 0x22, 0xc0, 0x21, 0x00, 0xa5, | |||
0x00, 0xa3, 0x00, 0xa1, 0x00, 0x9f, 0x00, 0x6b, | |||
0x00, 0x6a, 0x00, 0x69, 0x00, 0x68, 0x00, 0x39, | |||
0x00, 0x38, 0x00, 0x37, 0x00, 0x36, 0x00, 0x88, | |||
0x00, 0x87, 0x00, 0x86, 0x00, 0x85, 0xc0, 0x32, | |||
0xc0, 0x2e, 0xc0, 0x2a, 0xc0, 0x26, 0xc0, 0x0f, | |||
0xc0, 0x05, 0x00, 0x9d, 0x00, 0x3d, 0x00, 0x35, | |||
0x00, 0x84, 0xc0, 0x12, 0xc0, 0x08, 0xc0, 0x1c, | |||
0xc0, 0x1b, 0x00, 0x16, 0x00, 0x13, 0x00, 0x10, | |||
0x00, 0x0d, 0xc0, 0x0d, 0xc0, 0x03, 0x00, 0x0a, | |||
0xc0, 0x2f, 0xc0, 0x2b, 0xc0, 0x27, 0xc0, 0x23, | |||
0xc0, 0x13, 0xc0, 0x09, 0xc0, 0x1f, 0xc0, 0x1e, | |||
0x00, 0xa4, 0x00, 0xa2, 0x00, 0xa0, 0x00, 0x9e, | |||
0x00, 0x67, 0x00, 0x40, 0x00, 0x3f, 0x00, 0x3e, | |||
0x00, 0x33, 0x00, 0x32, 0x00, 0x31, 0x00, 0x30, | |||
0x00, 0x9a, 0x00, 0x99, 0x00, 0x98, 0x00, 0x97, | |||
0x00, 0x45, 0x00, 0x44, 0x00, 0x43, 0x00, 0x42, | |||
0xc0, 0x31, 0xc0, 0x2d, 0xc0, 0x29, 0xc0, 0x25, | |||
0xc0, 0x0e, 0xc0, 0x04, 0x00, 0x9c, 0x00, 0x3c, | |||
0x00, 0x2f, 0x00, 0x96, 0x00, 0x41, 0x00, 0x07, | |||
0xc0, 0x11, 0xc0, 0x07, 0xc0, 0x0c, 0xc0, 0x02, | |||
0x00, 0x05, 0x00, 0x04, 0x00, 0x15, 0x00, 0x12, | |||
0x00, 0x0f, 0x00, 0x0c, 0x00, 0x09, 0x00, 0x14, | |||
0x00, 0x11, 0x00, 0x0e, 0x00, 0x0b, 0x00, 0x08, | |||
0x00, 0x06, 0x00, 0x03, 0x00, 0xff, 0x01, 0x00, | |||
0x00, 0x49, 0x00, 0x0b, 0x00, 0x04, 0x03, 0x00, | |||
0x01, 0x02, 0x00, 0x0a, 0x00, 0x34, 0x00, 0x32, | |||
0x00, 0x0e, 0x00, 0x0d, 0x00, 0x19, 0x00, 0x0b, | |||
0x00, 0x0c, 0x00, 0x18, 0x00, 0x09, 0x00, 0x0a, | |||
0x00, 0x16, 0x00, 0x17, 0x00, 0x08, 0x00, 0x06, | |||
0x00, 0x07, 0x00, 0x14, 0x00, 0x15, 0x00, 0x04, | |||
0x00, 0x05, 0x00, 0x12, 0x00, 0x13, 0x00, 0x01, | |||
0x00, 0x02, 0x00, 0x03, 0x00, 0x0f, 0x00, 0x10, | |||
0x00, 0x11, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0f, | |||
0x00, 0x01, 0x01, | |||
}, | |||
{ | |||
0x16, 0x03, 0x03, 0x00, 0x30, 0x02, 0x00, 0x00, | |||
0x2c, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0xc0, 0x11, 0x00, 0x00, | |||
0x04, 0x00, 0x23, 0x00, 0x00, 0x16, 0x03, 0x03, | |||
0x02, 0xbe, 0x0b, 0x00, 0x02, 0xba, 0x00, 0x02, | |||
0xb7, 0x00, 0x02, 0xb4, 0x30, 0x82, 0x02, 0xb0, | |||
0x30, 0x82, 0x02, 0x19, 0xa0, 0x03, 0x02, 0x01, | |||
0x02, 0x02, 0x09, 0x00, 0x85, 0xb0, 0xbb, 0xa4, | |||
0x8a, 0x7f, 0xb8, 0xca, 0x30, 0x0d, 0x06, 0x09, | |||
0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, | |||
0x05, 0x05, 0x00, 0x30, 0x45, 0x31, 0x0b, 0x30, | |||
0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, | |||
0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, | |||
0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, | |||
0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, | |||
0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, | |||
0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, | |||
0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, | |||
0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, | |||
0x74, 0x64, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x30, | |||
0x30, 0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, | |||
0x33, 0x38, 0x5a, 0x17, 0x0d, 0x31, 0x31, 0x30, | |||
0x34, 0x32, 0x34, 0x30, 0x39, 0x30, 0x39, 0x33, | |||
0x38, 0x5a, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, | |||
0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, | |||
0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, | |||
0x04, 0x08, 0x13, 0x0a, 0x53, 0x6f, 0x6d, 0x65, | |||
0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, | |||
0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, | |||
0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, | |||
0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, | |||
0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, | |||
0x64, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, | |||
0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, | |||
0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, | |||
0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xbb, 0x79, | |||
0xd6, 0xf5, 0x17, 0xb5, 0xe5, 0xbf, 0x46, 0x10, | |||
0xd0, 0xdc, 0x69, 0xbe, 0xe6, 0x2b, 0x07, 0x43, | |||
0x5a, 0xd0, 0x03, 0x2d, 0x8a, 0x7a, 0x43, 0x85, | |||
0xb7, 0x14, 0x52, 0xe7, 0xa5, 0x65, 0x4c, 0x2c, | |||
0x78, 0xb8, 0x23, 0x8c, 0xb5, 0xb4, 0x82, 0xe5, | |||
0xde, 0x1f, 0x95, 0x3b, 0x7e, 0x62, 0xa5, 0x2c, | |||
0xa5, 0x33, 0xd6, 0xfe, 0x12, 0x5c, 0x7a, 0x56, | |||
0xfc, 0xf5, 0x06, 0xbf, 0xfa, 0x58, 0x7b, 0x26, | |||
0x3f, 0xb5, 0xcd, 0x04, 0xd3, 0xd0, 0xc9, 0x21, | |||
0x96, 0x4a, 0xc7, 0xf4, 0x54, 0x9f, 0x5a, 0xbf, | |||
0xef, 0x42, 0x71, 0x00, 0xfe, 0x18, 0x99, 0x07, | |||
0x7f, 0x7e, 0x88, 0x7d, 0x7d, 0xf1, 0x04, 0x39, | |||
0xc4, 0xa2, 0x2e, 0xdb, 0x51, 0xc9, 0x7c, 0xe3, | |||
0xc0, 0x4c, 0x3b, 0x32, 0x66, 0x01, 0xcf, 0xaf, | |||
0xb1, 0x1d, 0xb8, 0x71, 0x9a, 0x1d, 0xdb, 0xdb, | |||
0x89, 0x6b, 0xae, 0xda, 0x2d, 0x79, 0x02, 0x03, | |||
0x01, 0x00, 0x01, 0xa3, 0x81, 0xa7, 0x30, 0x81, | |||
0xa4, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, | |||
0x04, 0x16, 0x04, 0x14, 0xb1, 0xad, 0xe2, 0x85, | |||
0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, 0x23, | |||
0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, 0x39, | |||
0x30, 0x75, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, | |||
0x6e, 0x30, 0x6c, 0x80, 0x14, 0xb1, 0xad, 0xe2, | |||
0x85, 0x5a, 0xcf, 0xcb, 0x28, 0xdb, 0x69, 0xce, | |||
0x23, 0x69, 0xde, 0xd3, 0x26, 0x8e, 0x18, 0x88, | |||
0x39, 0xa1, 0x49, 0xa4, 0x47, 0x30, 0x45, 0x31, | |||
0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, | |||
0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, | |||
0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x0a, 0x53, | |||
0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, | |||
0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, | |||
0x04, 0x0a, 0x13, 0x18, 0x49, 0x6e, 0x74, 0x65, | |||
0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, | |||
0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, | |||
0x20, 0x4c, 0x74, 0x64, 0x82, 0x09, 0x00, 0x85, | |||
0xb0, 0xbb, 0xa4, 0x8a, 0x7f, 0xb8, 0xca, 0x30, | |||
0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, | |||
0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, | |||
0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, | |||
0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, | |||
0x08, 0x6c, 0x45, 0x24, 0xc7, 0x6b, 0xb1, 0x59, | |||
0xab, 0x0c, 0x52, 0xcc, 0xf2, 0xb0, 0x14, 0xd7, | |||
0x87, 0x9d, 0x7a, 0x64, 0x75, 0xb5, 0x5a, 0x95, | |||
0x66, 0xe4, 0xc5, 0x2b, 0x8e, 0xae, 0x12, 0x66, | |||
0x1f, 0xeb, 0x4f, 0x38, 0xb3, 0x6e, 0x60, 0xd3, | |||
0x92, 0xfd, 0xf7, 0x41, 0x08, 0xb5, 0x25, 0x13, | |||
0xb1, 0x18, 0x7a, 0x24, 0xfb, 0x30, 0x1d, 0xba, | |||
0xed, 0x98, 0xb9, 0x17, 0xec, 0xe7, 0xd7, 0x31, | |||
0x59, 0xdb, 0x95, 0xd3, 0x1d, 0x78, 0xea, 0x50, | |||
0x56, 0x5c, 0xd5, 0x82, 0x5a, 0x2d, 0x5a, 0x5f, | |||
0x33, 0xc4, 0xb6, 0xd8, 0xc9, 0x75, 0x90, 0x96, | |||
0x8c, 0x0f, 0x52, 0x98, 0xb5, 0xcd, 0x98, 0x1f, | |||
0x89, 0x20, 0x5f, 0xf2, 0xa0, 0x1c, 0xa3, 0x1b, | |||
0x96, 0x94, 0xdd, 0xa9, 0xfd, 0x57, 0xe9, 0x70, | |||
0xe8, 0x26, 0x6d, 0x71, 0x99, 0x9b, 0x26, 0x6e, | |||
0x38, 0x50, 0x29, 0x6c, 0x90, 0xa7, 0xbd, 0xd9, | |||
0x16, 0x03, 0x03, 0x01, 0x11, 0x0c, 0x00, 0x01, | |||
0x0d, 0x03, 0x00, 0x19, 0x85, 0x04, 0x01, 0x39, | |||
0xdc, 0xee, 0x44, 0x17, 0x5e, 0xdb, 0xd7, 0x27, | |||
0xaf, 0xb6, 0x56, 0xd9, 0xb4, 0x43, 0x5a, 0x99, | |||
0xcf, 0xaa, 0x31, 0x37, 0x0c, 0x6f, 0x3a, 0xa0, | |||
0xf8, 0x53, 0xc4, 0x74, 0xd1, 0x91, 0x0a, 0x46, | |||
0xf5, 0x38, 0x3b, 0x5c, 0x09, 0xd8, 0x97, 0xdc, | |||
0x4b, 0xaa, 0x70, 0x26, 0x48, 0xf2, 0xd6, 0x0b, | |||
0x31, 0xc9, 0xf8, 0xd4, 0x98, 0x43, 0xe1, 0x6c, | |||
0xd5, 0xc7, 0xb2, 0x8e, 0x0b, 0x01, 0xe6, 0xb6, | |||
0x00, 0x28, 0x80, 0x7b, 0xfc, 0x96, 0x8f, 0x0d, | |||
0xa2, 0x4f, 0xb0, 0x79, 0xaf, 0xdc, 0x61, 0x28, | |||
0x63, 0x33, 0x78, 0xf6, 0x31, 0x39, 0xfd, 0x8a, | |||
0xf4, 0x15, 0x18, 0x11, 0xfe, 0xdb, 0xd5, 0x07, | |||
0xda, 0x2c, 0xed, 0x49, 0xa0, 0x23, 0xbf, 0xd0, | |||
0x3a, 0x38, 0x1d, 0x54, 0xae, 0x1c, 0x7b, 0xea, | |||
0x29, 0xee, 0xd0, 0x38, 0xc1, 0x76, 0xa7, 0x7f, | |||
0x2a, 0xf4, 0xce, 0x1e, 0xac, 0xcc, 0x94, 0x79, | |||
0x90, 0x33, 0x04, 0x01, 0x00, 0x80, 0xac, 0xee, | |||
0xef, 0xfa, 0x25, 0x62, 0xee, 0x09, 0x64, 0x9f, | |||
0x9b, 0xf9, 0x99, 0x3e, 0xb0, 0x09, 0xb6, 0xfb, | |||
0xbd, 0x2a, 0x87, 0x72, 0x56, 0x43, 0xc4, 0x53, | |||
0x4c, 0xca, 0x94, 0x09, 0x7e, 0xc7, 0xce, 0xb0, | |||
0x2f, 0x7f, 0x21, 0x91, 0xbc, 0x0e, 0x33, 0x74, | |||
0x1c, 0xa8, 0x44, 0x51, 0xe5, 0x2f, 0xb5, 0x43, | |||
0xad, 0x7a, 0x95, 0xec, 0xd0, 0x4c, 0x6b, 0xb8, | |||
0x05, 0x89, 0x29, 0x23, 0x52, 0xe4, 0x89, 0x0d, | |||
0x07, 0xbf, 0xe7, 0xf9, 0x76, 0x6c, 0x86, 0xad, | |||
0xbd, 0x79, 0x80, 0x2d, 0xfa, 0xb3, 0x08, 0xf0, | |||
0xd6, 0x1b, 0xc5, 0x86, 0x41, 0x9a, 0xc5, 0x85, | |||
0x68, 0x58, 0x41, 0x9d, 0xa5, 0x14, 0x4b, 0xf5, | |||
0xc9, 0x5c, 0xe0, 0x12, 0xf4, 0x33, 0x75, 0x5e, | |||
0x05, 0xe7, 0x95, 0xff, 0x25, 0xdf, 0xa8, 0x66, | |||
0xc0, 0x5e, 0x00, 0xed, 0x76, 0xe4, 0x3e, 0x2c, | |||
0x41, 0x5b, 0x51, 0xca, 0x60, 0x5e, 0x16, 0x03, | |||
0x03, 0x00, 0x0c, 0x0d, 0x00, 0x00, 0x08, 0x01, | |||
0x01, 0x00, 0x02, 0x04, 0x01, 0x00, 0x00, 0x16, | |||
0x03, 0x03, 0x00, 0x04, 0x0e, 0x00, 0x00, 0x00, | |||
}, | |||
{ | |||
0x16, 0x03, 0x03, 0x03, 0xf5, 0x0b, 0x00, 0x03, | |||
0xf1, 0x00, 0x03, 0xee, 0x00, 0x03, 0xeb, 0x30, | |||
0x82, 0x03, 0xe7, 0x30, 0x82, 0x02, 0xcf, 0xa0, | |||
0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xb9, | |||
0xee, 0xd4, 0xd9, 0x55, 0xa5, 0x9e, 0xb3, 0x30, | |||
0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, | |||
0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x70, | |||
0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, | |||
0x06, 0x13, 0x02, 0x55, 0x4b, 0x31, 0x16, 0x30, | |||
0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0d, | |||
0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, 0x4c, 0x20, | |||
0x47, 0x72, 0x6f, 0x75, 0x70, 0x31, 0x22, 0x30, | |||
0x20, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x19, | |||
0x46, 0x4f, 0x52, 0x20, 0x54, 0x45, 0x53, 0x54, | |||
0x49, 0x4e, 0x47, 0x20, 0x50, 0x55, 0x52, 0x50, | |||
0x4f, 0x53, 0x45, 0x53, 0x20, 0x4f, 0x4e, 0x4c, | |||
0x59, 0x31, 0x25, 0x30, 0x23, 0x06, 0x03, 0x55, | |||
0x04, 0x03, 0x0c, 0x1c, 0x4f, 0x70, 0x65, 0x6e, | |||
0x53, 0x53, 0x4c, 0x20, 0x54, 0x65, 0x73, 0x74, | |||
0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, | |||
0x64, 0x69, 0x61, 0x74, 0x65, 0x20, 0x43, 0x41, | |||
0x30, 0x1e, 0x17, 0x0d, 0x31, 0x31, 0x31, 0x32, | |||
0x30, 0x38, 0x31, 0x34, 0x30, 0x31, 0x34, 0x38, | |||
0x5a, 0x17, 0x0d, 0x32, 0x31, 0x31, 0x30, 0x31, | |||
0x36, 0x31, 0x34, 0x30, 0x31, 0x34, 0x38, 0x5a, | |||
0x30, 0x64, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, | |||
0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x4b, 0x31, | |||
0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, | |||
0x0c, 0x0d, 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, | |||
0x4c, 0x20, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x31, | |||
0x22, 0x30, 0x20, 0x06, 0x03, 0x55, 0x04, 0x0b, | |||
0x0c, 0x19, 0x46, 0x4f, 0x52, 0x20, 0x54, 0x45, | |||
0x53, 0x54, 0x49, 0x4e, 0x47, 0x20, 0x50, 0x55, | |||
0x52, 0x50, 0x4f, 0x53, 0x45, 0x53, 0x20, 0x4f, | |||
0x4e, 0x4c, 0x59, 0x31, 0x19, 0x30, 0x17, 0x06, | |||
0x03, 0x55, 0x04, 0x03, 0x0c, 0x10, 0x54, 0x65, | |||
0x73, 0x74, 0x20, 0x53, 0x65, 0x72, 0x76, 0x65, | |||
0x72, 0x20, 0x43, 0x65, 0x72, 0x74, 0x30, 0x82, | |||
0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, | |||
0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, | |||
0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, | |||
0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xf3, | |||
0x84, 0xf3, 0x92, 0x36, 0xdc, 0xb2, 0x46, 0xca, | |||
0x66, 0x7a, 0xe5, 0x29, 0xc5, 0xf3, 0x49, 0x28, | |||
0x22, 0xd3, 0xb9, 0xfe, 0xe0, 0xde, 0xe4, 0x38, | |||
0xce, 0xee, 0x22, 0x1c, 0xe9, 0x91, 0x3b, 0x94, | |||
0xd0, 0x72, 0x2f, 0x87, 0x85, 0x59, 0x4b, 0x66, | |||
0xb1, 0xc5, 0xf5, 0x7a, 0x85, 0x5d, 0xc2, 0x0f, | |||
0xd3, 0x2e, 0x29, 0x58, 0x36, 0xcc, 0x48, 0x6b, | |||
0xa2, 0xa2, 0xb5, 0x26, 0xce, 0x67, 0xe2, 0x47, | |||
0xb6, 0xdf, 0x49, 0xd2, 0x3f, 0xfa, 0xa2, 0x10, | |||
0xb7, 0xc2, 0x97, 0x44, 0x7e, 0x87, 0x34, 0x6d, | |||
0x6d, 0xf2, 0x8b, 0xb4, 0x55, 0x2b, 0xd6, 0x21, | |||
0xde, 0x53, 0x4b, 0x90, 0xea, 0xfd, 0xea, 0xf9, | |||
0x38, 0x35, 0x2b, 0xf4, 0xe6, 0x9a, 0x0e, 0xf6, | |||
0xbb, 0x12, 0xab, 0x87, 0x21, 0xc3, 0x2f, 0xbc, | |||
0xf4, 0x06, 0xb8, 0x8f, 0x8e, 0x10, 0x07, 0x27, | |||
0x95, 0xe5, 0x42, 0xcb, 0xd1, 0xd5, 0x10, 0x8c, | |||
0x92, 0xac, 0xee, 0x0f, 0xdc, 0x23, 0x48, 0x89, | |||
0xc9, 0xc6, 0x93, 0x0c, 0x22, 0x02, 0xe7, 0x74, | |||
0xe7, 0x25, 0x00, 0xab, 0xf8, 0x0f, 0x5c, 0x10, | |||
0xb5, 0x85, 0x3b, 0x66, 0x94, 0xf0, 0xfb, 0x4d, | |||
0x57, 0x06, 0x55, 0x21, 0x22, 0x25, 0xdb, 0xf3, | |||
0xaa, 0xa9, 0x60, 0xbf, 0x4d, 0xaa, 0x79, 0xd1, | |||
0xab, 0x92, 0x48, 0xba, 0x19, 0x8e, 0x12, 0xec, | |||
0x68, 0xd9, 0xc6, 0xba, 0xdf, 0xec, 0x5a, 0x1c, | |||
0xd8, 0x43, 0xfe, 0xe7, 0x52, 0xc9, 0xcf, 0x02, | |||
0xd0, 0xc7, 0x7f, 0xc9, 0x7e, 0xb0, 0x94, 0xe3, | |||
0x53, 0x44, 0x58, 0x0b, 0x2e, 0xfd, 0x29, 0x74, | |||
0xb5, 0x06, 0x9b, 0x5c, 0x44, 0x8d, 0xfb, 0x32, | |||
0x75, 0xa4, 0x3a, 0xa8, 0x67, 0x7b, 0x87, 0x32, | |||
0x0a, 0x50, 0x8d, 0xe1, 0xa2, 0x13, 0x4a, 0x25, | |||
0xaf, 0xe6, 0x1c, 0xb1, 0x25, 0xbf, 0xb4, 0x99, | |||
0xa2, 0x53, 0xd3, 0xa2, 0x02, 0xbf, 0x11, 0x02, | |||
0x03, 0x01, 0x00, 0x01, 0xa3, 0x81, 0x8f, 0x30, | |||
0x81, 0x8c, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, | |||
0x13, 0x01, 0x01, 0xff, 0x04, 0x02, 0x30, 0x00, | |||
0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, | |||
0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x05, 0xe0, | |||
0x30, 0x2c, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, | |||
0x86, 0xf8, 0x42, 0x01, 0x0d, 0x04, 0x1f, 0x16, | |||
0x1d, 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, 0x4c, | |||
0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, | |||
0x65, 0x64, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, | |||
0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x30, 0x1d, | |||
0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, | |||
0x14, 0x82, 0xbc, 0xcf, 0x00, 0x00, 0x13, 0xd1, | |||
0xf7, 0x39, 0x25, 0x9a, 0x27, 0xe7, 0xaf, 0xd2, | |||
0xef, 0x20, 0x1b, 0x6e, 0xac, 0x30, 0x1f, 0x06, | |||
0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, | |||
0x80, 0x14, 0x36, 0xc3, 0x6c, 0x88, 0xe7, 0x95, | |||
0xfe, 0xb0, 0xbd, 0xec, 0xce, 0x3e, 0x3d, 0x86, | |||
0xab, 0x21, 0x81, 0x87, 0xda, 0xda, 0x30, 0x0d, | |||
0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, | |||
0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, | |||
0x01, 0x00, 0xa9, 0xbd, 0x4d, 0x57, 0x40, 0x74, | |||
0xfe, 0x96, 0xe9, 0x2b, 0xd6, 0x78, 0xfd, 0xb3, | |||
0x63, 0xcc, 0xf4, 0x0b, 0x4d, 0x12, 0xca, 0x5a, | |||
0x74, 0x8d, 0x9b, 0xf2, 0x61, 0xe6, 0xfd, 0x06, | |||
0x11, 0x43, 0x84, 0xfc, 0x17, 0xa0, 0xec, 0x63, | |||
0x63, 0x36, 0xb9, 0x9e, 0x36, 0x6a, 0xb1, 0x02, | |||
0x5a, 0x6a, 0x5b, 0x3f, 0x6a, 0xa1, 0xea, 0x05, | |||
0x65, 0xac, 0x7e, 0x40, 0x1a, 0x48, 0x65, 0x88, | |||
0xd1, 0x39, 0x4d, 0xd3, 0x4b, 0x77, 0xe9, 0xc8, | |||
0xbb, 0x2b, 0x9e, 0x5a, 0xf4, 0x08, 0x34, 0x39, | |||
0x47, 0xb9, 0x02, 0x08, 0x31, 0x9a, 0xf1, 0xd9, | |||
0x17, 0xc5, 0xe9, 0xa6, 0xa5, 0x96, 0x4b, 0x6d, | |||
0x40, 0xa9, 0x5b, 0x65, 0x28, 0xcb, 0xcb, 0x00, | |||
0x03, 0x82, 0x63, 0x37, 0xd3, 0xad, 0xb1, 0x96, | |||
0x3b, 0x76, 0xf5, 0x17, 0x16, 0x02, 0x7b, 0xbd, | |||
0x53, 0x53, 0x46, 0x72, 0x34, 0xd6, 0x08, 0x64, | |||
0x9d, 0xbb, 0x43, 0xfb, 0x64, 0xb1, 0x49, 0x07, | |||
0x77, 0x09, 0x61, 0x7a, 0x42, 0x17, 0x11, 0x30, | |||
0x0c, 0xd9, 0x27, 0x5c, 0xf5, 0x71, 0xb6, 0xf0, | |||
0x18, 0x30, 0xf3, 0x7e, 0xf1, 0x85, 0x3f, 0x32, | |||
0x7e, 0x4a, 0xaf, 0xb3, 0x10, 0xf7, 0x6c, 0xc6, | |||
0x85, 0x4b, 0x2d, 0x27, 0xad, 0x0a, 0x20, 0x5c, | |||
0xfb, 0x8d, 0x19, 0x70, 0x34, 0xb9, 0x75, 0x5f, | |||
0x7c, 0x87, 0xd5, 0xc3, 0xec, 0x93, 0x13, 0x41, | |||
0xfc, 0x73, 0x03, 0xb9, 0x8d, 0x1a, 0xfe, 0xf7, | |||
0x26, 0x86, 0x49, 0x03, 0xa9, 0xc5, 0x82, 0x3f, | |||
0x80, 0x0d, 0x29, 0x49, 0xb1, 0x8f, 0xed, 0x24, | |||
0x1b, 0xfe, 0xcf, 0x58, 0x90, 0x46, 0xe7, 0xa8, | |||
0x87, 0xd4, 0x1e, 0x79, 0xef, 0x99, 0x6d, 0x18, | |||
0x9f, 0x3e, 0x8b, 0x82, 0x07, 0xc1, 0x43, 0xc7, | |||
0xe0, 0x25, 0xb6, 0xf1, 0xd3, 0x00, 0xd7, 0x40, | |||
0xab, 0x4b, 0x7f, 0x2b, 0x7a, 0x3e, 0xa6, 0x99, | |||
0x4c, 0x54, 0x16, 0x03, 0x03, 0x00, 0x8a, 0x10, | |||
0x00, 0x00, 0x86, 0x85, 0x04, 0x01, 0x82, 0x13, | |||
0x67, 0x8e, 0x1c, 0x5a, 0x3e, 0x74, 0x20, 0xa5, | |||
0x2d, 0x6f, 0xa3, 0xd0, 0xef, 0x21, 0x0a, 0x06, | |||
0xb2, 0xae, 0xaa, 0x5a, 0x23, 0xf6, 0xa0, 0x54, | |||
0xa8, 0x3a, 0xc5, 0x02, 0xfc, 0x35, 0x8c, 0xe9, | |||
0x0b, 0x81, 0x70, 0x1e, 0x82, 0xfa, 0x48, 0xf6, | |||
0xb3, 0x17, 0xef, 0x19, 0x0c, 0xd3, 0x67, 0x36, | |||
0xcf, 0xef, 0xa3, 0xcf, 0x34, 0xb3, 0xd0, 0x5f, | |||
0x8b, 0x51, 0xcf, 0x33, 0x3d, 0xd6, 0x2e, 0x01, | |||
0xf2, 0x46, 0xcc, 0xed, 0x9c, 0x6c, 0xe9, 0x42, | |||
0x95, 0xcb, 0x6d, 0x28, 0xe4, 0x62, 0xf9, 0xe2, | |||
0xcf, 0x6d, 0xa1, 0xdd, 0xb8, 0x0e, 0x93, 0x55, | |||
0x58, 0x0d, 0xe3, 0x50, 0xef, 0x96, 0x9a, 0xec, | |||
0xcd, 0x68, 0xb0, 0xc6, 0x0f, 0xe6, 0x73, 0x22, | |||
0x95, 0xb9, 0x5e, 0x65, 0x12, 0x76, 0xdb, 0x87, | |||
0x72, 0x57, 0xd2, 0x7e, 0x42, 0xe0, 0xf4, 0x92, | |||
0x6a, 0x8e, 0x82, 0xaf, 0x68, 0x83, 0xc7, 0xed, | |||
0x25, 0x16, 0x03, 0x03, 0x01, 0x08, 0x0f, 0x00, | |||
0x01, 0x04, 0x04, 0x01, 0x01, 0x00, 0x53, 0xa2, | |||
0x0d, 0xce, 0xe3, 0x2f, 0xdc, 0xb0, 0x6e, 0xe8, | |||
0x58, 0x8b, 0x99, 0x63, 0xab, 0xfc, 0xeb, 0xdb, | |||
0xf7, 0xba, 0xc3, 0x5c, 0x7b, 0x8b, 0x1f, 0x04, | |||
0xa8, 0x13, 0xaf, 0x5f, 0x75, 0x82, 0x29, 0x08, | |||
0xa3, 0x20, 0xf1, 0xf3, 0xb8, 0x59, 0xc8, 0xd4, | |||
0xd7, 0x55, 0xdd, 0xcc, 0xf3, 0xc1, 0x16, 0x26, | |||
0xc8, 0x6d, 0x44, 0x82, 0xbc, 0x98, 0x5e, 0xbc, | |||
0x2c, 0x48, 0x0a, 0xb8, 0xaa, 0x43, 0x4d, 0xc2, | |||
0x45, 0x27, 0x86, 0x30, 0x88, 0x04, 0x58, 0x1b, | |||
0x98, 0x9e, 0x71, 0xb0, 0x95, 0xa6, 0xf7, 0xbc, | |||
0x14, 0x3a, 0xbf, 0x98, 0x6e, 0xb9, 0xdf, 0x7e, | |||
0x9c, 0xc9, 0xe4, 0x7f, 0x65, 0x25, 0x2a, 0xe7, | |||
0x85, 0x9b, 0x81, 0xca, 0xd2, 0x38, 0xc8, 0x45, | |||
0x17, 0x3c, 0x6f, 0x73, 0x03, 0x30, 0x7c, 0xa4, | |||
0xdd, 0x2d, 0x1a, 0x22, 0x9f, 0x2e, 0x83, 0x64, | |||
0x06, 0x7e, 0xf8, 0x64, 0x25, 0x2b, 0xb4, 0x60, | |||
0x4b, 0x09, 0x6a, 0x8b, 0x6f, 0x54, 0x42, 0xda, | |||
0x16, 0x9b, 0x9d, 0x44, 0xd1, 0x45, 0x9d, 0x7b, | |||
0x92, 0xd9, 0x2a, 0x03, 0xfe, 0xa1, 0x4d, 0xba, | |||
0x13, 0xa2, 0x74, 0x79, 0x22, 0xf9, 0x60, 0x5c, | |||
0x94, 0x59, 0x55, 0x11, 0x8c, 0x7f, 0x7b, 0x83, | |||
0x09, 0xe8, 0xe0, 0x10, 0x48, 0x3b, 0xbc, 0x9b, | |||
0xfa, 0x14, 0xb0, 0x94, 0x21, 0xf6, 0xe2, 0xdb, | |||
0x29, 0xd9, 0x51, 0xaa, 0x47, 0x72, 0x00, 0x23, | |||
0x7c, 0xe4, 0x8e, 0xf4, 0x4b, 0x02, 0x03, 0x35, | |||
0x26, 0x6c, 0x06, 0x76, 0x0b, 0x5c, 0x5f, 0xe0, | |||
0x2b, 0x31, 0xe1, 0x02, 0xe3, 0x4b, 0x86, 0x91, | |||
0xbf, 0x23, 0x5d, 0xa8, 0x70, 0xef, 0x5a, 0x57, | |||
0xe8, 0xdf, 0xb3, 0x85, 0x0d, 0x4b, 0xf3, 0xe0, | |||
0xc2, 0xf0, 0x28, 0xd1, 0x7e, 0x0e, 0xeb, 0xe1, | |||
0xb5, 0x13, 0xaf, 0xb4, 0x38, 0x7f, 0x86, 0xd1, | |||
0x57, 0xd3, 0x1e, 0x28, 0xd7, 0xdb, 0x14, 0x03, | |||
0x03, 0x00, 0x01, 0x01, 0x16, 0x03, 0x03, 0x00, | |||
0x24, 0x21, 0xaa, 0xfc, 0x8a, 0x39, 0xb3, 0xcf, | |||
0x73, 0x83, 0x8d, 0x9c, 0x8e, 0x1f, 0xac, 0x97, | |||
0x21, 0x42, 0xee, 0x25, 0x68, 0xd0, 0x15, 0x43, | |||
0xf6, 0x4c, 0x98, 0xf6, 0xf6, 0x96, 0x11, 0x36, | |||
0xae, 0xe2, 0xb3, 0x30, 0x94, | |||
}, | |||
{ | |||
0x16, 0x03, 0x03, 0x04, 0x61, 0x04, 0x00, 0x04, | |||
0x5d, 0x00, 0x00, 0x00, 0x00, 0x04, 0x57, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, | |||
0xea, 0x8b, 0xc5, 0xef, 0xba, 0x79, 0x9b, 0xa7, | |||
0x04, 0x72, 0x9c, 0xeb, 0x1a, 0xd7, 0x8a, 0x56, | |||
0xba, 0xbc, 0x1a, 0xab, 0xf8, 0xf4, 0x4f, 0x75, | |||
0x0a, 0x4e, 0x98, 0xa0, 0x06, 0x00, 0x67, 0x07, | |||
0x9e, 0x21, 0x9f, 0x9d, 0xe6, 0x51, 0xcb, 0xec, | |||
0x96, 0x31, 0xde, 0x1d, 0x46, 0x60, 0x4a, 0xbd, | |||
0xd8, 0x7a, 0x23, 0xa9, 0x3e, 0x59, 0x22, 0xf7, | |||
0xfd, 0x8a, 0x14, 0xa4, 0x09, 0xc2, 0x07, 0x10, | |||
0x80, 0x13, 0xee, 0xee, 0x70, 0x96, 0xdb, 0x22, | |||
0x8b, 0xbf, 0xac, 0x69, 0x7d, 0x7f, 0x39, 0x9c, | |||
0xe8, 0x3c, 0xaa, 0x21, 0x83, 0x2f, 0x74, 0x51, | |||
0xf8, 0xf4, 0x3a, 0x3e, 0xce, 0x89, 0xf3, 0x8f, | |||
0xdb, 0x7d, 0xb5, 0xd8, 0xdf, 0x3e, 0x51, 0x66, | |||
0x77, 0x27, 0xfc, 0xd1, 0x21, 0x11, 0x93, 0xc0, | |||
0xf3, 0x7c, 0x0d, 0xa6, 0xd2, 0x96, 0xfc, 0x7a, | |||
0x29, 0xe9, 0x07, 0xff, 0xa3, 0xf9, 0x85, 0x6c, | |||
0x00, 0x2b, 0x22, 0x32, 0x22, 0x76, 0x9f, 0xaf, | |||
0xc9, 0x3d, 0x6a, 0x93, 0x23, 0x27, 0xdd, 0x66, | |||
0x41, 0xed, 0xbc, 0x5f, 0x58, 0x33, 0xcc, 0x4c, | |||
0x3f, 0x3f, 0xad, 0x89, 0xa1, 0x71, 0x07, 0xfe, | |||
0xe3, 0xaf, 0x35, 0xc4, 0xb7, 0xae, 0xca, 0x06, | |||
0x88, 0xc2, 0x85, 0x96, 0xc4, 0x59, 0xd7, 0x23, | |||
0x5f, 0xcf, 0xcb, 0x61, 0x24, 0x04, 0x72, 0x60, | |||
0xbd, 0xfa, 0xd7, 0x07, 0x38, 0x5e, 0xbc, 0x7d, | |||
0x45, 0x20, 0x58, 0x2c, 0x8c, 0x19, 0xc4, 0x5a, | |||
0xd6, 0xd3, 0xf8, 0xd3, 0x7f, 0xee, 0x84, 0xb2, | |||
0x3f, 0x4d, 0x96, 0x96, 0xc7, 0xb6, 0x57, 0x68, | |||
0xe4, 0x90, 0x4e, 0xc6, 0x52, 0x4b, 0x39, 0x54, | |||
0x32, 0x78, 0x59, 0x8e, 0x65, 0xb3, 0xb4, 0x29, | |||
0xdf, 0x09, 0x4f, 0x92, 0x35, 0x3d, 0xa1, 0x97, | |||
0x0e, 0xb9, 0x3c, 0x6d, 0xd0, 0xf5, 0x6e, 0xb7, | |||
0xd5, 0xde, 0xa0, 0x2e, 0xd8, 0xaf, 0x0c, 0x4b, | |||
0xb0, 0x16, 0x50, 0xf1, 0xa8, 0xee, 0x16, 0x53, | |||
0x0c, 0x15, 0x27, 0x83, 0x65, 0xe1, 0x37, 0x74, | |||
0x75, 0xd0, 0xaf, 0x9e, 0xaa, 0xb4, 0x0c, 0x1b, | |||
0xb2, 0x75, 0x0d, 0xda, 0xc1, 0xaa, 0xbd, 0xba, | |||
0x5d, 0x71, 0xf1, 0x12, 0xa8, 0xa4, 0xb2, 0x37, | |||
0xe3, 0xf9, 0xb8, 0x4e, 0x34, 0x46, 0x16, 0x66, | |||
0xf7, 0x4e, 0xaa, 0xf0, 0x0f, 0x29, 0x0e, 0x79, | |||
0x93, 0x7b, 0xf4, 0x1f, 0xc7, 0x8f, 0x9a, 0x35, | |||
0xe0, 0x7d, 0xa4, 0xa4, 0x1e, 0xa3, 0xc9, 0xac, | |||
0x61, 0x3e, 0x7a, 0x5e, 0x46, 0x20, 0x61, 0xbc, | |||
0x93, 0x38, 0xaf, 0x60, 0x55, 0xc7, 0x11, 0xc1, | |||
0xc0, 0x9f, 0x84, 0x52, 0xa0, 0x25, 0x3c, 0xef, | |||
0xe4, 0x91, 0x04, 0xa1, 0x67, 0x5d, 0x8b, 0xf9, | |||
0xb4, 0x85, 0xb1, 0x90, 0xa0, 0xfa, 0xd5, 0xfc, | |||
0xb7, 0x28, 0x58, 0x16, 0x36, 0xe9, 0x7f, 0x46, | |||
0x8a, 0x2b, 0xd3, 0x8a, 0x42, 0x00, 0x54, 0xdf, | |||
0x8b, 0x5c, 0x31, 0x65, 0xde, 0xf6, 0x80, 0xbd, | |||
0x5e, 0x52, 0x67, 0xc4, 0x67, 0x11, 0x91, 0x9b, | |||
0x04, 0x4e, 0x9e, 0xdc, 0xe4, 0x00, 0xa3, 0x24, | |||
0x71, 0x3d, 0xe4, 0x05, 0x32, 0x96, 0xed, 0x9a, | |||
0x07, 0xd7, 0x41, 0x10, 0x6f, 0xee, 0x43, 0xc1, | |||
0xea, 0xdb, 0x5c, 0x51, 0x3c, 0x31, 0x48, 0xd5, | |||
0xdb, 0x1e, 0x3d, 0x09, 0x23, 0x89, 0x2f, 0x32, | |||
0x26, 0xfe, 0x88, 0x1b, 0x83, 0xf2, 0xba, 0x53, | |||
0x41, 0x9a, 0x74, 0xfc, 0x97, 0xd3, 0x0d, 0x16, | |||
0xb6, 0x8d, 0x55, 0x81, 0x74, 0xa4, 0xa9, 0xd6, | |||
0x27, 0x6b, 0xf7, 0x0c, 0x32, 0x99, 0x1a, 0xcf, | |||
0x00, 0x4b, 0xd4, 0xde, 0x0c, 0x6d, 0x52, 0xbc, | |||
0x4e, 0xac, 0xa9, 0x28, 0x9b, 0x4e, 0x55, 0x47, | |||
0xe3, 0x4b, 0x1a, 0xa0, 0xc0, 0x8d, 0xa9, 0xf6, | |||
0xcf, 0xcd, 0x0d, 0x44, 0x4c, 0x71, 0x32, 0xf5, | |||
0xb2, 0x0c, 0x5a, 0xc8, 0xfa, 0xa8, 0xcf, 0x35, | |||
0x68, 0xd8, 0x55, 0xa2, 0xb2, 0x65, 0xe5, 0x55, | |||
0x28, 0x2e, 0xc3, 0x69, 0xf8, 0x75, 0x8d, 0x6d, | |||
0x5f, 0xfb, 0x44, 0xb1, 0xf0, 0x86, 0xe5, 0xde, | |||
0x0f, 0xe7, 0x51, 0x96, 0x7f, 0x00, 0xa2, 0x1e, | |||
0xe2, 0x4b, 0x86, 0xe7, 0x4c, 0xdc, 0x95, 0x53, | |||
0xc5, 0xaa, 0x5a, 0x05, 0x5c, 0xa0, 0xde, 0xa8, | |||
0xc5, 0x6a, 0xb2, 0x09, 0xd4, 0xa0, 0xed, 0xe1, | |||
0x85, 0xb9, 0xa3, 0xde, 0x2b, 0x4d, 0xf9, 0x4a, | |||
0x72, 0x50, 0x26, 0xae, 0xf9, 0xc7, 0x78, 0x63, | |||
0x20, 0xa2, 0xc4, 0x88, 0xbe, 0xc6, 0x29, 0x4b, | |||
0xfc, 0x9c, 0x3d, 0x38, 0x6b, 0x60, 0x76, 0xe9, | |||
0xf7, 0xaa, 0x28, 0xc4, 0xe1, 0xfc, 0xfe, 0x3a, | |||
0xc3, 0x90, 0xb2, 0x2c, 0x7b, 0x10, 0xce, 0xe3, | |||
0xe9, 0x81, 0x87, 0x93, 0x26, 0x2f, 0x97, 0x30, | |||
0x4b, 0xf7, 0x10, 0x8e, 0x36, 0xf7, 0x00, 0x3e, | |||
0xf8, 0xd4, 0x56, 0xa7, 0x37, 0x07, 0x25, 0x19, | |||
0x03, 0x38, 0x0b, 0xdd, 0xec, 0x1a, 0x4f, 0xab, | |||
0x43, 0xd2, 0x34, 0x65, 0xba, 0x9f, 0x39, 0xfc, | |||
0x95, 0x1a, 0xf4, 0xa4, 0xc2, 0x32, 0x19, 0x23, | |||
0x04, 0xdb, 0x11, 0x11, 0xbe, 0xd1, 0xf0, 0x81, | |||
0x22, 0xd5, 0xd5, 0x32, 0x44, 0xe6, 0x02, 0xb5, | |||
0x34, 0x66, 0x37, 0x48, 0x51, 0xd7, 0x62, 0xb4, | |||
0xf7, 0x03, 0x38, 0x29, 0x79, 0x8d, 0x88, 0xa1, | |||
0x5c, 0xb0, 0xec, 0xf0, 0xc0, 0xd9, 0x81, 0xf4, | |||
0x15, 0xe0, 0x0b, 0x79, 0x87, 0xd8, 0x3e, 0x0f, | |||
0xc9, 0x64, 0x1a, 0x36, 0x81, 0xee, 0x44, 0xd6, | |||
0xea, 0xe3, 0x3f, 0x63, 0x43, 0xac, 0x0a, 0x40, | |||
0xe0, 0x35, 0xb3, 0x5e, 0x34, 0xc3, 0x1b, 0xd7, | |||
0x92, 0x8b, 0x6d, 0xf3, 0xae, 0x32, 0xaa, 0x05, | |||
0xca, 0x56, 0xb8, 0xb8, 0xed, 0xb3, 0xbd, 0x8a, | |||
0xdb, 0x31, 0x99, 0x92, 0x21, 0xe4, 0xe0, 0x23, | |||
0x78, 0xa6, 0x09, 0xb0, 0xbc, 0xb1, 0xdc, 0xdd, | |||
0x62, 0x2f, 0xcb, 0x22, 0x19, 0xf7, 0xe3, 0xc7, | |||
0x5d, 0x62, 0x4a, 0xb9, 0x52, 0x33, 0xf7, 0x15, | |||
0xb9, 0x99, 0x3f, 0xf8, 0xa1, 0x12, 0xac, 0x93, | |||
0x01, 0x4b, 0x1f, 0x2d, 0x59, 0x02, 0xe3, 0x94, | |||
0x1a, 0x98, 0x28, 0xb1, 0xfe, 0x79, 0xf5, 0xca, | |||
0x8c, 0xfb, 0x89, 0x6b, 0xe3, 0x4d, 0xf7, 0x42, | |||
0x4a, 0xfe, 0x00, 0x0b, 0xbc, 0x20, 0xef, 0x37, | |||
0x6a, 0xc6, 0xda, 0x80, 0x0e, 0x57, 0x00, 0xf4, | |||
0x95, 0x0c, 0x68, 0x47, 0x5f, 0xbc, 0x24, 0xe9, | |||
0x4b, 0xa2, 0x34, 0xb9, 0xc0, 0x0f, 0xe7, 0xaf, | |||
0xe4, 0x89, 0xee, 0x68, 0x5e, 0xd7, 0x4e, 0x3b, | |||
0x1e, 0x5b, 0x68, 0x38, 0x40, 0x49, 0x73, 0xec, | |||
0xf8, 0x38, 0xa6, 0x5a, 0x6a, 0xf7, 0x87, 0xe1, | |||
0xb6, 0xf6, 0xb7, 0x16, 0x2e, 0xa2, 0xe9, 0x14, | |||
0x2b, 0x22, 0x89, 0x26, 0xc7, 0xac, 0xa4, 0xc5, | |||
0xec, 0xfd, 0x72, 0xe8, 0x8c, 0x92, 0xdf, 0x14, | |||
0x90, 0xcb, 0xbc, 0xfd, 0x90, 0x2a, 0x6c, 0xc5, | |||
0x54, 0xad, 0x0c, 0x40, 0x81, 0x64, 0x8e, 0xe8, | |||
0xda, 0x07, 0x6e, 0xc2, 0xbb, 0x19, 0x97, 0x0b, | |||
0x23, 0x96, 0xe9, 0x17, 0x15, 0x76, 0x09, 0xf3, | |||
0xd3, 0x8b, 0xda, 0x8f, 0x3b, 0x6b, 0x08, 0x1d, | |||
0x7d, 0x55, 0x0d, 0x5e, 0x14, 0x6e, 0xda, 0x72, | |||
0x8f, 0xd3, 0x22, 0xeb, 0xb7, 0x4b, 0x8f, 0xed, | |||
0xe9, 0x20, 0x77, 0xc1, 0x7e, 0x2f, 0x89, 0xfd, | |||
0xa3, 0xf6, 0x25, 0x68, 0xc1, 0x1f, 0x44, 0xea, | |||
0x17, 0x6c, 0x51, 0xcd, 0x00, 0xc5, 0x91, 0xd6, | |||
0x46, 0x90, 0x8f, 0x88, 0x8c, 0x2e, 0xde, 0xd5, | |||
0x7d, 0x34, 0x9c, 0x16, 0x15, 0xa0, 0x58, 0x7d, | |||
0xe5, 0xab, 0xe6, 0xdc, 0x5f, 0xaa, 0x73, 0x34, | |||
0xa9, 0x69, 0xe7, 0x07, 0x11, 0x10, 0xa7, 0x58, | |||
0x63, 0xad, 0x5c, 0x89, 0x36, 0x9f, 0x1e, 0x35, | |||
0x34, 0x79, 0xbc, 0x79, 0x31, 0xcd, 0x2e, 0x06, | |||
0x97, 0x4c, 0x39, 0xfb, 0xba, 0xfa, 0x17, 0x77, | |||
0x3f, 0x6c, 0xd3, 0x0b, 0x23, 0x37, 0x08, 0xa4, | |||
0x5d, 0x3c, 0x04, 0xc1, 0x2a, 0xc2, 0x93, 0x2b, | |||
0xc0, 0xec, 0x7d, 0x61, 0x1f, 0xa2, 0x54, 0x92, | |||
0xda, 0x86, 0x34, 0x01, 0x40, 0x48, 0x7f, 0xaf, | |||
0x88, 0xfd, 0x3a, 0x05, 0x98, 0xd0, 0xb7, 0x81, | |||
0x4d, 0x60, 0x76, 0x8b, 0x39, 0x6e, 0x33, 0x97, | |||
0x99, 0xfa, 0x93, 0x0f, 0x7b, 0xb3, 0xaf, 0x95, | |||
0xb9, 0xdb, 0xa1, 0xcc, 0x8b, 0x32, 0x14, 0x03, | |||
0x03, 0x00, 0x01, 0x01, 0x16, 0x03, 0x03, 0x00, | |||
0x24, 0x53, 0x06, 0xc3, 0x99, 0xce, 0x22, 0x41, | |||
0x0e, 0x81, 0x2d, 0x6b, 0x35, 0xae, 0xd5, 0x7d, | |||
0x7e, 0x6b, 0xb4, 0xe9, 0xe9, 0x06, 0xbc, 0x5b, | |||
0x3b, 0xf2, 0x77, 0x2e, 0x0c, 0x2b, 0xba, 0x96, | |||
0x93, 0xb7, 0x2e, 0x1d, 0x49, 0x17, 0x03, 0x03, | |||
0x00, 0x21, 0x41, 0xb5, 0x78, 0xc2, 0xcb, 0x4e, | |||
0x52, 0x72, 0x2b, 0xdf, 0x9b, 0xc6, 0x75, 0x24, | |||
0xe1, 0x58, 0xb8, 0xe1, 0x78, 0x39, 0xa0, 0xe4, | |||
0x74, 0x00, 0xee, 0x6b, 0xb5, 0xbe, 0xe7, 0x48, | |||
0xbe, 0x61, 0x69, 0x15, 0x03, 0x03, 0x00, 0x16, | |||
0xcc, 0xf1, 0x43, 0x54, 0x49, 0xd3, 0x17, 0xd1, | |||
0x7a, 0xc0, 0x40, 0x05, 0xd0, 0x9e, 0x22, 0xbd, | |||
0x5b, 0x5c, 0xd9, 0x7f, 0xce, 0x34, | |||
}, | |||
} | |||
// cert.pem and key.pem were generated with generate_cert.go | |||
// Thus, they have no ExtKeyUsage fields and trigger an error | |||
// when verification is turned on. | |||
@@ -10,6 +10,7 @@ import ( | |||
"crypto/md5" | |||
"crypto/rsa" | |||
"crypto/sha1" | |||
"crypto/sha256" | |||
"crypto/x509" | |||
"errors" | |||
"io" | |||
@@ -84,7 +85,7 @@ func (ka rsaKeyAgreement) generateClientKeyExchange(config *Config, clientHello | |||
// md5SHA1Hash implements TLS 1.0's hybrid hash function which consists of the | |||
// concatenation of an MD5 and SHA1 hash. | |||
func md5SHA1Hash(slices ...[]byte) []byte { | |||
func md5SHA1Hash(slices [][]byte) []byte { | |||
md5sha1 := make([]byte, md5.Size+sha1.Size) | |||
hmd5 := md5.New() | |||
for _, slice := range slices { | |||
@@ -100,10 +101,29 @@ func md5SHA1Hash(slices ...[]byte) []byte { | |||
return md5sha1 | |||
} | |||
// sha256Hash implements TLS 1.2's hash function. | |||
func sha256Hash(slices [][]byte) []byte { | |||
h := sha256.New() | |||
for _, slice := range slices { | |||
h.Write(slice) | |||
} | |||
return h.Sum(nil) | |||
} | |||
// hashForServerKeyExchange hashes the given slices and returns their digest | |||
// and the identifier of the hash function used. | |||
func hashForServerKeyExchange(version uint16, slices ...[]byte) ([]byte, crypto.Hash) { | |||
if version >= VersionTLS12 { | |||
return sha256Hash(slices), crypto.SHA256 | |||
} | |||
return md5SHA1Hash(slices), crypto.MD5SHA1 | |||
} | |||
// ecdheRSAKeyAgreement implements a TLS key agreement where the server | |||
// generates a ephemeral EC public/private key pair and signs it. The | |||
// pre-master secret is then calculated using ECDH. | |||
type ecdheRSAKeyAgreement struct { | |||
version uint16 | |||
privateKey []byte | |||
curve elliptic.Curve | |||
x, y *big.Int | |||
@@ -150,16 +170,25 @@ Curve: | |||
serverECDHParams[3] = byte(len(ecdhePublic)) | |||
copy(serverECDHParams[4:], ecdhePublic) | |||
md5sha1 := md5SHA1Hash(clientHello.random, hello.random, serverECDHParams) | |||
sig, err := rsa.SignPKCS1v15(config.rand(), cert.PrivateKey.(*rsa.PrivateKey), crypto.MD5SHA1, md5sha1) | |||
digest, hashFunc := hashForServerKeyExchange(ka.version, clientHello.random, hello.random, serverECDHParams) | |||
sig, err := rsa.SignPKCS1v15(config.rand(), cert.PrivateKey.(*rsa.PrivateKey), hashFunc, digest) | |||
if err != nil { | |||
return nil, errors.New("failed to sign ECDHE parameters: " + err.Error()) | |||
} | |||
skx := new(serverKeyExchangeMsg) | |||
skx.key = make([]byte, len(serverECDHParams)+2+len(sig)) | |||
sigAndHashLen := 0 | |||
if ka.version >= VersionTLS12 { | |||
sigAndHashLen = 2 | |||
} | |||
skx.key = make([]byte, len(serverECDHParams)+sigAndHashLen+2+len(sig)) | |||
copy(skx.key, serverECDHParams) | |||
k := skx.key[len(serverECDHParams):] | |||
if ka.version >= VersionTLS12 { | |||
k[0] = hashSHA256 | |||
k[1] = signatureRSA | |||
k = k[2:] | |||
} | |||
k[0] = byte(len(sig) >> 8) | |||
k[1] = byte(len(sig)) | |||
copy(k[2:], sig) | |||
@@ -219,14 +248,21 @@ func (ka *ecdheRSAKeyAgreement) processServerKeyExchange(config *Config, clientH | |||
if len(sig) < 2 { | |||
return errServerKeyExchange | |||
} | |||
if ka.version >= VersionTLS12 { | |||
// ignore SignatureAndHashAlgorithm | |||
sig = sig[2:] | |||
if len(sig) < 2 { | |||
return errServerKeyExchange | |||
} | |||
} | |||
sigLen := int(sig[0])<<8 | int(sig[1]) | |||
if sigLen+2 != len(sig) { | |||
return errServerKeyExchange | |||
} | |||
sig = sig[2:] | |||
md5sha1 := md5SHA1Hash(clientHello.random, serverHello.random, serverECDHParams) | |||
return rsa.VerifyPKCS1v15(cert.PublicKey.(*rsa.PublicKey), crypto.MD5SHA1, md5sha1, sig) | |||
digest, hashFunc := hashForServerKeyExchange(ka.version, clientHello.random, serverHello.random, serverECDHParams) | |||
return rsa.VerifyPKCS1v15(cert.PublicKey.(*rsa.PublicKey), hashFunc, digest, sig) | |||
} | |||
func (ka *ecdheRSAKeyAgreement) generateClientKeyExchange(config *Config, clientHello *clientHelloMsg, cert *x509.Certificate) ([]byte, *clientKeyExchangeMsg, error) { | |||
@@ -5,9 +5,11 @@ | |||
package tls | |||
import ( | |||
"crypto" | |||
"crypto/hmac" | |||
"crypto/md5" | |||
"crypto/sha1" | |||
"crypto/sha256" | |||
"hash" | |||
) | |||
@@ -43,8 +45,8 @@ func pHash(result, secret, seed []byte, hash func() hash.Hash) { | |||
} | |||
} | |||
// pRF10 implements the TLS 1.0 pseudo-random function, as defined in RFC 2246, section 5. | |||
func pRF10(result, secret, label, seed []byte) { | |||
// prf10 implements the TLS 1.0 pseudo-random function, as defined in RFC 2246, section 5. | |||
func prf10(result, secret, label, seed []byte) { | |||
hashSHA1 := sha1.New | |||
hashMD5 := md5.New | |||
@@ -62,9 +64,18 @@ func pRF10(result, secret, label, seed []byte) { | |||
} | |||
} | |||
// pRF30 implements the SSL 3.0 pseudo-random function, as defined in | |||
// prf12 implements the TLS 1.2 pseudo-random function, as defined in RFC 5246, section 5. | |||
func prf12(result, secret, label, seed []byte) { | |||
labelAndSeed := make([]byte, len(label)+len(seed)) | |||
copy(labelAndSeed, label) | |||
copy(labelAndSeed[len(label):], seed) | |||
pHash(result, secret, labelAndSeed, sha256.New) | |||
} | |||
// prf30 implements the SSL 3.0 pseudo-random function, as defined in | |||
// www.mozilla.org/projects/security/pki/nss/ssl/draft302.txt section 6. | |||
func pRF30(result, secret, label, seed []byte) { | |||
func prf30(result, secret, label, seed []byte) { | |||
hashSHA1 := sha1.New() | |||
hashMD5 := md5.New() | |||
@@ -106,19 +117,27 @@ var keyExpansionLabel = []byte("key expansion") | |||
var clientFinishedLabel = []byte("client finished") | |||
var serverFinishedLabel = []byte("server finished") | |||
func prfForVersion(version uint16) func(result, secret, label, seed []byte) { | |||
switch version { | |||
case VersionSSL30: | |||
return prf30 | |||
case VersionTLS10, VersionTLS11: | |||
return prf10 | |||
case VersionTLS12: | |||
return prf12 | |||
default: | |||
panic("unknown version") | |||
} | |||
} | |||
// masterFromPreMasterSecret generates the master secret from the pre-master | |||
// secret. See http://tools.ietf.org/html/rfc5246#section-8.1 | |||
func masterFromPreMasterSecret(version uint16, preMasterSecret, clientRandom, serverRandom []byte) []byte { | |||
prf := pRF10 | |||
if version == VersionSSL30 { | |||
prf = pRF30 | |||
} | |||
var seed [tlsRandomLength * 2]byte | |||
copy(seed[0:len(clientRandom)], clientRandom) | |||
copy(seed[len(clientRandom):], serverRandom) | |||
masterSecret := make([]byte, masterSecretLength) | |||
prf(masterSecret, preMasterSecret, masterSecretLabel, seed[0:]) | |||
prfForVersion(version)(masterSecret, preMasterSecret, masterSecretLabel, seed[0:]) | |||
return masterSecret | |||
} | |||
@@ -126,18 +145,13 @@ func masterFromPreMasterSecret(version uint16, preMasterSecret, clientRandom, se | |||
// secret, given the lengths of the MAC key, cipher key and IV, as defined in | |||
// RFC 2246, section 6.3. | |||
func keysFromMasterSecret(version uint16, masterSecret, clientRandom, serverRandom []byte, macLen, keyLen, ivLen int) (clientMAC, serverMAC, clientKey, serverKey, clientIV, serverIV []byte) { | |||
prf := pRF10 | |||
if version == VersionSSL30 { | |||
prf = pRF30 | |||
} | |||
var seed [tlsRandomLength * 2]byte | |||
copy(seed[0:len(clientRandom)], serverRandom) | |||
copy(seed[len(serverRandom):], clientRandom) | |||
n := 2*macLen + 2*keyLen + 2*ivLen | |||
keyMaterial := make([]byte, n) | |||
prf(keyMaterial, masterSecret, keyExpansionLabel, seed[0:]) | |||
prfForVersion(version)(keyMaterial, masterSecret, keyExpansionLabel, seed[0:]) | |||
clientMAC = keyMaterial[:macLen] | |||
keyMaterial = keyMaterial[macLen:] | |||
serverMAC = keyMaterial[:macLen] | |||
@@ -153,37 +167,34 @@ func keysFromMasterSecret(version uint16, masterSecret, clientRandom, serverRand | |||
} | |||
func newFinishedHash(version uint16) finishedHash { | |||
return finishedHash{md5.New(), sha1.New(), md5.New(), sha1.New(), version} | |||
if version >= VersionTLS12 { | |||
return finishedHash{sha256.New(), sha256.New(), nil, nil, version} | |||
} | |||
return finishedHash{sha1.New(), sha1.New(), md5.New(), md5.New(), version} | |||
} | |||
// A finishedHash calculates the hash of a set of handshake messages suitable | |||
// for including in a Finished message. | |||
type finishedHash struct { | |||
clientMD5 hash.Hash | |||
clientSHA1 hash.Hash | |||
serverMD5 hash.Hash | |||
serverSHA1 hash.Hash | |||
version uint16 | |||
client hash.Hash | |||
server hash.Hash | |||
// Prior to TLS 1.2, an additional MD5 hash is required. | |||
clientMD5 hash.Hash | |||
serverMD5 hash.Hash | |||
version uint16 | |||
} | |||
func (h finishedHash) Write(msg []byte) (n int, err error) { | |||
h.clientMD5.Write(msg) | |||
h.clientSHA1.Write(msg) | |||
h.serverMD5.Write(msg) | |||
h.serverSHA1.Write(msg) | |||
return len(msg), nil | |||
} | |||
h.client.Write(msg) | |||
h.server.Write(msg) | |||
// finishedSum10 calculates the contents of the verify_data member of a TLSv1 | |||
// Finished message given the MD5 and SHA1 hashes of a set of handshake | |||
// messages. | |||
func finishedSum10(md5, sha1, label, masterSecret []byte) []byte { | |||
seed := make([]byte, len(md5)+len(sha1)) | |||
copy(seed, md5) | |||
copy(seed[len(md5):], sha1) | |||
out := make([]byte, finishedVerifyLength) | |||
pRF10(out, masterSecret, label, seed) | |||
return out | |||
if h.version < VersionTLS12 { | |||
h.clientMD5.Write(msg) | |||
h.serverMD5.Write(msg) | |||
} | |||
return len(msg), nil | |||
} | |||
// finishedSum30 calculates the contents of the verify_data member of a SSLv3 | |||
@@ -225,22 +236,52 @@ var ssl3ServerFinishedMagic = [4]byte{0x53, 0x52, 0x56, 0x52} | |||
// Finished message. | |||
func (h finishedHash) clientSum(masterSecret []byte) []byte { | |||
if h.version == VersionSSL30 { | |||
return finishedSum30(h.clientMD5, h.clientSHA1, masterSecret, ssl3ClientFinishedMagic) | |||
return finishedSum30(h.clientMD5, h.client, masterSecret, ssl3ClientFinishedMagic) | |||
} | |||
md5 := h.clientMD5.Sum(nil) | |||
sha1 := h.clientSHA1.Sum(nil) | |||
return finishedSum10(md5, sha1, clientFinishedLabel, masterSecret) | |||
out := make([]byte, finishedVerifyLength) | |||
if h.version >= VersionTLS12 { | |||
seed := h.client.Sum(nil) | |||
prf12(out, masterSecret, clientFinishedLabel, seed) | |||
} else { | |||
seed := make([]byte, 0, md5.Size+sha1.Size) | |||
seed = h.clientMD5.Sum(seed) | |||
seed = h.client.Sum(seed) | |||
prf10(out, masterSecret, clientFinishedLabel, seed) | |||
} | |||
return out | |||
} | |||
// serverSum returns the contents of the verify_data member of a server's | |||
// Finished message. | |||
func (h finishedHash) serverSum(masterSecret []byte) []byte { | |||
if h.version == VersionSSL30 { | |||
return finishedSum30(h.serverMD5, h.serverSHA1, masterSecret, ssl3ServerFinishedMagic) | |||
return finishedSum30(h.serverMD5, h.server, masterSecret, ssl3ServerFinishedMagic) | |||
} | |||
out := make([]byte, finishedVerifyLength) | |||
if h.version >= VersionTLS12 { | |||
seed := h.server.Sum(nil) | |||
prf12(out, masterSecret, serverFinishedLabel, seed) | |||
} else { | |||
seed := make([]byte, 0, md5.Size+sha1.Size) | |||
seed = h.serverMD5.Sum(seed) | |||
seed = h.server.Sum(seed) | |||
prf10(out, masterSecret, serverFinishedLabel, seed) | |||
} | |||
return out | |||
} | |||
// hashForClientCertificate returns a digest and hash function identifier | |||
// suitable for signing by a TLS client certificate. | |||
func (h finishedHash) hashForClientCertificate() ([]byte, crypto.Hash) { | |||
if h.version >= VersionTLS12 { | |||
digest := h.server.Sum(nil) | |||
return digest, crypto.SHA256 | |||
} | |||
md5 := h.serverMD5.Sum(nil) | |||
sha1 := h.serverSHA1.Sum(nil) | |||
return finishedSum10(md5, sha1, serverFinishedLabel, masterSecret) | |||
digest := make([]byte, 0, 36) | |||
digest = h.serverMD5.Sum(digest) | |||
digest = h.server.Sum(digest) | |||
return digest, crypto.MD5SHA1 | |||
} |