Fix challenge-response key data after Botan

* Fix #6420
* Refactor Challenge-Response key files to be more streamlined. Added a test to confirm raw key data is accurate.
This commit is contained in:
Jonathan White 2021-04-22 23:07:49 -04:00
parent 60adcacaaa
commit fd0bdaae80
14 changed files with 65 additions and 108 deletions

View file

@ -22,8 +22,9 @@
#include "core/Tools.h"
#include "crypto/Crypto.h"
#include "keys/YkChallengeResponseKey.h"
#include "keys/ChallengeResponseKey.h"
#include <QCryptographicHash>
#include <QScopedPointer>
#include <QSignalSpy>
@ -50,7 +51,7 @@ void TestYubiKeyChallengeResponse::testDetectDevices()
// Look at the information retrieved from the key(s)
for (auto key : YubiKey::instance()->foundKeys()) {
auto displayName = YubiKey::instance()->getDisplayName(key);
QVERIFY(displayName.contains("Challenge Response - Slot") || displayName.contains("Configured Slot -"));
QVERIFY(displayName.contains("Challenge-Response - Slot") || displayName.contains("Configured Slot -"));
QVERIFY(displayName.contains(QString::number(key.first)));
QVERIFY(displayName.contains(QString::number(key.second)));
}
@ -84,9 +85,11 @@ void TestYubiKeyChallengeResponse::testKeyChallenge()
QSKIP("No YubiKey contains a slot in passive mode.");
}
QScopedPointer<YkChallengeResponseKey> key(new YkChallengeResponseKey(pKey));
QScopedPointer<ChallengeResponseKey> key(new ChallengeResponseKey(pKey));
QByteArray ba("UnitTest");
QVERIFY(key->challenge(ba));
QCOMPARE(key->rawKey().size(), 20UL);
QCOMPARE(key->rawKey().size(), 20);
auto hash = QString(QCryptographicHash::hash(key->rawKey(), QCryptographicHash::Sha256).toHex());
QCOMPARE(hash, QString("2f7802c7112c301303526e7737b54d546c905076dca6e9538edf761a2264cd70"));
}