def getPrivateKey(self):
        """
        Try to load the private key from the last used file identified by
        C{getPublicKey}, potentially asking for the passphrase if the key is
        encrypted.
        """
        file = os.path.expanduser(self.usedFiles[-1])
        if not os.path.exists(file):
            return None
        try:
            return defer.succeed(keys.Key.fromFile(file))
        except keys.EncryptedKeyError:
            for i in range(3):
                prompt = "Enter passphrase for key '%s': " % \
                    self.usedFiles[-1]
                try:
                    p = self._getPassword(prompt)
                    return defer.succeed(keys.Key.fromFile(file, passphrase=p))
                except (keys.BadKeyError, ConchError):
                    pass
                return defer.fail(ConchError('bad password'))
            raise
        except __HOLE__:
            print
            reactor.stop()
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/conch/client/default.py/SSHUserAuthClient.getPrivateKey