mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-03 20:47:37 +03:00
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
This commit is contained in:
parent
4532108678
commit
6a0d05e1ef
23 changed files with 616 additions and 25 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue