diff --git a/qaesencryption.cpp b/qaesencryption.cpp index 2f771b1..c569b34 100644 --- a/qaesencryption.cpp +++ b/qaesencryption.cpp @@ -508,5 +508,5 @@ QByteArray QAESEncryption::decode(const QByteArray &rawText, const QByteArray &k QByteArray QAESEncryption::removePadding(const QByteArray &rawText) { - return RemovePadding(rawText, m_padding); + return RemovePadding(rawText, (Padding) m_padding); } diff --git a/unit_test/aestest.cpp b/unit_test/aestest.cpp index b83c198..94519d6 100644 --- a/unit_test/aestest.cpp +++ b/unit_test/aestest.cpp @@ -194,5 +194,23 @@ void AesTest::OFB256String() QByteArray encodeText = encryption.encode(inputStr.toLocal8Bit(), hashKey, iv); QByteArray decodedText = encryption.removePadding(encryption.decode(encodeText, hashKey, iv)); - QCOMPARE(inputStr, decodedText); + QCOMPARE(inputStr, QString(decodedText)); +} + +void AesTest::CBC256StringEven() +{ + QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::CBC); + + //16 byte string + QString inputStr("1234567890123456"); + QString key("123456789123"); + + QByteArray hashKey = QCryptographicHash::hash(key.toLocal8Bit(), QCryptographicHash::Sha256); + QByteArray encodeText = encryption.encode(inputStr.toLocal8Bit(), hashKey, iv); + QByteArray decodeText = encryption.decode(encodeText, hashKey, iv); + + QString decodedString = QString(encryption.removePadding(decodeText)); + + QCOMPARE(QString(decodeText), decodedString); + } diff --git a/unit_test/aestest.h b/unit_test/aestest.h index d2c098d..f992810 100644 --- a/unit_test/aestest.h +++ b/unit_test/aestest.h @@ -32,6 +32,8 @@ private slots: void OFB128Crypt(); void OFB256String(); + void CBC256StringEven(); + void cleanupTestCase(){} private: