Commit graph

248 commits

Author SHA1 Message Date
Richard van der Hoff
c09aa77c4a Avoid ldconfig in the Makefile
... because OSX doesn't support it.
2016-09-05 11:56:53 +01:00
Richard van der Hoff
057ab15c1a Merge pull request #14 from matrix-org/rav/convert_crypto_to_c
Convert crypto.hh into C-compatible interface
2016-09-05 10:42:09 +01:00
Richard van der Hoff
69f269ffaf Convert AES functions to plain C 2016-09-05 10:40:39 +01:00
Richard van der Hoff
f0acf6582f Convert Ed25519 and Curve25519 functions to plain C 2016-09-05 10:40:39 +01:00
Richard van der Hoff
2aad4cfa86 Merge pull request #15 from matrix-org/rav/has_received_message
OlmSession.has_received_message
2016-09-05 10:38:41 +01:00
Richard van der Hoff
fee1748c60 Merge pull request #16 from matrix-org/rav/fix_megolm_utf8
Fix megolm decryption of UTF-8
2016-09-05 10:37:55 +01:00
Richard van der Hoff
9d16d82089 Merge pull request #13 from matrix-org/rav/split_out_key_lengths
Create new constants for key lengths, etc
2016-09-05 10:36:43 +01:00
Richard van der Hoff
1d4c13c798 Fix megolm decryption of UTF-8
Repeat the fix from b10f90d for megolm messages.

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/2078.
2016-09-05 00:49:36 +01:00
Richard van der Hoff
2e9021c2e7 OlmSession.has_received_message
I find myself wanting to know if an OlmSession is in the pre-key state or not,
to help debugging at the application level.
2016-09-04 23:41:10 +01:00
Richard van der Hoff
39212987bd Create new constants for key lengths, etc
We were using olm::KEY_LENGTH for everything under the sun which happened to be
32 bytes long, and making a bunch of assumptions in the process. Create a bunch
of new constants (as C #defines rather than C++ consts so that I can use them
in another forthcoming refactor).
2016-09-02 15:11:14 +01:00
Richard van der Hoff
0c3f527dfd Bump version in package.json
... to match the Makefile
2016-09-01 14:31:34 +01:00
Richard van der Hoff
e3664ef1d2 Merge branch 'rav/ed25519_fix' 2016-09-01 14:12:38 +01:00
Richard van der Hoff
214e932806 Merge branch 'rav/ed25519_fix' 2016-09-01 14:06:57 +01:00
Richard van der Hoff
f7c428d62c update changelog
pre-1.0.0 was broken too
2016-09-01 14:00:26 +01:00
Richard van der Hoff
0c462cff11 Fix Ed25519 keypair generation
Ed25519 private keys, it turns out, have 64 bytes, not 32.

We were previously generating only 32 bytes (which is all that is required to
generate the public key), and then using the public key as the upper 32 bytes
when generating the per-message session key. This meant that everything
appeared to work, but the security of the private key was severely compromised.

By way of fixes:

 * Use the correct algorithm for generating the Ed25519 private key, and store
   all 512 bits of it.

 * Update the account pickle format and refuse to load the old format (since we
   should consider it compromised).

 * Bump the library version, and add a function to retrieve the library
   version, so that applications can verify that they are linked against a
   fixed version of the library.

 * Remove the curve25519_{sign, verify} functions which were unused and of
   dubious quality.
2016-09-01 13:35:23 +01:00
Matthew Hodgson
f2906ac0e7 refer to Double Ratchet in readme 2016-07-16 20:56:29 +01:00
Richard van der Hoff
f03febb772 Document the release process 2016-07-11 14:51:04 +01:00
Richard van der Hoff
d30db7b5c0 Makefile rules to build the rst into html 2016-07-11 14:50:49 +01:00
Richard van der Hoff
f3b9c3bbbb Prepare 1.0.0 release 2016-07-11 12:50:11 +01:00
Richard van der Hoff
f2151c0287 Merge branch 'rav/fix_decrypt_utf8' 2016-07-06 22:33:14 +01:00
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
Emmanuel Gil Peyrot
c8d00665b3 Add an install and an install-debug targets
This makes the user able to use the familiar `make install` syntax, and
allows overriding of the default directories using the DESTDIR and
PREFIX variables, for example:
 make DESTDIR=packaging PREFIX=/usr install
2016-07-05 23:21:28 +01:00
Emmanuel Gil Peyrot
06cdb3f75e Specify the soname in the library and its name
This provides users of this library the guarantee that the ABI will
stay stable when MAJOR will reach 1, and will stay backwards compatible
for the entire duration of the 1.x.y branch.

It does require the maintainers to always update the version in the
Makefile at every ABI change.
2016-07-05 23:21:22 +01:00
Richard van der Hoff
d8b24acb77 PR feedback
* write V1 pickles on the master branch
* the logging branch is going to write v0x80000001
2016-06-30 14:01:02 +01:00
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