Prepend the mode of operation to showkey's output.
authorBas Pape <baspape@gmail.com>
Sun, 25 Aug 2013 14:48:19 +0000 (16:48 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 10 Oct 2013 18:08:18 +0000 (20:08 +0200)
src/core/cipher.h
src/core/corenetwork.cpp
src/core/corenetwork.h
src/core/coreuserinputhandler.cpp

index e7f88b3..2cd8086 100644 (file)
@@ -34,6 +34,7 @@ public:
     bool setType(const QString &type);
     QString type() { return m_type; }
     static bool neededFeaturesAvailable();
     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
 
 private:
     //direction is true for encrypt, false for decrypt
index 101f527..5ef2557 100644 (file)
@@ -363,6 +363,19 @@ void CoreNetwork::setCipherKey(const QString &target, const QByteArray &key)
         return;
     }
 }
         return;
     }
 }
+
+
+bool CoreNetwork::cipherUsesCBC(const QString &target)
+{
+    CoreIrcChannel *c = qobject_cast<CoreIrcChannel*>(ircChannel(target));
+    if (c)
+        return c->cipher()->usesCBC();
+    CoreIrcUser *u = qobject_cast<CoreIrcUser*>(ircUser(target));
+    if (u)
+        return u->cipher()->usesCBC();
+
+    return false;
+}
 #endif /* HAVE_QCA2 */
 
 bool CoreNetwork::setAutoWhoDone(const QString &channel)
 #endif /* HAVE_QCA2 */
 
 bool CoreNetwork::setAutoWhoDone(const QString &channel)
index a1d42f1..7bc0108 100644 (file)
@@ -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);
     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);
 #endif
 
     void setAutoWhoEnabled(bool enabled);
index 87c497d..24d5f8b 100644 (file)
@@ -657,7 +657,7 @@ void CoreUserInputHandler::handleShowkey(const BufferInfo &bufferInfo, const QSt
         return;
     }
 
         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)
 
 #else
     Q_UNUSED(msg)