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

Python handshakesettings.HandshakeSettings类代码示例

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

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



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

示例1: test_maxKeySize_smaller_than_minKeySize

    def test_maxKeySize_smaller_than_minKeySize(self):
        hs = HandshakeSettings()
        hs.maxKeySize = 1024
        hs.minKeySize = 2048

        with self.assertRaises(ValueError):
            hs.validate()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:7,代码来源:test_tlslite_handshakesettings.py


示例2: test_client_with_server_responing_without_EMS

    def test_client_with_server_responing_without_EMS(self):
        # socket to generate the faux response
        gen_sock = MockSocket(bytearray(0))

        gen_record_layer = RecordLayer(gen_sock)
        gen_record_layer.version = (3, 2)

        server_hello = ServerHello().create(
                version=(3, 3),
                random=bytearray(32),
                session_id=bytearray(0),
                cipher_suite=CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA256,
                certificate_type=None,
                tackExt=None,
                next_protos_advertised=None)

        for res in gen_record_layer.sendRecord(server_hello):
            if res in (0, 1):
                self.assertTrue(False, "Blocking socket")
            else:
                break

        # test proper
        sock = MockSocket(gen_sock.sent[0])

        hs = HandshakeSettings()
        hs.requireExtendedMasterSecret = True

        conn = TLSConnection(sock)

        with self.assertRaises(TLSLocalAlert) as err:
            conn.handshakeClientCert(settings=hs)

        self.assertEqual(err.exception.description,
                         AlertDescription.insufficient_security)
开发者ID:RedHatLab,项目名称:tlslite-ng,代码行数:35,代码来源:test_tlslite_tlsconnection.py


示例3: test_cipherNames_with_unknown_name

    def test_cipherNames_with_unknown_name(self):
        hs = HandshakeSettings()
        hs.cipherNames = ["aes256"]

        newHs = hs.validate()

        self.assertEqual(["aes256"], newHs.cipherNames)
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:7,代码来源:test_tlslite_handshakesettings.py


示例4: test_requireExtendedMasterSecret_with_incompatible_use_EMS

    def test_requireExtendedMasterSecret_with_incompatible_use_EMS(self):
        hs = HandshakeSettings()
        hs.useExtendedMasterSecret = False
        hs.requireExtendedMasterSecret = True

        with self.assertRaises(ValueError):
            hs.validate()
开发者ID:LennyNiu,项目名称:tlslite-ng,代码行数:7,代码来源:test_tlslite_handshakesettings.py


示例5: test_minVersion_higher_than_maxVersion

    def test_minVersion_higher_than_maxVersion(self):
        hs = HandshakeSettings()
        hs.minVersion = (3, 3)
        hs.maxVersion = (3, 0)

        with self.assertRaises(ValueError):
            hs.validate()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:7,代码来源:test_tlslite_handshakesettings.py


示例6: test_getTLS13Suites

 def test_getTLS13Suites(self):
     hs = HandshakeSettings()
     hs.maxVersion = (3, 4)
     self.assertEqual(CipherSuite.getTLS13Suites(hs),
                      [CipherSuite.TLS_AES_256_GCM_SHA384,
                       CipherSuite.TLS_AES_128_GCM_SHA256,
                       CipherSuite.TLS_CHACHA20_POLY1305_SHA256])
开发者ID:tomato42,项目名称:tlslite-ng,代码行数:7,代码来源:test_tlslite_constants.py


示例7: test_maxVersion_without_TLSv1_2

    def test_maxVersion_without_TLSv1_2(self):
        hs = HandshakeSettings()
        hs.maxVersion = (3, 2)

        self.assertTrue("sha256" in hs.macNames)

        new_hs = hs.validate()

        self.assertFalse("sha256" in new_hs.macNames)
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:9,代码来源:test_tlslite_handshakesettings.py


示例8: test_requireExtendedMasterSecret

    def test_requireExtendedMasterSecret(self):
        hs = HandshakeSettings()
        self.assertFalse(hs.requireExtendedMasterSecret)

        hs.requireExtendedMasterSecret = True

        n_hs = hs.validate()

        self.assertTrue(n_hs.requireExtendedMasterSecret)
开发者ID:LennyNiu,项目名称:tlslite-ng,代码行数:9,代码来源:test_tlslite_handshakesettings.py


示例9: test_useEncryptThenMAC

    def test_useEncryptThenMAC(self):
        hs = HandshakeSettings()
        self.assertTrue(hs.useEncryptThenMAC)

        hs.useEncryptThenMAC = False

        n_hs = hs.validate()

        self.assertFalse(n_hs.useEncryptThenMAC)
开发者ID:LennyNiu,项目名称:tlslite-ng,代码行数:9,代码来源:test_tlslite_handshakesettings.py


示例10: test_client_SRP_key_exchange_with_too_small_params

    def test_client_SRP_key_exchange_with_too_small_params(self):
        keyExchange = self.keyExchange.makeServerKeyExchange('sha1')

        settings = HandshakeSettings()
        settings.minKeySize = 3072
        client_keyExchange = SRPKeyExchange(self.cipher_suite,
                                            self.client_hello,
                                            self.server_hello,
                                            None, None,
                                            srpUsername=bytearray(b'user'),
                                            password=bytearray(b'password'),
                                            settings=settings)
        with self.assertRaises(TLSInsufficientSecurity):
            client_keyExchange.processServerKeyExchange(None, keyExchange)
开发者ID:almond29,项目名称:tlslite-ng,代码行数:14,代码来源:test_tlslite_keyexchange.py


示例11: test_client_SRP_key_exchange_with_too_big_params

    def test_client_SRP_key_exchange_with_too_big_params(self):
        keyExchange = self.keyExchange.makeServerKeyExchange('sha1')

        settings = HandshakeSettings()
        settings.minKeySize = 512
        settings.maxKeySize = 1024
        client_keyExchange = SRPKeyExchange(self.cipher_suite,
                                            self.client_hello,
                                            self.server_hello,
                                            None, None,
                                            srpUsername='user',
                                            password='password',
                                            settings=settings)
        with self.assertRaises(TLSInsufficientSecurity):
            client_keyExchange.processServerKeyExchange(None, keyExchange)
开发者ID:LennyNiu,项目名称:tlslite-ng,代码行数:15,代码来源:test_tlslite_keyexchange.py


示例12: test_server_with_client_not_using_required_EMS

    def test_server_with_client_not_using_required_EMS(self):
        gen_sock = MockSocket(bytearray(0))

        gen_record_layer = RecordLayer(gen_sock)
        gen_record_layer.version = (3, 0)

        ciphers = [CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA256,
                   CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA256,
                   CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV]

        client_hello = ClientHello().create(version=(3, 3),
                                            random=bytearray(32),
                                            session_id=bytearray(0),
                                            cipher_suites=ciphers)

        for res in gen_record_layer.sendRecord(client_hello):
            if res in (0, 1):
                self.assertTrue(False, "Blocking socket")
            else:
                break

        # test proper
        sock = MockSocket(gen_sock.sent[0])

        conn = TLSConnection(sock)

        hs = HandshakeSettings()
        hs.requireExtendedMasterSecret = True

        srv_private_key = parsePEMKey(srv_raw_key, private=True)
        srv_cert_chain = X509CertChain([X509().parse(srv_raw_certificate)])
        with self.assertRaises(TLSLocalAlert) as err:
            conn.handshakeServer(certChain=srv_cert_chain,
                                 privateKey=srv_private_key,
                                 settings=hs)

        self.assertEqual(err.exception.description,
                         AlertDescription.insufficient_security)
开发者ID:RedHatLab,项目名称:tlslite-ng,代码行数:38,代码来源:test_tlslite_tlsconnection.py


示例13: test_certificateTypes_with_unknown_type

    def test_certificateTypes_with_unknown_type(self):
        hs = HandshakeSettings()
        hs.certificateTypes = [0, 42]

        with self.assertRaises(ValueError):
            hs.validate()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:6,代码来源:test_tlslite_handshakesettings.py


示例14: test_certificateTypes_empty

    def test_certificateTypes_empty(self):
        hs = HandshakeSettings()
        hs.certificateTypes = []

        with self.assertRaises(ValueError):
            hs.validate()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:6,代码来源:test_tlslite_handshakesettings.py


示例15: test_cipherNames_empty

    def test_cipherNames_empty(self):
        hs = HandshakeSettings()
        hs.cipherNames = []

        with self.assertRaises(ValueError):
            hs.validate()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:6,代码来源:test_tlslite_handshakesettings.py


示例16: test_invalid_signature_algorithm

 def test_invalid_signature_algorithm(self):
     hs = HandshakeSettings()
     hs.rsaSigHashes += ['md2']
     with self.assertRaises(ValueError):
         hs.validate()
开发者ID:LennyNiu,项目名称:tlslite-ng,代码行数:5,代码来源:test_tlslite_handshakesettings.py


示例17: test_cipherImplementations_with_unknown_implementations

    def test_cipherImplementations_with_unknown_implementations(self):
        hs = HandshakeSettings()
        hs.cipherImplementations = ["openssl", "NSS"]

        with self.assertRaises(ValueError):
            hs.validate()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:6,代码来源:test_tlslite_handshakesettings.py


示例18: test_maxKeySize_too_small

    def test_maxKeySize_too_small(self):
        hs = HandshakeSettings()
        hs.maxKeySize = 511

        with self.assertRaises(ValueError):
            hs.validate()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:6,代码来源:test_tlslite_handshakesettings.py


示例19: test_validate

    def test_validate(self):
        hs = HandshakeSettings()
        newHS = hs.validate()

        self.assertIsNotNone(newHS)
        self.assertIsNot(hs, newHS)
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:6,代码来源:test_tlslite_handshakesettings.py


示例20: test_getCertificateTypes_with_unsupported_type

    def test_getCertificateTypes_with_unsupported_type(self):
        hs = HandshakeSettings()
        hs.certificateTypes = ["x509", "openpgp"]

        with self.assertRaises(AssertionError):
            hs.getCertificateTypes()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:6,代码来源:test_tlslite_handshakesettings.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python clienthelper.ClientHelper类代码示例发布时间:2022-05-27
下一篇:
Python extensions.SNIExtension类代码示例发布时间: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