aboutsummaryrefslogtreecommitdiff
path: root/lib/crypto/qolmutility.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/crypto/qolmutility.cpp')
-rw-r--r--lib/crypto/qolmutility.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/crypto/qolmutility.cpp b/lib/crypto/qolmutility.cpp
index 3c6a14c7..ad78a226 100644
--- a/lib/crypto/qolmutility.cpp
+++ b/lib/crypto/qolmutility.cpp
@@ -5,6 +5,7 @@
#ifdef Quotient_E2EE_ENABLED
#include "crypto/qolmutility.h"
#include "olm/olm.h"
+#include <QDebug>
using namespace Quotient;
@@ -19,10 +20,12 @@ QOlmUtility::QOlmUtility()
{
auto utility = new uint8_t[olm_utility_size()];
m_utility = olm_utility(utility);
+ qDebug() << "created";
}
QOlmUtility::~QOlmUtility()
{
+ qDebug() << "deleted";
olm_clear_utility(m_utility);
delete[](reinterpret_cast<uint8_t *>(m_utility));
}
@@ -43,15 +46,27 @@ QString QOlmUtility::sha256Utf8Msg(const QString &message) const
}
std::variant<bool, QOlmError> QOlmUtility::ed25519Verify(const QByteArray &key,
- const QByteArray &message, QByteArray &signature)
+ const QByteArray &message, const QByteArray &signature)
{
- const auto error = olm_ed25519_verify(m_utility, key.data(), key.length(),
- message.data(), message.length(), signature.data(), signature.length());
+ QByteArray signatureBuf(signature.length(), '0');
+ std::copy(signature.begin(), signature.end(), signatureBuf.begin());
+ qDebug() << "3" << key << message << signature;
+
+ const auto ret = olm_ed25519_verify(m_utility, key.data(), key.size(),
+ message.data(), message.size(), (void *)signatureBuf.data(), signatureBuf.size());
+
+ const auto error = ret;
if (error == olm_error()) {
+ qDebug() << QString(olm_utility_last_error(m_utility));
return lastError(m_utility);
}
- return error == 0;
+
+ if (ret != 0) {
+ qDebug() << "ed25519Verify" << ret;
+ return false;
+ }
+ return true;
}