* @brief Decrypts and returns the plaintext key for the given provider. */
| 72 | * @brief Decrypts and returns the plaintext key for the given provider. |
| 73 | */ |
| 74 | QString AI::KeyVault::key(ProviderId provider) const |
| 75 | { |
| 76 | m_settings.beginGroup(QStringLiteral("ai/keys")); |
| 77 | const auto cipher = m_settings.value(settingsKey(provider)).toString(); |
| 78 | m_settings.endGroup(); |
| 79 | |
| 80 | if (cipher.isEmpty()) |
| 81 | return {}; |
| 82 | |
| 83 | auto plaintext = m_simpleCrypt.decryptToString(cipher); |
| 84 | if (m_simpleCrypt.lastError() != Licensing::SimpleCrypt::ErrorNoError) { |
| 85 | qCWarning(serialStudioAI) << "Key decrypt failed for" << settingsKey(provider); |
| 86 | return {}; |
| 87 | } |
| 88 | |
| 89 | return plaintext; |
| 90 | } |
| 91 | |
| 92 | //-------------------------------------------------------------------------------------------------- |
| 93 | // Mutations |
no test coverage detected