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 self._shutdown(False) | 289 # Don't invalidate the session on write failure if abrupt closes are |
| 290 # okay. |
| 291 self._shutdown(self.ignoreAbruptClose) |
290 raise | 292 raise |
291 | 293 |
292 def close(self): | 294 def close(self): |
293 """Close the TLS connection. | 295 """Close the TLS connection. |
294 | 296 |
295 This function will block until it has exchanged close_notify | 297 This function will block until it has exchanged close_notify |
296 alerts with the other party. After doing so, it will shut down the | 298 alerts with the other party. After doing so, it will shut down the |
297 TLS connection. Further attempts to read through this connection | 299 TLS connection. Further attempts to read through this connection |
298 will return "". Further attempts to write through this connection | 300 will return "". Further attempts to write through this connection |
299 will raise ValueError. | 301 will raise ValueError. |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 imac_md5.update(compatHMAC(label + masterSecret + bytearray([0x36]*48))) | 1144 imac_md5.update(compatHMAC(label + masterSecret + bytearray([0x36]*48))) |
1143 imac_sha.update(compatHMAC(label + masterSecret + bytearray([0x36]*40))) | 1145 imac_sha.update(compatHMAC(label + masterSecret + bytearray([0x36]*40))) |
1144 | 1146 |
1145 md5Bytes = MD5(masterSecret + bytearray([0x5c]*48) + \ | 1147 md5Bytes = MD5(masterSecret + bytearray([0x5c]*48) + \ |
1146 bytearray(imac_md5.digest())) | 1148 bytearray(imac_md5.digest())) |
1147 shaBytes = SHA1(masterSecret + bytearray([0x5c]*40) + \ | 1149 shaBytes = SHA1(masterSecret + bytearray([0x5c]*40) + \ |
1148 bytearray(imac_sha.digest())) | 1150 bytearray(imac_sha.digest())) |
1149 | 1151 |
1150 return md5Bytes + shaBytes | 1152 return md5Bytes + shaBytes |
1151 | 1153 |
OLD | NEW |