• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python codec.Parser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_lengthCheck

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

        p.startLengthCheck(1)

        self.assertEqual([0, 0], p.getFixList(1, 2))
        self.assertEqual([1, 2, 3], p.getVarList(1, 1))
        # should not raise exception
        p.stopLengthCheck()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:9,代码来源:test_tlslite_utils_codec.py


示例17: filter

def filter(packetNo, data, source, target):
    bytes = stringToBytes(data)
    if packetNo == 0 and 'Client2Server' in str(source):
        p = Parser(bytes[5:])
        p.get(1)
        clientHello = ClientHello()
        clientHello.parse(p)
        print bcolors.OKGREEN + "Client supports TLS version: %s" % \
            str(clientHello.client_version)
        print "Client supports ciphersuites: %s" % \
            str([CIPHER_MAP.get(i,i) for i in clientHello.cipher_suites]) \
            + bcolors.ENDC
    elif packetNo == 0 and 'Client2Server' not in str(source):
        p = Parser(bytes[5:])
        p.get(1)
        serverHello = ServerHello()
        serverHello.parse(p)
        print bcolors.OKGREEN + "Server selected TLS version: %s" % \
            str(serverHello.server_version)
        print "Server selected ciphersuite: %s" % \
            str(CIPHER_MAP.get(serverHello.cipher_suite,
                               serverHello.cipher_suite)) + bcolors.ENDC

    target.write(data)        
    return data
开发者ID:adacapo21,项目名称:TwistedEve,代码行数:25,代码来源:tlsinfo.py


示例18: test_setLengthCheck_with_bad_data

    def test_setLengthCheck_with_bad_data(self):
        p = Parser(bytearray(b"\x04" + b"\x00\x01" + b"\x00\x02"))

        p.setLengthCheck(7)
        self.assertEqual([1, 2], p.getVarList(2, 1))

        with self.assertRaises(SyntaxError):
            p.stopLengthCheck()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:8,代码来源:test_tlslite_utils_codec.py


示例19: test_setLengthCheck

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

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


示例20: test_setLengthCheck

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

        p.setLengthCheck(7)
        self.assertEqual([1, 2, 3], p.getVarList(2, 1))
        p.stopLengthCheck()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:6,代码来源:test_tlslite_utils_codec.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python codec.Writer类代码示例发布时间:2022-05-27
下一篇:
Python tlsrecordlayer.TLSRecordLayer类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap