diff --git a/src/crypto/SymmetricCipher.h b/src/crypto/SymmetricCipher.h index 65cab76f..b8b3eb13 100644 --- a/src/crypto/SymmetricCipher.h +++ b/src/crypto/SymmetricCipher.h @@ -59,11 +59,11 @@ public: return m_backend->process(data, ok); } - inline bool processInPlace(QByteArray& data) { + inline bool processInPlace(QByteArray& data) Q_REQUIRED_RESULT { return m_backend->processInPlace(data); } - inline bool processInPlace(QByteArray& data, quint64 rounds) { + inline bool processInPlace(QByteArray& data, quint64 rounds) Q_REQUIRED_RESULT { Q_ASSERT(rounds > 0); return m_backend->processInPlace(data, rounds); } diff --git a/src/crypto/SymmetricCipherBackend.h b/src/crypto/SymmetricCipherBackend.h index 763ffb40..8f19b8ed 100644 --- a/src/crypto/SymmetricCipherBackend.h +++ b/src/crypto/SymmetricCipherBackend.h @@ -29,8 +29,8 @@ public: virtual bool setIv(const QByteArray& iv) = 0; virtual QByteArray process(const QByteArray& data, bool* ok) = 0; - virtual bool processInPlace(QByteArray& data) = 0; - virtual bool processInPlace(QByteArray& data, quint64 rounds) = 0; + virtual bool processInPlace(QByteArray& data) Q_REQUIRED_RESULT = 0; + virtual bool processInPlace(QByteArray& data, quint64 rounds) Q_REQUIRED_RESULT = 0; virtual bool reset() = 0; virtual int blockSize() const = 0; diff --git a/src/crypto/SymmetricCipherGcrypt.h b/src/crypto/SymmetricCipherGcrypt.h index bc156009..367ee5b9 100644 --- a/src/crypto/SymmetricCipherGcrypt.h +++ b/src/crypto/SymmetricCipherGcrypt.h @@ -35,8 +35,8 @@ public: bool setIv(const QByteArray& iv); QByteArray process(const QByteArray& data, bool* ok); - bool processInPlace(QByteArray& data); - bool processInPlace(QByteArray& data, quint64 rounds); + bool processInPlace(QByteArray& data) Q_REQUIRED_RESULT; + bool processInPlace(QByteArray& data, quint64 rounds) Q_REQUIRED_RESULT; bool reset(); int blockSize() const; diff --git a/src/format/KeePass2RandomStream.h b/src/format/KeePass2RandomStream.h index c951a95a..022c8399 100644 --- a/src/format/KeePass2RandomStream.h +++ b/src/format/KeePass2RandomStream.h @@ -29,7 +29,7 @@ public: bool init(const QByteArray& key); QByteArray randomBytes(int size, bool* ok); QByteArray process(const QByteArray& data, bool* ok); - bool processInPlace(QByteArray& data); + bool processInPlace(QByteArray& data) Q_REQUIRED_RESULT; QString errorString() const; private: diff --git a/src/format/KeePass2XmlReader.cpp b/src/format/KeePass2XmlReader.cpp index c3844886..ed5715cb 100644 --- a/src/format/KeePass2XmlReader.cpp +++ b/src/format/KeePass2XmlReader.cpp @@ -877,7 +877,9 @@ QPair KeePass2XmlReader::parseEntryBinary(Entry* entry) && (attr.value("Protected") == "True"); if (isProtected && !value.isEmpty()) { - m_randomStream->processInPlace(value); + if (!m_randomStream->processInPlace(value)) { + raiseError(m_randomStream->errorString()); + } } } diff --git a/src/keys/CompositeKey.cpp b/src/keys/CompositeKey.cpp index 31485186..4fae5f91 100644 --- a/src/keys/CompositeKey.cpp +++ b/src/keys/CompositeKey.cpp @@ -186,7 +186,7 @@ void TransformKeyBenchmarkThread::run() t.start(); do { - cipher.processInPlace(key, 100); + Q_UNUSED(cipher.processInPlace(key, 100)); m_rounds += 100; } while (t.elapsed() < m_msec); } diff --git a/tests/TestKeePass2RandomStream.cpp b/tests/TestKeePass2RandomStream.cpp index b41f1e87..cb881337 100644 --- a/tests/TestKeePass2RandomStream.cpp +++ b/tests/TestKeePass2RandomStream.cpp @@ -49,7 +49,7 @@ void TestKeePass2RandomStream::test() QByteArray cipherPad; cipherPad.fill('\0', Size); - cipher.processInPlace(cipherPad); + QVERIFY(cipher.processInPlace(cipherPad)); QByteArray cipherData; cipherData.resize(Size); @@ -68,7 +68,7 @@ void TestKeePass2RandomStream::test() randomStreamData.append(randomStream.process(data.mid(7, 1), &ok)); QVERIFY(ok); QByteArray tmpData = data.mid(8, 12); - randomStream.processInPlace(tmpData); + QVERIFY(randomStream.processInPlace(tmpData)); randomStreamData.append(tmpData); randomStreamData.append(randomStream.process(data.mid(20, 44), &ok)); QVERIFY(ok);