Random matrix-related scripts.
Go to file
Aleksa Sarai c42ef15984
merge branch 'pr-1'
Florian Heese (1):
  replaced pycrypto with its successor pycryptodome

LGTMs: cyphar
2021-11-11 09:59:47 +11:00
COPYING *: license under GPLv3+ 2019-04-14 04:26:52 +10:00
README.md replaced pycrypto with its successor pycryptodome 2021-02-03 23:38:36 +01:00
megolm_backup.py megolm_backup: cleanliness improvements to IV handling 2019-04-15 18:49:28 +10:00
requirements.txt replaced pycrypto with its successor pycryptodome 2021-02-03 23:38:36 +01:00

README.md

matrix-utils

Random matrix utilities.

megolm_backup.py

This script can be used to modify your offline megolm key backups from a shell. The main use of this is to filter what keys you'd like to share with another user (let's say you have a 1:1 chat, and the other user lost all their keys and you need to give them access without giving access to all of your rooms). There is currently no Riot-based tooling for this, so this script can help in the meantime.

I've tested the output and input format with my own room keys and it has worked so far.

usage: megolm_backup.py [-h] [-o OUTPUT] (--into | --from) [file]

Operate on megolm session backups.

positional arguments:
  file                  Input text file (- for stdin).

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        Output text file (- for stdout).
  --into                Encrypt and represent file as a megolm session backup.
  --from                Decrypt the given megolm session and output the
                        contents.

Using the above example, let's say we want to only get session keys of the room !foo:matrix.org. You can do this fairly easily with jq:

% megolm_backup.py --from riot-keys.py |
	jq 'map(select(.room_id == "!foo:matrix.org"))' |
	megolm_backup.py --into > new-riot-keys.txt

You need to have PyCryptodome installed in order for this script to work.

License

matrix-utils is licensed under the GNU General Public License version 3 or later.

Copyright (C) 2019 Aleksa Sarai <cyphar@cyphar.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.