Пример #1
0
 def test_sign_ecdsa_384(self):
     # verify that the rsa private key can sign and verify
     key = ECDSAKey.from_private_key_file(_support('test_ecdsa_384.key'))
     msg = key.sign_ssh_data(b'ice weasels')
     self.assertTrue(type(msg) is Message)
     msg.rewind()
     self.assertEqual('ecdsa-sha2-nistp384', 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))
Пример #2
0
    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))
Пример #3
0
    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))
Пример #4
0
    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, 'ice weasels')
        self.assert_(type(msg) is Message)
        msg.rewind()
        self.assertEquals('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=str(key))
        self.assert_(pub.verify_ssh_sig('ice weasels', msg))