Commit graph

128 commits

Author SHA1 Message Date
David Baker
621097f62b Yay for incorrect comments breaking the build... 2019-01-30 18:18:55 +00: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
manuroe
2784e49595
Merge pull request #70 from matrix-org/manuroe/objc_pk
OLMKit: Add objc wrappers for pk encryption/decryption
2018-10-22 08:25:41 +02:00
Hubert Chathi
09dc3b6025 document a couple more places where olm clobbers things 2018-10-16 16:13:09 -04:00
manuroe
2ea2bc8ebc Fix compilation warning for olm_pk_private_key_length(void); 2018-10-16 15:52:41 +02:00
David Baker
fac1d52dfe Add aliases for deprecated functions 2018-10-11 18:16:39 +01:00
Hubert Chathi
f6e3f7f44a
Merge branch 'master' into dbkr/pk_private_export_import 2018-10-05 14:52:01 -04:00
Hubert Chathi
173339ae9a add more comments describing the pk encrypt/decrypt functions 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
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
Hubert Chathi
dac2c1064e use void in type signatures for functions with no arguments 2018-06-28 17:13:52 -04:00
Hubert Chathi
f709b062bb add functions for pickling/unpickling a decryption object 2018-06-28 17:10:36 -04:00
Hubert Chathi
128d45cc83 add initial implementation of basic private key encryption functionality 2018-06-27 16:38:45 -04:00
Hubert Chathi
6a2a2741e8 fix some comments 2018-06-27 16:35:15 -04:00
manuroe
9d81046f90 Fix warnings reported by LLVM 2018-06-27 12:25:27 -04:00
Alexey Rusakov
3c33180fe3 Avoid C99 inside C++ code
This disrupts building at least with Visual Studio.

Signed-off-by: Alexey Rusakov <ktirf@users.sf.net>
2017-09-29 09:35:04 +01:00
Richard van der Hoff
c04b770cd3 Add some tests for inbound session import/export 2017-01-10 14:11:42 +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
Mark Haines
7e9f3bebb8 Document the return values for olm_matches_inbound_session 2016-10-25 14:42:10 +01:00
Richard van der Hoff
21ce3491dd Clear random buf in olm_init_outbound_group_session
All the other methods clear their random inputs. This one needs to do the same,
to reduce the risk of the randomness being used elsewhere and leaking key info.
2016-10-21 17:19:59 +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
Richard van der Hoff
76aad9d9c3 Update comment on olm_account_one_time_keys
Document what it actually returns.
2016-09-16 14:05:48 +01:00
Mark Haines
d7bc00c81d Merge pull request #23 from matrix-org/markjh/remove_message_index
Remove the messsage index from olm_init_inbound_group_session
2016-09-13 17:54:14 +01:00
Mark Haines
a628ef41bd Remove the messsage index from olm_init_inbound_group_session since it is read from the session_key 2016-09-13 17:51:02 +01:00
Mark Haines
6971f54fea Add a olm_inbound_group_session_id method 2016-09-13 17:02:36 +01:00
Richard van der Hoff
2fc83aa9ac Sign megolm messages
Add ed25519 keys to the inbound and outbound sessions, and use them to sign and
verify megolm messages.

We just stuff the ed25519 public key in alongside the megolm session key (and
add a version byte), to save adding more boilerplate to the JS/python/etc
layers.
2016-09-06 15:26:26 +01:00
Richard van der Hoff
50cd2b2a43 Clean up some typos
Remove redundant args from some js funcs, and fix a comment typo
2016-09-06 14:06:43 +01:00
Richard van der Hoff
833ecd3c73 Convert ed25519 pickling functions to C
... so that I can use them from the group session bits.
2016-09-05 12:59:12 +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
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
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