当前位置: 首页>>代码示例>>Python>>正文


Python codec.Parser类代码示例

本文整理汇总了Python中tlslite.utils.codec.Parser的典型用法代码示例。如果您正苦于以下问题:Python Parser类的具体用法?Python Parser怎么用?Python Parser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Parser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process

    def process(self, state, msg):
        """
        @type state: ConnectionState
        @type msg: Message
        """
        assert msg.contentType == ContentType.handshake
        parser = Parser(msg.write())
        hs_type = parser.get(1)
        assert hs_type == HandshakeType.finished
        if self.version is None:
            self.version = state.version

        finished = Finished(self.version)
        finished.parse(parser)

        verify_expected = calcFinished(state.version,
                                       state.master_secret,
                                       state.cipher,
                                       state.handshake_hashes,
                                       not state.client)

        assert finished.verify_data == verify_expected

        state.handshake_messages.append(finished)
        state.server_verify_data = finished.verify_data
        state.handshake_hashes.update(msg.write())
开发者ID:ZESecurity,项目名称:tlsfuzzer,代码行数:26,代码来源:expect.py

示例2: test_getRemainingLength

    def test_getRemainingLength(self):
        p = Parser(bytearray(b"\x00\x01\x05"))

        self.assertEqual(1, p.get(2))
        self.assertEqual(1, p.getRemainingLength())
        self.assertEqual(5, p.get(1))
        self.assertEqual(0, p.getRemainingLength())
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:7,代码来源:test_tlslite_utils_codec.py

示例3: test_getVarTupleList_with_missing_elements

    def test_getVarTupleList_with_missing_elements(self):
        p = Parser(bytearray(
            b'\x00\x02' +
            b'\x00'))

        with self.assertRaises(SyntaxError):
            p.getVarTupleList(1, 2, 2)
开发者ID:tomato42,项目名称:tlslite-ng,代码行数:7,代码来源:test_tlslite_utils_codec.py

示例4: test_getFixBytes_with_incorrect_data

    def test_getFixBytes_with_incorrect_data(self):
        p = Parser(bytearray(
            b'\x00\x04'
            ))

        with self.assertRaises(SyntaxError):
            p.getFixBytes(10)
开发者ID:tomato42,项目名称:tlslite-ng,代码行数:7,代码来源:test_tlslite_utils_codec.py

示例5: process

    def process(self, state, msg):
        """Check if the VERIFY message has expected value"""
        assert msg.contentType == ContentType.handshake
        parser = Parser(msg.write())

        msg_type = parser.get(1)
        assert msg_type == SSL2HandshakeType.server_verify
开发者ID:akokare,项目名称:tlsfuzzer,代码行数:7,代码来源:expect.py

示例6: test_getVarTupleList_with_incorrect_length

    def test_getVarTupleList_with_incorrect_length(self):
        p = Parser(bytearray(
            b'\x00\x03' +
            b'\x00'*3))

        with self.assertRaises(SyntaxError):
            p.getVarTupleList(1, 2, 2)
开发者ID:tomato42,项目名称:tlslite-ng,代码行数:7,代码来源:test_tlslite_utils_codec.py

示例7: test_get_with_too_few_bytes_left

    def test_get_with_too_few_bytes_left(self):
        p = Parser(bytearray(b'\x02\x01'))

        p.get(1)

        with self.assertRaises(SyntaxError):
            p.get(2)
开发者ID:tomato42,项目名称:tlslite-ng,代码行数:7,代码来源:test_tlslite_utils_codec.py

示例8: test_getFixList

    def test_getFixList(self):
        p = Parser(bytearray(
            b'\x00\x01' +
            b'\x00\x02' +
            b'\x00\x03'))

        self.assertEqual([1,2,3], p.getFixList(2, 3))
        self.assertEqual(6, p.index)
开发者ID:tomato42,项目名称:tlslite-ng,代码行数:8,代码来源:test_tlslite_utils_codec.py

示例9: test_getVarList

    def test_getVarList(self):
        p = Parser(bytearray(
            b'\x06' +
            b'\x00\x01\x00' +
            b'\x00\x00\xff'))

        self.assertEqual([256, 255], p.getVarList(3, 1))
        self.assertEqual(7, p.index)
开发者ID:tomato42,项目名称:tlslite-ng,代码行数:8,代码来源:test_tlslite_utils_codec.py

示例10: test_atLengthCheck

    def test_atLengthCheck(self):
        p = Parser(bytearray(b"\x00\x06" + b"\x05" + b"\x01\xff" + b"\x07" + b"\x01\xf0"))

        p.startLengthCheck(2)
        while not p.atLengthCheck():
            p.get(1)
            p.getVarBytes(1)
        p.stopLengthCheck()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:8,代码来源:test_tlslite_utils_codec.py

示例11: test_getVarList_with_incorrect_length

    def test_getVarList_with_incorrect_length(self):
        p = Parser(bytearray(
            b'\x07' +
            b'\x00\x01\x00'
            b'\x00\x00\xff'
            b'\x00'))

        with self.assertRaises(SyntaxError):
            p.getVarList(3,1)
开发者ID:tomato42,项目名称:tlslite-ng,代码行数:9,代码来源:test_tlslite_utils_codec.py

示例12: test_getVarTupleList

    def test_getVarTupleList(self):
        p = Parser(bytearray(
            b'\x00\x06' +       # length of list
            b'\x01\x00' +       # first tuple
            b'\x01\x05' +       # second tuple
            b'\x04\x00'         # third tuple
            ))

        self.assertEqual(p.getVarTupleList(1, 2, 2),
                [(1, 0),
                 (1, 5),
                 (4, 0)])
开发者ID:tomato42,项目名称:tlslite-ng,代码行数:12,代码来源:test_tlslite_utils_codec.py

示例13: test_atLengthCheck

    def test_atLengthCheck(self):
        p = Parser(bytearray(
            b'\x00\x06' +
            b'\x05' +
            b'\x01\xff' +
            b'\x07' +
            b'\x01\xf0'
            ))

        p.startLengthCheck(2)
        while not p.atLengthCheck():
            p.get(1)
            p.getVarBytes(1)
        p.stopLengthCheck()
开发者ID:tomato42,项目名称:tlslite-ng,代码行数:14,代码来源:test_tlslite_utils_codec.py

示例14: process

    def process(self, state, msg):
        """
        @type state: ConnectionState
        """
        assert msg.contentType == ContentType.handshake

        parser = Parser(msg.write())
        hs_type = parser.get(1)
        assert hs_type == HandshakeType.certificate

        cert = Certificate(self.cert_type)
        cert.parse(parser)

        state.handshake_messages.append(cert)
        state.handshake_hashes.update(msg.write())
开发者ID:NetPainter,项目名称:tlsfuzzer,代码行数:15,代码来源:expect.py

示例15: test_lengthCheck_with_incorrect_parsing

    def test_lengthCheck_with_incorrect_parsing(self):
        p = Parser(bytearray(b"\x06" + b"\x00\x00" + b"\x02" + b"\x01\x02" + b"\x03"))

        p.startLengthCheck(1)
        self.assertEqual([0, 0], p.getFixList(1, 2))
        self.assertEqual([1, 2], p.getVarList(1, 1))
        with self.assertRaises(SyntaxError):
            p.stopLengthCheck()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:8,代码来源:test_tlslite_utils_codec.py


注:本文中的tlslite.utils.codec.Parser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。