Commit Graph

46 Commits

Author SHA1 Message Date
Jack Lloyd
e8b4474cb9 Fix handling when attempting to decrypt with a session that isn't found
There were two discrepancies between the logic here and the original
logic of libsignal-protocol-java.

First, if the session record had an uninitialized active session, in
Java this would still attempt decryption with the old session states,
but Rust would stop immediately without trying the old states. [I am
not sure if this ever happens but it could possibly occur due to use
of archiveCurrentState]

Secondly, we returned the wrong error condition. We treated lack of a
sender chain as an invalid state (effectively an internal error) but
Java treats it as an invalid message, which makes sense in so far as
it is a message which we are unable to process with the information we
have available. This wrong error type led to an unexpected exception
being thrown in Android.
2021-01-07 14:17:17 -05:00
Jack Lloyd
0a4f50f4df Remove SessionState from the Rust API 2021-01-06 12:57:41 -05:00
Jack Lloyd
30773b6210 cargo fmt 2020-12-18 13:23:45 -05:00
Jack Lloyd
ad8e40ff7c Convert fingerprints to use proto2 encoding 2020-12-18 13:05:13 -05:00
Jack Lloyd
2e8339e154 Add a known answer test for fingerprint protobuf encoding 2020-12-18 12:54:53 -05:00
Jordan Rose
997c399884 Rust: Move deny-warnings behavior into CI
Warnings don't need to be immediately fixed locally, and they make it
harder to test with newer nightlies. CI is the place to enforce it.
2020-12-10 14:22:20 -08:00
Jack Lloyd
ef9ea63fd3 cargo fmt 2020-12-10 13:17:56 -05:00
Jack Lloyd
0c9607e604 Don't expose SenderKey implementation detail types 2020-12-10 13:11:42 -05:00
Jack Lloyd
ae35ebd418 Don't export *
Name the specific things we are exporting from this crate.
2020-12-10 13:11:42 -05:00
Jack Lloyd
93b74eb56d Remove remote_registration_id and session_version from Rust
These are here just to copy the Java SessionCipher API but if you
need this just load the session record from your store.

[The Java library does exactly this, without bothering to call the
Rust version]
2020-12-10 13:11:42 -05:00
Jack Lloyd
371d746a36 Hide some more of the Rust API
Previously ChainKey etc were used by JNI during some intermediate
steps in converting the Java library to use Rust. But no longer,
so don't export them.
2020-12-10 13:11:41 -05:00
Jack Lloyd
e9ae35d826 Merge pull request #111 from signalapp/jack/cleanup-imports
Clean up some imports
2020-12-10 13:10:27 -05:00
Jack Lloyd
9ac6912397 Clean up some imports
Why was this re-exporting the type with a new name?
2020-12-10 09:03:37 -05:00
Jack Lloyd
f87c41b0d1 Avoid returning SessionState from the ratchet initializer functions
These still need to be exposed for the Java tests but they only
need to see the SessionRecord not the SessionState.

The internal functions still need to return a SessionState due to how
these functions are used within the crate.
2020-12-10 08:32:47 -05:00
Jack Lloyd
d9177ca951 cargo fmt 2020-12-10 07:46:34 -05:00
Jack Lloyd
6330c87f73 Update Rust tests to avoid SessionState 2020-12-10 07:37:27 -05:00
Jack Lloyd
2b405e4f91 Make most of Rust's SessionState pub(crate)
Remove some functions which were not used within the crate or the bindings.

Also fix some type errors in the JNI binding - SessionState was being
used instead of SessionRecord, and this happened to work because the
first element of a SessionRecord is an Option<SessionState>
2020-12-10 07:19:14 -05:00
Jack Lloyd
4b4af51b08 Remove more of SessionState from the Java binding
Leaving only a few bits still directly used by Android
2020-12-09 17:29:20 -05:00
Jack Lloyd
f471a455c0 Merge pull request #102 from signalapp/jack/java-session-cleanup
Cleanup Java Session logic
2020-12-09 16:52:14 -05:00
Jordan Rose
2e72dc3f4c Comment protobuf definitions where order matters for repeated fields 2020-12-08 17:06:36 -08:00
Jack Lloyd
f8182af008 Invoke native methods instead of manipulating protobufs within Java 2020-12-08 18:13:12 -05:00
Jordan Rose
df87cd2edf UnidentifiedSenderMessageContent: Don't validate the sender up front
Both the Android and iOS clients currently allow customizing this
validatation logic for testing purposes, and iOS additionally wants to
log the information about the unwrapped message even if there are
problems with it.

iOS does also currently log information about the unwrapped message
even if the static key being used is wrong, but in order to fix that
we'd have to have a secondary return value (either the expected static
key, computed during decrypt-to-USMC, or a flag saying whether the
comparison failed).
2020-12-01 16:50:49 -08:00
Jack Lloyd
643a637b34 Merge pull request #77 from signalapp/jack/sealed-sender
Sealed Sender
2020-12-01 17:43:30 -05:00
Jordan Rose
f555b5084d Sealed sender prekey messages are type 1, not 3 2020-11-30 10:30:40 -08:00
Jack Lloyd
5123d43c08 Clippy fix 2020-11-21 04:57:08 -05:00
Jack Lloyd
040c03045d cargo fmt 2020-11-20 05:28:50 -05:00
Jack Lloyd
74f56a5a68 Avoid magic constants 2020-11-20 05:28:04 -05:00
Jack Lloyd
5e3f0193c4 Enable warnings again 2020-11-20 05:12:27 -05:00
Jack Lloyd
1f63a4cd37 cargo fmt 2020-11-19 17:54:12 -05:00
Jack Lloyd
43eb4aacd8 Add sealed sender cipher tests in Rust
Just ports of the Java tests
2020-11-19 17:48:08 -05:00
Jack Lloyd
786b9b5792 SealedSessionCipher decrypt 2020-11-19 16:06:04 -05:00
Jack Lloyd
405d071ead SealedSessionCipher encrypt 2020-11-19 13:24:29 -05:00
Jack Lloyd
ddda1a3635 UnidentifiedSenderMessage 2020-11-19 13:24:29 -05:00
Jack Lloyd
4a8705dce1 UnidentifiedSenderMessageContent 2020-11-19 13:24:29 -05:00
Jack Lloyd
507629ff0d Add SenderCertificate and ServerCertificate 2020-11-19 13:24:29 -05:00
Jack Lloyd
387031ef68 Remove support for PendingKeyExchange
This is something from the TextSecure days and is no longer used.
2020-11-18 16:57:17 -05:00
Jack Lloyd
7434023567 Remove some unused protobufs 2020-11-18 16:10:30 -05:00
Jack Lloyd
fff2efeca4 Fix some new clippy warnings from nightly 2020-11-09 12:46:57 -05:00
Jack Lloyd
aaf9b93429 Merge pull request #26 from signalapp/jack/add-public-key-bytes
Add PublicKey::public_key_bytes
2020-11-05 14:54:03 -05:00
Jordan Rose
33b8c6ad8d Run cargo fmt after async changes 2020-11-03 14:35:38 -08:00
Jordan Rose
90a9f76dc6 Thread 'async' through any protocol APIs that take Stores
In preparation for Desktop, which must asynchronously access its
database (rather than putting the entire operation on a background
thread with synchronization at the database layer).

The FFI and JNI wrappers (as well as the tests) use
futures::executor::block_on to turn the operations back into
synchronous ones.
2020-11-03 14:35:38 -08:00
Jack Lloyd
9a7785686b Add PublicKey::public_key_bytes
Signal-Android needs this function, probably Swift will as well.

Also fix the Swift tests on Linux
2020-11-03 17:06:04 -05:00
Jack Lloyd
946e0670f6 Switch to AGPL 3.0 2020-11-02 17:53:10 -05:00
Jack Lloyd
b8a50a1291 Bump aes-soft crate to 0.6
As it has some nice optimizations vs 0.5
2020-10-28 13:41:58 -04:00
Jordan Rose
c1ffb1b805 ffi: Expose named constants for CiphertextMessageType
Also:
- Expose them to Swift as well in a type-safe way
- Verify that each constant matches the encoding used in rust/protocol/
2020-10-22 11:34:25 -07:00
Jack Lloyd
a0a4ffb40f Move libsignal-protocol-rust to rust/protocol 2020-10-15 15:41:20 -04:00