diff --git a/src/libs/utils/ssh/sshcryptofacility.cpp b/src/libs/utils/ssh/sshcryptofacility.cpp index 8f0afe748d2..b8a85c961d5 100644 --- a/src/libs/utils/ssh/sshcryptofacility.cpp +++ b/src/libs/utils/ssh/sshcryptofacility.cpp @@ -36,6 +36,7 @@ #include "sshcapabilities_p.h" #include "sshexception_p.h" #include "sshkeyexchange_p.h" +#include "sshkeypasswordretriever_p.h" #include "sshpacket_p.h" #include @@ -226,7 +227,7 @@ void SshEncryptionFacility::createAuthenticationKeyFromPKCS8(const QByteArray &p Pipe pipe; pipe.process_msg(convertByteArray(privKeyFileContents), privKeyFileContents.size()); - Private_Key * const key = PKCS8::load_key(pipe, m_rng); + Private_Key * const key = PKCS8::load_key(pipe, m_rng, SshKeyPasswordRetriever()); if (DSA_PrivateKey * const dsaKey = dynamic_cast(key)) { m_authKeyAlgoName = SshCapabilities::PubKeyDss; m_authKey.reset(dsaKey); diff --git a/src/libs/utils/ssh/sshkeypasswordretriever.cpp b/src/libs/utils/ssh/sshkeypasswordretriever.cpp new file mode 100644 index 00000000000..976495c872f --- /dev/null +++ b/src/libs/utils/ssh/sshkeypasswordretriever.cpp @@ -0,0 +1,54 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "sshkeypasswordretriever_p.h" + +#include +#include +#include + +namespace Utils { +namespace Internal { + +std::string SshKeyPasswordRetriever::get_passphrase(const std::string &, const std::string &, + UI_Result &result) const +{ + bool ok; + const QString &password = QInputDialog::getText(0, + QCoreApplication::translate("Utils::Ssh", "Password required"), + QCoreApplication::translate("Utils::Ssh", "Please enter the password for your private key."), + QLineEdit::Password, QString(), &ok); + result = ok ? OK : CANCEL_ACTION; + return std::string(password.toLocal8Bit().data()); +} + +} // namespace Internal +} // namespace Utils diff --git a/src/libs/utils/ssh/sshkeypasswordretriever_p.h b/src/libs/utils/ssh/sshkeypasswordretriever_p.h new file mode 100644 index 00000000000..95701d83b0c --- /dev/null +++ b/src/libs/utils/ssh/sshkeypasswordretriever_p.h @@ -0,0 +1,52 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef KEYPASSWORDRETRIEVER_H +#define KEYPASSWORDRETRIEVER_H + +#include + +#include + +namespace Utils { +namespace Internal { + +class SshKeyPasswordRetriever : public Botan::User_Interface +{ +public: + std::string get_passphrase(const std::string &what, const std::string &source, + UI_Result &result) const; +}; + +} // namespace Internal +} // namespace Utils + +#endif // KEYPASSWORDRETRIEVER_H diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri index 230e9464acf..2dfb07dde68 100644 --- a/src/libs/utils/utils-lib.pri +++ b/src/libs/utils/utils-lib.pri @@ -86,6 +86,7 @@ SOURCES += $$PWD/environment.cpp \ $$PWD/ssh/sftpchannel.cpp \ $$PWD/ssh/sshremoteprocessrunner.cpp \ $$PWD/ssh/sshconnectionmanager.cpp \ + $$PWD/ssh/sshkeypasswordretriever.cpp \ $$PWD/outputformatter.cpp \ $$PWD/flowlayout.cpp \ $$PWD/networkaccessmanager.cpp @@ -187,6 +188,7 @@ HEADERS += \ $$PWD/ssh/sshremoteprocessrunner.h \ $$PWD/ssh/sshconnectionmanager.h \ $$PWD/ssh/sshpseudoterminal.h \ + $$PWD/ssh/sshkeypasswordretriever_p.h \ $$PWD/statuslabel.h \ $$PWD/outputformatter.h \ $$PWD/outputformat.h \