From 38acc352a3f3aac40c132e5321da540da38c832e Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sun, 2 Oct 2016 02:50:52 +0100 Subject: 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 --- python/olm/account.py | 1 + python/olm/session.py | 1 + 2 files changed, 2 insertions(+) (limited to 'python/olm') diff --git a/python/olm/account.py b/python/olm/account.py index 7673329..3fa1049 100644 --- a/python/olm/account.py +++ b/python/olm/account.py @@ -41,6 +41,7 @@ account_function(lib.olm_account_one_time_keys_length) account_function(lib.olm_account_one_time_keys, c_void_p, c_size_t) account_function(lib.olm_account_mark_keys_as_published) account_function(lib.olm_account_max_number_of_one_time_keys) +account_function(lib.olm_pickle_account_length) account_function( lib.olm_account_generate_one_time_keys_random_length, c_size_t diff --git a/python/olm/session.py b/python/olm/session.py index 308f220..19d43d3 100644 --- a/python/olm/session.py +++ b/python/olm/session.py @@ -58,6 +58,7 @@ session_function( c_void_p, c_size_t, # Identity Key c_void_p, c_size_t, # Pre Key Message ) +session_function(lib.olm_pickle_session_length) session_function(lib.olm_encrypt_message_type) session_function(lib.olm_encrypt_random_length) session_function(lib.olm_encrypt_message_length, c_size_t) -- cgit v1.2.3 From 653790eacbf7dcf94cbf181657cdb0c30c890c3f Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 20 Oct 2016 09:58:55 +0100 Subject: Return the message index when decrypting group messages. Applications can use the index to detect replays of the same message. --- python/olm/__main__.py | 2 +- python/olm/inbound_group_session.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'python/olm') diff --git a/python/olm/__main__.py b/python/olm/__main__.py index cf9158d..eb76301 100755 --- a/python/olm/__main__.py +++ b/python/olm/__main__.py @@ -328,7 +328,7 @@ def do_group_decrypt(args): session = InboundGroupSession() session.unpickle(args.key, read_base64_file(args.session_file)) message = args.message_file.read() - plaintext = session.decrypt(message) + plaintext, message_index = session.decrypt(message) with open(args.session_file, "wb") as f: f.write(session.pickle(args.key)) args.plaintext_file.write(plaintext) diff --git a/python/olm/inbound_group_session.py b/python/olm/inbound_group_session.py index d5547fd..27a569c 100644 --- a/python/olm/inbound_group_session.py +++ b/python/olm/inbound_group_session.py @@ -43,6 +43,7 @@ inbound_group_session_function( lib.olm_group_decrypt, c_void_p, c_size_t, # message c_void_p, c_size_t, # plaintext + POINTER(c_uint32), # message_index ) inbound_group_session_function(lib.olm_inbound_group_session_id_length) @@ -82,11 +83,14 @@ class InboundGroupSession(object): ) plaintext_buffer = create_string_buffer(max_plaintext_length) message_buffer = create_string_buffer(message) + + message_index = c_uint32() plaintext_length = lib.olm_group_decrypt( self.ptr, message_buffer, len(message), - plaintext_buffer, max_plaintext_length + plaintext_buffer, max_plaintext_length, + byref(message_index) ) - return plaintext_buffer.raw[:plaintext_length] + return plaintext_buffer.raw[:plaintext_length], message_index def session_id(self): id_length = lib.olm_inbound_group_session_id_length(self.ptr) -- cgit v1.2.3 From 700596b46aadcc224c1768b40d11cf2150b866ac Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 25 Oct 2016 14:50:15 +0100 Subject: Update python wrapper to run against libolm.so.2 --- python/olm/_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python/olm') diff --git a/python/olm/_base.py b/python/olm/_base.py index bc5c206..80720d9 100644 --- a/python/olm/_base.py +++ b/python/olm/_base.py @@ -7,7 +7,7 @@ def read_random(n): return f.read(n) lib = cdll.LoadLibrary(os.path.join( - os.path.dirname(__file__), "..", "..", "build", "libolm.so.1") + os.path.dirname(__file__), "..", "..", "build", "libolm.so.2") ) lib.olm_error.argtypes = [] -- cgit v1.2.3