Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorangelsl <angelsl@in04.sg>2017-11-12 21:23:01 +0300
committerJonathan White <support@dmapps.us>2018-01-13 22:23:26 +0300
commit6a0d05e1ef6c15a77c543ecba927ad77fb2f395c (patch)
tree673989b25267da1fa16e1b0b9d7506886ed16a6c /tests/TestSymmetricCipher.cpp
parent4532108678e5b86cd064c9d234db55055a86a17c (diff)
Add support for various algorithms for kdbx4
* Add SHA512 support to CryptoHash * Add ChaCha20 support * Add HMAC support * Add new HmacBlockStream, used in KDBX 4 * Add support for ChaCha20 protected stream
Diffstat (limited to 'tests/TestSymmetricCipher.cpp')
-rw-r--r--tests/TestSymmetricCipher.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/TestSymmetricCipher.cpp b/tests/TestSymmetricCipher.cpp
index c1e947063..bfa3c3db8 100644
--- a/tests/TestSymmetricCipher.cpp
+++ b/tests/TestSymmetricCipher.cpp
@@ -342,6 +342,56 @@ void TestSymmetricCipher::testSalsa20()
QCOMPARE(cipherTextB.mid(448, 64), expectedCipherText4);
}
+void TestSymmetricCipher::testChaCha20()
+{
+ // https://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04#section-7
+ bool ok;
+
+ {
+ QByteArray key = QByteArray::fromHex("0000000000000000000000000000000000000000000000000000000000000000");
+ QByteArray iv = QByteArray::fromHex("0000000000000000");
+ SymmetricCipher cipher(SymmetricCipher::ChaCha20, SymmetricCipher::Stream, SymmetricCipher::Encrypt);
+ QVERIFY(cipher.init(key, iv));
+ QCOMPARE(cipher.process(QByteArray(64, 0), &ok),
+ QByteArray::fromHex(
+ "76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669b2ee6586"));
+ QVERIFY(ok);
+ }
+
+ {
+ QByteArray key = QByteArray::fromHex("0000000000000000000000000000000000000000000000000000000000000001");
+ QByteArray iv = QByteArray::fromHex("0000000000000000");
+ SymmetricCipher cipher(SymmetricCipher::ChaCha20, SymmetricCipher::Stream, SymmetricCipher::Encrypt);
+ QVERIFY(cipher.init(key, iv));
+ QCOMPARE(cipher.process(QByteArray(64, 0), &ok),
+ QByteArray::fromHex(
+ "4540f05a9f1fb296d7736e7b208e3c96eb4fe1834688d2604f450952ed432d41bbe2a0b6ea7566d2a5d1e7e20d42af2c53d792b1c43fea817e9ad275ae546963"));
+ QVERIFY(ok);
+ }
+
+ {
+ QByteArray key = QByteArray::fromHex("0000000000000000000000000000000000000000000000000000000000000000");
+ QByteArray iv = QByteArray::fromHex("0000000000000001");
+ SymmetricCipher cipher(SymmetricCipher::ChaCha20, SymmetricCipher::Stream, SymmetricCipher::Encrypt);
+ QVERIFY(cipher.init(key, iv));
+ QCOMPARE(cipher.process(QByteArray(60, 0), &ok),
+ QByteArray::fromHex(
+ "de9cba7bf3d69ef5e786dc63973f653a0b49e015adbff7134fcb7df137821031e85a050278a7084527214f73efc7fa5b5277062eb7a0433e445f41e3"));
+ QVERIFY(ok);
+ }
+
+ {
+ QByteArray key = QByteArray::fromHex("0000000000000000000000000000000000000000000000000000000000000000");
+ QByteArray iv = QByteArray::fromHex("0100000000000000");
+ SymmetricCipher cipher(SymmetricCipher::ChaCha20, SymmetricCipher::Stream, SymmetricCipher::Encrypt);
+ QVERIFY(cipher.init(key, iv));
+ QCOMPARE(cipher.process(QByteArray(64, 0), &ok),
+ QByteArray::fromHex(
+ "ef3fdfd6c61578fbf5cf35bd3dd33b8009631634d21e42ac33960bd138e50d32111e4caf237ee53ca8ad6426194a88545ddc497a0b466e7d6bbdb0041b2f586b"));
+ QVERIFY(ok);
+ }
+}
+
void TestSymmetricCipher::testPadding()
{
QByteArray key = QByteArray::fromHex("603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4");