本文整理汇总了Python中tlslite.utils.codec.Parser.get方法的典型用法代码示例。如果您正苦于以下问题:Python Parser.get方法的具体用法?Python Parser.get怎么用?Python Parser.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tlslite.utils.codec.Parser
的用法示例。
在下文中一共展示了Parser.get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_with_too_few_bytes_left
# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
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)
示例2: filter
# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
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
示例3: test_getRemainingLength
# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
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())
示例4: test_atLengthCheck
# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
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()
示例5: process
# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
def process(self, state, msg):
"""Analyse the error message"""
assert msg.contentType == ContentType.handshake
parser = Parser(msg.write())
hs_type = parser.get(1)
assert hs_type == SSL2HandshakeType.error
if self.error is not None:
assert self.error == parser.get(2)
示例6: test_atLengthCheck
# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
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()
示例7: process
# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
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())
示例8: process
# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
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())
示例9: test_get
# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
def test_get(self):
p = Parser(bytearray(b'\x02\x01\x00'))
self.assertEqual(2, p.get(1))
self.assertEqual(256, p.get(2))
self.assertEqual(3, p.index)