X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fcipher.cpp;h=a8232a3c1fc29b338fb214d22aa823398e2c9f0f;hb=1ed9e77710cf3ccdafd5aa2104456eea1d94cc25;hp=7cc75d0a5774cab7e972e0ceaa970ecd0edfe77b;hpb=d921c7e14b3bd35d2b9f022ae88b90d83b97d568;p=quassel.git diff --git a/src/core/cipher.cpp b/src/core/cipher.cpp index 7cc75d0a..a8232a3c 100644 --- a/src/core/cipher.cpp +++ b/src/core/cipher.cpp @@ -364,6 +364,10 @@ QByteArray Cipher::blowfishECB(QByteArray cipherText, bool direction) } else { + // ECB Blowfish encodes in blocks of 12 chars, so anything else is malformed input + if ((temp.length() % 12) != 0) + return cipherText; + temp = b64ToByte(temp); while ((temp.length() % 8) != 0) temp.append('\0'); } @@ -376,8 +380,13 @@ QByteArray Cipher::blowfishECB(QByteArray cipherText, bool direction) if (!cipher.ok()) return cipherText; - if (direction) + if (direction) { + // Sanity check + if ((temp2.length() % 8) != 0) + return cipherText; + temp2 = byteToB64(temp2); + } return temp2; } @@ -420,13 +429,13 @@ QByteArray Cipher::byteToB64(QByteArray text) right += v; for (int i = 0; i < 6; i++) { - encoded.append(base64.at(right & 0x3F).toAscii()); + encoded.append(base64.at(right & 0x3F).toLatin1()); right = right >> 6; } - //TODO make sure the .toascii doesn't break anything + //TODO make sure the .toLatin1 doesn't break anything for (int i = 0; i < 6; i++) { - encoded.append(base64.at(left & 0x3F).toAscii()); + encoded.append(base64.at(left & 0x3F).toLatin1()); left = left >> 6; } }