diff --git a/native/cpp/CommonCpp/CryptoTools/CryptoModule.h b/native/cpp/CommonCpp/CryptoTools/CryptoModule.h --- a/native/cpp/CommonCpp/CryptoTools/CryptoModule.h +++ b/native/cpp/CommonCpp/CryptoTools/CryptoModule.h @@ -83,7 +83,7 @@ std::string signMessage(const std::string &message); static void verifySignature( const std::string &publicKey, - const std::string &message, + const OlmBuffer &message, const std::string &signature); std::optional validatePrekey(); }; diff --git a/native/cpp/CommonCpp/CryptoTools/CryptoModule.cpp b/native/cpp/CommonCpp/CryptoTools/CryptoModule.cpp --- a/native/cpp/CommonCpp/CryptoTools/CryptoModule.cpp +++ b/native/cpp/CommonCpp/CryptoTools/CryptoModule.cpp @@ -449,7 +449,7 @@ void CryptoModule::verifySignature( const std::string &publicKey, - const std::string &message, + const OlmBuffer &message, const std::string &signature) { OlmBuffer utilityBuffer; utilityBuffer.resize(::olm_utility_size()); @@ -458,8 +458,8 @@ olmUtility, (uint8_t *)publicKey.data(), publicKey.length(), - (uint8_t *)message.data(), - message.length(), + message.data(), + message.size(), (uint8_t *)signature.data(), signature.length()); if (verificationResult == -1) { @@ -470,7 +470,7 @@ std::optional CryptoModule::validatePrekey() { static const uint64_t maxPrekeyPublishTime = 30 * 24 * 60 * 60; // 30 days - static const uint64_t maxOldPrekeyAge = 24 * 60 * 60; // 24 hours + static const uint64_t maxOldPrekeyAge = 24 * 60 * 60; // 24 hours std::optional maybeNewPrekey; bool prekeyDoesntExist = this->prekeyDoesntExist(); diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp --- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp +++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp @@ -2073,8 +2073,10 @@ taskType job = [=, &innerRt]() { std::string error; try { + crypto::OlmBuffer messageBuffer( + messageStr.begin(), messageStr.end()); crypto::CryptoModule::verifySignature( - keyStr, messageStr, signatureStr); + keyStr, messageBuffer, signatureStr); } catch (const std::exception &e) { error = "verifying signature failed with: " + std::string(e.what()); }