| 336 | } |
| 337 | |
| 338 | std::string CryptoModule::decrypt( |
| 339 | const std::string &targetDeviceId, |
| 340 | EncryptedData &encryptedData) { |
| 341 | if (!this->hasSessionFor(targetDeviceId)) { |
| 342 | throw std::runtime_error{SESSION_DOES_NOT_EXIST_ERROR}; |
| 343 | } |
| 344 | auto session = this->sessions.at(targetDeviceId); |
| 345 | if (encryptedData.sessionVersion.has_value() && |
| 346 | encryptedData.sessionVersion.value() < session->getVersion()) { |
| 347 | throw std::runtime_error{INVALID_SESSION_VERSION_ERROR}; |
| 348 | } |
| 349 | return session->decrypt(encryptedData); |
| 350 | } |
| 351 | |
| 352 | std::string CryptoModule::signMessage(const std::string &message) { |
| 353 | try { |
nothing calls this directly
no test coverage detected