aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autotests/testolmaccount.cpp12
-rw-r--r--autotests/testolmutility.cpp2
-rw-r--r--lib/crypto/qolmaccount.cpp19
-rw-r--r--lib/crypto/qolmutility.cpp6
4 files changed, 23 insertions, 16 deletions
diff --git a/autotests/testolmaccount.cpp b/autotests/testolmaccount.cpp
index 8d979e0b..4eed1980 100644
--- a/autotests/testolmaccount.cpp
+++ b/autotests/testolmaccount.cpp
@@ -309,7 +309,6 @@ void TestOlmAccount::claimKeys()
deviceKeys[bob->userId()] = QStringList();
auto job = alice->callApi<QueryKeysJob>(deviceKeys);
connect(job, &BaseJob::result, this, [bob, alice, aliceOlm, job, this] {
- qDebug() << job->jsonData();
auto bobDevices = job->deviceKeys()[bob->userId()];
QVERIFY(bobDevices.size() > 0);
@@ -337,7 +336,16 @@ void TestOlmAccount::claimKeys()
// The key is the one bob sent.
auto oneTimeKey = job->oneTimeKeys()[userId][deviceId];
- QVERIFY(oneTimeKey.canConvert<SignedOneTimeKey>());
+ QVERIFY(oneTimeKey.canConvert<QVariantMap>());
+
+ QVariantMap varMap = oneTimeKey.toMap();
+ bool found = false;
+ for (const auto key : varMap.keys()) {
+ if (key.startsWith(QStringLiteral("signed_curve25519"))) {
+ found = true;
+ }
+ }
+ QVERIFY(found);
//auto algo = oneTimeKey.begin().key();
//auto contents = oneTimeKey.begin().value();
diff --git a/autotests/testolmutility.cpp b/autotests/testolmutility.cpp
index cb92a0df..1d9978d3 100644
--- a/autotests/testolmutility.cpp
+++ b/autotests/testolmutility.cpp
@@ -61,7 +61,6 @@ void TestOlmUtility::verifySignedOneTimeKey()
auto utilityBuf = new uint8_t[olm_utility_size()];
auto utility = olm_utility(utilityBuf);
- qDebug() << "1" << aliceOlm->identityKeys().ed25519 << msg << QString::fromUtf8(sig);
QByteArray signatureBuf1(sig.length(), '0');
std::copy(sig.begin(), sig.end(), signatureBuf1.begin());
@@ -73,7 +72,6 @@ void TestOlmUtility::verifySignedOneTimeKey()
msg.size(),
(void *)sig.data(),
sig.size());
- qDebug() << "2" << aliceOlm->identityKeys().ed25519 << msg << QString::fromUtf8(signatureBuf1);
QCOMPARE(std::string(olm_utility_last_error(utility)), "SUCCESS");
QCOMPARE(res, 0);
diff --git a/lib/crypto/qolmaccount.cpp b/lib/crypto/qolmaccount.cpp
index e27bbee1..0f354d3e 100644
--- a/lib/crypto/qolmaccount.cpp
+++ b/lib/crypto/qolmaccount.cpp
@@ -129,10 +129,19 @@ QByteArray QOlmAccount::sign(const QJsonObject &message) const
QByteArray QOlmAccount::signIdentityKeys() const
{
const auto keys = identityKeys();
- const QJsonObject j{ {Curve25519Key, QString(keys.curve25519)}, {Ed25519Key, QString(keys.ed25519)} };
- QJsonDocument doc;
- doc.setObject(j);
- return sign(doc.toJson());
+ QJsonObject body
+ {
+ {"algorithms", QJsonArray{"m.olm.v1.curve25519-aes-sha2", "m.megolm.v1.aes-sha2"}},
+ {"user_id", m_userId},
+ {"device_id", m_deviceId},
+ {"keys",
+ QJsonObject{
+ {QStringLiteral("curve25519:") + m_deviceId, QString::fromUtf8(keys.curve25519)},
+ {QStringLiteral("ed25519:") + m_deviceId, QString::fromUtf8(keys.ed25519)}
+ }
+ }
+ };
+ return sign(QJsonDocument(body).toJson(QJsonDocument::Compact));
}
@@ -279,7 +288,6 @@ bool Quotient::verifyIdentitySignature(const DeviceKeys &deviceKeys,
const auto signature = deviceKeys.signatures[userId][signKeyId];
if (signature.isEmpty()) {
- qDebug() << "signature empty";
return false;
}
@@ -305,7 +313,6 @@ bool Quotient::ed25519VerifySignature(const QString &signingKey,
auto signatureBuf = signature.toUtf8();
auto result = utility.ed25519Verify(signingKeyBuf, canonicalJson, signatureBuf);
if (std::holds_alternative<QOlmError>(result)) {
- qDebug() << "error:" << std::get<QOlmError>(result);
return false;
}
diff --git a/lib/crypto/qolmutility.cpp b/lib/crypto/qolmutility.cpp
index ad78a226..87615770 100644
--- a/lib/crypto/qolmutility.cpp
+++ b/lib/crypto/qolmutility.cpp
@@ -20,12 +20,10 @@ 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));
}
@@ -51,19 +49,15 @@ std::variant<bool, QOlmError> QOlmUtility::ed25519Verify(const QByteArray &key,
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);
}
if (ret != 0) {
- qDebug() << "ed25519Verify" << ret;
return false;
}
return true;