| 108 | } |
| 109 | |
| 110 | bool CryptoModule::isPrekeySignatureValid() { |
| 111 | try { |
| 112 | const std::string signingPublicKey = |
| 113 | getSigningPublicKey(this->getIdentityKeys()); |
| 114 | |
| 115 | const std::string prekey = this->getPrekey(); |
| 116 | const std::string prekeySignature = this->getPrekeySignature(); |
| 117 | |
| 118 | // Use the dedicated prekey verification function that decodes base64 |
| 119 | ::verify_prekey_signature(signingPublicKey, prekey, prekeySignature); |
| 120 | return true; |
| 121 | } catch (const std::exception &e) { |
| 122 | std::string rawMessage{e.what()}; |
| 123 | if (rawMessage.find("The signature was invalid") != std::string::npos) { |
| 124 | return false; |
| 125 | } |
| 126 | |
| 127 | std::string errorMessage{ |
| 128 | "prekey signature verification failed with: " + rawMessage}; |
| 129 | Logger::log(errorMessage); |
| 130 | throw std::runtime_error(errorMessage); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | std::string CryptoModule::getIdentityKeys() { |
| 135 | this->exposePublicIdentityKeys(); |
no test coverage detected