OLD | NEW |
1 # Authors: | 1 # Authors: |
2 # Trevor Perrin | 2 # Trevor Perrin |
3 # Google (adapted by Sam Rushing) - NPN support | 3 # Google (adapted by Sam Rushing) - NPN support |
4 # Martin von Loewis - python 3 port | 4 # Martin von Loewis - python 3 port |
5 # | 5 # |
6 # See the LICENSE file for legal information regarding use of this file. | 6 # See the LICENSE file for legal information regarding use of this file. |
7 | 7 |
8 """Helper class for TLSConnection.""" | 8 """Helper class for TLSConnection.""" |
9 from __future__ import generators | 9 from __future__ import generators |
10 | 10 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 block = bytearray(s[startIndex : endIndex]) | 279 block = bytearray(s[startIndex : endIndex]) |
280 applicationData = ApplicationData().create(block) | 280 applicationData = ApplicationData().create(block) |
281 for result in self._sendMsg(applicationData, \ | 281 for result in self._sendMsg(applicationData, \ |
282 randomizeFirstBlock): | 282 randomizeFirstBlock): |
283 yield result | 283 yield result |
284 randomizeFirstBlock = False #only on 1st message | 284 randomizeFirstBlock = False #only on 1st message |
285 index += 1 | 285 index += 1 |
286 except GeneratorExit: | 286 except GeneratorExit: |
287 raise | 287 raise |
288 except Exception: | 288 except Exception: |
289 # Don't invalidate the session on write failure if abrupt closes are | 289 self._shutdown(False) |
290 # okay. | |
291 self._shutdown(self.ignoreAbruptClose) | |
292 raise | 290 raise |
293 | 291 |
294 def close(self): | 292 def close(self): |
295 """Close the TLS connection. | 293 """Close the TLS connection. |
296 | 294 |
297 This function will block until it has exchanged close_notify | 295 This function will block until it has exchanged close_notify |
298 alerts with the other party. After doing so, it will shut down the | 296 alerts with the other party. After doing so, it will shut down the |
299 TLS connection. Further attempts to read through this connection | 297 TLS connection. Further attempts to read through this connection |
300 will return "". Further attempts to write through this connection | 298 will return "". Further attempts to write through this connection |
301 will raise ValueError. | 299 will raise ValueError. |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 imac_md5.update(compatHMAC(label + masterSecret + bytearray([0x36]*48))) | 1142 imac_md5.update(compatHMAC(label + masterSecret + bytearray([0x36]*48))) |
1145 imac_sha.update(compatHMAC(label + masterSecret + bytearray([0x36]*40))) | 1143 imac_sha.update(compatHMAC(label + masterSecret + bytearray([0x36]*40))) |
1146 | 1144 |
1147 md5Bytes = MD5(masterSecret + bytearray([0x5c]*48) + \ | 1145 md5Bytes = MD5(masterSecret + bytearray([0x5c]*48) + \ |
1148 bytearray(imac_md5.digest())) | 1146 bytearray(imac_md5.digest())) |
1149 shaBytes = SHA1(masterSecret + bytearray([0x5c]*40) + \ | 1147 shaBytes = SHA1(masterSecret + bytearray([0x5c]*40) + \ |
1150 bytearray(imac_sha.digest())) | 1148 bytearray(imac_sha.digest())) |
1151 | 1149 |
1152 return md5Bytes + shaBytes | 1150 return md5Bytes + shaBytes |
1153 | 1151 |
OLD | NEW |