1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

EncryptedPasswordBackend: Coding style

This commit is contained in:
nowrep 2013-06-26 13:24:18 +02:00
parent 870ead19d3
commit 7a0a4ea31e
2 changed files with 16 additions and 16 deletions

View File

@ -69,7 +69,7 @@ QVector<PasswordEntry> DatabaseEncryptedPasswordBackend::getEntries(const QUrl &
data.password = query.value(2).toString();
data.data = query.value(3).toByteArray();
if (decryptPasswordEntry(&data, &aesDecryptor)) {
if (decryptPasswordEntry(data, &aesDecryptor)) {
list.append(data);
}
}
@ -97,7 +97,7 @@ QVector<PasswordEntry> DatabaseEncryptedPasswordBackend::getAllEntries()
data.password = query.value(3).toString();
data.data = query.value(4).toByteArray();
if (decryptPasswordEntry(&data, &aesDecryptor)) {
if (decryptPasswordEntry(data, &aesDecryptor)) {
list.append(data);
}
}
@ -147,7 +147,7 @@ void DatabaseEncryptedPasswordBackend::addEntry(const PasswordEntry &entry)
PasswordEntry encryptedEntry = entry;
AesInterface aesEncryptor;
if (encryptPasswordEntry(&encryptedEntry, &aesEncryptor)) {
if (encryptPasswordEntry(encryptedEntry, &aesEncryptor)) {
QSqlQuery query;
query.prepare("INSERT INTO autofill_encrypted (server, data_encrypted, username_encrypted, password_encrypted, last_used) "
"VALUES (?,?,?,?,strftime('%s', 'now'))");
@ -165,7 +165,7 @@ bool DatabaseEncryptedPasswordBackend::updateEntry(const PasswordEntry &entry)
AesInterface aesEncryptor;
PasswordEntry encryptedEntry = entry;
if (encryptPasswordEntry(&encryptedEntry, &aesEncryptor)) {
if (encryptPasswordEntry(encryptedEntry, &aesEncryptor)) {
QSqlQuery query;
// Data is empty only for HTTP/FTP authorization
@ -310,28 +310,28 @@ bool DatabaseEncryptedPasswordBackend::isPasswordVerified(const QByteArray &pass
return false;
}
bool DatabaseEncryptedPasswordBackend::decryptPasswordEntry(PasswordEntry* entry, AesInterface* aesInterface)
bool DatabaseEncryptedPasswordBackend::decryptPasswordEntry(PasswordEntry &entry, AesInterface* aesInterface)
{
if (!hasPermission() || !entry) {
if (!hasPermission()) {
return false;
}
entry->username = QString::fromUtf8(aesInterface->decrypt(entry->username.toUtf8(), m_masterPassword));
entry->password = QString::fromUtf8(aesInterface->decrypt(entry->password.toUtf8(), m_masterPassword));
entry->data = aesInterface->decrypt(entry->data, m_masterPassword);
entry.username = QString::fromUtf8(aesInterface->decrypt(entry.username.toUtf8(), m_masterPassword));
entry.password = QString::fromUtf8(aesInterface->decrypt(entry.password.toUtf8(), m_masterPassword));
entry.data = aesInterface->decrypt(entry.data, m_masterPassword);
return aesInterface->isOk();
}
bool DatabaseEncryptedPasswordBackend::encryptPasswordEntry(PasswordEntry* entry, AesInterface* aesInterface)
bool DatabaseEncryptedPasswordBackend::encryptPasswordEntry(PasswordEntry &entry, AesInterface* aesInterface)
{
if (!hasPermission() || !entry) {
if (!hasPermission()) {
return false;
}
entry->username = QString::fromUtf8(aesInterface->encrypt(entry->username.toUtf8(), m_masterPassword));
entry->password = QString::fromUtf8(aesInterface->encrypt(entry->password.toUtf8(), m_masterPassword));
entry->data = aesInterface->encrypt(entry->data, m_masterPassword);
entry.username = QString::fromUtf8(aesInterface->encrypt(entry.username.toUtf8(), m_masterPassword));
entry.password = QString::fromUtf8(aesInterface->encrypt(entry.password.toUtf8(), m_masterPassword));
entry.data = aesInterface->encrypt(entry.data, m_masterPassword);
return aesInterface->isOk();
}

View File

@ -64,8 +64,8 @@ public:
bool hasPermission();
bool isPasswordVerified(const QByteArray &password);
bool decryptPasswordEntry(PasswordEntry* entry, AesInterface* aesInterface);
bool encryptPasswordEntry(PasswordEntry* entry, AesInterface* aesInterface);
bool decryptPasswordEntry(PasswordEntry &entry, AesInterface* aesInterface);
bool encryptPasswordEntry(PasswordEntry &entry, AesInterface* aesInterface);
void tryToChangeMasterPassword(const QByteArray &newPassword);
void removeMasterPassword();