1 Only in chromium: patches
2 diff -aur tlslite-0.3.8/tlslite/TLSConnection.py chromium/tlslite/TLSConnection.py
3 --- tlslite-0.3.8/tlslite/TLSConnection.py 2004-10-06 01:55:37.000000000 -0400
4 +++ chromium/tlslite/TLSConnection.py 2010-08-18 22:17:30.962786700 -0400
7 def handshakeServer(self, sharedKeyDB=None, verifierDB=None,
8 certChain=None, privateKey=None, reqCert=False,
9 - sessionCache=None, settings=None, checker=None):
10 + sessionCache=None, settings=None, checker=None,
12 """Perform a handshake in the role of server.
14 This function performs an SSL or TLS handshake. Depending on
16 invoked to examine the other party's authentication
17 credentials, if the handshake completes succesfully.
19 + @type reqCAs: list of L{array.array} of unsigned bytes
20 + @param reqCAs: A collection of DER-encoded DistinguishedNames that
21 + will be sent along with a certificate request. This does not affect
24 @raise socket.error: If a socket error occurs.
25 @raise tlslite.errors.TLSAbruptCloseError: If the socket is closed
26 without a preceding alert.
27 @@ -1006,13 +1012,14 @@
29 for result in self.handshakeServerAsync(sharedKeyDB, verifierDB,
30 certChain, privateKey, reqCert, sessionCache, settings,
36 def handshakeServerAsync(self, sharedKeyDB=None, verifierDB=None,
37 certChain=None, privateKey=None, reqCert=False,
38 - sessionCache=None, settings=None, checker=None):
39 + sessionCache=None, settings=None, checker=None,
41 """Start a server handshake operation on the TLS connection.
43 This function returns a generator which behaves similarly to
44 @@ -1028,14 +1035,15 @@
45 sharedKeyDB=sharedKeyDB,
46 verifierDB=verifierDB, certChain=certChain,
47 privateKey=privateKey, reqCert=reqCert,
48 - sessionCache=sessionCache, settings=settings)
49 + sessionCache=sessionCache, settings=settings,
51 for result in self._handshakeWrapperAsync(handshaker, checker):
55 def _handshakeServerAsyncHelper(self, sharedKeyDB, verifierDB,
56 certChain, privateKey, reqCert, sessionCache,
60 self._handshakeStart(client=False)
63 raise ValueError("Caller passed a certChain but no privateKey")
64 if privateKey and not certChain:
65 raise ValueError("Caller passed a privateKey but no certChain")
66 + if reqCAs and not reqCert:
67 + raise ValueError("Caller passed reqCAs but not reqCert")
70 settings = HandshakeSettings()
72 msgs.append(ServerHello().create(self.version, serverRandom,
73 sessionID, cipherSuite, certificateType))
74 msgs.append(Certificate(certificateType).create(serverCertChain))
76 + if reqCert and reqCAs:
77 + msgs.append(CertificateRequest().create([], reqCAs))
79 msgs.append(CertificateRequest())
80 msgs.append(ServerHelloDone())
81 for result in self._sendMsgs(msgs):
82 diff -aur tlslite-0.3.8/tlslite/X509.py chromium/tlslite/X509.py
83 --- tlslite-0.3.8/tlslite/X509.py 2004-03-19 21:43:19.000000000 -0400
84 +++ chromium/tlslite/X509.py 2010-08-18 22:17:30.967787000 -0400
87 @type publicKey: L{tlslite.utils.RSAKey.RSAKey}
88 @ivar publicKey: The subject public key from the certificate.
90 + @type subject: L{array.array} of unsigned bytes
91 + @ivar subject: The DER-encoded ASN.1 subject distinguished name.
95 self.bytes = createByteArraySequence([])
100 """Parse a PEM-encoded X.509 certificate.
103 subjectPublicKeyInfoIndex = 5
106 + self.subject = tbsCertificateP.getChildBytes(\
107 + subjectPublicKeyInfoIndex - 1)
109 #Get the subjectPublicKeyInfo
110 subjectPublicKeyInfoP = tbsCertificateP.getChild(\
111 subjectPublicKeyInfoIndex)
112 diff -aur tlslite-0.3.8/tlslite/messages.py chromium/tlslite/messages.py
113 --- tlslite-0.3.8/tlslite/messages.py 2004-10-06 01:01:24.000000000 -0400
114 +++ chromium/tlslite/messages.py 2010-08-18 22:17:30.976787500 -0400
117 self.contentType = ContentType.handshake
118 self.certificate_types = []
119 - #treat as opaque bytes for now
120 - self.certificate_authorities = createByteArraySequence([])
121 + self.certificate_authorities = []
123 def create(self, certificate_types, certificate_authorities):
124 self.certificate_types = certificate_types
127 p.startLengthCheck(3)
128 self.certificate_types = p.getVarList(1, 1)
129 - self.certificate_authorities = p.getVarBytes(2)
130 + ca_list_length = p.get(2)
132 + self.certificate_authorities = []
133 + while index != ca_list_length:
134 + ca_bytes = p.getVarBytes(2)
135 + self.certificate_authorities.append(ca_bytes)
136 + index += len(ca_bytes)+2
141 w = HandshakeMsg.preWrite(self, HandshakeType.certificate_request,
143 w.addVarSeq(self.certificate_types, 1, 1)
144 - w.addVarSeq(self.certificate_authorities, 1, 2)
147 + for ca_dn in self.certificate_authorities:
148 + caLength += len(ca_dn)+2
151 + for ca_dn in self.certificate_authorities:
152 + w.addVarSeq(ca_dn, 1, 2)
153 return HandshakeMsg.postWrite(self, w, trial)
155 class ServerKeyExchange(HandshakeMsg):
156 diff -aur tlslite-0.3.8/tlslite/utils/ASN1Parser.py chromium/tlslite/utils/ASN1Parser.py
157 --- tlslite-0.3.8/tlslite/utils/ASN1Parser.py 2004-10-06 01:02:40.000000000 -0400
158 +++ chromium/tlslite/utils/ASN1Parser.py 2010-08-18 22:17:30.979787700 -0400
161 #Assuming this is a sequence...
162 def getChild(self, which):
163 + return ASN1Parser(self.getChildBytes(which))
165 + def getChildBytes(self, which):
166 p = Parser(self.value)
167 for x in range(which+1):
170 length = self._getASN1Length(p)
171 p.getFixBytes(length)
172 - return ASN1Parser(p.bytes[markIndex : p.index])
173 + return p.bytes[markIndex : p.index]
175 #Decode the ASN.1 DER length field
176 def _getASN1Length(self, p):