Add key serialization to support Quick Unlock

This commit is contained in:
Jonathan White
2022-02-18 10:17:21 -05:00
parent acce1bc5ce
commit a76daeb4c5
11 changed files with 194 additions and 16 deletions

View File

@@ -33,6 +33,16 @@ QByteArray ChallengeResponseKey::rawKey() const
return QByteArray(m_key.data(), m_key.size());
}
void ChallengeResponseKey::setRawKey(const QByteArray&)
{
// Nothing to do here
}
YubiKeySlot ChallengeResponseKey::slotData() const
{
return m_keySlot;
}
QString ChallengeResponseKey::error() const
{
return m_error;
@@ -52,3 +62,21 @@ bool ChallengeResponseKey::challenge(const QByteArray& challenge)
return result == YubiKey::ChallengeResult::YCR_SUCCESS;
}
QByteArray ChallengeResponseKey::serialize() const
{
QByteArray data;
QDataStream stream(&data, QIODevice::WriteOnly);
stream << uuid().toRfc4122() << m_keySlot;
return data;
}
void ChallengeResponseKey::deserialize(const QByteArray& data)
{
QDataStream stream(data);
QByteArray uuidData;
stream >> uuidData;
if (uuid().toRfc4122() == uuidData) {
stream >> m_keySlot;
}
}