當前位置: 首頁>>代碼示例>>Python>>正文


Python TLSRecordLayer.closed方法代碼示例

本文整理匯總了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)
開發者ID:RedHatLab,項目名稱:tlslite-ng,代碼行數:37,代碼來源:test_tlslite_tlsrecordlayer.py

示例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)
開發者ID:almond29,項目名稱:tlslite-ng,代碼行數:26,代碼來源:test_tlslite_tlsrecordlayer.py


注:本文中的tlslite.tlsrecordlayer.TLSRecordLayer.closed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。