Commit b72c3cba authored by Christian Kandeler's avatar Christian Kandeler

SSH: Use categorized logging.

Change-Id: I9890c7d4a86320c835e70e66c523c5a2f7b41421
Reviewed-by: default avatarMichal Klocek <michal.klocek@theqtcompany.com>
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
parent 54d64971
......@@ -33,6 +33,7 @@
#include "sshexception_p.h"
#include "sshincomingpacket_p.h"
#include "sshlogging_p.h"
#include "sshsendfacility_p.h"
#include <QDir>
......@@ -256,9 +257,7 @@ void SftpChannelPrivate::handleChannelSuccess()
{
if (channelState() == CloseRequested)
return;
#ifdef CREATOR_SSH_DEBUG
qDebug("sftp subsystem initialized");
#endif
qCDebug(sshLog, "sftp subsystem initialized");
sendData(m_outgoingPacket.generateInit(ProtocolVersion).rawData());
m_sftpState = InitSent;
}
......@@ -293,15 +292,13 @@ void SftpChannelPrivate::handleChannelDataInternal(const QByteArray &data)
void SftpChannelPrivate::handleChannelExtendedDataInternal(quint32 type,
const QByteArray &data)
{
qWarning("Unexpected extended data '%s' of type %d on SFTP channel.",
data.data(), type);
qCWarning(sshLog, "Unexpected extended data '%s' of type %d on SFTP channel.",
data.data(), type);
}
void SftpChannelPrivate::handleExitStatus(const SshChannelExitStatus &exitStatus)
{
#ifdef CREATOR_SSH_DEBUG
qDebug("Remote SFTP service exited with exit code %d", exitStatus.exitStatus);
#endif
qCDebug(sshLog, "Remote SFTP service exited with exit code %d", exitStatus.exitStatus);
if (channelState() == CloseRequested || channelState() == Closed)
return;
......@@ -322,9 +319,7 @@ void SftpChannelPrivate::handleExitSignal(const SshChannelExitSignal &signal)
void SftpChannelPrivate::handleCurrentPacket()
{
#ifdef CREATOR_SSH_DEBUG
qDebug("Handling SFTP packet of type %d", m_incomingPacket.type());
#endif
qCDebug(sshLog, "Handling SFTP packet of type %d", m_incomingPacket.type());
switch (m_incomingPacket.type()) {
case SSH_FXP_VERSION:
handleServerVersion();
......@@ -359,9 +354,7 @@ void SftpChannelPrivate::handleServerVersion()
"Unexpected SSH_FXP_VERSION packet.");
}
#ifdef CREATOR_SSH_DEBUG
qDebug("sftp init received");
#endif
qCDebug(sshLog, "sftp init received");
const quint32 serverVersion = m_incomingPacket.extractServerVersion();
if (serverVersion != ProtocolVersion) {
emit channelError(tr("Protocol version mismatch: Expected %1, got %2")
......@@ -450,9 +443,7 @@ void SftpChannelPrivate::handlePutHandle(const JobMap::Iterator &it)
void SftpChannelPrivate::handleStatus()
{
const SftpStatusResponse &response = m_incomingPacket.asStatusResponse();
#ifdef CREATOR_SSH_DEBUG
qDebug("%s: status = %d", Q_FUNC_INFO, response.status);
#endif
qCDebug(sshLog, "%s: status = %d", Q_FUNC_INFO, response.status);
JobMap::Iterator it = lookupJob(response.requestId);
switch (it.value()->type()) {
case AbstractSftpOperation::ListDir:
......@@ -850,9 +841,7 @@ void SftpChannelPrivate::closeHook()
void SftpChannelPrivate::handleOpenSuccessInternal()
{
#ifdef CREATOR_SSH_DEBUG
qDebug("SFTP session started");
#endif
qCDebug(sshLog, "SFTP session started");
m_sendFacility.sendSftpPacket(remoteChannel());
m_sftpState = SubsystemRequested;
}
......
......@@ -31,6 +31,7 @@
#include "sftpincomingpacket_p.h"
#include "sshexception_p.h"
#include "sshlogging_p.h"
#include "sshpacketparser_p.h"
namespace QSsh {
......@@ -42,10 +43,8 @@ SftpIncomingPacket::SftpIncomingPacket() : m_length(0)
void SftpIncomingPacket::consumeData(QByteArray &newData)
{
#ifdef CREATOR_SSH_DEBUG
qDebug("%s: current data size = %d, new data size = %d", Q_FUNC_INFO,
qCDebug(sshLog, "%s: current data size = %d, new data size = %d", Q_FUNC_INFO,
m_data.size(), newData.size());
#endif
if (isComplete() || dataSize() + newData.size() < sizeof m_length)
return;
......
......@@ -30,6 +30,7 @@
#include "sftpoutgoingpacket_p.h"
#include "sshlogging_p.h"
#include "sshpacket_p.h"
#include <QtEndian>
......@@ -183,10 +184,7 @@ SftpOutgoingPacket &SftpOutgoingPacket::init(SftpPacketType type,
m_data[TypeOffset] = type;
if (type != SSH_FXP_INIT) {
appendInt(requestId);
#ifdef CREATOR_SSH_DEBUG
qDebug("Generating SFTP packet of type %d with request id %u", type,
requestId);
#endif
qCDebug(sshLog, "Generating SFTP packet of type %d with request id %u", type, requestId);
}
return *this;
}
......
......@@ -29,6 +29,7 @@ SOURCES = $$PWD/sshsendfacility.cpp \
$$PWD/sshkeycreationdialog.cpp \
$$PWD/sshinit.cpp \
$$PWD/sshdirecttcpiptunnel.cpp \
$$PWD/sshlogging.cpp \
$$PWD/sshhostkeydatabase.cpp
HEADERS = $$PWD/sshsendfacility_p.h \
......@@ -66,6 +67,7 @@ HEADERS = $$PWD/sshsendfacility_p.h \
$$PWD/sshdirecttcpiptunnel_p.h \
$$PWD/sshinit_p.h \
$$PWD/sshdirecttcpiptunnel.h \
$$PWD/sshlogging_p.h \
$$PWD/sshhostkeydatabase.h
FORMS = $$PWD/sshkeycreationdialog.ui
......
......@@ -36,6 +36,7 @@ QtcLibrary {
"sshkeygenerator.cpp", "sshkeygenerator.h",
"sshkeypasswordretriever.cpp",
"sshkeypasswordretriever_p.h",
"sshlogging.cpp", "sshlogging_p.h",
"sshoutgoingpacket.cpp", "sshoutgoingpacket_p.h",
"sshpacket.cpp", "sshpacket_p.h",
"sshpacketparser.cpp", "sshpacketparser_p.h",
......
......@@ -31,6 +31,7 @@
#include "sshchannel_p.h"
#include "sshincomingpacket_p.h"
#include "sshlogging_p.h"
#include "sshsendfacility_p.h"
#include <botan/botan.h>
......@@ -80,7 +81,7 @@ void AbstractSshChannel::requestSessionStart()
setChannelState(SessionRequested);
m_timeoutTimer.start(ReplyTimeout);
} catch (const Botan::Exception &e) {
qDebug("Botan error: %s", e.what());
qCWarning(sshLog, "Botan error: %s", e.what());
closeChannel();
}
}
......@@ -91,7 +92,7 @@ void AbstractSshChannel::sendData(const QByteArray &data)
m_sendBuffer += data;
flushSendBuffer();
} catch (const Botan::Exception &e) {
qDebug("Botan error: %s", e.what());
qCWarning(sshLog, "Botan error: %s", e.what());
closeChannel();
}
}
......@@ -154,11 +155,9 @@ void AbstractSshChannel::handleOpenSuccess(quint32 remoteChannelId,
"Maximum packet size too low.");
}
#ifdef CREATOR_SSH_DEBUG
qDebug("Channel opened. remote channel id: %u, remote window size: %u, "
qCDebug(sshLog, "Channel opened. remote channel id: %u, remote window size: %u, "
"remote max packet size: %u",
remoteChannelId, remoteWindowSize, remoteMaxPacketSize);
#endif
m_remoteChannel = remoteChannelId;
m_remoteWindowSize = remoteWindowSize;
m_remoteMaxPacketSize = remoteMaxPacketSize;
......@@ -183,9 +182,7 @@ void AbstractSshChannel::handleOpenFailure(const QString &reason)
m_timeoutTimer.stop();
#ifdef CREATOR_SSH_DEBUG
qDebug("Channel open request failed for channel %u", m_localChannel);
#endif
qCDebug(sshLog, "Channel open request failed for channel %u", m_localChannel);
handleOpenFailureInternal(reason);
}
......@@ -201,9 +198,7 @@ void AbstractSshChannel::handleChannelEof()
void AbstractSshChannel::handleChannelClose()
{
#ifdef CREATOR_SSH_DEBUG
qDebug("Receiving CLOSE for channel %u", m_localChannel);
#endif
qCDebug(sshLog, "Receiving CLOSE for channel %u", m_localChannel);
if (channelState() == Inactive || channelState() == Closed) {
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR,
"Unexpected SSH_MSG_CHANNEL_CLOSE message.");
......@@ -235,7 +230,7 @@ void AbstractSshChannel::handleChannelRequest(const SshIncomingPacket &packet)
else if (requestType == SshIncomingPacket::ExitSignalType)
handleExitSignal(packet.extractChannelExitSignal());
else if (requestType != "eow@openssh.com") // Suppress warning for this one, as it's sent all the time.
qWarning("Ignoring unknown request type '%s'", requestType.data());
qCWarning(sshLog, "Ignoring unknown request type '%s'", requestType.data());
}
int AbstractSshChannel::handleChannelOrExtendedChannelData(const QByteArray &data)
......@@ -244,7 +239,7 @@ int AbstractSshChannel::handleChannelOrExtendedChannelData(const QByteArray &dat
const int bytesToDeliver = qMin<quint32>(data.size(), maxDataSize());
if (bytesToDeliver != data.size())
qWarning("Misbehaving server does not respect local window, clipping.");
qCWarning(sshLog, "Misbehaving server does not respect local window, clipping.");
m_localWindowSize -= bytesToDeliver;
if (m_localWindowSize < maxPacketSize()) {
......
......@@ -39,6 +39,7 @@
#include "sshexception_p.h"
#include "sshinit_p.h"
#include "sshkeyexchange_p.h"
#include "sshlogging_p.h"
#include "sshremoteprocess.h"
#include <botan/botan.h>
......@@ -196,7 +197,7 @@ int SshConnection::closeAllChannels()
try {
return d->m_channelManager->closeAllChannels(Internal::SshChannelManager::CloseAllRegular);
} catch (const Botan::Exception &e) {
qDebug("%s: %s", Q_FUNC_INFO, e.what());
qCWarning(Internal::sshLog, "%s: %s", Q_FUNC_INFO, e.what());
return -1;
}
}
......@@ -324,10 +325,7 @@ void SshConnectionPrivate::handleIncomingData()
if (!canUseSocket())
return;
m_incomingData += m_socket->readAll();
#ifdef CREATOR_SSH_DEBUG
qDebug("state = %d, remote data size = %d", m_state,
m_incomingData.count());
#endif
qCDebug(sshLog, "state = %d, remote data size = %d", m_state, m_incomingData.count());
if (m_serverId.isEmpty())
handleServerId();
handlePackets();
......@@ -346,10 +344,8 @@ void SshConnectionPrivate::handleIncomingData()
// RFC 4253, 4.2.
void SshConnectionPrivate::handleServerId()
{
#ifdef CREATOR_SSH_DEBUG
qDebug("%s: incoming data size = %d, incoming data = '%s'",
qCDebug(sshLog, "%s: incoming data size = %d, incoming data = '%s'",
Q_FUNC_INFO, m_incomingData.count(), m_incomingData.data());
#endif
const int newLinePos = m_incomingData.indexOf('\n');
if (newLinePos == -1)
return; // Not enough data yet.
......
......@@ -35,6 +35,7 @@
#include "sshexception_p.h"
#include "sshkeyexchange_p.h"
#include "sshkeypasswordretriever_p.h"
#include "sshlogging_p.h"
#include "sshpacket_p.h"
#include <botan/botan.h>
......@@ -213,9 +214,7 @@ void SshEncryptionFacility::createAuthenticationKey(const QByteArray &privKeyFil
return;
m_authKeyAlgoName.clear();
#ifdef CREATOR_SSH_DEBUG
qDebug("%s: Key not cached, reading", Q_FUNC_INFO);
#endif
qCDebug(sshLog, "%s: Key not cached, reading", Q_FUNC_INFO);
QList<BigInt> pubKeyParams;
QList<BigInt> allKeyParams;
QString error1;
......@@ -223,9 +222,7 @@ void SshEncryptionFacility::createAuthenticationKey(const QByteArray &privKeyFil
if (!createAuthenticationKeyFromPKCS8(privKeyFileContents, pubKeyParams, allKeyParams, error1)
&& !createAuthenticationKeyFromOpenSSL(privKeyFileContents, pubKeyParams, allKeyParams,
error2)) {
#ifdef CREATOR_SSH_DEBUG
qDebug("%s: %s\n\t%s\n", Q_FUNC_INFO, qPrintable(error1), qPrintable(error2));
#endif
qCDebug(sshLog, "%s: %s\n\t%s\n", Q_FUNC_INFO, qPrintable(error1), qPrintable(error2));
throw SshClientException(SshKeyFileError, SSH_TR("Decoding of private key file failed: "
"Format not understood."));
}
......@@ -274,7 +271,8 @@ bool SshEncryptionFacility::createAuthenticationKeyFromPKCS8(const QByteArray &p
<< ecdsaKey->public_point().get_affine_y();
allKeyParams << pubKeyParams << value;
} else {
qWarning("%s: Unexpected code flow, expected success or exception.", Q_FUNC_INFO);
qCWarning(sshLog, "%s: Unexpected code flow, expected success or exception.",
Q_FUNC_INFO);
return false;
}
} catch (const Exception &ex) {
......@@ -438,13 +436,11 @@ void SshDecryptionFacility::decrypt(QByteArray &data, quint32 offset,
quint32 dataSize) const
{
convert(data, offset, dataSize);
#ifdef CREATOR_SSH_DEBUG
qDebug("Decrypted data:");
qCDebug(sshLog, "Decrypted data:");
const char * const start = data.constData() + offset;
const char * const end = start + dataSize;
for (const char *c = start; c < end; ++c)
qDebug() << "'" << *c << "' (0x" << (static_cast<int>(*c) & 0xff) << ")";
#endif
qCDebug(sshLog, ) << "'" << *c << "' (0x" << (static_cast<int>(*c) & 0xff) << ")";
}
} // namespace Internal
......
......@@ -31,6 +31,7 @@
#include "sshdirecttcpiptunnel_p.h"
#include "sshincomingpacket_p.h"
#include "sshlogging_p.h"
#include "sshsendfacility_p.h"
#include <QTimer>
......@@ -82,18 +83,18 @@ void SshDirectTcpIpTunnelPrivate::handleChannelDataInternal(const QByteArray &da
void SshDirectTcpIpTunnelPrivate::handleChannelExtendedDataInternal(quint32 type,
const QByteArray &data)
{
qDebug("%s: Unexpected extended channel data. Type is %u, content is '%s'.", Q_FUNC_INFO, type,
data.constData());
qCWarning(sshLog, "%s: Unexpected extended channel data. Type is %u, content is '%s'.",
Q_FUNC_INFO, type, data.constData());
}
void SshDirectTcpIpTunnelPrivate::handleExitStatus(const SshChannelExitStatus &exitStatus)
{
qDebug("%s: Unexpected exit status %d.", Q_FUNC_INFO, exitStatus.exitStatus);
qCWarning(sshLog, "%s: Unexpected exit status %d.", Q_FUNC_INFO, exitStatus.exitStatus);
}
void SshDirectTcpIpTunnelPrivate::handleExitSignal(const SshChannelExitSignal &signal)
{
qDebug("%s: Unexpected exit signal %s.", Q_FUNC_INFO, signal.signal.constData());
qCWarning(sshLog, "%s: Unexpected exit signal %s.", Q_FUNC_INFO, signal.signal.constData());
}
void SshDirectTcpIpTunnelPrivate::closeHook()
......@@ -166,7 +167,7 @@ void SshDirectTcpIpTunnel::initialize()
d->setChannelState(AbstractSshChannel::SessionRequested);
d->m_timeoutTimer.start(d->ReplyTimeout);
} catch (const Botan::Exception &e) { // Won't happen, but let's play it safe.
qDebug("Botan error: %s", e.what());
qCWarning(sshLog, "Botan error: %s", e.what());
d->closeChannel();
}
}
......
......@@ -29,6 +29,8 @@
****************************************************************************/
#include "sshhostkeydatabase.h"
#include "sshlogging_p.h"
#include <QByteArray>
#include <QCoreApplication>
#include <QDir>
......@@ -72,7 +74,7 @@ bool SshHostKeyDatabase::load(const QString &filePath, QString *error)
foreach (const QByteArray &line, content.split('\n')) {
const QList<QByteArray> &lineData = line.trimmed().split(' ');
if (lineData.count() != 2) {
qDebug("Unexpected line \"%s\" in file \"%s\".", line.constData(),
qCDebug(Internal::sshLog, "Unexpected line \"%s\" in file \"%s\".", line.constData(),
qPrintable(filePath));
continue;
}
......
......@@ -33,6 +33,7 @@
#include "ssh_global.h"
#include "sshbotanconversions_p.h"
#include "sshcapabilities_p.h"
#include "sshlogging_p.h"
namespace QSsh {
namespace Internal {
......@@ -66,10 +67,8 @@ void SshIncomingPacket::reset()
void SshIncomingPacket::consumeData(QByteArray &newData)
{
#ifdef CREATOR_SSH_DEBUG
qDebug("%s: current data size = %d, new data size = %d",
qCDebug(sshLog, "%s: current data size = %d, new data size = %d",
Q_FUNC_INFO, m_data.size(), newData.size());
#endif
if (isComplete() || newData.isEmpty())
return;
......@@ -83,9 +82,7 @@ void SshIncomingPacket::consumeData(QByteArray &newData)
const int bytesToTake
= qMin<quint32>(minSize - currentDataSize(), newData.size());
moveFirstBytes(m_data, newData, bytesToTake);
#ifdef CREATOR_SSH_DEBUG
qDebug("Took %d bytes from new data", bytesToTake);
#endif
qCDebug(sshLog, "Took %d bytes from new data", bytesToTake);
if (currentDataSize() < minSize)
return;
}
......@@ -97,14 +94,10 @@ void SshIncomingPacket::consumeData(QByteArray &newData)
= qMin<quint32>(length() + 4 + macLength() - currentDataSize(),
newData.size());
moveFirstBytes(m_data, newData, bytesToTake);
#ifdef CREATOR_SSH_DEBUG
qDebug("Took %d bytes from new data", bytesToTake);
#endif
qCDebug(sshLog, "Took %d bytes from new data", bytesToTake);
if (isComplete()) {
#ifdef CREATOR_SSH_DEBUG
qDebug("Message complete. Overall size: %u, payload size: %u",
qCDebug(sshLog, "Message complete. Overall size: %u, payload size: %u",
m_data.size(), m_length - paddingLength() - 1);
#endif
decrypt();
++m_serverSeqNr;
}
......@@ -509,19 +502,13 @@ QByteArray SshIncomingPacket::extractChannelRequestType() const
void SshIncomingPacket::calculateLength() const
{
Q_ASSERT(currentDataSize() >= minPacketSize());
#ifdef CREATOR_SSH_DEBUG
qDebug("Length field before decryption: %d-%d-%d-%d", m_data.at(0) & 0xff,
qCDebug(sshLog, "Length field before decryption: %d-%d-%d-%d", m_data.at(0) & 0xff,
m_data.at(1) & 0xff, m_data.at(2) & 0xff, m_data.at(3) & 0xff);
#endif
m_decrypter.decrypt(m_data, 0, cipherBlockSize());
#ifdef CREATOR_SSH_DEBUG
qDebug("Length field after decryption: %d-%d-%d-%d", m_data.at(0) & 0xff, m_data.at(1) & 0xff, m_data.at(2) & 0xff, m_data.at(3) & 0xff);
qDebug("message type = %d", m_data.at(TypeOffset));
#endif
qCDebug(sshLog, "Length field after decryption: %d-%d-%d-%d", m_data.at(0) & 0xff, m_data.at(1) & 0xff, m_data.at(2) & 0xff, m_data.at(3) & 0xff);
qCDebug(sshLog, "message type = %d", m_data.at(TypeOffset));
m_length = SshPacketParser::asUint32(m_data, static_cast<quint32>(0));
#ifdef CREATOR_SSH_DEBUG
qDebug("decrypted length is %u", m_length);
#endif
qCDebug(sshLog, "decrypted length is %u", m_length);
}
} // namespace Internal
......
......@@ -33,15 +33,13 @@
#include "ssh_global.h"
#include "sshbotanconversions_p.h"
#include "sshcapabilities_p.h"
#include "sshlogging_p.h"
#include "sshsendfacility_p.h"
#include "sshexception_p.h"
#include "sshincomingpacket_p.h"
#include <botan/botan.h>
#ifdef CREATOR_SSH_DEBUG
#include <iostream>
#endif
#include <string>
using namespace Botan;
......@@ -54,26 +52,16 @@ namespace {
// For debugging
void printNameList(const char *listName, const SshNameList &list)
{
#ifdef CREATOR_SSH_DEBUG
qDebug("%s:", listName);
qCDebug(sshLog, "%s:", listName);
foreach (const QByteArray &name, list.names)
qDebug("%s", name.constData());
#else
Q_UNUSED(listName);
Q_UNUSED(list);
#endif
qCDebug(sshLog, "%s", name.constData());
}
#ifdef CREATOR_SSH_DEBUG
void printData(const char *name, const QByteArray &data)
{
std::cerr << std::hex;
qDebug("The client thinks the %s has length %d and is:", name, data.count());
for (int i = 0; i < data.count(); ++i)
std::cerr << (static_cast<unsigned int>(data.at(i)) & 0xff) << ' ';
std::cerr << std::endl;
qCDebug(sshLog, "The client thinks the %s has length %d and is: %s", name, data.count(),
data.toHex().constData());
}
#endif
} // anonymous namespace
......@@ -93,9 +81,7 @@ void SshKeyExchange::sendKexInitPacket(const QByteArray &serverId)
bool SshKeyExchange::sendDhInitPacket(const SshIncomingPacket &serverKexInit)
{
#ifdef CREATOR_SSH_DEBUG
qDebug("server requests key exchange");
#endif
qCDebug(sshLog, "server requests key exchange");
serverKexInit.printRawBytes();
SshKeyExchangeInit kexInitParams
= serverKexInit.extractKeyExchangeInitData();
......@@ -110,9 +96,7 @@ bool SshKeyExchange::sendDhInitPacket(const SshIncomingPacket &serverKexInit)
printNameList("Compression algorithms client to server", kexInitParams.compressionAlgorithmsClientToServer);
printNameList("Languages client to server", kexInitParams.languagesClientToServer);
printNameList("Languages server to client", kexInitParams.languagesServerToClient);
#ifdef CREATOR_SSH_DEBUG
qDebug("First packet follows: %d", kexInitParams.firstKexPacketFollows);
#endif
qCDebug(sshLog, "First packet follows: %d", kexInitParams.firstKexPacketFollows);
m_kexAlgoName = SshCapabilities::findBestMatch(SshCapabilities::KeyExchangeMethods,
kexInitParams.keyAlgorithms.names);
......@@ -161,6 +145,13 @@ void SshKeyExchange::sendNewKeysPacket(const SshIncomingPacket &dhReply,
concatenatedData += AbstractSshPacket::encodeString(m_clientKexInitPayload);
concatenatedData += AbstractSshPacket::encodeString(m_serverKexInitPayload);
concatenatedData += reply.k_s;
printData("Client Id", AbstractSshPacket::encodeString(clientId));
printData("Server Id", AbstractSshPacket::encodeString(m_serverId));
printData("Client Payload", AbstractSshPacket::encodeString(m_clientKexInitPayload));
printData("Server payload", AbstractSshPacket::encodeString(m_serverKexInitPayload));
printData("K_S", reply.k_s);
SecureVector<byte> encodedK;
if (m_dhKey) {
concatenatedData += AbstractSshPacket::encodeMpInt(m_dhKey->get_y());
......@@ -169,6 +160,8 @@ void SshKeyExchange::sendNewKeysPacket(const SshIncomingPacket &dhReply,
SecureVector<byte> encodedF = BigInt::encode(reply.f);
encodedK = dhOp.agree(encodedF, encodedF.size());
m_dhKey.reset(nullptr);
printData("y", AbstractSshPacket::encodeMpInt(m_dhKey->get_y()));
printData("f", AbstractSshPacket::encodeMpInt(reply.f));
} else {
Q_ASSERT(m_ecdhKey);
concatenatedData // Q_C.
......@@ -181,25 +174,15 @@ void SshKeyExchange::sendNewKeysPacket(const SshIncomingPacket &dhReply,
const BigInt k = BigInt::decode(encodedK);
m_k = AbstractSshPacket::encodeMpInt(k); // Roundtrip, as Botan encodes BigInts somewhat differently.
printData("K", m_k);
concatenatedData += m_k;
printData("Concatenated data", concatenatedData);
m_hash.reset(get_hash(botanHMacAlgoName(hashAlgoForKexAlgo())));
const SecureVector<byte> &hashResult = m_hash->process(convertByteArray(concatenatedData),
concatenatedData.size());
m_h = convertByteArray(hashResult);
#ifdef CREATOR_SSH_DEBUG
printData("Client Id", AbstractSshPacket::encodeString(clientId));
printData("Server Id", AbstractSshPacket::encodeString(m_serverId));
printData("Client Payload", AbstractSshPacket::encodeString(m_clientKexInitPayload));
printData("Server payload", AbstractSshPacket::encodeString(m_serverKexInitPayload));
printData("K_S", reply.k_s);
printData("y", AbstractSshPacket::encodeMpInt(m_dhKey->get_y()));
printData("f", AbstractSshPacket::encodeMpInt(reply.f));
printData("K", m_k);
printData("Concatenated data", concatenatedData);
printData("H", m_h);
#endif // CREATOR_SSH_DEBUG
QScopedPointer<Public_Key> sigKey;
if (m_serverHostKeyAlgo == SshCapabilities::PubKeyDss) {
......
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "sshlogging_p.h"
namespace QSsh {
namespace Internal {
Q_LOGGING_CATEGORY(sshLog, "qtc.ssh")
} // namespace Internal
} // namespace QSsh
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef SSHLOGGING_P_H
#define SSHLOGGING_P_H
#include <QLoggingCategory>
namespace QSsh {
namespace Internal {
Q_DECLARE_LOGGING_CATEGORY(sshLog)
} // namespace Internal
} // namespace QSsh