mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
chore(core): improve failed decryption error handling
This commit is contained in:
parent
5c1fe52010
commit
e1201f901f
|
@ -325,6 +325,10 @@ QString getDecryptionError(TOX_ERR_DECRYPTION error)
|
||||||
"The input data was shorter than TOX_PASS_ENCRYPTION_EXTRA_LENGTH bytes.");
|
"The input data was shorter than TOX_PASS_ENCRYPTION_EXTRA_LENGTH bytes.");
|
||||||
case TOX_ERR_DECRYPTION_BAD_FORMAT:
|
case TOX_ERR_DECRYPTION_BAD_FORMAT:
|
||||||
return QStringLiteral("The input data is missing the magic number or is corrupted.");
|
return QStringLiteral("The input data is missing the magic number or is corrupted.");
|
||||||
|
case TOX_ERR_DECRYPTION_KEY_DERIVATION_FAILED:
|
||||||
|
return QStringLiteral("The crypto lib was unable to derive a key from the given passphrase.");
|
||||||
|
case TOX_ERR_DECRYPTION_FAILED:
|
||||||
|
return QStringLiteral("Decryption failed. Either the data was corrupted or the password/key was incorrect.");
|
||||||
default:
|
default:
|
||||||
return QStringLiteral("Unknown decryption error.");
|
return QStringLiteral("Unknown decryption error.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QByteArray>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#ifndef TOXENCRYPT_H
|
#ifndef TOXENCRYPT_H
|
||||||
#define TOXENCRYPT_H
|
#define TOXENCRYPT_H
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
struct Tox_Pass_Key;
|
struct Tox_Pass_Key;
|
||||||
|
|
|
@ -436,11 +436,11 @@ QPixmap Profile::loadAvatar(const ToxPk& owner)
|
||||||
QPixmap pic;
|
QPixmap pic;
|
||||||
if (Settings::getInstance().getShowIdenticons()) {
|
if (Settings::getInstance().getShowIdenticons()) {
|
||||||
|
|
||||||
const QByteArray avataData = loadAvatarData(owner);
|
const QByteArray avatarData = loadAvatarData(owner);
|
||||||
if (avataData.isEmpty()) {
|
if (avatarData.isEmpty()) {
|
||||||
pic = QPixmap::fromImage(Identicon(owner.getKey()).toImage(16));
|
pic = QPixmap::fromImage(Identicon(owner.getKey()).toImage(16));
|
||||||
} else {
|
} else {
|
||||||
pic.loadFromData(avataData);
|
pic.loadFromData(avatarData);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -473,6 +473,9 @@ QByteArray Profile::loadAvatarData(const ToxPk& owner)
|
||||||
QByteArray pic = file.readAll();
|
QByteArray pic = file.readAll();
|
||||||
if (avatarEncrypted && !pic.isEmpty()) {
|
if (avatarEncrypted && !pic.isEmpty()) {
|
||||||
pic = passkey->decrypt(pic);
|
pic = passkey->decrypt(pic);
|
||||||
|
if (pic.isEmpty()) {
|
||||||
|
qWarning() << "Failed to decrypt avatar at" << path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pic;
|
return pic;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user