twisted.conch.test.keydata.privateRSA_openssh

Here are the examples of the python api twisted.conch.test.keydata.privateRSA_openssh taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

19 Examples 7

Example 1

Project: mythbox Source File: test_agent.py
Function: set_up
    def setUp(self):
        # wire up our client <-> server
        self.client, self.server, self.pump = iosim.connectedServerAndClient(
            agent.SSHAgentServer, agent.SSHAgentClient)

        # the server's end of the protocol is stateful and we store it on the
        # factory, for which we only need a mock
        self.server.factory = StubFactory()

        # pub/priv keys of each kind
        self.rsaPrivate = keys.Key.fromString(keydata.privateRSA_openssh)
        self.dsaPrivate = keys.Key.fromString(keydata.privateDSA_openssh)

        self.rsaPublic = keys.Key.fromString(keydata.publicRSA_openssh)
        self.dsaPublic = keys.Key.fromString(keydata.publicDSA_openssh)

Example 2

Project: mythbox Source File: test_default.py
    def test_getPrivateKey(self):
        """
        L{SSHUserAuthClient.getPrivateKey} will load a private key from the
        last used file populated by L{SSHUserAuthClient.getPublicKey}, and
        return a L{Deferred} which fires with the corresponding private L{Key}.
        """
        rsaPrivate = Key.fromString(keydata.privateRSA_openssh)
        options = ConchOptions()
        options.identitys = [self.rsaFile.path]
        client = SSHUserAuthClient("user",  options, None)
        # Populate the list of used files
        client.getPublicKey()

        def _cbGetPrivateKey(key):
            self.assertEquals(key.isPublic(), False)
            self.assertEquals(key, rsaPrivate)

        return client.getPrivateKey().addCallback(_cbGetPrivateKey)

Example 3

Project: mythbox Source File: test_keys.py
Function: test_object_type
    def test_objectType(self):
        """
        Test that objectType, returns the correct type for objects.
        """
        self.assertEquals(keys.objectType(keys.Key.fromString(
            keydata.privateRSA_openssh).keyObject), 'ssh-rsa')
        self.assertEquals(keys.objectType(keys.Key.fromString(
            keydata.privateDSA_openssh).keyObject), 'ssh-dss')
        self.assertRaises(keys.BadKeyError, keys.objectType, None)

Example 4

Project: mythbox Source File: test_keys.py
Function: test_tolsh
    def test_toLSH(self):
        """
        Test that the Key object generates LSH keys correctly.
        """
        key = keys.Key.fromString(keydata.privateRSA_openssh)
        self.assertEquals(key.toString('lsh'), keydata.privateRSA_lsh)
        self.assertEquals(key.public().toString('lsh'),
                keydata.publicRSA_lsh)
        key = keys.Key.fromString(keydata.privateDSA_openssh)
        self.assertEquals(key.toString('lsh'), keydata.privateDSA_lsh)
        self.assertEquals(key.public().toString('lsh'),
                keydata.publicDSA_lsh)

Example 5

Project: mythbox Source File: test_keys.py
Function: test_toagentv3
    def test_toAgentv3(self):
        """
        Test that the Key object generates Agent v3 keys correctly.
        """
        key = keys.Key.fromString(keydata.privateRSA_openssh)
        self.assertEquals(key.toString('agentv3'), keydata.privateRSA_agentv3)
        key = keys.Key.fromString(keydata.privateDSA_openssh)
        self.assertEquals(key.toString('agentv3'), keydata.privateDSA_agentv3)

Example 6

Project: mythbox Source File: test_keys.py
Function: test_sign
    def test_sign(self):
        """
        Test that the Key object generates correct signatures.
        """
        key = keys.Key.fromString(keydata.privateRSA_openssh)
        self.assertEquals(key.sign(''), self.rsaSignature)
        key = keys.Key.fromString(keydata.privateDSA_openssh)
        self.assertEquals(key.sign(''), self.dsaSignature)

Example 7

Project: mythbox Source File: test_userauth.py
Function: test_old_publickey_getprivatekey
    def test_old_publickey_getPrivateKey(self):
        """
        Old SSHUserAuthClients returned a PyCrypto key object from
        getPrivateKey().  Test that _cbSignData signs the data warns the
        user about the deprecation, but signs the data correctly.
        """
        oldAuth = OldClientAuth('foo', FakeTransport.Service())
        d = self.assertWarns(DeprecationWarning, "Returning a PyCrypto key "
                             "object from SSHUserAuthClient.getPrivateKey() is "
                             "deprecated since Twisted 9.0.  "
                             "Return a keys.Key() instead.", userauth.__file__,
                             oldAuth.signData, None, 'data')
        def _checkSignedData(sig):
            self.assertEquals(sig,
                keys.Key.fromString(keydata.privateRSA_openssh).sign(
                    'data'))
        d.addCallback(_checkSignedData)
        return d

Example 8

Project: SubliminalCollaborator Source File: test_default.py
    def test_getPrivateKey(self):
        """
        L{SSHUserAuthClient.getPrivateKey} will load a private key from the
        last used file populated by L{SSHUserAuthClient.getPublicKey}, and
        return a L{Deferred} which fires with the corresponding private L{Key}.
        """
        rsaPrivate = Key.fromString(keydata.privateRSA_openssh)
        options = ConchOptions()
        options.identitys = [self.rsaFile.path]
        client = SSHUserAuthClient("user",  options, None)
        # Populate the list of used files
        client.getPublicKey()

        def _cbGetPrivateKey(key):
            self.assertEqual(key.isPublic(), False)
            self.assertEqual(key, rsaPrivate)

        return client.getPrivateKey().addCallback(_cbGetPrivateKey)

Example 9

Project: SubliminalCollaborator Source File: test_keys.py
Function: test_object_type
    def test_objectType(self):
        """
        Test that objectType, returns the correct type for objects.
        """
        self.assertEqual(keys.objectType(keys.Key.fromString(
            keydata.privateRSA_openssh).keyObject), 'ssh-rsa')
        self.assertEqual(keys.objectType(keys.Key.fromString(
            keydata.privateDSA_openssh).keyObject), 'ssh-dss')
        self.assertRaises(keys.BadKeyError, keys.objectType, None)

Example 10

Project: SubliminalCollaborator Source File: test_keys.py
Function: test_tolsh
    def test_toLSH(self):
        """
        Test that the Key object generates LSH keys correctly.
        """
        key = keys.Key.fromString(keydata.privateRSA_openssh)
        self.assertEqual(key.toString('lsh'), keydata.privateRSA_lsh)
        self.assertEqual(key.public().toString('lsh'),
                keydata.publicRSA_lsh)
        key = keys.Key.fromString(keydata.privateDSA_openssh)
        self.assertEqual(key.toString('lsh'), keydata.privateDSA_lsh)
        self.assertEqual(key.public().toString('lsh'),
                keydata.publicDSA_lsh)

Example 11

Project: SubliminalCollaborator Source File: test_keys.py
Function: test_toagentv3
    def test_toAgentv3(self):
        """
        Test that the Key object generates Agent v3 keys correctly.
        """
        key = keys.Key.fromString(keydata.privateRSA_openssh)
        self.assertEqual(key.toString('agentv3'), keydata.privateRSA_agentv3)
        key = keys.Key.fromString(keydata.privateDSA_openssh)
        self.assertEqual(key.toString('agentv3'), keydata.privateDSA_agentv3)

Example 12

Project: SubliminalCollaborator Source File: test_keys.py
Function: test_sign
    def test_sign(self):
        """
        Test that the Key object generates correct signatures.
        """
        key = keys.Key.fromString(keydata.privateRSA_openssh)
        self.assertEqual(key.sign(''), self.rsaSignature)
        key = keys.Key.fromString(keydata.privateDSA_openssh)
        self.assertEqual(key.sign(''), self.dsaSignature)

Example 13

Project: SubliminalCollaborator Source File: test_userauth.py
Function: test_old_publickey_getprivatekey
    def test_old_publickey_getPrivateKey(self):
        """
        Old SSHUserAuthClients returned a PyCrypto key object from
        getPrivateKey().  Test that _cbSignData signs the data warns the
        user about the deprecation, but signs the data correctly.
        """
        oldAuth = OldClientAuth('foo', FakeTransport.Service())
        d = self.assertWarns(DeprecationWarning, "Returning a PyCrypto key "
                             "object from SSHUserAuthClient.getPrivateKey() is "
                             "deprecated since Twisted 9.0.  "
                             "Return a keys.Key() instead.", userauth.__file__,
                             oldAuth.signData, None, 'data')
        def _checkSignedData(sig):
            self.assertEqual(sig,
                keys.Key.fromString(keydata.privateRSA_openssh).sign(
                    'data'))
        d.addCallback(_checkSignedData)
        return d

Example 14

Project: mythbox Source File: test_default.py
    def test_getPrivateKeyPassphrase(self):
        """
        L{SSHUserAuthClient} can get a private key from a file, and return a
        Deferred called back with a private L{Key} object, even if the key is
        encrypted.
        """
        rsaPrivate = Key.fromString(keydata.privateRSA_openssh)
        passphrase = 'this is the passphrase'
        self.rsaFile.setContent(rsaPrivate.toString('openssh', passphrase))
        options = ConchOptions()
        options.identitys = [self.rsaFile.path]
        client = SSHUserAuthClient("user",  options, None)
        # Populate the list of used files
        client.getPublicKey()

        def _getPassword(prompt):
            self.assertEquals(prompt,
                              "Enter passphrase for key '%s': " % (
                              self.rsaFile.path,))
            return passphrase

        def _cbGetPrivateKey(key):
            self.assertEquals(key.isPublic(), False)
            self.assertEquals(key, rsaPrivate)

        self.patch(client, '_getPassword', _getPassword)
        return client.getPrivateKey().addCallback(_cbGetPrivateKey)

Example 15

Project: mythbox Source File: test_keys.py
    def _signRSA(self, data):
        key = keys.Key.fromString(keydata.privateRSA_openssh)
        sig = key.sign(data)
        return key.keyObject, sig

Example 16

Project: mythbox Source File: test_openssh_compat.py
    def setUp(self):
        self.factory = OpenSSHFactory()
        self.keysDir = FilePath(self.mktemp())
        self.keysDir.makedirs()
        self.factory.dataRoot = self.keysDir.path

        self.keysDir.child("ssh_host_foo").setContent("foo")
        self.keysDir.child("bar_key").setContent("foo")
        self.keysDir.child("ssh_host_one_key").setContent(
            keydata.privateRSA_openssh)
        self.keysDir.child("ssh_host_two_key").setContent(
            keydata.privateDSA_openssh)
        self.keysDir.child("ssh_host_three_key").setContent(
            "not a key content")

        self.keysDir.child("ssh_host_one_key.pub").setContent(
            keydata.publicRSA_openssh)

        self.mockos = MockOS()
        self.patch(os, "seteuid", self.mockos.seteuid)
        self.patch(os, "setegid", self.mockos.setegid)

Example 17

Project: mythbox Source File: test_userauth.py
Function: get_private_key
    def getPrivateKey(self):
        """
        Return the private key object for the RSA key.
        """
        return defer.succeed(keys.Key.fromString(keydata.privateRSA_openssh))

Example 18

Project: mythbox Source File: test_userauth.py
Function: get_private_key
    def getPrivateKey(self):
        return defer.succeed(keys.Key.fromString(
            keydata.privateRSA_openssh).keyObject)

Example 19

Project: SubliminalCollaborator Source File: test_default.py
    def test_getPrivateKeyPassphrase(self):
        """
        L{SSHUserAuthClient} can get a private key from a file, and return a
        Deferred called back with a private L{Key} object, even if the key is
        encrypted.
        """
        rsaPrivate = Key.fromString(keydata.privateRSA_openssh)
        passphrase = 'this is the passphrase'
        self.rsaFile.setContent(rsaPrivate.toString('openssh', passphrase))
        options = ConchOptions()
        options.identitys = [self.rsaFile.path]
        client = SSHUserAuthClient("user",  options, None)
        # Populate the list of used files
        client.getPublicKey()

        def _getPassword(prompt):
            self.assertEqual(prompt,
                              "Enter passphrase for key '%s': " % (
                              self.rsaFile.path,))
            return passphrase

        def _cbGetPrivateKey(key):
            self.assertEqual(key.isPublic(), False)
            self.assertEqual(key, rsaPrivate)

        self.patch(client, '_getPassword', _getPassword)
        return client.getPrivateKey().addCallback(_cbGetPrivateKey)