aboutsummaryrefslogtreecommitdiff
path: root/lib/encryptionmanager.cpp
diff options
context:
space:
mode:
authorAlexey Andreyev <aa13q@ya.ru>2019-07-14 02:33:39 +0300
committerAlexey Andreyev <aa13q@ya.ru>2019-07-14 02:33:39 +0300
commitf1546e894b2a7550bce3e8d84067968bf5cf7087 (patch)
tree82d305b68af2cc1ec4b7ce48376710ced334bb0a /lib/encryptionmanager.cpp
parent74caea2669b8f76ca76507bc40321fdcd23dc522 (diff)
downloadlibquotient-f1546e894b2a7550bce3e8d84067968bf5cf7087.tar.gz
libquotient-f1546e894b2a7550bce3e8d84067968bf5cf7087.zip
E2EE: provide a shared header with encryption standard key names
Diffstat (limited to 'lib/encryptionmanager.cpp')
-rw-r--r--lib/encryptionmanager.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/encryptionmanager.cpp b/lib/encryptionmanager.cpp
index 50db9889..08b68911 100644
--- a/lib/encryptionmanager.cpp
+++ b/lib/encryptionmanager.cpp
@@ -8,18 +8,12 @@
#include "csapi/keys.h"
#include "connection.h"
+#include "e2ee.h"
using namespace QMatrixClient;
using namespace QtOlm;
using std::move;
-static const auto ed25519Name = QStringLiteral("ed25519");
-static const auto Curve25519Name = QStringLiteral("curve25519");
-static const auto SignedCurve25519Name = QStringLiteral("signed_curve25519");
-static const auto OlmV1Curve25519AesSha2AlgoName = QStringLiteral("m.olm.v1.curve25519-aes-sha2");
-static const auto MegolmV1AesSha2AlgoName = QStringLiteral("m.megolm.v1.aes-sha2");
-static const QStringList SupportedAlgorithms = { OlmV1Curve25519AesSha2AlgoName, MegolmV1AesSha2AlgoName };
-
class EncryptionManager::Private
{
public:
@@ -49,8 +43,8 @@ class EncryptionManager::Private
targetKeysNumber = olmAccount->maxOneTimeKeys(); // 2 // see note below
targetOneTimeKeyCounts =
{
- {SignedCurve25519Name, qRound(signedKeysProportion * targetKeysNumber)},
- {Curve25519Name, qRound((1-signedKeysProportion) * targetKeysNumber)}
+ {SignedCurve25519Key, qRound(signedKeysProportion * targetKeysNumber)},
+ {Curve25519Key, qRound((1-signedKeysProportion) * targetKeysNumber)}
};
}
~Private() = default;
@@ -104,11 +98,11 @@ void EncryptionManager::uploadIdentityKeys(Connection* connection)
*/
{
{
- Curve25519Name + QStringLiteral(":") + connection->deviceId(),
+ Curve25519Key + QStringLiteral(":") + connection->deviceId(),
d->olmAccount->curve25519IdentityKey()
},
{
- ed25519Name + QStringLiteral(":") + connection->deviceId(),
+ Ed25519Key + QStringLiteral(":") + connection->deviceId(),
d->olmAccount->ed25519IdentityKey()
}
},
@@ -133,7 +127,7 @@ void EncryptionManager::uploadIdentityKeys(Connection* connection)
connection->userId(),
{
{
- ed25519Name + QStringLiteral(":") + connection->deviceId(),
+ Ed25519Key + QStringLiteral(":") + connection->deviceId(),
d->olmAccount->sign(deviceKeysJsonObject)
}
}
@@ -158,8 +152,8 @@ void EncryptionManager::uploadOneTimeKeys(Connection* connection, bool forceUpda
}
- int signedKeysToUploadCount = d->oneTimeKeysToUploadCounts.value(SignedCurve25519Name, 0);
- int unsignedKeysToUploadCount = d->oneTimeKeysToUploadCounts.value(Curve25519Name, 0);
+ int signedKeysToUploadCount = d->oneTimeKeysToUploadCounts.value(SignedCurve25519Key, 0);
+ int unsignedKeysToUploadCount = d->oneTimeKeysToUploadCounts.value(Curve25519Key, 0);
d->olmAccount->generateOneTimeKeys(signedKeysToUploadCount + unsignedKeysToUploadCount);
@@ -179,11 +173,11 @@ void EncryptionManager::uploadOneTimeKeys(Connection* connection, bool forceUpda
{QStringLiteral("key"), it.value().toString()}
};
key = d->olmAccount->sign(message);
- keyType = SignedCurve25519Name;
+ keyType = SignedCurve25519Key;
} else {
key = it.value();
- keyType = Curve25519Name;
+ keyType = Curve25519Key;
}
++oneTimeKeysCounter;
oneTimeKeys.insert(QString("%1:%2").arg(keyType).arg(keyId), key);