Commit graph

977 commits

Author SHA1 Message Date
Richard van der Hoff
8dd3c182ee Make space in the session pickle for chain index
Keeping track of the chain index is a useful thing to do, but is only required
if we've enabled diagnostics. Extend the session pickle format to make a space
for it, so that pickles can be transferred between the logging_enabled branch
and the master branch without loss of information.

Also add some tests for session pickling which explicitly check that we can
unpickle both formats of pickle.
2016-06-30 11:38:01 +01:00
Richard van der Hoff
757c422578 Remove unused 'chain_index' from Ratchet
This was introduced when I was experimenting with support for logging progress
in Olm. That is now relegated to the logging_enabled branch, so this should
probably be removed.

This also fixes the incompatibility of session pickles from the current master
branch with those from olm 0.1.0.
2016-06-30 11:31:36 +01:00
Richard van der Hoff
803672931a Put a signature on sent group messages
It's important that group messages be signed by the sender, rather than by a
secret derived from the shared secret.
2016-05-26 18:01:02 +01:00
Richard van der Hoff
7c5ab63fd8 js group demo: use a remoteOps object
To make sure that we don't sneakily use methods which we wouldn't be able to
for remote users, expose an interface object which contains the remote
interface.
2016-05-26 17:14:33 +01:00
Richard van der Hoff
952a3e15cf Merge branch 'rav/group_chat_js_bindings' 2016-05-26 13:58:14 +01:00
Richard van der Hoff
389a181ea8 javascript/olm_inbound_group_session.js: fix length arg
message.length counts codepoints; we need bytes.
2016-05-26 13:57:09 +01:00
Mark Haines
09b8c3d7bc Merge remote-tracking branch 'matrix/master' 2016-05-26 13:27:23 +01:00
Mark Haines
bfeb554e86 Add a fuzzer for olm_group_decrypt 2016-05-26 13:25:34 +01:00
Richard van der Hoff
315fbfc921 Add a demo for group messaging via the JS bindings 2016-05-25 17:48:01 +01:00
Richard van der Hoff
013f27f3dc Javascript bindings for group sessions 2016-05-25 17:48:01 +01:00
Richard van der Hoff
708fddd747 Remove session_id from group messages
Putting the session_id inside the packed message body makes it hard to extract
so that we can decide which session to use. We don't think there is any
advantage to having thes sesion_id protected by the HMACs, so we're going to
move it to the JSON framing.
2016-05-25 17:42:32 +01:00
Richard van der Hoff
ee8172d882 Compile some of the crypto libs directly
sha256.c and aes.c contain conflicting declarations, so we need to compile them
as separate units. This requires a bit more Makefile-shuffling; the build
directory now includes 'src' or 'lib' as appropriate, and we just mkdir -p
before each compilation.
2016-05-25 17:08:44 +01:00
Richard van der Hoff
27b57c8d88 Merge branch 'rav/more_group_chat/1' 2016-05-25 15:46:50 +01:00
Richard van der Hoff
fae8dacab5 Add a comment explaining Mark's latest fix 2016-05-25 15:44:39 +01:00
Richard van der Hoff
54d43010c8 Merge branch 'rav/jenkins_build' 2016-05-25 15:33:33 +01:00
Mark Haines
19a7fb5df5 Fix an integer wrap around bug and add a couple more tests 2016-05-25 15:00:05 +01:00
Mark Haines
024685f3db Merge branch 'markjh/fuzzingII' 2016-05-25 14:32:03 +01:00
Richard van der Hoff
01ea3d4b9a Fix handling of integer wraparound in megolm.c 2016-05-24 17:52:35 +01:00
Richard van der Hoff
1f31427139 megolm_advance_to: Remove excessive optimisation
There was some slightly overcomplex logic designed to save a couple of hash
operations when R(0) and R(1) were advanced, but the extra code was hard to
understand and didn't save much.
2016-05-24 17:38:43 +01:00
Richard van der Hoff
ef8d24f483 megolm.c: rewrite counter update
We no longer need to keep track of intermediate values of the counter, which
means we can update it much more easily.
2016-05-24 17:33:41 +01:00
Richard van der Hoff
f3c0dd76d7 megolm.c: Remove spurious arguments to rehash_part
These were left over from when rehash_part did a bunch of logging.
2016-05-24 17:03:42 +01:00
Richard van der Hoff
8d55954ce1 Avoid use of jq in test_olm
I want to use test_olm.sh on jenkins, which lacks jq. Hence, add support to
olm.main to get id and one-time keys individually.
2016-05-24 16:50:26 +01:00
Richard van der Hoff
ed039d331c Merge branch 'master' into rav/jenkins_build 2016-05-24 16:30:23 +01:00
Richard van der Hoff
8d31f42b1e Build the tests with -g
think this got lost when mark added separate release/debug builds
2016-05-24 16:28:14 +01:00
Richard van der Hoff
1b15465c42 Separate base64ing from the rest of msg encoding
Factor the actual message encoding/decoding and encrypting/decrypting out to
separate functions from the top-level functions which do the base64-wrangling.

This is particularly helpful in the 'outbound' code-path where the offsets
required to allow room to base64-encode make the flow hard to see when it's all inline.
2016-05-24 16:23:19 +01:00
Richard van der Hoff
a919a149fb Update megolm_cipher as a global struct
Initialise megolm_cipher via the preprocessor macro, instead of with a
function.
2016-05-24 14:54:01 +01:00
Richard van der Hoff
a49d7284f3 add a script for jenkins to run 2016-05-24 14:45:32 +01:00
Richard van der Hoff
15cb4ec0c0 Build the crypto libs as C99
Some of the crypto libs rely on UINT64_C, which in glibc 2.17 and earlier was
not defined for C++ code (see
https://sourceware.org/bugzilla/show_bug.cgi?id=15366).
2016-05-24 14:41:49 +01:00
Richard van der Hoff
fa1e9446ac Use _olm_unset instead of memset
memset is at risk of being optimised away, so use _olm_unset instead.
2016-05-24 13:40:21 +01:00
Richard van der Hoff
173cbe112c Avoid relying on uint -> int casting behaviour
The behaviour when casting from a uint32_t which has overflowed (so has the top
bit set) to int32_t is implementation-defined, so let's avoid relying on it.
2016-05-24 13:40:21 +01:00
Richard van der Hoff
846ab858a6 Python wrapper: support for inbound group sessions 2016-05-24 13:40:21 +01:00
Richard van der Hoff
fc4756ddf1 Fix up some names, and protobuf tags
Make names (of session_key and message_index) more consistent.

Use our own protobuf tags rather than trying to piggyback on the one-to-one
structure.
2016-05-24 13:40:21 +01:00
Richard van der Hoff
a073d12d83 Support for pickling inbound group sessions 2016-05-24 13:40:21 +01:00
Richard van der Hoff
39ad75314b Implement decrypting inbound group messages
Includes creation of inbound sessions, etc
2016-05-24 13:39:34 +01:00
Richard van der Hoff
8b1514c0a6 Implement functions to get the state of outbound session
We need to be able to inspect an outbound session so that we can tell our peer
how to set up an inbound session.
2016-05-24 13:39:34 +01:00
Richard van der Hoff
e545ad7eaf Outbound group session support in the python wrappers 2016-05-24 13:39:34 +01:00
Richard van der Hoff
c058554132 Implement pickling/unpickling for outbound group sessions 2016-05-24 13:39:34 +01:00
Richard van der Hoff
caaed796ad Implementation of an outbound group session 2016-05-24 13:39:34 +01:00
Richard van der Hoff
68d3c7bfa9 Implementation of the megolm ratchet 2016-05-24 13:39:34 +01:00
Richard van der Hoff
42a300fc62 Factor out pickle_encoding from olm.cpp
We don't need to have all of the top-level pickling functions in olm.cpp;
factor out the utilities to support it to pickle_encoding.cpp (and make sure
that they have plain-C bindings).
2016-05-24 13:39:32 +01:00
Richard van der Hoff
256bce10fc Factor out olm_error_to_string to a separate file
I want to be able to use this functionality from elsewhere, so factor it out to
its own file.
2016-05-24 13:35:28 +01:00
Richard van der Hoff
2e7800cf65 Merge branch 'rav/c_bindings' 2016-05-24 13:33:33 +01:00
Richard van der Hoff
2fd28a6682 Rewrite _olm_cipher_aes_sha_256 initialisation
Replace the init-static-var dance with some preprocessor macros
2016-05-24 12:06:47 +01:00
Richard van der Hoff
d4a3c8dbaa Remove 'destruct' from cipher_ops
We never delete a cipher, and the destruct op is empty, so it's a bit pointless
2016-05-24 09:56:01 +01:00
Mark Haines
b1c5732fc8 Fix bug in bounds check when parsing 2016-05-23 19:37:58 +01:00
Richard van der Hoff
444ef1f706 Prefix for internal symbols
Give a load of internal symbols "_olm_" prefixes. This better delineates the
public and private interfaces in the module, and helps avoid internal symbols
leaking out and possibly being abused.
2016-05-23 18:55:06 +01:00
Richard van der Hoff
c57b2b71c5 C bindings for base64 functions 2016-05-23 18:55:06 +01:00
Richard van der Hoff
a1855b99b9 C binding for olm::unset 2016-05-23 18:55:05 +01:00
Richard van der Hoff
07b33acee5 C bindings for pickle functions 2016-05-23 18:55:05 +01:00
Richard van der Hoff
294cf482ea Convert cipher.hh to plain C 2016-05-23 18:55:05 +01:00