本文整理匯總了Python中tlslite.tlsrecordlayer.TLSRecordLayer.closed方法的典型用法代碼示例。如果您正苦於以下問題:Python TLSRecordLayer.closed方法的具體用法?Python TLSRecordLayer.closed怎麽用?Python TLSRecordLayer.closed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tlslite.tlsrecordlayer.TLSRecordLayer
的用法示例。
在下文中一共展示了TLSRecordLayer.closed方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_write_with_BEAST_record_splitting
# 需要導入模塊: from tlslite.tlsrecordlayer import TLSRecordLayer [as 別名]
# 或者: from tlslite.tlsrecordlayer.TLSRecordLayer import closed [as 別名]
def test_write_with_BEAST_record_splitting(self):
mock_sock = MockSocket(bytearray(0))
record_layer = TLSRecordLayer(mock_sock)
record_layer.version = (3, 1)
record_layer.closed = False
record_layer._recordLayer.calcPendingStates(
CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA, bytearray(48), bytearray(32), bytearray(32), None
)
record_layer._recordLayer.changeWriteState()
record_layer.write(bytearray(32))
self.assertEqual(len(mock_sock.sent), 2)
msg1 = mock_sock.sent[0]
self.assertEqual(
bytearray(
b"\x17"
+ b"\x03\x01" # application data
+ b"\x00\x20" # TLSv1.0 # length 32 bytes = data(1) + MAC(20) + padding(11)
),
msg1[:5],
)
self.assertEqual(len(msg1[5:]), 32)
msg2 = mock_sock.sent[1]
self.assertEqual(
bytearray(
b"\x17"
+ b"\x03\x01" # application data
+ b"\x00\x40" # TLSv1.0 # length 64 bytes = data(31) + MAC(20) + padding(13)
),
msg2[:5],
)
self.assertEqual(len(msg2[5:]), 64)
示例2: test_write_with_BEAST_record_splitting_and_empty_write
# 需要導入模塊: from tlslite.tlsrecordlayer import TLSRecordLayer [as 別名]
# 或者: from tlslite.tlsrecordlayer.TLSRecordLayer import closed [as 別名]
def test_write_with_BEAST_record_splitting_and_empty_write(self):
mock_sock = MockSocket(bytearray(0))
record_layer = TLSRecordLayer(mock_sock)
record_layer.version = (3, 1)
record_layer.closed = False
record_layer._recordLayer.calcPendingStates(
CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA,
bytearray(48),
bytearray(32),
bytearray(32),
None)
record_layer._recordLayer.changeWriteState()
record_layer.write(bytearray(0))
self.assertEqual(len(mock_sock.sent), 1)
msg1 = mock_sock.sent[0]
self.assertEqual(bytearray(
b'\x17' + # application data
b'\x03\x01' + # TLSv1.0
b'\x00\x20' # length 32 bytes = data(0) + MAC(20) + padding(12)
), msg1[:5])
self.assertEqual(len(msg1[5:]), 32)