aboutsummaryrefslogtreecommitdiff
path: root/autotests/testfilecrypto.cpp
blob: b86114a435cf427746ddf300efb4eee92fd806ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// SPDX-FileCopyrightText: 2022 Tobias Fella <fella@posteo.de>
//
// SPDX-License-Identifier: LGPL-2.1-or-later

#include "testfilecrypto.h"

#include "events/filesourceinfo.h"

#include <qtest.h>

using namespace Quotient;
void TestFileCrypto::encryptDecryptData()
{
    QByteArray data = "ABCDEF";
    auto [file, cipherText] = EncryptedFileMetadata::encryptFile(data);
    auto decrypted = file.decryptFile(cipherText);
    // AES CTR produces ciphertext of the same size as the original
    QCOMPARE(cipherText.size(), data.size());
    QCOMPARE(decrypted.size(), data.size());
    QCOMPARE(decrypted, data);
}
QTEST_APPLESS_MAIN(TestFileCrypto)