Catch and handle all errors from libgcrypt.

This commit is contained in:
Felix Geyer 2015-05-09 19:47:53 +02:00
parent a7f4e2d0cd
commit a762cef0a9
29 changed files with 622 additions and 194 deletions

View file

@ -43,6 +43,8 @@ void TestKeys::testComposite()
CompositeKey* compositeKey1 = new CompositeKey();
PasswordKey* passwordKey1 = new PasswordKey();
PasswordKey* passwordKey2 = new PasswordKey("test");
bool ok;
QString errorString;
// make sure that addKey() creates a copy of the keys
compositeKey1->addKey(*passwordKey1);
@ -50,13 +52,15 @@ void TestKeys::testComposite()
delete passwordKey1;
delete passwordKey2;
QByteArray transformed = compositeKey1->transform(QByteArray(32, '\0'), 1);
QByteArray transformed = compositeKey1->transform(QByteArray(32, '\0'), 1, &ok, &errorString);
QVERIFY(ok);
QCOMPARE(transformed.size(), 32);
// make sure the subkeys are copied
CompositeKey* compositeKey2 = compositeKey1->clone();
delete compositeKey1;
QCOMPARE(compositeKey2->transform(QByteArray(32, '\0'), 1), transformed);
QCOMPARE(compositeKey2->transform(QByteArray(32, '\0'), 1, &ok, &errorString), transformed);
QVERIFY(ok);
delete compositeKey2;
CompositeKey* compositeKey3 = new CompositeKey();
@ -130,7 +134,7 @@ void TestKeys::testCreateFileKey()
compositeKey.addKey(fileKey);
Database* dbOrg = new Database();
dbOrg->setKey(compositeKey);
QVERIFY(dbOrg->setKey(compositeKey));
dbOrg->metadata()->setName(dbName);
QBuffer dbBuffer;
@ -182,7 +186,10 @@ void TestKeys::benchmarkTransformKey()
QByteArray seed(32, '\x4B');
bool ok;
QString errorString;
QBENCHMARK {
compositeKey.transform(seed, 1e6);
compositeKey.transform(seed, 1e6, &ok, &errorString);
}
}