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


Python paramiko.ECDSAKey类代码示例

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


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

示例1: test_C_generate_ecdsa

    def test_C_generate_ecdsa(self):
        key = ECDSAKey.generate()
        msg = key.sign_ssh_data(b'jerri blank')
        msg.rewind()
        self.assertTrue(key.verify_ssh_sig(b'jerri blank', msg))
        self.assertEqual(key.get_bits(), 256)
        self.assertEqual(key.get_name(), 'ecdsa-sha2-nistp256')

        key = ECDSAKey.generate(bits=256)
        msg = key.sign_ssh_data(b'jerri blank')
        msg.rewind()
        self.assertTrue(key.verify_ssh_sig(b'jerri blank', msg))
        self.assertEqual(key.get_bits(), 256)
        self.assertEqual(key.get_name(), 'ecdsa-sha2-nistp256')

        key = ECDSAKey.generate(bits=384)
        msg = key.sign_ssh_data(b'jerri blank')
        msg.rewind()
        self.assertTrue(key.verify_ssh_sig(b'jerri blank', msg))
        self.assertEqual(key.get_bits(), 384)
        self.assertEqual(key.get_name(), 'ecdsa-sha2-nistp384')

        key = ECDSAKey.generate(bits=521)
        msg = key.sign_ssh_data(b'jerri blank')
        msg.rewind()
        self.assertTrue(key.verify_ssh_sig(b'jerri blank', msg))
        self.assertEqual(key.get_bits(), 521)
        self.assertEqual(key.get_name(), 'ecdsa-sha2-nistp521')
开发者ID:AlexanderChernikov,项目名称:paramiko,代码行数:28,代码来源:test_pkey.py

示例2: test_12_compare_ecdsa

 def test_12_compare_ecdsa(self):
     # verify that the private & public keys compare equal
     key = ECDSAKey.from_private_key_file('tests/test_ecdsa.key')
     self.assertEquals(key, key)
     pub = ECDSAKey(data=bytes(key))
     self.assert_(key.can_sign())
     self.assert_(not pub.can_sign())
     self.assertEquals(key, pub)
开发者ID:chuckds,项目名称:paramiko,代码行数:8,代码来源:test_pkey.py

示例3: test_20_compare_ecdsa_521

 def test_20_compare_ecdsa_521(self):
     # verify that the private & public keys compare equal
     key = ECDSAKey.from_private_key_file(test_path('test_ecdsa_521.key'))
     self.assertEqual(key, key)
     pub = ECDSAKey(data=key.asbytes())
     self.assertTrue(key.can_sign())
     self.assertTrue(not pub.can_sign())
     self.assertEqual(key, pub)
开发者ID:AlexanderChernikov,项目名称:paramiko,代码行数:8,代码来源:test_pkey.py

示例4: test_16_compare_ecdsa_384

 def test_16_compare_ecdsa_384(self):
     # verify that the private & public keys compare equal
     key = ECDSAKey.from_private_key_file(_support("test_ecdsa_384.key"))
     self.assertEqual(key, key)
     pub = ECDSAKey(data=key.asbytes())
     self.assertTrue(key.can_sign())
     self.assertTrue(not pub.can_sign())
     self.assertEqual(key, pub)
开发者ID:gaudenz,项目名称:paramiko,代码行数:8,代码来源:test_pkey.py

示例5: test_13_sign_ecdsa

    def test_13_sign_ecdsa(self):
        # verify that the rsa private key can sign and verify
        key = ECDSAKey.from_private_key_file('tests/test_ecdsa.key')
        msg = key.sign_ssh_data(rng, b'ice weasels')
        self.assert_(type(msg) is Message)
        msg.rewind()
        self.assertEquals(b'ecdsa-sha2-nistp256', msg.get_string())
        # ECDSA signatures, like DSS signatures, tend to be different
        # each time, so we can't compare against a "known correct"
        # signature.
        # Even the length of the signature can change.

        msg.rewind()
        pub = ECDSAKey(data=bytes(key))
        self.assert_(pub.verify_ssh_sig(b'ice weasels', msg))
开发者ID:chuckds,项目名称:paramiko,代码行数:15,代码来源:test_pkey.py

示例6: test_10_load_ecdsa

    def test_10_load_ecdsa(self):
        key = ECDSAKey.from_private_key_file('tests/test_ecdsa.key')
        self.assertEquals(b'ecdsa-sha2-nistp256', key.get_name())
        exp_ecdsa = FINGER_ECDSA.split()[1].replace(b':', b'')
        my_ecdsa = hexlify(key.get_fingerprint())
        self.assertEquals(exp_ecdsa, my_ecdsa)
        self.assertEquals(PUB_ECDSA.split()[1], key.get_base64())
        self.assertEquals(256, key.get_bits())

        s = BytesIO()
        key.write_private_key(s)
        self.assertEquals(ECDSA_PRIVATE_OUT, s.getvalue())
        s.seek(0)
        key2 = ECDSAKey.from_private_key(StringIO(s.getvalue().decode()))
        self.assertEquals(key, key2)
开发者ID:chuckds,项目名称:paramiko,代码行数:15,代码来源:test_pkey.py

示例7: test_21_sign_ecdsa_521

    def test_21_sign_ecdsa_521(self):
        # verify that the rsa private key can sign and verify
        key = ECDSAKey.from_private_key_file(test_path('test_ecdsa_521.key'))
        msg = key.sign_ssh_data(b'ice weasels')
        self.assertTrue(type(msg) is Message)
        msg.rewind()
        self.assertEqual('ecdsa-sha2-nistp521', msg.get_text())
        # ECDSA signatures, like DSS signatures, tend to be different
        # each time, so we can't compare against a "known correct"
        # signature.
        # Even the length of the signature can change.

        msg.rewind()
        pub = ECDSAKey(data=key.asbytes())
        self.assertTrue(pub.verify_ssh_sig(b'ice weasels', msg))
开发者ID:AlexanderChernikov,项目名称:paramiko,代码行数:15,代码来源:test_pkey.py

示例8: test_14_load_ecdsa_384

    def test_14_load_ecdsa_384(self):
        key = ECDSAKey.from_private_key_file(test_path('test_ecdsa_384.key'))
        self.assertEqual('ecdsa-sha2-nistp384', key.get_name())
        exp_ecdsa = b(FINGER_ECDSA_384.split()[1].replace(':', ''))
        my_ecdsa = hexlify(key.get_fingerprint())
        self.assertEqual(exp_ecdsa, my_ecdsa)
        self.assertEqual(PUB_ECDSA_384.split()[1], key.get_base64())
        self.assertEqual(384, key.get_bits())

        s = StringIO()
        key.write_private_key(s)
        self.assertEqual(ECDSA_PRIVATE_OUT_384, s.getvalue())
        s.seek(0)
        key2 = ECDSAKey.from_private_key(s)
        self.assertEqual(key, key2)
开发者ID:AlexanderChernikov,项目名称:paramiko,代码行数:15,代码来源:test_pkey.py

示例9: test_10_load_ecdsa_256

    def test_10_load_ecdsa_256(self):
        key = ECDSAKey.from_private_key_file(_support("test_ecdsa_256.key"))
        self.assertEqual("ecdsa-sha2-nistp256", key.get_name())
        exp_ecdsa = b(FINGER_ECDSA_256.split()[1].replace(":", ""))
        my_ecdsa = hexlify(key.get_fingerprint())
        self.assertEqual(exp_ecdsa, my_ecdsa)
        self.assertEqual(PUB_ECDSA_256.split()[1], key.get_base64())
        self.assertEqual(256, key.get_bits())

        s = StringIO()
        key.write_private_key(s)
        self.assertEqual(ECDSA_PRIVATE_OUT_256, s.getvalue())
        s.seek(0)
        key2 = ECDSAKey.from_private_key(s)
        self.assertEqual(key, key2)
开发者ID:gaudenz,项目名称:paramiko,代码行数:15,代码来源:test_pkey.py

示例10: test_11_load_ecdsa_password

 def test_11_load_ecdsa_password(self):
     key = ECDSAKey.from_private_key_file('tests/test_ecdsa_password.key', 'television')
     self.assertEquals(b'ecdsa-sha2-nistp256', key.get_name())
     exp_ecdsa = FINGER_ECDSA.split()[1].replace(b':', b'')
     my_ecdsa = hexlify(key.get_fingerprint())
     self.assertEquals(exp_ecdsa, my_ecdsa)
     self.assertEquals(PUB_ECDSA.split()[1], key.get_base64())
     self.assertEquals(256, key.get_bits())
开发者ID:chuckds,项目名称:paramiko,代码行数:8,代码来源:test_pkey.py

示例11: test_19_load_ecdsa_password_521

 def test_19_load_ecdsa_password_521(self):
     key = ECDSAKey.from_private_key_file(test_path('test_ecdsa_password_521.key'), b'television')
     self.assertEqual('ecdsa-sha2-nistp521', key.get_name())
     exp_ecdsa = b(FINGER_ECDSA_521.split()[1].replace(':', ''))
     my_ecdsa = hexlify(key.get_fingerprint())
     self.assertEqual(exp_ecdsa, my_ecdsa)
     self.assertEqual(PUB_ECDSA_521.split()[1], key.get_base64())
     self.assertEqual(521, key.get_bits())
开发者ID:AlexanderChernikov,项目名称:paramiko,代码行数:8,代码来源:test_pkey.py

示例12: test_15_load_ecdsa_password_384

 def test_15_load_ecdsa_password_384(self):
     key = ECDSAKey.from_private_key_file(_support('test_ecdsa_password_384.key'), b'television')
     self.assertEqual('ecdsa-sha2-nistp384', key.get_name())
     exp_ecdsa = b(FINGER_ECDSA_384.split()[1].replace(':', ''))
     my_ecdsa = hexlify(key.get_fingerprint())
     self.assertEqual(exp_ecdsa, my_ecdsa)
     self.assertEqual(PUB_ECDSA_384.split()[1], key.get_base64())
     self.assertEqual(384, key.get_bits())
开发者ID:expressDESERT,项目名称:paramiko,代码行数:8,代码来源:test_pkey.py

示例13: test_11_load_ecdsa_password

 def test_11_load_ecdsa_password(self):
     key = ECDSAKey.from_private_key_file(test_path("test_ecdsa_password.key"), b"television")
     self.assertEqual("ecdsa-sha2-nistp256", key.get_name())
     exp_ecdsa = b(FINGER_ECDSA.split()[1].replace(":", ""))
     my_ecdsa = hexlify(key.get_fingerprint())
     self.assertEqual(exp_ecdsa, my_ecdsa)
     self.assertEqual(PUB_ECDSA.split()[1], key.get_base64())
     self.assertEqual(256, key.get_bits())
开发者ID:ab9-er,项目名称:paramiko,代码行数:8,代码来源:test_pkey.py

示例14: test_18_load_ecdsa_521

    def test_18_load_ecdsa_521(self):
        key = ECDSAKey.from_private_key_file(test_path('test_ecdsa_521.key'))
        self.assertEqual('ecdsa-sha2-nistp521', key.get_name())
        exp_ecdsa = b(FINGER_ECDSA_521.split()[1].replace(':', ''))
        my_ecdsa = hexlify(key.get_fingerprint())
        self.assertEqual(exp_ecdsa, my_ecdsa)
        self.assertEqual(PUB_ECDSA_521.split()[1], key.get_base64())
        self.assertEqual(521, key.get_bits())

        s = StringIO()
        key.write_private_key(s)
        # Different versions of OpenSSL (SSLeay versions 0x1000100f and
        # 0x1000207f for instance) use different apparently valid (as far as
        # ssh-keygen is concerned) padding. So we can't check the actual value
        # of the pem encoded key.
        s.seek(0)
        key2 = ECDSAKey.from_private_key(s)
        self.assertEqual(key, key2)
开发者ID:AlexanderChernikov,项目名称:paramiko,代码行数:18,代码来源:test_pkey.py

示例15: test_19_load_ecdsa_password_521

 def test_19_load_ecdsa_password_521(self):
     key = ECDSAKey.from_private_key_file(
         _support("test_ecdsa_password_521.key"), b"television"
     )
     self.assertEqual("ecdsa-sha2-nistp521", key.get_name())
     exp_ecdsa = b(FINGER_ECDSA_521.split()[1].replace(":", ""))
     my_ecdsa = hexlify(key.get_fingerprint())
     self.assertEqual(exp_ecdsa, my_ecdsa)
     self.assertEqual(PUB_ECDSA_521.split()[1], key.get_base64())
     self.assertEqual(521, key.get_bits())
开发者ID:gaudenz,项目名称:paramiko,代码行数:10,代码来源:test_pkey.py


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