Strip space chars from recovery passphrase

This commit is contained in:
Nicolas Werner 2021-12-15 18:25:10 +01:00
parent 57d1dffdbd
commit 6d69248109
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
1 changed files with 7 additions and 1 deletions

View File

@ -1103,7 +1103,13 @@ ChatPage::decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescriptio
if (text.isEmpty())
return;
auto decryptionKey = mtx::crypto::key_from_recoverykey(text.toStdString(), keyDesc);
// strip space chars from a recovery key. It can't contain those, but some clients insert them
// to make them easier to read.
QString stripped = text;
stripped.remove(' ');
stripped.remove('\n');
stripped.remove('\t');
auto decryptionKey = mtx::crypto::key_from_recoverykey(stripped.toStdString(), keyDesc);
if (!decryptionKey && keyDesc.passphrase) {
try {