Page MenuHomePhorge

D63.1732363602.diff
No OneTemporary

Size
7 KB
Referenced Files
None
Subscribers
None

D63.1732363602.diff

diff --git a/src/client/actions/encryption.hpp b/src/client/actions/encryption.hpp
--- a/src/client/actions/encryption.hpp
+++ b/src/client/actions/encryption.hpp
@@ -28,8 +28,6 @@
ClientResult updateClient(ClientModel m, EncryptMegOlmEventAction a);
- ClientResult updateClient(ClientModel m, EncryptOlmEventAction a);
-
ClientResult updateClient(ClientModel m, SetDeviceTrustLevelAction a);
ClientResult updateClient(ClientModel m, SetTrustLevelNeededToSendKeysAction a);
diff --git a/src/client/actions/encryption.cpp b/src/client/actions/encryption.cpp
--- a/src/client/actions/encryption.cpp
+++ b/src/client/actions/encryption.cpp
@@ -559,22 +559,6 @@
};
}
- ClientResult updateClient(ClientModel m, EncryptOlmEventAction a)
- {
- auto encryptedEvent = m.olmEncrypt(a.e, a.devices, a.random);
-
- return {
- std::move(m),
- [=](auto && /* ctx */) {
- auto retJson = json::object({
- {"encrypted", encryptedEvent.originalJson()},
- });
-
- return EffectStatus(/* succ = */ true, retJson);
- }
- };
- }
-
ClientResult updateClient(ClientModel m, SetDeviceTrustLevelAction a)
{
auto maybeOldInfo = m.deviceLists.get(a.userId, a.deviceId);
diff --git a/src/client/client-model.hpp b/src/client/client-model.hpp
--- a/src/client/client-model.hpp
+++ b/src/client/client-model.hpp
@@ -96,9 +96,6 @@
std::pair<Event, std::optional<std::string> /* sessionKey */>
megOlmEncrypt(Event e, std::string roomId, Timestamp timeMs, RandomData random);
- /// precondition: the one-time keys for those devices must already be claimed
- [[deprecated("Use olmEncryptSplit instead")]]
- Event olmEncrypt(Event e, immer::map<std::string, immer::flex_vector<std::string>> userIdToDeviceIdMap, RandomData random);
/// precondition: the one-time keys for those devices must already be claimed
/// @return A map from user id to device id to encrypted event for that device
@@ -534,27 +531,6 @@
RandomData random;
};
- /**
- * The action to encrypt events with olm for multiple devices.
- *
- * If the action is successful,
- * The result `r` will be such that `r.dataJson("encrypted")`
- * contains the json of the encrypted event.
- */
- struct EncryptOlmEventAction
- {
- using UserIdToDeviceIdMap = immer::map<std::string, immer::flex_vector<std::string>>;
- static std::size_t randomSize(UserIdToDeviceIdMap devices);
-
- /// Devices to encrypt for.
- UserIdToDeviceIdMap devices;
- /// The event to encrypt.
- Event e;
- /// The random data for the encryption. Must be of at least
- /// size `randomSize(devices)`.
- RandomData random;
- };
-
struct SetDeviceTrustLevelAction
{
std::string userId;
@@ -573,6 +549,7 @@
struct PrepareForSharingRoomKeyAction
{
using UserIdToDeviceIdMap = immer::map<std::string, immer::flex_vector<std::string>>;
+ static std::size_t randomSize(UserIdToDeviceIdMap devices);
/// The room to share the key event in.
std::string roomId;
@@ -581,7 +558,7 @@
/// The key event to encrypt.
Event e;
/// The random data for the encryption. Must be of at least
- /// size `EncryptOlmEventAction::randomSize(devices)`.
+ /// size `randomSize(devices)`.
RandomData random;
};
diff --git a/src/client/client-model.cpp b/src/client/client-model.cpp
--- a/src/client/client-model.cpp
+++ b/src/client/client-model.cpp
@@ -176,55 +176,6 @@
return { Event(JsonWrap(j)), keyOpt };
}
- Event ClientModel::olmEncrypt(Event e,
- immer::map<std::string, immer::flex_vector<std::string>> userIdToDeviceIdMap, RandomData random)
- {
- if (!crypto) {
- kzo.client.dbg() << "We do not have e2ee, so do not encrypt events" << std::endl;
- return e;
- }
-
- if (e.encrypted()) {
- kzo.client.dbg() << "The event is already encrypted. Ignoring it." << std::endl;
- return e;
- }
-
- auto origJson = e.originalJson().get();
-
- auto encJson = json::object();
- encJson["content"] = json{
- {"algorithm", CryptoConstants::olmAlgo},
- {"ciphertext", json::object()},
- {"sender_key", constCrypto().curve25519IdentityKey()},
- };
-
- encJson["type"] = "m.room.encrypted";
-
- for (auto [userId, devices] : userIdToDeviceIdMap) {
- for (auto dev : devices) {
- auto devInfoOpt = deviceLists.get(userId, dev);
- if (! devInfoOpt) {
- continue;
- }
- auto devInfo = devInfoOpt.value();
- auto jsonForThisDevice = origJson;
- jsonForThisDevice["sender"] = this->userId;
- jsonForThisDevice["recipient"] = userId;
- jsonForThisDevice["recipient_keys"] = json{
- {CryptoConstants::ed25519, devInfo.ed25519Key}
- };
- jsonForThisDevice["keys"] = json{
- {CryptoConstants::ed25519, constCrypto().ed25519IdentityKey()}
- };
- encJson["content"]["ciphertext"]
- .merge_patch(withCrypto([&](auto &c) { return c.encryptOlmWithRandom(random, jsonForThisDevice, devInfo.curve25519Key); }));
- random.erase(0, Crypto::encryptOlmMaxRandomSize());
- }
- }
-
- return Event(JsonWrap(encJson));
- }
-
immer::map<std::string, immer::map<std::string, Event>> ClientModel::olmEncryptSplit(
Event e,
immer::map<std::string, immer::flex_vector<std::string>> userIdToDeviceIdMap, RandomData random)
@@ -331,7 +282,7 @@
return 0;
}
- std::size_t EncryptOlmEventAction::randomSize(EncryptOlmEventAction::UserIdToDeviceIdMap devices)
+ std::size_t PrepareForSharingRoomKeyAction::randomSize(PrepareForSharingRoomKeyAction::UserIdToDeviceIdMap devices)
{
auto singleRandomSize = Crypto::encryptOlmMaxRandomSize();
auto deviceNum = accumulate(devices, std::size_t{},
diff --git a/src/client/clientfwd.hpp b/src/client/clientfwd.hpp
--- a/src/client/clientfwd.hpp
+++ b/src/client/clientfwd.hpp
@@ -67,7 +67,6 @@
struct QueryKeysAction;
struct ClaimKeysAction;
struct EncryptMegOlmEventAction;
- struct EncryptOlmEventAction;
struct SetDeviceTrustLevelAction;
struct SetTrustLevelNeededToSendKeysAction;
struct PrepareForSharingRoomKeyAction;
@@ -132,7 +131,6 @@
QueryKeysAction,
ClaimKeysAction,
EncryptMegOlmEventAction,
- EncryptOlmEventAction,
SetDeviceTrustLevelAction,
SetTrustLevelNeededToSendKeysAction,
PrepareForSharingRoomKeyAction,
diff --git a/src/client/room/room.cpp b/src/client/room/room.cpp
--- a/src/client/room/room.cpp
+++ b/src/client/room/room.cpp
@@ -444,7 +444,7 @@
return ctx.dispatch(PrepareForSharingRoomKeyAction{
rid,
devicesToSend, keyEv,
- rg.generateRange<RandomData>(EncryptOlmEventAction::randomSize(devicesToSend))
+ rg.generateRange<RandomData>(PrepareForSharingRoomKeyAction::randomSize(devicesToSend))
});
})
.then([ctx, r, devicesToSend, rid](auto status) {

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 4:06 AM (18 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39332
Default Alt Text
D63.1732363602.diff (7 KB)

Event Timeline