1
0
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:
Anthony Bilinski 2018-10-31 11:51:57 -07:00
parent 5c1fe52010
commit e1201f901f
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
3 changed files with 13 additions and 6 deletions

View File

@ -325,6 +325,10 @@ QString getDecryptionError(TOX_ERR_DECRYPTION error)
"The input data was shorter than TOX_PASS_ENCRYPTION_EXTRA_LENGTH bytes.");
case TOX_ERR_DECRYPTION_BAD_FORMAT:
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:
return QStringLiteral("Unknown decryption error.");
}

View File

@ -17,12 +17,12 @@
along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QByteArray>
#include <QString>
#ifndef TOXENCRYPT_H
#define TOXENCRYPT_H
#include <QByteArray>
#include <QString>
#include <memory>
struct Tox_Pass_Key;

View File

@ -436,11 +436,11 @@ QPixmap Profile::loadAvatar(const ToxPk& owner)
QPixmap pic;
if (Settings::getInstance().getShowIdenticons()) {
const QByteArray avataData = loadAvatarData(owner);
if (avataData.isEmpty()) {
const QByteArray avatarData = loadAvatarData(owner);
if (avatarData.isEmpty()) {
pic = QPixmap::fromImage(Identicon(owner.getKey()).toImage(16));
} else {
pic.loadFromData(avataData);
pic.loadFromData(avatarData);
}
} else {
@ -473,6 +473,9 @@ QByteArray Profile::loadAvatarData(const ToxPk& owner)
QByteArray pic = file.readAll();
if (avatarEncrypted && !pic.isEmpty()) {
pic = passkey->decrypt(pic);
if (pic.isEmpty()) {
qWarning() << "Failed to decrypt avatar at" << path;
}
}
return pic;