Commit Graph

111 Commits (f16377822f2b3b0f00bebf244d2dfb8fb1712344)

Author SHA1 Message Date
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 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
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 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 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 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 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 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 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
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
Richard van der Hoff f9139dfa6a Convert error.hh to plain C 2016-05-23 18:55:05 +01:00
Richard van der Hoff e533b0dc8e Give SHA256 functions C bindings 2016-05-23 18:55:05 +01:00
Richard van der Hoff 4f1bb49d20 Rename olm.hh to olm.h 2016-05-23 18:55:05 +01:00
Richard van der Hoff acae4e8438 Remove functions which return strings
We don't want anything which does dynamic memory allocation in the library.
2016-05-20 15:07:10 +01:00
Richard van der Hoff 2a09ccbd63 Remove vestiges of logging
Remove the (now non-functional) declarations of olm_set_log_level in the C and
js wrappers.
2016-05-16 11:50:44 +01:00
Richard van der Hoff 3965320a9c Remove logging functionality
Concerns have been raised that including logging functionality makes it harder
to audit the implementation to ensure that no secret information is leaked. We
are therefore removing it from the master branch.
2016-05-16 11:13:54 +01:00
Richard van der Hoff b3db0e6ee1 translate logging.cpp to C 2016-05-16 11:05:57 +01:00
Richard van der Hoff 48cb5f925d Add olm::log_enabled_for 2016-05-16 11:04:26 +01:00
Richard van der Hoff 11dbf2aab3 Fix a bunch of compiler warnings, and turn on warnings. 2016-04-26 18:10:13 +01:00
Richard van der Hoff 9848f84452 Add some logging to help understand what's going on 2016-04-26 17:55:26 +01:00
Richard van der Hoff e7a2af1ede Add a basic logging implementation 2016-04-26 12:30:18 +01:00
Mark Haines 5e1b8a5b3b Add docstrings for the utility class 2015-08-20 10:08:15 +01:00
Mark Haines 7649125a9e Add docstrings for the Session methods 2015-08-19 18:16:47 +01:00
Mark Haines b318055185 Replace hard coded references to the 32-byte key length with a constant, add utilities for copying data to and from fixed sized arrays 2015-08-19 17:32:06 +01:00
Mark Haines a378a40b3a Document that the ciphertext and plaintext may share a buffer when encrypting and decrypting 2015-08-19 15:39:19 +01:00
Mark Haines 900d2d70b4 Add docstring for the base64 encode/decode methods 2015-08-19 15:38:20 +01:00
Mark Haines c35d1d420f Check that the end of input hasn't been reached when unpickling a list 2015-08-11 13:14:06 +01:00
Mark Haines 39c1f3b355 Add methods for computing sha256 hashes and validating ed25519 signatures 2015-07-24 14:29:52 +01:00
Mark Haines 3468886e27 Add method getting a session id. Update the python and javascript bindings 2015-07-16 11:45:20 +01:00
Mark Haines 89d9b972a6 Add versions of olm_session_create_inbound and olm_session_matches_inbound which take the curve25519 identity key of the remote device we think the message is from as an additional argument 2015-07-16 10:45:10 +01:00
Mark Haines 3bfa8e5863 Fix bug in list where the wrong value was copied if an item was inserted at the beinging of the list 2015-07-15 16:31:45 +01:00
Mark Haines 137aa31e95 olm_account_last_error and olm_clear_account should take an Account not a Session 2015-07-15 13:24:26 +01:00
Mark Haines 2e49a6f41e Clear the random buffers once they've been used. Add methods for clearing the account and session object once they've been used 2015-07-10 18:29:14 +01:00
Mark Haines 5ad929104e Version the pickled objects and check for errors when unpickling them 2015-07-10 18:00:18 +01:00
Mark Haines b6e248c9a5 Output simpler JSON for the account keys, don't sign the JSON but instead provide a olm_account_sign method so that the user of the library can sign the JSON themselves 2015-07-10 11:57:53 +01:00
Mark Haines 373acefde7 Add c bindings for the methods for managing one time keys 2015-07-09 18:35:54 +01:00
Mark Haines 5634be0507 Add methods for generating new one time keys and for tracking which one time keys have been published 2015-07-09 16:09:16 +01:00
Mark Haines 0e988237f6 Don't pass a key id when creating a new outbound session 2015-07-08 16:04:18 +01:00
Mark Haines 532dc0d4e7 Change the JSON format for one time keys to include what algorithm they are for 2015-07-08 15:30:34 +01:00
Mark Haines dceae043b3 Remove the RemoteKey type since it wasn't being used 2015-07-08 14:57:55 +01:00
Mark Haines 5291ec78b5 Send the public part of the one time key rather than passing an identifier 2015-07-08 14:53:25 +01:00
Mark Haines 974e0984bd Update the javascript bindings and demo to match the format of the identity key JSON 2015-07-08 11:16:00 +01:00
Mark Haines 3a382aec59 Encode the account keys as a signed JSON object 2015-07-07 16:42:03 +01:00
Mark Haines 2a873fd4e1 Add functions for creating and verifying ed25519 signatures 2015-07-07 09:50:32 +01:00
Mark Haines a30a64d179 Rename generate_key to curve25519_generate_key 2015-07-07 09:03:12 +01:00
Mark Haines f1cd5613f6 Remove the last resort one time key 2015-07-07 09:01:38 +01:00
Mark Haines 667e415c74 Removed SignedKey class 2015-07-07 08:56:18 +01:00
Matthew Hodgson 17aa7e6580 remove rogue axolotls 2015-06-28 17:56:40 +02:00
Matthew Hodgson 09d4125ff1 Rename axolotlpp as olm to avoid confusion with Axolotl-the-spec and Axolotl-the-OWS-libraries at moxie's request 2015-06-27 01:15:23 +02:00