From 3972e140226f32760bb2606650f93132c188b2dc Mon Sep 17 00:00:00 2001 From: Bas Pape Date: Sun, 25 Aug 2013 16:48:19 +0200 Subject: [PATCH] Prepend the mode of operation to showkey's output. --- src/core/cipher.h | 1 + src/core/corenetwork.cpp | 13 +++++++++++++ src/core/corenetwork.h | 1 + src/core/coreuserinputhandler.cpp | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/core/cipher.h b/src/core/cipher.h index e7f88b38..2cd80860 100644 --- a/src/core/cipher.h +++ b/src/core/cipher.h @@ -34,6 +34,7 @@ public: bool setType(const QString &type); QString type() { return m_type; } static bool neededFeaturesAvailable(); + inline bool usesCBC() { return m_cbc; } private: //direction is true for encrypt, false for decrypt diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index 101f5276..5ef25571 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -363,6 +363,19 @@ void CoreNetwork::setCipherKey(const QString &target, const QByteArray &key) return; } } + + +bool CoreNetwork::cipherUsesCBC(const QString &target) +{ + CoreIrcChannel *c = qobject_cast(ircChannel(target)); + if (c) + return c->cipher()->usesCBC(); + CoreIrcUser *u = qobject_cast(ircUser(target)); + if (u) + return u->cipher()->usesCBC(); + + return false; +} #endif /* HAVE_QCA2 */ bool CoreNetwork::setAutoWhoDone(const QString &channel) diff --git a/src/core/corenetwork.h b/src/core/corenetwork.h index a1d42f19..7bc0108b 100644 --- a/src/core/corenetwork.h +++ b/src/core/corenetwork.h @@ -123,6 +123,7 @@ public slots: Cipher *cipher(const QString &recipient); QByteArray cipherKey(const QString &recipient) const; void setCipherKey(const QString &recipient, const QByteArray &key); + bool cipherUsesCBC(const QString &target); #endif void setAutoWhoEnabled(bool enabled); diff --git a/src/core/coreuserinputhandler.cpp b/src/core/coreuserinputhandler.cpp index 87c497d4..24d5f8b8 100644 --- a/src/core/coreuserinputhandler.cpp +++ b/src/core/coreuserinputhandler.cpp @@ -657,7 +657,7 @@ void CoreUserInputHandler::handleShowkey(const BufferInfo &bufferInfo, const QSt return; } - emit displayMsg(Message::Info, bufname, tr("The key for %1 is %2").arg(target).arg(QString(key))); + emit displayMsg(Message::Info, bufname, tr("The key for %1 is %2:%3").arg(target, network()->cipherUsesCBC(target) ? "CBC" : "ECB", QString(key))); #else Q_UNUSED(msg) -- 2.20.1