Commit graph

98 commits

Author SHA1 Message Date
Hubert Chathi
bac8ca7802 prepare for 3.1.0 release 2019-04-17 17:31:01 -04:00
Hubert Chathi
ebc156e7c2 re-add null termination in javascript
because older versions of emscripten don't support the length argument to
UTF8ToString.
2019-04-08 15:54:02 -04:00
Damir Jelić
071029c201 javascript: Switch from deprecated Pointer_stringify() to UTF8toString().
The Pointer_stringify() function is deprecated and has a couple of
issues because it tries to guess the encoding of the buffer. In some
cases it can ignore the length parameter which could end up in
inconsistencies.

Switch to UTF8toString() that takes a length parameter and respects,
that way we don't need to allocate an additional byte for a NULL byte.
2019-04-08 15:18:28 -04:00
Hubert Chathi
3148157ea4 add support for an incorrect KDF that snuck into Riot 1.0 2019-04-02 23:39:05 -04:00
Hubert Chathi
0348f06a56 rename functions to be more consistent 2019-03-13 22:39:21 -04:00
Hubert Chathi
48dda7922d call the right function and remove unnecessary include 2019-02-01 11:39:06 -05:00
David Baker
8df2ab7c07 Add signing class to the pk module 2019-01-29 20:47:41 +00:00
Hubert Chathi
94f664e725
initial implementation of short authentication string generation 2019-01-21 23:21:41 -05:00
Hubert Chathi
ff24af601a prepare release 3.0.0 2018-10-23 12:58:10 -04:00
Hubert Chathi
340a4965c9 include the non-wasm version in the package 2018-10-23 12:24:49 -04:00
Hubert Chathi
93f764200e zero buffers in the JavaScript bindings 2018-10-16 17:50:34 -04:00
Hubert Chathi
22f8649c10 also ignore the non-wasm JS file 2018-10-16 16:11:22 -04:00
David Baker
e73ebcea67 Merge remote-tracking branch 'origin/master' into dbkr/pk_private_export_import 2018-10-10 20:15:40 +01:00
Hubert Chathi
f6e3f7f44a
Merge branch 'master' into dbkr/pk_private_export_import 2018-10-05 14:52:01 -04:00
Hubert Chathi
0a25ec137f
Merge branch 'master' into dbkr/wasm 2018-10-05 10:50:01 -04:00
Hubert Chathi
bad14db8da remove unneeded polyfill 2018-10-05 10:35:09 -04:00
Hubert Chathi
8520168e0b fix some code style issues and typos 2018-10-05 10:35:09 -04:00
David Baker
602c00a8d6 Dual-build wasm and asm.js olm 2018-10-04 20:09:54 +01:00
David Baker
e521ee84c5 Add an export for the length of a private key 2018-10-02 19:21:05 +01:00
David Baker
0346145a81 Work with PkDecryption keys by their private keys
Change interface to allow the app to get the private part of the
key and instantiate a decryption object from just the private part
of the key.

Changes the function generating a key from random bytes to be
initialising a key with a private key (because it's exactly the
same thing). Exports & imports private key parts as ArrayBuffer at
JS level rather than base64 assuming we are moving that way in
general.
2018-10-02 12:02:56 +01:00
David Baker
0ad32c9896 Call appropriate wrapper function
Don't think this matters since there's no PkEncryption /
PkDecryption object being passed, but for the sake of consistency
2018-10-01 13:22:04 +01:00
David Baker
c4a3918686 Support passing olm options into init() 2018-09-26 16:38:39 +01:00
David Baker
dfbe8a4796 Return same promise if init() called many times
So we only init the library once.
2018-09-25 17:48:17 +01:00
David Baker
263b94428a Another day, another interface
Change the interface again, hopefully this time a bit more normal.
Now we wrap the emscripten module completely and just expose the
high level objects.

The olm library export is now imported as normal (ie. returns
a module rather than a function returning a module) but has an
`init` method which *must* be called. This returns a promise
which resolves when the module is ready. It also rejects if the
module failed to set up, unlike before (and unlike the
promise-not-a-promise that emscripten returns).

Generally catch failures to init the module.
2018-09-25 17:13:29 +01:00
David Baker
f29d8cdd7b Also ship the wasm file 2018-09-21 16:39:04 +01:00
David Baker
5e87db615a Make OLM_OPTIONS work again
The closure compiler was just renaming the variable so it never
would have picked them up. Make it an extern so it knows what to do.
2018-09-21 16:35:17 +01:00
David Baker
122867c45c WebAssembly support!
Quite a lot going on in this PR:
 * Updates to support recent emscripten, switching to WASM which is now the default
 * Use emscripten's MODULARIZE option rather than wrapping it ourself, since doing
   so in pre-post js doesn't work anymore.
 * Most changes are moving the emscripten runtime functions to top-level
   calls rather than in the Module object.
 * Get rid of duplicated NULL_BYTE_PADDING_LENGTH
 * Fix ciphertext_length used without being declared
 * Fix things that caused the closure compiler to error, eg. using
   OLM_OPTIONS without a declaration.
 * Wait until module is inited to do OLM_ERROR = olm_error()

The main BREAKING CHANGE here is that the module now needs to initialise
asyncronously (because it has to load the wasm file). require()ing olm
now gives a function which needs to be called to create an instance.
The resulting object has a promise-like then() method that can be used
to detect when the module is ready. (We could use MODULARIZE_INSTANCE
to return the module directly as before, rather than the function,
but then we don't get the .then() method).
2018-09-21 16:01:51 +01:00
Hubert Chathi
98e8ee1b0d prepare 2.3.0 2018-07-04 15:24:44 -04:00
Hubert Chathi
f709b062bb add functions for pickling/unpickling a decryption object 2018-06-28 17:10:36 -04:00
Hubert Chathi
3ed0ec226c add termination 2018-06-28 17:03:46 -04:00
Hubert Chathi
552da6eafe use the correct method to get the random length 2018-06-27 17:36:55 -04:00
Hubert Chathi
128d45cc83 add initial implementation of basic private key encryption functionality 2018-06-27 16:38:45 -04:00
Hubert Chathi
3f5b9dd6d7 patch for libolm: fix some typos in JavaScript library
From 4a82d31e8cb808a04956fc847ed0ec0ff322b956 Mon Sep 17 00:00:00 2001
From: Hubert Chathi <hubert@uhoreg.ca>
Date: Wed, 3 Jan 2018 21:37:43 -0500
Subject: [PATCH] fix some typos in JavaScript library

Signed-off-by: Hubert Chathi <hubert@uhoreg.ca>
2018-01-09 15:57:47 +00:00
Richard van der Hoff
77eaaa3d5f prepare v2.2.2 2017-03-01 16:21:37 +00:00
Richard van der Hoff
b185229c2b Prep v2.2.1 2017-01-18 18:16:32 +00:00
Richard van der Hoff
150c360e82 Bump version numbers to 2.2.0 2017-01-18 16:03:02 +00: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
86b64b653a Bump version numbers throughout 2016-12-22 15:03:00 +00:00
Richard van der Hoff
e2e398bd94 Add some tests for the Javascript wrappers
These would have helped avoid the recent FRV.
2016-12-19 09:43:58 +00:00
Richard van der Hoff
8e554ab5ef Avoid buffer overrun on encryption
Make sure we null-terminate encrypted strings before passing them to
UTF8ToString.

This used to work when we allocated the buffer on the stack, because it turns
out that allocate() zeroinits the returned memory. malloc(), of course, does
not.
2016-12-16 14:42:41 +00:00
Richard van der Hoff
7fd63bcac7 Merge pull request #39 from matrix-org/rav/messages_on_heap
Allocate memory for message blobs on the heap
2016-12-15 16:54:39 +00:00
Richard van der Hoff
09b3e1eecd typo 2016-12-15 16:28:30 +00:00
Richard van der Hoff
8356fa37ad zero out plaintext buffers
Avoid leaving copies of the plaintext sitting around in the emscripten heap.
2016-12-15 13:37:34 +00:00
Richard van der Hoff
76610c0a3a Allocate memory for message blobs on the heap
Messages can be very large, so we don't really want to allocate them on the
stack. Switch to using the heap for them, and try to clean up some of the
string handling while we're at it.
2016-12-14 12:05:56 +00:00
Richard van der Hoff
51b141ecb6 Let apps override emscripten settings
Read settings from OLM_OPTIONS to allow apps to configure some options. In
particular, this is useful for setting the heap size.
2016-12-14 11:46:12 +00:00
Richard van der Hoff
1bf807bf33 Better handling of exceptions during loading
If we get an exception during load, don't define half of window.Olm (which
confuses apps).

This is a partial fix to https://github.com/vector-im/riot-web/issues/2726.
2016-12-12 16:52:03 +00:00
Richard van der Hoff
27c7b4a767 Version bump for 2.0.0 2016-10-25 11:35:20 +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
Mark Haines
ec7d968623 Changelog and version bump for 1.3.0 2016-09-14 13:55:54 +01:00