From 5fbeb3e29b6440a799d9320e871a1d4d509130b8 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 6 Jan 2017 12:55:05 +0000 Subject: 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. --- javascript/olm_inbound_group_session.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'javascript') diff --git a/javascript/olm_inbound_group_session.js b/javascript/olm_inbound_group_session.js index 2e4727f..8721a10 100644 --- a/javascript/olm_inbound_group_session.js +++ b/javascript/olm_inbound_group_session.js @@ -123,4 +123,21 @@ InboundGroupSession.prototype['session_id'] = restore_stack(function() { return Pointer_stringify(session_id); }); +InboundGroupSession.prototype['first_known_index'] = restore_stack(function() { + return inbound_group_session_method( + Module['_olm_inbound_group_session_first_known_index'] + )(this.ptr); +}); + +InboundGroupSession.prototype['export_session'] = restore_stack(function(message_index) { + var key_length = inbound_group_session_method( + Module['_olm_export_inbound_group_session_length'] + )(this.ptr); + var key = stack(key_length + NULL_BYTE_PADDING_LENGTH); + outbound_group_session_method(Module['_olm_export_inbound_group_session'])( + this.ptr, key, key_length, message_index + ); + return Pointer_stringify(key); +}); + olm_exports['InboundGroupSession'] = InboundGroupSession; -- cgit v1.2.3 From a2f0c93a93f6914291954b08a7518b4f17561c11 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 6 Jan 2017 17:40:39 +0000 Subject: 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. --- javascript/olm_inbound_group_session.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'javascript') diff --git a/javascript/olm_inbound_group_session.js b/javascript/olm_inbound_group_session.js index 8721a10..6bc745d 100644 --- a/javascript/olm_inbound_group_session.js +++ b/javascript/olm_inbound_group_session.js @@ -61,6 +61,15 @@ InboundGroupSession.prototype['create'] = restore_stack(function(session_key) { ); }); +InboundGroupSession.prototype['import_session'] = restore_stack(function(session_key) { + var key_array = array_from_string(session_key); + var key_buffer = stack(key_array); + + inbound_group_session_method(Module['_olm_import_inbound_group_session'])( + this.ptr, key_buffer, key_array.length + ); +}); + InboundGroupSession.prototype['decrypt'] = restore_stack(function( message ) { -- cgit v1.2.3