本文整理汇总了Python中tlsfuzzer.runner.ConnectionState类的典型用法代码示例。如果您正苦于以下问题:Python ConnectionState类的具体用法?Python ConnectionState怎么用?Python ConnectionState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConnectionState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_process_with_ssl2
def test_process_with_ssl2(self):
exp = ExpectFinished((2, 0))
state = ConnectionState()
state.msg_sock = mock.MagicMock()
msg = ServerFinished().create(bytearray(range(12)))
exp.process(state, msg)
示例2: test_process_with_not_matching_signature_algorithms
def test_process_with_not_matching_signature_algorithms(self):
exp = ExpectServerKeyExchange(valid_sig_algs=[(HashAlgorithm.sha256,
SignatureAlgorithm.rsa)])
state = ConnectionState()
state.cipher = CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA
cert = Certificate(CertificateType.x509).\
create(X509CertChain([X509().parse(srv_raw_certificate)]))
private_key = parsePEMKey(srv_raw_key, private=True)
client_hello = ClientHello()
client_hello.client_version = (3, 3)
client_hello.random = bytearray(32)
state.client_random = client_hello.random
state.handshake_messages.append(client_hello)
server_hello = ServerHello()
server_hello.server_version = (3, 3)
server_hello.random = bytearray(32)
state.server_random = server_hello.random
# server hello is not necessary for the test to work
#state.handshake_messages.append(server_hello)
state.handshake_messages.append(cert)
srv_key_exchange = DHE_RSAKeyExchange(\
CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
client_hello,
server_hello,
private_key)
msg = srv_key_exchange.makeServerKeyExchange('sha1')
with self.assertRaises(TLSIllegalParameterException):
exp.process(state, msg)
示例3: test_post_send
def test_post_send(self):
state = ConnectionState()
state.get_server_public_key = lambda: self.priv_key
cke = ClientKeyExchangeGenerator(constants.CipherSuite.TLS_RSA_WITH_NULL_MD5, (3, 3))
ret = cke.generate(state)
cke.post_send(state)
示例4: test_get_last_message_of_type_with_no_messages_of_that_type
def test_get_last_message_of_type_with_no_messages_of_that_type(self):
state = ConnectionState()
msg = messages.ServerHello()
msg.server_version = (3, 1)
state.handshake_messages.append(msg)
msg = state.get_last_message_of_type(messages.ClientHello)
self.assertIsNone(msg)
示例5: test_process
def test_process(self):
state = ConnectionState()
state.msg_sock = mock.MagicMock()
close = Close()
close.process(state)
state.msg_sock.sock.close.called_once_with()
示例6: test_post_send_with_resumption
def test_post_send_with_resumption(self):
fg = FinishedGenerator()
state = ConnectionState()
state.resuming = True
ret = fg.generate(state)
fg.post_send(state)
self.assertFalse(state.resuming)
示例7: test_process_with_size
def test_process_with_size(self):
node = SetMaxRecordSize(2048)
state = ConnectionState()
state.msg_sock = mock.MagicMock()
node.process(state)
self.assertEqual(2048, state.msg_sock.recordSize)
示例8: test_generate_with_dhe
def test_generate_with_dhe(self):
state = ConnectionState()
state.key_exchange = mock.MagicMock()
cke = ClientKeyExchangeGenerator(
cipher=constants.CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA)
ret = cke.generate(state)
self.assertIs(ret, state.key_exchange.makeClientKeyExchange())
示例9: test_post_send
def test_post_send(self):
ccsg = ChangeCipherSpecGenerator()
ccsg.generate(None)
state = ConnectionState()
state.msg_sock = mock.MagicMock()
ccsg.post_send(state)
self.assertTrue(state.msg_sock.calcPendingStates.called)
self.assertTrue(state.msg_sock.changeWriteState.called)
示例10: test_generate_TLS_1_1
def test_generate_TLS_1_1(self):
priv_key = generateRSAKey(1024)
cert_ver_g = CertificateVerifyGenerator(priv_key)
state = ConnectionState()
state.version = (3, 2)
msg = cert_ver_g.generate(state)
self.assertIsNotNone(msg)
self.assertEqual(len(msg.signature), 128)
示例11: test_generate_with_export_cipher
def test_generate_with_export_cipher(self):
cmk = ClientMasterKeyGenerator(
cipher=constants.CipherSuite.SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5)
state = ConnectionState()
state.msg_sock = mock.MagicMock()
state.get_server_public_key = mock.MagicMock()
ret = cmk.generate(state)
self.assertEqual(len(ret.clear_key), 11)
示例12: test_generate
def test_generate(self):
state = ConnectionState()
state.get_server_public_key = lambda: self.priv_key
cke = ClientKeyExchangeGenerator()
ret = cke.generate(state)
self.assertEqual(len(ret.encryptedPreMasterSecret), 128)
decrypt = self.priv_key.decrypt(ret.encryptedPreMasterSecret)
self.assertEqual(decrypt[:2], bytearray([3, 3]))
示例13: test_generate_with_ssl2
def test_generate_with_ssl2(self):
fg = FinishedGenerator((0, 2))
state = ConnectionState()
state.msg_sock = mock.MagicMock()
state.session_id = bytearray(b'abba')
ret = fg.generate(state)
self.assertEqual(ret.verify_data, bytearray(b'abba'))
state.msg_sock.changeWriteState.assert_called_once_with()
state.msg_sock.changeReadState.assert_called_once_with()
示例14: test_generate_with_des_cipher
def test_generate_with_des_cipher(self):
cmk = ClientMasterKeyGenerator(
cipher=constants.CipherSuite.SSL_CK_DES_64_CBC_WITH_MD5)
state = ConnectionState()
state.msg_sock = mock.MagicMock()
state.get_server_public_key = mock.MagicMock()
ret = cmk.generate(state)
self.assertEqual(ret.encrypted_key,
state.get_server_public_key().encrypt())
示例15: test_get_server_public_key_with_valid_messages
def test_get_server_public_key_with_valid_messages(self):
state = ConnectionState()
msg = messages.Certificate(constants.CertificateType.x509)
cert_list = mock.MagicMock()
msg.create(cert_list)
state.handshake_messages.append(msg)
state.get_server_public_key()
self.assertTrue(cert_list.getEndEntityPublicKey.called)