| 245 | } |
| 246 | |
| 247 | void db_key::updateKeyEncryptionScheme() |
| 248 | { |
| 249 | bool common_success = true; |
| 250 | if (!pki_evp::validateDatabasePassword(pki_evp::passwd)) |
| 251 | return; |
| 252 | if (Settings["legacy-keys-updated"]) |
| 253 | return; |
| 254 | |
| 255 | QList<pki_evp *> privates, withOwnPassword; |
| 256 | privates = Store.sqlSELECTpki<pki_evp>("SELECT item from private_keys"); |
| 257 | |
| 258 | qDebug() << "Updating encryption scheme of" << privates.size() << "keys"; |
| 259 | |
| 260 | Transaction; |
| 261 | if (!TransBegin()) |
| 262 | return; |
| 263 | |
| 264 | for (pki_evp *key : privates) { |
| 265 | if (key->isPubKey()) { |
| 266 | qWarning() << "BUG: private key" << key << "is not private"; |
| 267 | continue; // Should not happen |
| 268 | } |
| 269 | bool conv_success = key->updateLegacyEncryption(); |
| 270 | if (!conv_success && key->getOwnPass() == pki_key::ptPrivate) { |
| 271 | withOwnPassword << key; |
| 272 | } else { |
| 273 | common_success &= conv_success; |
| 274 | } |
| 275 | } |
| 276 | qDebug() << "Success:" << common_success << "Legacy keys:" |
| 277 | << withOwnPassword.size(); |
| 278 | ign_openssl_error(); |
| 279 | TransCommit(); |
| 280 | if (withOwnPassword.size() > 0) { |
| 281 | QString items; |
| 282 | for (pki_evp *key : withOwnPassword) |
| 283 | items += "'" + key->getIntName() + "' "; |
| 284 | XCA_WARN(tr("Internal key update: The keys: %1 must be updated once by resetting and setting its private password").arg(items)); |
| 285 | } |
| 286 | if (common_success && withOwnPassword.isEmpty()) |
| 287 | Settings["legacy-keys-updated"] = true; |
| 288 | } |
| 289 | |
| 290 | void db_key::setOwnPass(QModelIndex idx, enum pki_key::passType x) |
| 291 | { |
no test coverage detected