OLD | NEW |
1 # Authors: | 1 # Authors: |
2 # Trevor Perrin | 2 # Trevor Perrin |
3 # Google - handling CertificateRequest.certificate_types | 3 # Google - handling CertificateRequest.certificate_types |
4 # Google (adapted by Sam Rushing and Marcelo Fernandez) - NPN support | 4 # Google (adapted by Sam Rushing and Marcelo Fernandez) - NPN support |
5 # Dimitris Moraitis - Anon ciphersuites | 5 # Dimitris Moraitis - Anon ciphersuites |
6 # Yngve Pettersen (ported by Paul Sokolovsky) - TLS 1.2 | 6 # Yngve Pettersen (ported by Paul Sokolovsky) - TLS 1.2 |
7 # | 7 # |
8 # See the LICENSE file for legal information regarding use of this file. | 8 # See the LICENSE file for legal information regarding use of this file. |
9 | 9 |
10 """Classes representing TLS messages.""" | 10 """Classes representing TLS messages.""" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 self.srp_username = None # a string | 133 self.srp_username = None # a string |
134 self.tack = False | 134 self.tack = False |
135 self.alpn_protos_advertised = None | 135 self.alpn_protos_advertised = None |
136 self.supports_npn = False | 136 self.supports_npn = False |
137 self.server_name = bytearray(0) | 137 self.server_name = bytearray(0) |
138 self.channel_id = False | 138 self.channel_id = False |
139 self.extended_master_secret = False | 139 self.extended_master_secret = False |
140 self.tb_client_params = [] | 140 self.tb_client_params = [] |
141 self.support_signed_cert_timestamps = False | 141 self.support_signed_cert_timestamps = False |
142 self.status_request = False | 142 self.status_request = False |
| 143 self.has_supported_versions = False |
143 self.ri = False | 144 self.ri = False |
144 | 145 |
145 def create(self, version, random, session_id, cipher_suites, | 146 def create(self, version, random, session_id, cipher_suites, |
146 certificate_types=None, srpUsername=None, | 147 certificate_types=None, srpUsername=None, |
147 tack=False, alpn_protos_advertised=None, | 148 tack=False, alpn_protos_advertised=None, |
148 supports_npn=False, serverName=None): | 149 supports_npn=False, serverName=None): |
149 self.client_version = version | 150 self.client_version = version |
150 self.random = random | 151 self.random = random |
151 self.session_id = session_id | 152 self.session_id = session_id |
152 self.cipher_suites = cipher_suites | 153 self.cipher_suites = cipher_suites |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 # when selecting an OCSP responder and SHOULD include | 245 # when selecting an OCSP responder and SHOULD include |
245 # request_extensions in the OCSP request. | 246 # request_extensions in the OCSP request. |
246 p.getFixBytes(extLength) | 247 p.getFixBytes(extLength) |
247 self.status_request = True | 248 self.status_request = True |
248 elif extType == ExtensionType.renegotiation_info: | 249 elif extType == ExtensionType.renegotiation_info: |
249 # We don't support renegotiation, so if we receive this | 250 # We don't support renegotiation, so if we receive this |
250 # extension, it should contain a single null byte. | 251 # extension, it should contain a single null byte. |
251 if extLength != 1 or p.getFixBytes(extLength)[0] != 0: | 252 if extLength != 1 or p.getFixBytes(extLength)[0] != 0: |
252 raise SyntaxError() | 253 raise SyntaxError() |
253 self.ri = True | 254 self.ri = True |
| 255 elif extType == ExtensionType.supported_versions: |
| 256 # Ignore the extension, but make a note of it for |
| 257 # intolerance simulation. |
| 258 self.has_supported_versions = True |
| 259 _ = p.getFixBytes(extLength) |
254 else: | 260 else: |
255 _ = p.getFixBytes(extLength) | 261 _ = p.getFixBytes(extLength) |
256 index2 = p.index | 262 index2 = p.index |
257 if index2 - index1 != extLength: | 263 if index2 - index1 != extLength: |
258 raise SyntaxError("Bad length for extension_data") | 264 raise SyntaxError("Bad length for extension_data") |
259 soFar += 4 + extLength | 265 soFar += 4 + extLength |
260 if CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV in self.cipher_suit
es: | 266 if CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV in self.cipher_suit
es: |
261 self.ri = True | 267 self.ri = True |
262 p.stopLengthCheck() | 268 p.stopLengthCheck() |
263 return self | 269 return self |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 newMsg = ApplicationData().create(self.bytes[:1]) | 884 newMsg = ApplicationData().create(self.bytes[:1]) |
879 self.bytes = self.bytes[1:] | 885 self.bytes = self.bytes[1:] |
880 return newMsg | 886 return newMsg |
881 | 887 |
882 def parse(self, p): | 888 def parse(self, p): |
883 self.bytes = p.bytes | 889 self.bytes = p.bytes |
884 return self | 890 return self |
885 | 891 |
886 def write(self): | 892 def write(self): |
887 return self.bytes | 893 return self.bytes |
OLD | NEW |