Commit Graph

120 Commits

Author SHA1 Message Date
Jordan Rose
fa113a571e Point folks to libsignal-client instead
Some checks failed
Rust / build (push) Has been cancelled
2020-11-09 13:49:18 -08:00
Jordan Rose
39ba4489fe Derive all (Partial)?(Ord|Eq) for IdentityKey
...instead of deriving some and synthesizing others. Caught by nightly
`cargo clippy`.
2020-10-13 11:23:01 -07:00
Jack Lloyd
fe28cb9679 Add a test that verifies contexts are passed back 2020-10-06 13:32:51 -04:00
Jack Lloyd
7e1dbcc26e Derive Clone on all types 2020-10-05 17:14:39 -04:00
Jack Lloyd
146ff74995 Add warning to README 2020-09-18 16:06:50 -04:00
Jack Lloyd
f02bdf6eb5 Remove some redundant uses of ref 2020-09-17 12:55:18 -04:00
Jack Lloyd
a375f1d92a Improve the error types used for FFI errors 2020-09-17 12:54:17 -04:00
Jack Lloyd
e9c03b2f06 Add a Context parameter which is passed back to storage callbacks
This is needed on iOS which uses similar functionality so that all
operations occur within a DB transaction.
2020-09-17 12:54:03 -04:00
Jack Lloyd
9b2fa1618d Add GPL license notification to all source files
Use rustfmt to enforce format
2020-08-28 12:44:23 -04:00
Jack Lloyd
69b648b48b Update all dependencies to latest versions 2020-08-28 12:44:08 -04:00
Jack Lloyd
ffcf2e8be4 Change benchmark to more accurately reflect performance 2020-08-27 11:59:26 -04:00
Jack Lloyd
518d5991b0 Use constant time comparison for public keys 2020-08-26 11:50:18 -04:00
Jack Lloyd
724c886327 Remove has_message_keys
First we see if we have message keys, then in a distinct operation
we find them again and remove them. Just do it in one step.
2020-08-24 12:41:42 -04:00
Jack Lloyd
c4daa0f5cc cargo fmt 2020-08-20 16:34:04 -04:00
Jack Lloyd
09d1851fd9 Fix a bug in message decryption
We should reject duplicated messages immediately without trying
to decrypt them with every state.

Reorder some prekey handling functions to match the Java
2020-08-20 16:34:04 -04:00
Jack Lloyd
6dac966d71 Expose the functions for decrypting with prekey and SignalMessage
Java has different API points for this and having distinct functions
to call simplifies things on the FFI side.
2020-08-20 16:34:04 -04:00
Jack Lloyd
ec7a132f63 Un-struct SessionCipher
The Java code uses a class here which contains referencs to the various
stores. However this is less than convenient in the case of FFI.
In particular encryption only requires access to a couple of the stores.
2020-08-20 16:34:04 -04:00
Jack Lloyd
2a04176285 Remove some unused storage callbacks
A lot of these functions are afaict just defined on the interface,
implemented in Signal-Android, and then never used anywhere at all. A
few are used within the Signal-Android client, but not in
libsignal-protocol-{java,rust}. Remove anything that we ourselves do
not need implemented, because every additional function on these
traits adds a few dozen lines in the JNI interop layer.

This doesn't negatively affect Signal-Android since we will retain the
various functions on the Java interface specs. They'll simply never be
invoked, which is mostly the status quo anyway with
libsignal-protocol-java.
2020-08-18 13:19:00 -04:00
Jack Lloyd
5101e38cae Export Direction enum 2020-08-17 18:15:33 -04:00
Jack Lloyd
82035c14c6 cargo fmt 2020-08-17 14:57:25 -04:00
Jack Lloyd
ae764bc78a Add SenderKeyName::sender_name, sender_device_id
Avoids an unnecessary clone when getting the device ID since otherwise
we call sender() which clones the ProtocolAddress but then we extract
the u32 and throw away the string.

Rename SenderKeyRecord::empty to is_empty to match Java.
2020-08-17 14:57:25 -04:00
Jack Lloyd
aebe140ed6 Fix sender key logic
The Java storage interface wants to return a newly allocated
SenderKeyRecord if it is new. This seems weird to me vs just returning
null but in any case detect a fresh record.

We continue to expect an Option<> and create a new fresh record if
None is returned as other bindings may find it more convenient to just
return None/null/whatever.

Also limit sender key IDs to 31-bits for Java
2020-08-17 14:57:25 -04:00
Jack Lloyd
dc392949f2 Add FfiBindingError
This allows bindings (ex JNI) to pass errors received from a callback
back through libsignal-protocol-rust so they can be returned by the
operation which had invoked the callback.

We could instead do something fancy with Any here instead, so that a
callback into Java which throws an exception ends with exception being
captured, flowing through libsignal-protocol-rust and then rethrown
when we return to Java. But it's not clear if that's so necessary
vs the much simpler option of capturing the exception text.
2020-08-17 14:57:25 -04:00
Jack Lloyd
b25516f75e cargo fmt 2020-08-12 19:58:56 -04:00
Jack Lloyd
5f9578c312 Allow deriving a public key from the private key
Also clamp private keys on deserialization
2020-08-12 19:45:37 -04:00
Jack Lloyd
19ef92eaec Fix a clippy warning 2020-08-11 17:11:46 -04:00
Jack Lloyd
ed09f6044e More FFI fixes, a few missing functions and changes of types 2020-08-11 17:11:46 -04:00
Jack Lloyd
d9d3bee790 More changes for FFI
Rename KeyPair::new to KeyPair::generate and add a KeyPair::new which
just takes the respective public and private key.

Add deserialize functions for PreKey and SignedPreKey objects
2020-08-11 17:11:46 -04:00
Jack Lloyd
b086534b16 Small changes to make FFI simpler 2020-08-05 17:17:12 -04:00
Jack Lloyd
920f1a6d07 Add features to enable the dalek backends 2020-08-03 21:08:17 -04:00
Jack Lloyd
3cc635d27d cargo fmt 2020-08-03 21:08:17 -04:00
Jack Lloyd
993f845301 Add a simple benchmark
Shuffle some of the test support code into support/mod.rs so it can
be used in benchmarks also
2020-08-03 21:08:17 -04:00
Jack Lloyd
2d8098ad84 More ratchet tests
Enable some pre-existing tests which were disabled due to bad cfg()

Add some ratchet tests from libsignal-protocol-java which were missed
2020-08-03 21:07:12 -04:00
Jack Lloyd
ab1e9f373a New fmt behavior 2020-08-03 17:21:27 -04:00
Jack Lloyd
d4d867f748 Remove dead code
The Java equivalent of remove_previous_session_states is also dead - not called
within either the lib itself nor by Signal-Android.

The previous_counter field in SignalMessage seems to be dead and I don't
understand its purpose. It is similar dead in the Java code (read, but not used
anywhere within the class and not exposed via a getter).

Unrelated, export HKDF as Signal-Android uses HKDF via libsignal

Now dead code is also prohibited. modulo the previous_counter field.
2020-08-03 17:21:27 -04:00
Jack Lloyd
67ead624a9 Expose a few fingerprint functions as public API 2020-08-03 15:26:05 -04:00
Jack Lloyd
bc5dec2d9c Run clippy in CI 2020-07-30 15:06:49 -04:00
Jack Lloyd
a98ec0a84e Move verify_signature and calculate_agreement onto the relevant structs
Since these functions are needed for FFI bindings and it makes sense
for them to exist on the struct itself
2020-07-30 13:49:20 -04:00
Jack Lloyd
b6fcd32ae3 Ignore editor backups 2020-07-30 13:49:20 -04:00
Jack Lloyd
2ef8c0888c Fix clippy warnings 2020-07-30 13:49:20 -04:00
Jack Lloyd
175689382e Add LICENSE and README files 2020-07-30 13:49:20 -04:00
Jack Lloyd
9d4bebcee7 Move arbitrary constants to consts.rs 2020-07-28 15:37:54 -04:00
Jack Lloyd
b30bec68cd Remove SenderKeyName::serialize 2020-07-28 15:19:53 -04:00
Jack Lloyd
0191ec0408 Clean up error handling surrounding AES encryption 2020-07-28 15:19:53 -04:00
Jack Lloyd
286cb46578 Add group tests ported from Java 2020-07-28 15:19:53 -04:00
Jack Lloyd
677a529ab3 Add group cipher logic 2020-07-28 15:19:53 -04:00
Jack Lloyd
187fc261f8 Implement SenderKeyStore for InMemSignalProtocolStore 2020-07-28 15:19:53 -04:00
Jack Lloyd
b95f7beb12 Add logic for handling sender keys 2020-07-28 15:19:53 -04:00
Jack Lloyd
1e35fe0956 Implement SenderKeyDistributionMessage 2020-07-28 15:19:53 -04:00
Jack Lloyd
7e16c12cf2 Add some Error types 2020-07-28 15:19:53 -04:00