diff options
-rw-r--r-- | include/olm/account.hh | 2 | ||||
-rw-r--r-- | javascript/demo.html | 10 | ||||
-rw-r--r-- | javascript/olm_post.js | 21 | ||||
-rw-r--r-- | src/account.cpp | 2 |
4 files changed, 28 insertions, 7 deletions
diff --git a/include/olm/account.hh b/include/olm/account.hh index 1a4778b..b51fc1e 100644 --- a/include/olm/account.hh +++ b/include/olm/account.hh @@ -96,7 +96,7 @@ struct Account { std::uint8_t const * device_id, std::size_t device_id_length, std::uint64_t valid_after_ts, std::uint64_t valid_until_ts, - std::uint8_t * identity_keys, std::size_t identity_keys_length + std::uint8_t * identity_json, std::size_t identity_json_length ); OneTimeKey const * lookup_key( diff --git a/javascript/demo.html b/javascript/demo.html index cace119..5a32e96 100644 --- a/javascript/demo.html +++ b/javascript/demo.html @@ -29,10 +29,16 @@ document.addEventListener("DOMContentLoaded", function (event) { tasks.push(["alice", "Creating account", function() { alice.create() }]); tasks.push(["bob", "Creating account", function() { bob.create() }]); tasks.push(["alice", "Create outbound session", function() { - var bobs_keys_1 = JSON.parse(bob.identity_keys())[0]; + var bobs_id_keys = JSON.parse(bob.identity_keys("bob", "bob_device", 0, 0)); + var bobs_curve25519_key; + for (key in bobs_id_keys.keys) { + if (key.startsWith("curve25519:")) { + bobs_curve25519_key = bobs_id_keys.keys[key]; + } + } var bobs_keys_2 = JSON.parse(bob.one_time_keys())[1]; a_session.create_outbound( - alice, bobs_keys_1[1], bobs_keys_2[0], bobs_keys_2[1] + alice, bobs_curve25519_key, bobs_keys_2[0], bobs_keys_2[1] ); }]); tasks.push(["alice", "Encrypt first message", function() { diff --git a/javascript/olm_post.js b/javascript/olm_post.js index 6ebd198..0494460 100644 --- a/javascript/olm_post.js +++ b/javascript/olm_post.js @@ -63,13 +63,28 @@ Account.prototype['create'] = restore_stack(function() { ); }); -Account.prototype['identity_keys'] = restore_stack(function() { +Account.prototype['identity_keys'] = restore_stack(function( + user_id, device_id, valid_after, valid_until +) { + var user_id_array = array_from_string(user_id); + var device_id_array = array_from_string(device_id); var keys_length = account_method( Module['_olm_account_identity_keys_length'] - )(this.ptr); + )( + this.ptr, user_id_array.length, device_id_array.length, + valid_after, valid_after / Math.pow(2, 32), + valid_until, valid_until / Math.pow(2, 32) + ); + var user_id_buffer = stack(user_id_array); + var device_id_buffer = stack(device_id_array); var keys = stack(keys_length); account_method(Module['_olm_account_identity_keys'])( - this.ptr, keys, keys_length + this.ptr, + user_id_buffer, user_id_array.length, + device_id_buffer, device_id_array.length, + valid_after, valid_after / Math.pow(2, 32), + valid_until, valid_until / Math.pow(2, 32), + keys, keys_length ); return Pointer_stringify(keys, keys_length); }); diff --git a/src/account.cpp b/src/account.cpp index 1ca3b13..54edf6e 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -170,8 +170,8 @@ std::size_t olm::Account::get_identity_json_length( std::size_t olm::Account::get_identity_json( std::uint8_t const * user_id, std::size_t user_id_length, std::uint8_t const * device_id, std::size_t device_id_length, - std::uint64_t valid_until_ts, std::uint64_t valid_after_ts, + std::uint64_t valid_until_ts, std::uint8_t * identity_json, std::size_t identity_json_length ) { |