twisted.conch.ssh.keys.Key.fromString.blob

Here are the examples of the python api twisted.conch.ssh.keys.Key.fromString.blob taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

46 Examples 7

Example 1

Project: mythbox
Source File: test_agent.py
View license
    def test_requestIdentities(self):
        """
        Assert that we get all of the keys/comments that we add when we issue a
        request for all identities.
        """
        d = self.client.requestIdentities()
        self.pump.flush()
        def _check(keyt):
            expected = {}
            expected[self.dsaPublic.blob()] = 'a comment'
            expected[self.rsaPublic.blob()] = 'another comment'

            received = {}
            for k in keyt:
                received[keys.Key.fromString(k[0], type='blob').blob()] = k[1]
            self.assertEquals(expected, received)
        return d.addCallback(_check)

Example 2

Project: mythbox
Source File: test_agent.py
View license
    def test_requestIdentities(self):
        """
        Assert that we get all of the keys/comments that we add when we issue a
        request for all identities.
        """
        d = self.client.requestIdentities()
        self.pump.flush()
        def _check(keyt):
            expected = {}
            expected[self.dsaPublic.blob()] = 'a comment'
            expected[self.rsaPublic.blob()] = 'another comment'

            received = {}
            for k in keyt:
                received[keys.Key.fromString(k[0], type='blob').blob()] = k[1]
            self.assertEquals(expected, received)
        return d.addCallback(_check)

Example 3

Project: mythbox
Source File: test_userauth.py
View license
    def requestAvatarId(self, creds):
        if creds.blob == keys.Key.fromString(keydata.publicRSA_openssh).blob():
            if creds.signature is not None:
                obj = keys.Key.fromString(creds.blob)
                if obj.verify(creds.signature, creds.sigData):
                    return creds.username
            else:
                raise ValidPublicKey()
        raise UnauthorizedLogin()

Example 4

Project: mythbox
Source File: test_userauth.py
View license
    def test_successfulPrivateKeyAuthentication(self):
        """
        Test that private key authentication completes sucessfully,
        """
        blob = keys.Key.fromString(keydata.publicRSA_openssh).blob()
        obj = keys.Key.fromString(keydata.privateRSA_openssh)
        packet = (NS('foo') + NS('none') + NS('publickey') + '\xff'
                + NS(obj.sshType()) + NS(blob))
        self.authServer.transport.sessionID = 'test'
        signature = obj.sign(NS('test') + chr(userauth.MSG_USERAUTH_REQUEST)
                + packet)
        packet += NS(signature)
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        def check(ignored):
            self.assertEquals(self.authServer.transport.packets,
                    [(userauth.MSG_USERAUTH_SUCCESS, '')])
        return d.addCallback(check)

Example 5

Project: mythbox
Source File: test_userauth.py
View license
    def test_verifyValidPrivateKey(self):
        """
        Test that verifying a valid private key works.
        """
        blob = keys.Key.fromString(keydata.publicRSA_openssh).blob()
        packet = (NS('foo') + NS('none') + NS('publickey') + '\x00'
                + NS('ssh-rsa') + NS(blob))
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        def check(ignored):
            self.assertEquals(self.authServer.transport.packets,
                    [(userauth.MSG_USERAUTH_PK_OK, NS('ssh-rsa') + NS(blob))])
        return d.addCallback(check)

Example 6

Project: mythbox
Source File: test_userauth.py
View license
    def test_failedPrivateKeyAuthenticationWithoutSignature(self):
        """
        Test that private key authentication fails when the public key
        is invalid.
        """
        blob = keys.Key.fromString(keydata.publicDSA_openssh).blob()
        packet = (NS('foo') + NS('none') + NS('publickey') + '\x00'
                + NS('ssh-dsa') + NS(blob))
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        return d.addCallback(self._checkFailed)

Example 7

Project: mythbox
Source File: test_userauth.py
View license
    def test_failedPrivateKeyAuthenticationWithSignature(self):
        """
        Test that private key authentication fails when the public key
        is invalid.
        """
        blob = keys.Key.fromString(keydata.publicRSA_openssh).blob()
        obj = keys.Key.fromString(keydata.privateRSA_openssh)
        packet = (NS('foo') + NS('none') + NS('publickey') + '\xff'
                + NS('ssh-rsa') + NS(blob) + NS(obj.sign(blob)))
        self.authServer.transport.sessionID = 'test'
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        return d.addCallback(self._checkFailed)

Example 8

Project: mythbox
Source File: test_userauth.py
View license
    def test_old_publickey_getPublicKey(self):
        """
        Old SSHUserAuthClients returned strings of public key blobs from
        getPublicKey().  Test that a Deprecation warning is raised but the key is
        verified correctly.
        """
        oldAuth = OldClientAuth('foo', FakeTransport.Service())
        oldAuth.transport = FakeTransport(None)
        oldAuth.transport.sessionID = 'test'
        oldAuth.serviceStarted()
        oldAuth.transport.packets = []
        self.assertWarns(DeprecationWarning, "Returning a string from "
                         "SSHUserAuthClient.getPublicKey() is deprecated since "
                         "Twisted 9.0.  Return a keys.Key() instead.",
                         userauth.__file__, oldAuth.tryAuth, 'publickey')
        self.assertEquals(oldAuth.transport.packets, [
                (userauth.MSG_USERAUTH_REQUEST, NS('foo') + NS('nancy') +
                 NS('publickey') + '\x00' + NS('ssh-rsa') +
                 NS(keys.Key.fromString(keydata.publicRSA_openssh).blob()))])

Example 9

Project: mythbox
Source File: test_userauth.py
View license
    def requestAvatarId(self, creds):
        if creds.blob == keys.Key.fromString(keydata.publicRSA_openssh).blob():
            if creds.signature is not None:
                obj = keys.Key.fromString(creds.blob)
                if obj.verify(creds.signature, creds.sigData):
                    return creds.username
            else:
                raise ValidPublicKey()
        raise UnauthorizedLogin()

Example 10

Project: mythbox
Source File: test_userauth.py
View license
    def test_successfulPrivateKeyAuthentication(self):
        """
        Test that private key authentication completes sucessfully,
        """
        blob = keys.Key.fromString(keydata.publicRSA_openssh).blob()
        obj = keys.Key.fromString(keydata.privateRSA_openssh)
        packet = (NS('foo') + NS('none') + NS('publickey') + '\xff'
                + NS(obj.sshType()) + NS(blob))
        self.authServer.transport.sessionID = 'test'
        signature = obj.sign(NS('test') + chr(userauth.MSG_USERAUTH_REQUEST)
                + packet)
        packet += NS(signature)
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        def check(ignored):
            self.assertEquals(self.authServer.transport.packets,
                    [(userauth.MSG_USERAUTH_SUCCESS, '')])
        return d.addCallback(check)

Example 11

Project: mythbox
Source File: test_userauth.py
View license
    def test_verifyValidPrivateKey(self):
        """
        Test that verifying a valid private key works.
        """
        blob = keys.Key.fromString(keydata.publicRSA_openssh).blob()
        packet = (NS('foo') + NS('none') + NS('publickey') + '\x00'
                + NS('ssh-rsa') + NS(blob))
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        def check(ignored):
            self.assertEquals(self.authServer.transport.packets,
                    [(userauth.MSG_USERAUTH_PK_OK, NS('ssh-rsa') + NS(blob))])
        return d.addCallback(check)

Example 12

Project: mythbox
Source File: test_userauth.py
View license
    def test_failedPrivateKeyAuthenticationWithoutSignature(self):
        """
        Test that private key authentication fails when the public key
        is invalid.
        """
        blob = keys.Key.fromString(keydata.publicDSA_openssh).blob()
        packet = (NS('foo') + NS('none') + NS('publickey') + '\x00'
                + NS('ssh-dsa') + NS(blob))
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        return d.addCallback(self._checkFailed)

Example 13

Project: mythbox
Source File: test_userauth.py
View license
    def test_failedPrivateKeyAuthenticationWithSignature(self):
        """
        Test that private key authentication fails when the public key
        is invalid.
        """
        blob = keys.Key.fromString(keydata.publicRSA_openssh).blob()
        obj = keys.Key.fromString(keydata.privateRSA_openssh)
        packet = (NS('foo') + NS('none') + NS('publickey') + '\xff'
                + NS('ssh-rsa') + NS(blob) + NS(obj.sign(blob)))
        self.authServer.transport.sessionID = 'test'
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        return d.addCallback(self._checkFailed)

Example 14

Project: mythbox
Source File: test_userauth.py
View license
    def test_old_publickey_getPublicKey(self):
        """
        Old SSHUserAuthClients returned strings of public key blobs from
        getPublicKey().  Test that a Deprecation warning is raised but the key is
        verified correctly.
        """
        oldAuth = OldClientAuth('foo', FakeTransport.Service())
        oldAuth.transport = FakeTransport(None)
        oldAuth.transport.sessionID = 'test'
        oldAuth.serviceStarted()
        oldAuth.transport.packets = []
        self.assertWarns(DeprecationWarning, "Returning a string from "
                         "SSHUserAuthClient.getPublicKey() is deprecated since "
                         "Twisted 9.0.  Return a keys.Key() instead.",
                         userauth.__file__, oldAuth.tryAuth, 'publickey')
        self.assertEquals(oldAuth.transport.packets, [
                (userauth.MSG_USERAUTH_REQUEST, NS('foo') + NS('nancy') +
                 NS('publickey') + '\x00' + NS('ssh-rsa') +
                 NS(keys.Key.fromString(keydata.publicRSA_openssh).blob()))])

Example 15

View license
    def test_requestIdentities(self):
        """
        Assert that we get all of the keys/comments that we add when we issue a
        request for all identities.
        """
        d = self.client.requestIdentities()
        self.pump.flush()
        def _check(keyt):
            expected = {}
            expected[self.dsaPublic.blob()] = 'a comment'
            expected[self.rsaPublic.blob()] = 'another comment'

            received = {}
            for k in keyt:
                received[keys.Key.fromString(k[0], type='blob').blob()] = k[1]
            self.assertEqual(expected, received)
        return d.addCallback(_check)

Example 16

View license
    def test_requestIdentities(self):
        """
        Assert that we get all of the keys/comments that we add when we issue a
        request for all identities.
        """
        d = self.client.requestIdentities()
        self.pump.flush()
        def _check(keyt):
            expected = {}
            expected[self.dsaPublic.blob()] = 'a comment'
            expected[self.rsaPublic.blob()] = 'another comment'

            received = {}
            for k in keyt:
                received[keys.Key.fromString(k[0], type='blob').blob()] = k[1]
            self.assertEqual(expected, received)
        return d.addCallback(_check)

Example 17

Project: SubliminalCollaborator
Source File: test_ssh.py
View license
        def verifyHostKey(self, key, fp):
            keyMatch = key == keys.Key.fromString(publicRSA_openssh).blob()
            fingerprintMatch = (
                fp == '3d:13:5f:cb:c9:79:8a:93:06:27:65:bc:3d:0b:8f:af')
            if keyMatch and fingerprintMatch:
                return defer.succeed(1)
            return defer.fail(Exception("Key or fingerprint mismatch"))

Example 18

View license
    def requestAvatarId(self, creds):
        if creds.blob == keys.Key.fromString(keydata.publicRSA_openssh).blob():
            if creds.signature is not None:
                obj = keys.Key.fromString(creds.blob)
                if obj.verify(creds.signature, creds.sigData):
                    return creds.username
            else:
                raise ValidPublicKey()
        raise UnauthorizedLogin()

Example 19

View license
    def test_successfulPrivateKeyAuthentication(self):
        """
        Test that private key authentication completes sucessfully,
        """
        blob = keys.Key.fromString(keydata.publicRSA_openssh).blob()
        obj = keys.Key.fromString(keydata.privateRSA_openssh)
        packet = (NS('foo') + NS('none') + NS('publickey') + '\xff'
                + NS(obj.sshType()) + NS(blob))
        self.authServer.transport.sessionID = 'test'
        signature = obj.sign(NS('test') + chr(userauth.MSG_USERAUTH_REQUEST)
                + packet)
        packet += NS(signature)
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        def check(ignored):
            self.assertEqual(self.authServer.transport.packets,
                    [(userauth.MSG_USERAUTH_SUCCESS, '')])
        return d.addCallback(check)

Example 20

View license
    def test_verifyValidPrivateKey(self):
        """
        Test that verifying a valid private key works.
        """
        blob = keys.Key.fromString(keydata.publicRSA_openssh).blob()
        packet = (NS('foo') + NS('none') + NS('publickey') + '\x00'
                + NS('ssh-rsa') + NS(blob))
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        def check(ignored):
            self.assertEqual(self.authServer.transport.packets,
                    [(userauth.MSG_USERAUTH_PK_OK, NS('ssh-rsa') + NS(blob))])
        return d.addCallback(check)

Example 21

View license
    def test_failedPrivateKeyAuthenticationWithoutSignature(self):
        """
        Test that private key authentication fails when the public key
        is invalid.
        """
        blob = keys.Key.fromString(keydata.publicDSA_openssh).blob()
        packet = (NS('foo') + NS('none') + NS('publickey') + '\x00'
                + NS('ssh-dsa') + NS(blob))
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        return d.addCallback(self._checkFailed)

Example 22

View license
    def test_failedPrivateKeyAuthenticationWithSignature(self):
        """
        Test that private key authentication fails when the public key
        is invalid.
        """
        blob = keys.Key.fromString(keydata.publicRSA_openssh).blob()
        obj = keys.Key.fromString(keydata.privateRSA_openssh)
        packet = (NS('foo') + NS('none') + NS('publickey') + '\xff'
                + NS('ssh-rsa') + NS(blob) + NS(obj.sign(blob)))
        self.authServer.transport.sessionID = 'test'
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        return d.addCallback(self._checkFailed)

Example 23

View license
    def test_old_publickey_getPublicKey(self):
        """
        Old SSHUserAuthClients returned strings of public key blobs from
        getPublicKey().  Test that a Deprecation warning is raised but the key is
        verified correctly.
        """
        oldAuth = OldClientAuth('foo', FakeTransport.Service())
        oldAuth.transport = FakeTransport(None)
        oldAuth.transport.sessionID = 'test'
        oldAuth.serviceStarted()
        oldAuth.transport.packets = []
        self.assertWarns(DeprecationWarning, "Returning a string from "
                         "SSHUserAuthClient.getPublicKey() is deprecated since "
                         "Twisted 9.0.  Return a keys.Key() instead.",
                         userauth.__file__, oldAuth.tryAuth, 'publickey')
        self.assertEqual(oldAuth.transport.packets, [
                (userauth.MSG_USERAUTH_REQUEST, NS('foo') + NS('nancy') +
                 NS('publickey') + '\x00' + NS('ssh-rsa') +
                 NS(keys.Key.fromString(keydata.publicRSA_openssh).blob()))])

Example 24

Project: SubliminalCollaborator
Source File: test_ssh.py
View license
        def verifyHostKey(self, key, fp):
            keyMatch = key == keys.Key.fromString(publicRSA_openssh).blob()
            fingerprintMatch = (
                fp == '3d:13:5f:cb:c9:79:8a:93:06:27:65:bc:3d:0b:8f:af')
            if keyMatch and fingerprintMatch:
                return defer.succeed(1)
            return defer.fail(Exception("Key or fingerprint mismatch"))

Example 25

View license
    def requestAvatarId(self, creds):
        if creds.blob == keys.Key.fromString(keydata.publicRSA_openssh).blob():
            if creds.signature is not None:
                obj = keys.Key.fromString(creds.blob)
                if obj.verify(creds.signature, creds.sigData):
                    return creds.username
            else:
                raise ValidPublicKey()
        raise UnauthorizedLogin()

Example 26

View license
    def test_successfulPrivateKeyAuthentication(self):
        """
        Test that private key authentication completes sucessfully,
        """
        blob = keys.Key.fromString(keydata.publicRSA_openssh).blob()
        obj = keys.Key.fromString(keydata.privateRSA_openssh)
        packet = (NS('foo') + NS('none') + NS('publickey') + '\xff'
                + NS(obj.sshType()) + NS(blob))
        self.authServer.transport.sessionID = 'test'
        signature = obj.sign(NS('test') + chr(userauth.MSG_USERAUTH_REQUEST)
                + packet)
        packet += NS(signature)
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        def check(ignored):
            self.assertEqual(self.authServer.transport.packets,
                    [(userauth.MSG_USERAUTH_SUCCESS, '')])
        return d.addCallback(check)

Example 27

View license
    def test_verifyValidPrivateKey(self):
        """
        Test that verifying a valid private key works.
        """
        blob = keys.Key.fromString(keydata.publicRSA_openssh).blob()
        packet = (NS('foo') + NS('none') + NS('publickey') + '\x00'
                + NS('ssh-rsa') + NS(blob))
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        def check(ignored):
            self.assertEqual(self.authServer.transport.packets,
                    [(userauth.MSG_USERAUTH_PK_OK, NS('ssh-rsa') + NS(blob))])
        return d.addCallback(check)

Example 28

View license
    def test_failedPrivateKeyAuthenticationWithoutSignature(self):
        """
        Test that private key authentication fails when the public key
        is invalid.
        """
        blob = keys.Key.fromString(keydata.publicDSA_openssh).blob()
        packet = (NS('foo') + NS('none') + NS('publickey') + '\x00'
                + NS('ssh-dsa') + NS(blob))
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        return d.addCallback(self._checkFailed)

Example 29

View license
    def test_failedPrivateKeyAuthenticationWithSignature(self):
        """
        Test that private key authentication fails when the public key
        is invalid.
        """
        blob = keys.Key.fromString(keydata.publicRSA_openssh).blob()
        obj = keys.Key.fromString(keydata.privateRSA_openssh)
        packet = (NS('foo') + NS('none') + NS('publickey') + '\xff'
                + NS('ssh-rsa') + NS(blob) + NS(obj.sign(blob)))
        self.authServer.transport.sessionID = 'test'
        d = self.authServer.ssh_USERAUTH_REQUEST(packet)
        return d.addCallback(self._checkFailed)

Example 30

View license
    def test_old_publickey_getPublicKey(self):
        """
        Old SSHUserAuthClients returned strings of public key blobs from
        getPublicKey().  Test that a Deprecation warning is raised but the key is
        verified correctly.
        """
        oldAuth = OldClientAuth('foo', FakeTransport.Service())
        oldAuth.transport = FakeTransport(None)
        oldAuth.transport.sessionID = 'test'
        oldAuth.serviceStarted()
        oldAuth.transport.packets = []
        self.assertWarns(DeprecationWarning, "Returning a string from "
                         "SSHUserAuthClient.getPublicKey() is deprecated since "
                         "Twisted 9.0.  Return a keys.Key() instead.",
                         userauth.__file__, oldAuth.tryAuth, 'publickey')
        self.assertEqual(oldAuth.transport.packets, [
                (userauth.MSG_USERAUTH_REQUEST, NS('foo') + NS('nancy') +
                 NS('publickey') + '\x00' + NS('ssh-rsa') +
                 NS(keys.Key.fromString(keydata.publicRSA_openssh).blob()))])

Example 31

Project: graphite
Source File: manhole.py
View license
  def __init__(self, userKeys):
    self.userKeys = {}
    for username, keyData in userKeys.items():
      self.userKeys[username] = keys.Key.fromString(data=keyData).blob()

Example 32

Project: carbon
Source File: manhole.py
View license
  def __init__(self, userKeys):
    self.userKeys = {}
    for username, keyData in userKeys.items():
      self.userKeys[username] = keys.Key.fromString(data=keyData).blob()

Example 33

Project: mythbox
Source File: test_ssh.py
View license
        def checkKey(self, credentials):
            unittest.assertEquals(credentials.username, 'testuser', 'bad username')
            unittest.assertEquals(credentials.blob, keys.Key.fromString(publicDSA_openssh).blob())
            return 1

Example 34

Project: mythbox
Source File: test_ssh.py
View license
        def verifyHostKey(self, key, fp):
            unittest.assertEquals(key, keys.Key.fromString(publicRSA_openssh).blob())
            unittest.assertEquals(fp,'3d:13:5f:cb:c9:79:8a:93:06:27:65:bc:3d:0b:8f:af')
            return defer.succeed(1)

Example 35

Project: mythbox
Source File: test_userauth.py
View license
    def getPublicKey(self):
        return keys.Key.fromString(keydata.publicRSA_openssh).blob()

Example 36

Project: mythbox
Source File: test_userauth.py
View license
    def test_publickey(self):
        """
        Test that the client can authenticate with a public key.
        """
        self.authClient.ssh_USERAUTH_FAILURE(NS('publickey') + '\x00')
        self.assertEquals(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, NS('foo') + NS('nancy')
                    + NS('publickey') + '\x00' + NS('ssh-dss')
                    + NS(keys.Key.fromString(
                        keydata.publicDSA_openssh).blob())))
       # that key isn't good
        self.authClient.ssh_USERAUTH_FAILURE(NS('publickey') + '\x00')
        blob = NS(keys.Key.fromString(keydata.publicRSA_openssh).blob())
        self.assertEquals(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, (NS('foo') + NS('nancy')
                    + NS('publickey') + '\x00'+ NS('ssh-rsa') + blob)))
        self.authClient.ssh_USERAUTH_PK_OK(NS('ssh-rsa')
            + NS(keys.Key.fromString(keydata.publicRSA_openssh).blob()))
        sigData = (NS(self.authClient.transport.sessionID)
                + chr(userauth.MSG_USERAUTH_REQUEST) + NS('foo')
                + NS('nancy') + NS('publickey') + '\xff' + NS('ssh-rsa')
                + blob)
        obj = keys.Key.fromString(keydata.privateRSA_openssh)
        self.assertEquals(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, NS('foo') + NS('nancy')
                    + NS('publickey') + '\xff' + NS('ssh-rsa') + blob
                    + NS(obj.sign(sigData))))

Example 37

Project: mythbox
Source File: test_ssh.py
View license
        def checkKey(self, credentials):
            unittest.assertEquals(credentials.username, 'testuser', 'bad username')
            unittest.assertEquals(credentials.blob, keys.Key.fromString(publicDSA_openssh).blob())
            return 1

Example 38

Project: mythbox
Source File: test_ssh.py
View license
        def verifyHostKey(self, key, fp):
            unittest.assertEquals(key, keys.Key.fromString(publicRSA_openssh).blob())
            unittest.assertEquals(fp,'3d:13:5f:cb:c9:79:8a:93:06:27:65:bc:3d:0b:8f:af')
            return defer.succeed(1)

Example 39

Project: mythbox
Source File: test_userauth.py
View license
    def getPublicKey(self):
        return keys.Key.fromString(keydata.publicRSA_openssh).blob()

Example 40

Project: mythbox
Source File: test_userauth.py
View license
    def test_publickey(self):
        """
        Test that the client can authenticate with a public key.
        """
        self.authClient.ssh_USERAUTH_FAILURE(NS('publickey') + '\x00')
        self.assertEquals(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, NS('foo') + NS('nancy')
                    + NS('publickey') + '\x00' + NS('ssh-dss')
                    + NS(keys.Key.fromString(
                        keydata.publicDSA_openssh).blob())))
       # that key isn't good
        self.authClient.ssh_USERAUTH_FAILURE(NS('publickey') + '\x00')
        blob = NS(keys.Key.fromString(keydata.publicRSA_openssh).blob())
        self.assertEquals(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, (NS('foo') + NS('nancy')
                    + NS('publickey') + '\x00'+ NS('ssh-rsa') + blob)))
        self.authClient.ssh_USERAUTH_PK_OK(NS('ssh-rsa')
            + NS(keys.Key.fromString(keydata.publicRSA_openssh).blob()))
        sigData = (NS(self.authClient.transport.sessionID)
                + chr(userauth.MSG_USERAUTH_REQUEST) + NS('foo')
                + NS('nancy') + NS('publickey') + '\xff' + NS('ssh-rsa')
                + blob)
        obj = keys.Key.fromString(keydata.privateRSA_openssh)
        self.assertEquals(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, NS('foo') + NS('nancy')
                    + NS('publickey') + '\xff' + NS('ssh-rsa') + blob
                    + NS(obj.sign(sigData))))

Example 41

Project: SubliminalCollaborator
Source File: test_ssh.py
View license
        def checkKey(self, credentials):
            blob = keys.Key.fromString(publicDSA_openssh).blob()
            if credentials.username == 'testuser' and credentials.blob == blob:
                return True
            return False

Example 42

View license
    def getPublicKey(self):
        return keys.Key.fromString(keydata.publicRSA_openssh).blob()

Example 43

View license
    def test_publickey(self):
        """
        Test that the client can authenticate with a public key.
        """
        self.authClient.ssh_USERAUTH_FAILURE(NS('publickey') + '\x00')
        self.assertEqual(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, NS('foo') + NS('nancy')
                    + NS('publickey') + '\x00' + NS('ssh-dss')
                    + NS(keys.Key.fromString(
                        keydata.publicDSA_openssh).blob())))
       # that key isn't good
        self.authClient.ssh_USERAUTH_FAILURE(NS('publickey') + '\x00')
        blob = NS(keys.Key.fromString(keydata.publicRSA_openssh).blob())
        self.assertEqual(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, (NS('foo') + NS('nancy')
                    + NS('publickey') + '\x00'+ NS('ssh-rsa') + blob)))
        self.authClient.ssh_USERAUTH_PK_OK(NS('ssh-rsa')
            + NS(keys.Key.fromString(keydata.publicRSA_openssh).blob()))
        sigData = (NS(self.authClient.transport.sessionID)
                + chr(userauth.MSG_USERAUTH_REQUEST) + NS('foo')
                + NS('nancy') + NS('publickey') + '\x01' + NS('ssh-rsa')
                + blob)
        obj = keys.Key.fromString(keydata.privateRSA_openssh)
        self.assertEqual(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, NS('foo') + NS('nancy')
                    + NS('publickey') + '\x01' + NS('ssh-rsa') + blob
                    + NS(obj.sign(sigData))))

Example 44

Project: SubliminalCollaborator
Source File: test_ssh.py
View license
        def checkKey(self, credentials):
            blob = keys.Key.fromString(publicDSA_openssh).blob()
            if credentials.username == 'testuser' and credentials.blob == blob:
                return True
            return False

Example 45

View license
    def getPublicKey(self):
        return keys.Key.fromString(keydata.publicRSA_openssh).blob()

Example 46

View license
    def test_publickey(self):
        """
        Test that the client can authenticate with a public key.
        """
        self.authClient.ssh_USERAUTH_FAILURE(NS('publickey') + '\x00')
        self.assertEqual(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, NS('foo') + NS('nancy')
                    + NS('publickey') + '\x00' + NS('ssh-dss')
                    + NS(keys.Key.fromString(
                        keydata.publicDSA_openssh).blob())))
       # that key isn't good
        self.authClient.ssh_USERAUTH_FAILURE(NS('publickey') + '\x00')
        blob = NS(keys.Key.fromString(keydata.publicRSA_openssh).blob())
        self.assertEqual(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, (NS('foo') + NS('nancy')
                    + NS('publickey') + '\x00'+ NS('ssh-rsa') + blob)))
        self.authClient.ssh_USERAUTH_PK_OK(NS('ssh-rsa')
            + NS(keys.Key.fromString(keydata.publicRSA_openssh).blob()))
        sigData = (NS(self.authClient.transport.sessionID)
                + chr(userauth.MSG_USERAUTH_REQUEST) + NS('foo')
                + NS('nancy') + NS('publickey') + '\x01' + NS('ssh-rsa')
                + blob)
        obj = keys.Key.fromString(keydata.privateRSA_openssh)
        self.assertEqual(self.authClient.transport.packets[-1],
                (userauth.MSG_USERAUTH_REQUEST, NS('foo') + NS('nancy')
                    + NS('publickey') + '\x01' + NS('ssh-rsa') + blob
                    + NS(obj.sign(sigData))))