Commit Graph

107 Commits (emscripten-backport)

Author SHA1 Message Date
Damir Jelić 32b99b7935 python: Add support for the long KDF MAC calculation. 2019-04-09 10:57:36 +02:00
Damir Jelić 659eb34fa4 python: Remove an unneeded and old copyright header. 2019-04-09 10:47:26 +02:00
Hubert Chathi 74e9300daf add python bindings for PK signing 2019-04-08 17:19:47 -04:00
Hubert Chathi 2a6400716c
Merge branch 'master' into poljar/python-sas 2019-04-08 15:08:17 -04:00
Damir Jelić 709687a7b5 python: Build the build headers with setup.py.
This allows downstream users to install this python module with pip as
well as allowing people to declare it as a dependency in their setup.py.

Signed-off-by: Damir Jelić <poljar@termina.org.uk>
2019-04-08 15:04:32 -04:00
Damir Jelić f1d45c2cd3 python: Fix the MANIFEST file.
This patch adds the Olm header files to the manifest, this results in
the header files being added to source distributions of the python-olm
module.

The headers are required to build the module. Including them in the
source distribution is the easiest way to make sure that builds from the
source distribution will succeed provided that the Olm C library is
already installed.

Signed-off-by: Damir Jelić <poljar@termina.org.uk>
2019-04-08 15:04:32 -04:00
Damir Jelić f160d693b6 python: Add PK bindings.
This patch adds bindings to the PK part of the Olm library contained in
the pk.h header file.

Encryption, decryption as well as pickling/unpickling of the decryption
object is supported.

Signed-off-by: Damir Jelić <poljar@termina.org.uk>
2019-04-08 15:04:32 -04:00
Damir Jelić 0883a922ff python: Make the typing module a requirement only for old python versions.
Typing is part of standard library from python 3.5 and from python 3.7
onwards trying to install it results in an error.

This patch disables typing installation on python versions that are
newer than 3.5.

Signed-off-by: Damir Jelić <poljar@termina.org.uk>
2019-04-08 15:04:32 -04:00
Damir Jelić fcfa5f12a4 python: Expose the sha256() function in the utilities.
Signed-off-by: Damir Jelić <poljar@termina.org.uk>
2019-04-02 12:56:59 +02:00
Damir Jelić 446628753b python: Add Short Authentication String bindings.
This patch adds bindings to the SAS part of the Olm library contained in
the sas.h header file.

Signed-off-by: Damir Jelić <poljar@termina.org.uk>
2019-04-02 12:56:53 +02:00
Damir Jelić 45091c158d python: Turn the signature buffer into a bytearray.
This is a workaround for a bug where signature verification would
overwrite the variable holding the signature.

This only happens on python2.

Signed-off-by: Damir Jelić <poljar@termina.org.uk>
2019-01-23 17:10:44 -05:00
Hubert Chathi ff24af601a prepare release 3.0.0 2018-10-23 12:58:10 -04:00
Hubert Chathi 0ec6a65858 add more buffer clearing 2018-10-16 15:59:32 -04:00
Hubert Chathi 5ef6a844d6 overwrite buffers that may contain sensitive data
also reduce the amount of memory copying that we do
2018-10-16 00:31:56 -04:00
Hubert Chathi 357d4ff479 remove unnecessary comments about not enough random 2018-10-16 00:04:45 -04:00
Hubert Chathi 019ff702a0 add license headers to python bindings 2018-10-15 13:54:14 -04:00
Hubert Chathi af6c3ca5ce add dummy header files for generating cffi function list 2018-10-12 20:27:40 -04:00
Hubert Chathi 6c2f136bc9 remove code coverage and TravisCI badges
since they're not for the right repository any more
2018-10-12 19:19:19 -04:00
Hubert Chathi 718763f8fc build and test improvements
- build both Python2 and Python3 libs by default, and add separate rules
  building Python2 and Python.
- use the libraries as built by setuptools, rather than building again
  separately
2018-10-12 19:11:19 -04:00
Hubert Chathi 29b021b183 remove redundant license file 2018-10-12 18:55:37 -04:00
Hubert Chathi 04bbd728ba always use files from ../include and ../build 2018-10-12 18:55:05 -04:00
Hubert Chathi d4b2cce603 generate python/include/olm/olm.h automatically 2018-10-12 18:53:18 -04:00
Damir Jelić ac071d9c0d python: Enable build with the local build of the Olm C library.
This patch adds the ability to build the bindings without having a
globally installed Olm C library.

Provided that the C library is already built, the tests can be run now
with make test.

Signed-off-by: Damir Jelić <poljar@termina.org.uk>
2018-07-18 17:44:32 -04:00
Damir Jelić e3d6673371 python: Import improved python bindings.
This commit imports the python bindings from:
    https://github.com/poljar/python-olm

The bindings are imported at commit c44b145818520d69eaaa350fb95afcb846125e0f

Minor modifications were made while importing:
    - Removed travis config
    - Removed Arch Linux PKGBUILD
    - Removed the html docs, they can be rebuild by running make html in
      the docs folder
    - Slightly modified the README

The new bindings feature some improvements over the old ones:
    - Python 2 and 3 support
    - Automatic memory management
    - Automatic memory clearing before it is freed
    - Type signatures via the python typing module
    - Full test coverage
    - Properties are utilized where it makes sense (e.g. account.id)

Signed-off-by: Damir Jelić <poljar@termina.org.uk>
2018-07-18 17:44:32 -04:00
Damir Jelić 2fccf44015 python: Remove the python bindings.
Signed-off-by: Damir Jelić <poljar@termina.org.uk>
2018-07-18 17:44:32 -04:00
Wilfried Klaebe 62b576b903 Python: add binding for olm_remove_one_time_keys
Signed-off-by: Wilfried Klaebe <w+gitstuff@chaos.in-kiel.de>
2018-05-29 11:41:25 +01:00
Richard van der Hoff f8c61b8f84 Python: Make ed25519_verify take some arguments
It's not much use if everything is hardcoded.
2017-04-24 13:14:36 +01:00
Richard van der Hoff 853ea8fbc7 Merge branch 'master'
Merge master into patched branch to fix conflicts prior to merge back to master
2017-04-24 12:35:17 +01:00
Richard van der Hoff 1225de14d7 PEP8
Fix line lengths in newly-added code
2017-04-24 12:34:28 +01:00
pik a3e5beab89 Add ed25519_verify to __init__.py and add test for ed25519_verify
Signed-off-by: Alexander Maznev <alexander.maznev@gmail.com>
2017-04-24 12:29:45 +01:00
pik e632bc9e52 Add utility module to olm/python - for ed25519_verify
Signed-off-by: Alexander Maznev <alexander.maznev@gmail.com>
2017-04-24 12:29:45 +01:00
pik 51840d82dc Return python int instead of c_uint32 for InboundGroupSession.decrypt message_index
Signed-off-by: Alexander Maznev <alexander.maznev@gmail.com>
2017-04-18 19:15:51 +01:00
Richard van der Hoff ed6ebb9a4d PEP8 for python bindings
make the python code adhere to PEP8
2017-04-18 19:07:56 +01:00
J08nY 001dc1edaa Python: Switch to a more general os.urandom for randomness source
Signed-off-by: Jan Jancar <johny@neuromancer.sk>
2017-04-04 10:45:11 +01:00
Richard van der Hoff a2f0c93a93 Implement importing group session data
olm_import_inbound_group_session, which reads the format written by
olm_export_inbound_group_session to initialise a group session.
2017-01-09 17:45:46 +00:00
Richard van der Hoff 5fbeb3e29b Enable exporting inbound group session keys
A pair of functions which allow you to export the megolm keys for an inbound
group session, so that an application can save/restore them.
2017-01-06 16:41:56 +00:00
Richard van der Hoff 700596b46a Update python wrapper to run against libolm.so.2 2016-10-25 14:50:15 +01:00
Mark Haines 5a98012c0d Merge pull request #31 from matrix-org/markjh/groupmessageindex
Return the message index when decrypting group messages.
2016-10-21 09:57:42 +01:00
Mark Haines 653790eacb Return the message index when decrypting group messages.
Applications can use the index to detect replays of the same message.
2016-10-20 09:58:55 +01:00
Matthew Hodgson 38acc352a3 fix missing ctypes function signatures
These missing signatures were causing OSX to truncate 64-bit pointers
to 32-bit pointers when calling the missing methods, causing segfaults
2016-10-02 02:50:52 +01:00
Richard van der Hoff b411f07df9 InboundGroupSession.init no longer requires a separate message_index 2016-09-22 16:24:03 +01:00
Richard van der Hoff cfcee54a81 Handle non-base64 chars in pickle files 2016-09-22 15:09:40 +01:00
Mark Haines d7bc00c81d Merge pull request #23 from matrix-org/markjh/remove_message_index
Remove the messsage index from olm_init_inbound_group_session
2016-09-13 17:54:14 +01:00
Mark Haines a628ef41bd Remove the messsage index from olm_init_inbound_group_session since it is read from the session_key 2016-09-13 17:51:02 +01:00
Mark Haines 6971f54fea Add a olm_inbound_group_session_id method 2016-09-13 17:02:36 +01:00
Richard van der Hoff 0c462cff11 Fix Ed25519 keypair generation
Ed25519 private keys, it turns out, have 64 bytes, not 32.

We were previously generating only 32 bytes (which is all that is required to
generate the public key), and then using the public key as the upper 32 bytes
when generating the per-message session key. This meant that everything
appeared to work, but the security of the private key was severely compromised.

By way of fixes:

 * Use the correct algorithm for generating the Ed25519 private key, and store
   all 512 bits of it.

 * Update the account pickle format and refuse to load the old format (since we
   should consider it compromised).

 * Bump the library version, and add a function to retrieve the library
   version, so that applications can verify that they are linked against a
   fixed version of the library.

 * Remove the curve25519_{sign, verify} functions which were unused and of
   dubious quality.
2016-09-01 13:35:23 +01:00
Richard van der Hoff 27b57c8d88 Merge branch 'rav/more_group_chat/1' 2016-05-25 15:46:50 +01:00
Richard van der Hoff 8d55954ce1 Avoid use of jq in test_olm
I want to use test_olm.sh on jenkins, which lacks jq. Hence, add support to
olm.main to get id and one-time keys individually.
2016-05-24 16:50:26 +01:00
Richard van der Hoff a49d7284f3 add a script for jenkins to run 2016-05-24 14:45:32 +01:00
Richard van der Hoff 846ab858a6 Python wrapper: support for inbound group sessions 2016-05-24 13:40:21 +01:00
Richard van der Hoff 8b1514c0a6 Implement functions to get the state of outbound session
We need to be able to inspect an outbound session so that we can tell our peer
how to set up an inbound session.
2016-05-24 13:39:34 +01:00
Richard van der Hoff e545ad7eaf Outbound group session support in the python wrappers 2016-05-24 13:39:34 +01:00
Richard van der Hoff 7ccaae564a Refactor python wrappers
Split the python wrappers into separate modules
2016-05-20 15:25:43 +01:00
Matthew Hodgson 28622db92f switch from /usr/bin/python to /usr/bin/env python. this doesn't help folks whose python path points at python3 (e.g. Arch linux) though, but I see no choice than they have to change the shebangs, as we do on Synapse. For instance, OSX doesn't have a python2 symlink, otherwise we'd use /usr/bin/env python2 shebang. 2015-11-01 13:05:51 +00:00
Mark Haines 3468886e27 Add method getting a session id. Update the python and javascript bindings 2015-07-16 11:45:20 +01:00
Mark Haines c965a0e619 Call the right c function from Session.matches_inbound. It was calling create_inbound_session rather than matches_inbound_session 2015-07-15 12:45:50 +01:00
Mark Haines 36d17d1cb2 Move olm.py to a python subdirectory. Add a script for testing the olm.py script 2015-07-14 11:38:43 +01:00