MCPcopy
hub / github.com/XX-net/XX-Net / _sendMsg

Method _sendMsg

code/default/lib/noarch/tlslite/tlsrecordlayer.py:912–944  ·  view source on GitHub ↗

Fragment and send message through socket

(self, msg, randomizeFirstBlock=True, update_hashes=True)

Source from the content-addressed store, hash-verified

910 self.sock.buffer_writes = False
911
912 def _sendMsg(self, msg, randomizeFirstBlock=True, update_hashes=True):
913 """Fragment and send message through socket"""
914 #Whenever we're connected and asked to send an app data message,
915 #we first send the first byte of the message. This prevents
916 #an attacker from launching a chosen-plaintext attack based on
917 #knowing the next IV (a la BEAST).
918 if randomizeFirstBlock and self.version <= (3, 1) \
919 and self._recordLayer.isCBCMode() \
920 and msg.contentType == ContentType.application_data:
921 msgFirstByte = msg.splitFirstByte()
922 for result in self._sendMsgThroughSocket(msgFirstByte):
923 yield result
924 if len(msg.write()) == 0:
925 return
926
927 buf = msg.write()
928 contentType = msg.contentType
929 #Update handshake hashes
930 if update_hashes and contentType == ContentType.handshake:
931 self._handshake_hash.update(buf)
932
933 #Fragment big messages
934 while len(buf) > self.recordSize:
935 newB = buf[:self.recordSize]
936 buf = buf[self.recordSize:]
937
938 msgFragment = Message(contentType, newB)
939 for result in self._sendMsgThroughSocket(msgFragment):
940 yield result
941
942 msgFragment = Message(contentType, buf)
943 for result in self._sendMsgThroughSocket(msgFragment):
944 yield result
945
946 def _queue_message(self, msg):
947 """Just queue message for sending, for record layer coalescing."""

Callers 15

writeAsyncMethod · 0.95
_decrefAsyncMethod · 0.95
_sendErrorMethod · 0.95
_sendMsgsMethod · 0.95
_queue_flushMethod · 0.95
_getMsgMethod · 0.95
write_heartbeatMethod · 0.95
_clientTLS13HandshakeMethod · 0.80
_clientKeyExchangeMethod · 0.80

Calls 6

_sendMsgThroughSocketMethod · 0.95
MessageClass · 0.85
isCBCModeMethod · 0.80
splitFirstByteMethod · 0.80
writeMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected