Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: third_party/tlslite/tlslite/tlsrecordlayer.py

Issue 280853002: Preserve transport errors for OpenSSL sockets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: USE_NSS -> USE_OPENSSL for Windows and Mac Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 from .utils.compat import * 11 from .utils.compat import *
12 from .utils.cryptomath import * 12 from .utils.cryptomath import *
13 from .utils.cipherfactory import createAES, createRC4, createTripleDES 13 from .utils.cipherfactory import createAES, createRC4, createTripleDES
14 from .utils.codec import * 14 from .utils.codec import *
15 from .errors import * 15 from .errors import *
16 from .messages import * 16 from .messages import *
17 from .mathtls import * 17 from .mathtls import *
18 from .constants import * 18 from .constants import *
19 from .utils.cryptomath import getRandomBytes 19 from .utils.cryptomath import getRandomBytes
20 20
21 import socket 21 import socket
22 import struct
22 import errno 23 import errno
23 import traceback 24 import traceback
24 25
25 class _ConnectionState(object): 26 class _ConnectionState(object):
26 def __init__(self): 27 def __init__(self):
27 self.macContext = None 28 self.macContext = None
28 self.encContext = None 29 self.encContext = None
29 self.seqnum = 0 30 self.seqnum = 0
30 31
31 def getSeqNumBytes(self): 32 def getSeqNumBytes(self):
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 self.session.resumable = False 515 self.session.resumable = False
515 516
516 517
517 def _sendError(self, alertDescription, errorStr=None): 518 def _sendError(self, alertDescription, errorStr=None):
518 alert = Alert().create(alertDescription, AlertLevel.fatal) 519 alert = Alert().create(alertDescription, AlertLevel.fatal)
519 for result in self._sendMsg(alert): 520 for result in self._sendMsg(alert):
520 yield result 521 yield result
521 self._shutdown(False) 522 self._shutdown(False)
522 raise TLSLocalAlert(alert, errorStr) 523 raise TLSLocalAlert(alert, errorStr)
523 524
525 def _abortWithReset(self):
526 #Set an SO_LINGER timeout of 0 to send a TCP RST.
527 self.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER,
528 struct.pack('ii', 1, 0))
529 self._shutdown(False)
530
524 def _sendMsgs(self, msgs): 531 def _sendMsgs(self, msgs):
525 randomizeFirstBlock = True 532 randomizeFirstBlock = True
526 for msg in msgs: 533 for msg in msgs:
527 for result in self._sendMsg(msg, randomizeFirstBlock): 534 for result in self._sendMsg(msg, randomizeFirstBlock):
528 yield result 535 yield result
529 randomizeFirstBlock = True 536 randomizeFirstBlock = True
530 537
531 def _sendMsg(self, msg, randomizeFirstBlock = True): 538 def _sendMsg(self, msg, randomizeFirstBlock = True):
532 #Whenever we're connected and asked to send an app data message, 539 #Whenever we're connected and asked to send an app data message,
533 #we first send the first byte of the message. This prevents 540 #we first send the first byte of the message. This prevents
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 imac_md5.update(compatHMAC(label + masterSecret + bytearray([0x36]*48))) 1149 imac_md5.update(compatHMAC(label + masterSecret + bytearray([0x36]*48)))
1143 imac_sha.update(compatHMAC(label + masterSecret + bytearray([0x36]*40))) 1150 imac_sha.update(compatHMAC(label + masterSecret + bytearray([0x36]*40)))
1144 1151
1145 md5Bytes = MD5(masterSecret + bytearray([0x5c]*48) + \ 1152 md5Bytes = MD5(masterSecret + bytearray([0x5c]*48) + \
1146 bytearray(imac_md5.digest())) 1153 bytearray(imac_md5.digest()))
1147 shaBytes = SHA1(masterSecret + bytearray([0x5c]*40) + \ 1154 shaBytes = SHA1(masterSecret + bytearray([0x5c]*40) + \
1148 bytearray(imac_sha.digest())) 1155 bytearray(imac_sha.digest()))
1149 1156
1150 return md5Bytes + shaBytes 1157 return md5Bytes + shaBytes
1151 1158
OLDNEW
« net/socket/ssl_client_socket_unittest.cc ('K') | « third_party/tlslite/tlslite/tlsconnection.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698