olm/javascript
Richard van der Hoff 939aa747dd JS: make sure returned strings are null-terminated
It turns out that the 'length' argument to 'Pointer_stringify' doesn't work if
the input includes characters >= 128.

Rather than try to figure out which methods can return UTF-8, and which always
return plain ascii, replace all uses of Pointer_stringify with a 'length'
argument with the version that expects a NULL-terminated input, and extend the
buffer by a byte to allow space for a null-terminator.

In the case of decrypt, we need to add the null ourself.

Fixes https://github.com/vector-im/vector-web/issues/1719.
2016-07-06 22:32:51 +01:00
..
demo Put a signature on sent group messages 2016-05-26 18:01:02 +01:00
.gitignore Make 'npm build' build the js lib 2016-04-26 12:12:08 +01:00
README.md Javascript bindings for group sessions 2016-05-25 17:48:01 +01:00
olm_inbound_group_session.js javascript/olm_inbound_group_session.js: fix length arg 2016-05-26 13:57:09 +01:00
olm_outbound_group_session.js Javascript bindings for group sessions 2016-05-25 17:48:01 +01:00
olm_post.js JS: make sure returned strings are null-terminated 2016-07-06 22:32:51 +01:00
olm_pre.js Fix a console error when importing in a browser 2015-12-02 14:06:01 +00:00
package.json Add support for building the JS wrappers to the Makefile 2016-05-20 15:15:40 +01:00

README.md

Olm

Example:

var alice = new Olm.Account();
var bob = new Olm.Account();
alice.create();
bob.create();
bob.generate_one_time_keys(1);

var bobs_id_keys = JSON.parse(bob.identity_keys());
var bobs_id_key = bobs_id_keys.curve25519;
var bobs_ot_keys = JSON.parse(bob.one_time_keys());
for (key in bobs_ot_keys.curve25519) {
    var bobs_ot_key = bobs_ot_keys.curve25519[key];
}

alice_session = new Olm.Session();
alice_session.create_outbound(alice, bobs_id_key, bobs_ot_key);
alice_message = a_session.encrypt("Hello");

bob_session.create_inbound(bob, bob_message);
var plaintext = bob_session.decrypt(message_1.type, bob_message);
bob.remove_one_time_keys(bob_session);

Group chat:

var outbound_session = new Olm.OutboundGroupSession();
outbound_session.create();

// exchange these over a secure channel
var session_id = group_session.session_id();
var session_key = group_session.session_key();
var message_index = group_session.message_index();

var inbound_session = new Olm.InboundGroupSession();
inbound_session.create(message_index, session_key);

var ciphertext = outbound_session.encrypt("Hello");
var plaintext = inbound_session.decrypt(ciphertext);