Coder Social home page Coder Social logo

aiomatrix's People

Contributors

ebnerandreas avatar thejj avatar zuntrax avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ebnerandreas

aiomatrix's Issues

OTK long term handling

A number of one time keys have to be stored permanently on the server.

No long term handling implemented yet.

After the initial device key uploads about 100 OTKs are uploaded. They can be checked via the get_otk_count() function that yields the current amount of otks which come as a reply in the sync() message.

Class EventManager: Use default dict instead of list

The class attribute subscriber_list has to be updated for every new event that wants to be parsed. A default dict would get rid of that.

However, maybe it is required to be forced to manually add the new event to the eventManager and the filter.

Pypi package renaming

Hi! I'm developing client library for matrix in Python and wanted to publish it on PyPi as aiomatrix but found your library. It looks abandoned, so I thought it's okay to ask if you could rename your PyPi package.
Could you please change your library name to aiomatrix-py or something like that?

Implement m.room.powerlevels

This is an important endpoint to offer for rooms especially for encryption purpose.
A room can only be set to "encrypted mode" (sending m.room.encryption event) by having Administrator (100) right, therefore if the API user creates the room using room.create_room() nobody apart from the API user can set the room to encrypted. Might be interesting to offer this functionality also regarding the possiblility of writing "guarding bots".

Use config file

Create a config file that defines specific parameters that are now either set in the Session class itself or passed in the init like 'save_directory_path' or 'supported_encryption_version'

Improve Own Olm Session management

At the moment, everytime we share our MegOlm session key with one of the members of the room, we initiate a new OlmSession.
Riot, for example, uses (if possible) an existing olm session with the user that has been used before.
The current implementation is not wrong, however, it might be better to go for the Riot approach.

Things to change (theoretically):

  • Check whether there's already a valid/known olm session in the self.session.olm_sessions list
  • then encrypt the meg olm session keys using this session and set the message 'type' field to 1 (instead of 0 == prekey message)

Better protection against attacks etc.

At the moment everything is implemented and tested in a secure environment. Everything is implemented for when "everything goes well".

Required: More checks of incoming parameters and handling the errors/wrong messages in a way that does not lead to DoS.

Improved Pickle of self.meg_ses

At the moment, the own OutboundGroupSession (stored in self.meg_ses) triggers pickle of the whole self.room_keys after every sent of a message. This creates a lot of overhead if there are a lot of rooms and a lot of users in them.

Possible solutions:

  • Only pickle the meg_ses after every sent (not the whole list)
  • Pickle the whole list only within the destructor of the room object (which would be best)

API useable without encryption

Might be interesting to make it possible to use the API without encryption.

At the moment, as soon as you create a session the whole Olm Account/Key handling takes place including saving/uploading of new keys. Maybe a flag/paramter to indicate no encryption required.

Extra Encryption class

One major problem is, that the PreKey event (parsed by the filter class and distributed by the eventManager class) is not room based.
It can't be, because the room information is part of the encrypted content of the message (see below).

At the moment, every room object listining for prekey message events get the message, creates an olm session and decrypts it just to realize that this message might not be for him. I also think that it might cause problems due to the fact that multiple olm sessions are created with the same initial message (don't know if that causes issues, short workaround would be to remove the subscription as soon as you receive an correct olm message, however, this would cause problems if a olm session in future is renewed for this room)

Therefore, one idea would be to have a Encryption class that takes are of creating olm sessions and distributing the decrypted prekey messages to the relevant rooms. This Encryption class could also take care of the storing/pickling/loading of the room keys.

Also, the strict separation of lowlevel (JSON parsing) and highlevel is broken at the moment. The PreKey class accesses the JSON itself despite being a high level class. That's another reason for a lowlevel Encryption class.

{
"sender":"@ebnera:in.tum.de",
"sender_device":"IXSABTUFJC",
"keys":{"ed25519":"0Bk1QwAj2a4+E9ZNbL6szC0qj9JcScVIpdrNI5ZTowU"},
"recipient":"@fuhhbarmatrixtest:matrix.org",
"recipient_keys":{"ed25519":"qGUDoyysVcD3wgQZk6fu0aJNm01IeVn9m5WsJ09diok"},
"type":"m.room_key",
"content":{
"algorithm":"m.megolm.v1.aes-sha2",
"room_id":"!pvAiYjulqdNNXdjfHT:in.tum.de",
"session_id":"MEXyh8flJdc1nHRCbT6UEpM3ySL3lyVJk2lLkdN+sPA",
"session_key":"AgAAAAApKLafaR2+c+TS1pxnVeOIykeS4xiuABE7QDBofTGdUD0x7MvhCcYNyqsPWgtLzMuO+J+EK68KYY+HFaxY8cTOQgd/ZOGlCiSAa/+OhzDd/+Xk4f0mEkjehOVxQnPfWK1zTVhRKZN9DOUAXWtpfppbzaGX1tQz0LQVvDAflGR3DTBF8ofH5SXXNZx0Qm0+lBKTN8ki95clSZNpS5HTfrDwTHJAr0UN7w1aPMXi7H+rmeJxNZhmUQiptU9hmy6BF6ZpCHFEjN19s0TN2STAUF0oKkjeDnDZpU1okbVoBhOdCA",
"chain_index":0
}
}

Order of PreKey and Encrypted message

The partner sends us the prekey and the m.room.enrypted message of the first room message almost at the same time.
The sync() reads both events in one HTTP response and puts both into the corresponding event loops.
Due to the fact that we have an asynchronous behavior it can happen that we are trying to decrypt the message before the prekey message is handled. Therefore, at the moment, we have this workaround:

        if not meg_ses:
            await asyncio.sleep(5)
            meg_ses = self.room_keys.get((message[1], sender_device_id, session_id))

Maybe a better solution can be found to synchronize the events.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.