forked from qt-creator/qt-creator
Revert "SSH: Work around issue with dynamic_cast."
This reverts commit 6f7ce3f48e.
The workaround turned out to be incomplete and has therefore
been superseded.
Change-Id: Ic60cd810f72ca833c1725024d2816baf5ce47372
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
41
src/libs/3rdparty/botan/botan.cpp
vendored
41
src/libs/3rdparty/botan/botan.cpp
vendored
@@ -47182,44 +47182,3 @@ u32bit version_minor() { return BOTAN_VERSION_MINOR; }
|
||||
u32bit version_patch() { return BOTAN_VERSION_PATCH; }
|
||||
|
||||
}
|
||||
|
||||
namespace Botan {
|
||||
PublicKeyPtr createRsaPublicKey(const BigInt &e, const BigInt &n)
|
||||
{
|
||||
return PublicKeyPtr(new RSA_PublicKey(e, n));
|
||||
}
|
||||
|
||||
PublicKeyPtr createDsaPublicKey(const DL_Group &group, const BigInt &y)
|
||||
{
|
||||
return PublicKeyPtr(new DSA_PublicKey(group, y));
|
||||
}
|
||||
|
||||
PrivateKeyPtr createRsaPrivateKey(RandomNumberGenerator &rng, const BigInt &p, const BigInt &q,
|
||||
const BigInt &e, const BigInt &d, const BigInt &n)
|
||||
{
|
||||
return PrivateKeyPtr(new RSA_PrivateKey(rng, p, q, e, d, n));
|
||||
}
|
||||
|
||||
PrivateKeyPtr createRsaPrivateKey(RandomNumberGenerator &rng, size_t bits, size_t exp)
|
||||
{
|
||||
return PrivateKeyPtr(new RSA_PrivateKey(rng, bits, exp));
|
||||
}
|
||||
|
||||
PrivateKeyPtr createDsaPrivateKey(RandomNumberGenerator &rng, const DL_Group &group,
|
||||
const BigInt &private_key)
|
||||
{
|
||||
return PrivateKeyPtr(new DSA_PrivateKey(rng, group, private_key));
|
||||
}
|
||||
|
||||
PrivateKeyPtr loadPkcs8PrivateKey(DataSource& source, RandomNumberGenerator& rng,
|
||||
const User_Interface& ui)
|
||||
{
|
||||
return PrivateKeyPtr(PKCS8::load_key(source, rng, ui));
|
||||
}
|
||||
|
||||
DhPrivateKeyPtr createDhPrivateKey(RandomNumberGenerator &rng, const DL_Group &grp, const BigInt &x)
|
||||
{
|
||||
return DhPrivateKeyPtr(new DH_PrivateKey(rng, grp, x));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
20
src/libs/3rdparty/botan/botan.h
vendored
20
src/libs/3rdparty/botan/botan.h
vendored
@@ -9,7 +9,6 @@
|
||||
#define BOTAN_AMALGAMATION_H__
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include <iosfwd>
|
||||
#include <map>
|
||||
@@ -16182,26 +16181,7 @@ class BOTAN_DLL ANSI_X919_MAC : public MessageAuthenticationCode
|
||||
SecureVector<byte> state;
|
||||
size_t position;
|
||||
};
|
||||
}
|
||||
|
||||
namespace Botan {
|
||||
typedef QSharedPointer<Public_Key> PublicKeyPtr;
|
||||
BOTAN_DLL PublicKeyPtr createRsaPublicKey(const BigInt &e, const BigInt &n);
|
||||
BOTAN_DLL PublicKeyPtr createDsaPublicKey(const DL_Group& group, const BigInt& y);
|
||||
|
||||
typedef QSharedPointer<Private_Key> PrivateKeyPtr;
|
||||
BOTAN_DLL PrivateKeyPtr createRsaPrivateKey(RandomNumberGenerator& rng, const BigInt& p,
|
||||
const BigInt& q, const BigInt& e, const BigInt& d = 0, const BigInt& n = 0);
|
||||
BOTAN_DLL PrivateKeyPtr createRsaPrivateKey(RandomNumberGenerator& rng, size_t bits,
|
||||
size_t exp = 65537);
|
||||
BOTAN_DLL PrivateKeyPtr createDsaPrivateKey(RandomNumberGenerator& rng, const DL_Group& group,
|
||||
const BigInt& private_key = 0);
|
||||
BOTAN_DLL PrivateKeyPtr loadPkcs8PrivateKey(DataSource& source, RandomNumberGenerator& rng,
|
||||
const User_Interface& ui);
|
||||
|
||||
typedef QSharedPointer<DH_PrivateKey> DhPrivateKeyPtr;
|
||||
BOTAN_DLL DhPrivateKeyPtr createDhPrivateKey(RandomNumberGenerator& rng, const DL_Group& grp,
|
||||
const BigInt& x = 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -217,14 +217,16 @@ bool SshEncryptionFacility::createAuthenticationKeyFromPKCS8(const QByteArray &p
|
||||
try {
|
||||
Pipe pipe;
|
||||
pipe.process_msg(convertByteArray(privKeyFileContents), privKeyFileContents.size());
|
||||
const PrivateKeyPtr authKey = loadPkcs8PrivateKey(pipe, m_rng, SshKeyPasswordRetriever());
|
||||
if (DSA_PrivateKey * const dsaKey = dynamic_cast<DSA_PrivateKey *>(authKey.data())) {
|
||||
Private_Key * const key = PKCS8::load_key(pipe, m_rng, SshKeyPasswordRetriever());
|
||||
if (DSA_PrivateKey * const dsaKey = dynamic_cast<DSA_PrivateKey *>(key)) {
|
||||
m_authKeyAlgoName = SshCapabilities::PubKeyDss;
|
||||
m_authKey.reset(dsaKey);
|
||||
pubKeyParams << dsaKey->group_p() << dsaKey->group_q()
|
||||
<< dsaKey->group_g() << dsaKey->get_y();
|
||||
allKeyParams << pubKeyParams << dsaKey->get_x();
|
||||
} else if (RSA_PrivateKey * const rsaKey = dynamic_cast<RSA_PrivateKey *>(authKey.data())) {
|
||||
} else if (RSA_PrivateKey * const rsaKey = dynamic_cast<RSA_PrivateKey *>(key)) {
|
||||
m_authKeyAlgoName = SshCapabilities::PubKeyRsa;
|
||||
m_authKey.reset(rsaKey);
|
||||
pubKeyParams << rsaKey->get_e() << rsaKey->get_n();
|
||||
allKeyParams << pubKeyParams << rsaKey->get_p() << rsaKey->get_q()
|
||||
<< rsaKey->get_d();
|
||||
@@ -232,7 +234,6 @@ bool SshEncryptionFacility::createAuthenticationKeyFromPKCS8(const QByteArray &p
|
||||
qWarning("%s: Unexpected code flow, expected success or exception.", Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
m_authKey = authKey;
|
||||
} catch (const Botan::Exception &ex) {
|
||||
error = QLatin1String(ex.what());
|
||||
return false;
|
||||
@@ -289,13 +290,15 @@ bool SshEncryptionFacility::createAuthenticationKeyFromOpenSSL(const QByteArray
|
||||
if (m_authKeyAlgoName == SshCapabilities::PubKeyDss) {
|
||||
BigInt p, q, g, y, x;
|
||||
sequence.decode (p).decode (q).decode (g).decode (y).decode (x);
|
||||
m_authKey = createDsaPrivateKey(m_rng, DL_Group(p, q, g), x);
|
||||
DSA_PrivateKey * const dsaKey = new DSA_PrivateKey(m_rng, DL_Group(p, q, g), x);
|
||||
m_authKey.reset(dsaKey);
|
||||
pubKeyParams << p << q << g << y;
|
||||
allKeyParams << pubKeyParams << x;
|
||||
} else {
|
||||
BigInt p, q, e, d, n;
|
||||
sequence.decode(n).decode(e).decode(d).decode(p).decode(q);
|
||||
m_authKey = createRsaPrivateKey(m_rng, p, q, e, d, n);
|
||||
RSA_PrivateKey * const rsaKey = new RSA_PrivateKey(m_rng, p, q, e, d, n);
|
||||
m_authKey.reset(rsaKey);
|
||||
pubKeyParams << e << n;
|
||||
allKeyParams << pubKeyParams << p << q << d;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ private:
|
||||
QByteArray m_authKeyAlgoName;
|
||||
QByteArray m_authPubKeyBlob;
|
||||
QByteArray m_cachedPrivKeyContents;
|
||||
QSharedPointer<Botan::Private_Key> m_authKey;
|
||||
QScopedPointer<Botan::Private_Key> m_authKey;
|
||||
mutable Botan::AutoSeeded_RNG m_rng;
|
||||
};
|
||||
|
||||
|
||||
@@ -135,7 +135,8 @@ bool SshKeyExchange::sendDhInitPacket(const SshIncomingPacket &serverKexInit)
|
||||
kexInitParams.compressionAlgorithmsServerToClient.names);
|
||||
|
||||
AutoSeeded_RNG rng;
|
||||
m_dhKey = createDhPrivateKey(rng, DL_Group(botanKeyExchangeAlgoName(keyAlgo)));
|
||||
m_dhKey.reset(new DH_PrivateKey(rng,
|
||||
DL_Group(botanKeyExchangeAlgoName(keyAlgo))));
|
||||
|
||||
m_serverKexInitPayload = serverKexInit.payLoad();
|
||||
m_sendFacility.sendKeyDhInitPacket(m_dhKey->get_y());
|
||||
@@ -182,24 +183,28 @@ void SshKeyExchange::sendNewKeysPacket(const SshIncomingPacket &dhReply,
|
||||
printData("H", m_h);
|
||||
#endif // CREATOR_SSH_DEBUG
|
||||
|
||||
QSharedPointer<Public_Key> publicKey;
|
||||
QByteArray algorithm;
|
||||
QScopedPointer<Public_Key> sigKey;
|
||||
QScopedPointer<PK_Verifier> verifier;
|
||||
if (m_serverHostKeyAlgo == SshCapabilities::PubKeyDss) {
|
||||
const DL_Group group(reply.parameters.at(0), reply.parameters.at(1),
|
||||
reply.parameters.at(2));
|
||||
publicKey = createDsaPublicKey(group, reply.parameters.at(3));
|
||||
algorithm = SshCapabilities::PubKeyDss;
|
||||
DSA_PublicKey * const dsaKey
|
||||
= new DSA_PublicKey(group, reply.parameters.at(3));
|
||||
sigKey.reset(dsaKey);
|
||||
verifier.reset(new PK_Verifier(*dsaKey, botanEmsaAlgoName(SshCapabilities::PubKeyDss)));
|
||||
} else if (m_serverHostKeyAlgo == SshCapabilities::PubKeyRsa) {
|
||||
publicKey = createRsaPublicKey(reply.parameters.at(1), reply.parameters.at(0));
|
||||
algorithm = SshCapabilities::PubKeyRsa;
|
||||
RSA_PublicKey * const rsaKey
|
||||
= new RSA_PublicKey(reply.parameters.at(1), reply.parameters.at(0));
|
||||
sigKey.reset(rsaKey);
|
||||
verifier.reset(new PK_Verifier(*rsaKey, botanEmsaAlgoName(SshCapabilities::PubKeyRsa)));
|
||||
} else {
|
||||
Q_ASSERT(!"Impossible: Neither DSS nor RSA!");
|
||||
}
|
||||
const byte * const botanH = convertByteArray(m_h);
|
||||
const Botan::byte * const botanSig
|
||||
= convertByteArray(reply.signatureBlob);
|
||||
if (!PK_Verifier(*publicKey, botanEmsaAlgoName(algorithm)).verify_message(botanH, m_h.size(),
|
||||
botanSig, reply.signatureBlob.size())) {
|
||||
if (!verifier->verify_message(botanH, m_h.size(), botanSig,
|
||||
reply.signatureBlob.size())) {
|
||||
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_KEY_EXCHANGE_FAILED,
|
||||
"Invalid signature in SSH_MSG_KEXDH_REPLY packet.");
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QScopedPointer>
|
||||
#include <QSharedPointer>
|
||||
|
||||
namespace Botan {
|
||||
class DH_PrivateKey;
|
||||
@@ -71,7 +70,7 @@ private:
|
||||
QByteArray m_serverId;
|
||||
QByteArray m_clientKexInitPayload;
|
||||
QByteArray m_serverKexInitPayload;
|
||||
QSharedPointer<Botan::DH_PrivateKey> m_dhKey;
|
||||
QScopedPointer<Botan::DH_PrivateKey> m_dhKey;
|
||||
QByteArray m_k;
|
||||
QByteArray m_h;
|
||||
QByteArray m_serverHostKeyAlgo;
|
||||
|
||||
@@ -59,9 +59,9 @@ bool SshKeyGenerator::generateKeys(KeyType type, PrivateKeyFormat format, int ke
|
||||
AutoSeeded_RNG rng;
|
||||
KeyPtr key;
|
||||
if (m_type == Rsa)
|
||||
key = createRsaPrivateKey(rng, keySize);
|
||||
key = KeyPtr(new RSA_PrivateKey(rng, keySize));
|
||||
else
|
||||
key = createDsaPrivateKey(rng, DL_Group(rng, DL_Group::DSA_Kosherizer, keySize));
|
||||
key = KeyPtr(new DSA_PrivateKey(rng, DL_Group(rng, DL_Group::DSA_Kosherizer, keySize)));
|
||||
switch (format) {
|
||||
case Pkcs8:
|
||||
generatePkcs8KeyStrings(key, rng);
|
||||
|
||||
Reference in New Issue
Block a user