Properly detect CBC in key negotiation.
authorBas Pape <baspape@gmail.com>
Sun, 25 Aug 2013 13:52:40 +0000 (15:52 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 10 Oct 2013 18:08:18 +0000 (20:08 +0200)
When FiSH starts a key exchange, it appends CBC to the key to indicate
that it wants to use CBC rather than EBC. The cipher code simply
rejected this key.

src/core/cipher.cpp

index 9ea9c13..7cc75d0 100644 (file)
@@ -170,6 +170,13 @@ QByteArray Cipher::initKeyExchange()
 QByteArray Cipher::parseInitKeyX(QByteArray key)
 {
     QCA::Initializer init;
 QByteArray Cipher::parseInitKeyX(QByteArray key)
 {
     QCA::Initializer init;
+    bool isCBC = false;
+
+    if (key.endsWith(" CBC"))
+    {
+        isCBC = true;
+        key.chop(4);
+    }
 
     if (key.length() != 181)
         return QByteArray();
 
     if (key.length() != 181)
         return QByteArray();
@@ -198,6 +205,9 @@ QByteArray Cipher::parseInitKeyX(QByteArray key)
     //remove trailing = because mircryption and fish think it's a swell idea.
     while (sharedKey.endsWith('=')) sharedKey.chop(1);
 
     //remove trailing = because mircryption and fish think it's a swell idea.
     while (sharedKey.endsWith('=')) sharedKey.chop(1);
 
+    if (isCBC)
+        sharedKey.prepend("cbc:");
+
     bool success = setKey(sharedKey);
 
     if (!success)
     bool success = setKey(sharedKey);
 
     if (!success)