0
0
mirror of https://github.com/signalapp/libsignal.git synced 2024-09-20 20:03:07 +02:00
Commit Graph

584 Commits

Author SHA1 Message Date
Jordan Rose
8fa2f4a73f JNI: Rethrow callback exceptions instead of wrapping them 2021-01-12 11:54:19 -08:00
Jordan Rose
5e9bf3d5d1 Remove unused error variants from Signal{Ffi,Jni}Error 2021-01-12 11:54:19 -08:00
Jordan Rose
049300d9d4 JNI: Report callback exceptions as the "cause" of a callback failing 2021-01-12 11:54:19 -08:00
Jordan Rose
9d901b27c8 Abstract over ApplicationCallback errors
This simplifies SignalProtocolError at the cost of an extra heap
allocation for other errors. On its own, that probably isn't worth it,
but this lays groundwork for propagating exceptions / errors back up
in the native environment.
2021-01-12 11:54:19 -08:00
Jordan Rose
609a1de733 JNI: remove unused helper function 2021-01-12 11:54:19 -08:00
Jack Lloyd
ba91fe441e
Merge pull request #135 from signalapp/jack/fix-decrypt-logic
Fix handling when attempting to decrypt with a session that isn't found
2021-01-07 16:47:51 -05:00
Jack Lloyd
0184984db5 Add a test that decryption works after you archive a session state 2021-01-07 15:24:44 -05:00
Jack Lloyd
5cd00ffe1d
Merge pull request #134 from signalapp/jack/fix-empty-session-access
Resolve difference in behavior between Java and Rust SessionRecord
2021-01-07 14:24:56 -05:00
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
f6a6b210f5 Handle another possible error on our sealed sender fuzzing test 2021-01-07 13:54:37 -05:00
Jack Lloyd
9e208765de Don't swallow all errors only the one we except when a session is absent 2021-01-07 13:33:31 -05:00
Jack Lloyd
564a1b7d54 Resolve difference in behavior between Java and Rust SessionRecord
In libsignal-protocol-java, SessionRecord holds a SesssionState struct which is
the "active" session plus a list of old states. If the record is freshly
created, there is still a SessionState, but it is an uninitialized/new protobuf
structure which causes all fields to be empty/zero/false.

So in the original Java logic you can call for example hasSenderChain, and on
an empty/fresh record it will return false. However in Rust, in this case the
Option is empty and we return an error instead.

For hasSenderChain, it seems reasonable to return false if there is no active
session, since if there is no session there is certainly no chain.

Android also expects the session version to be == 0 on such sessions, but this
makes less sense, so have this logic only in the Java binding and not in the
Rust library proper.
2021-01-07 13:15:25 -05:00
Jack Lloyd
239534e062
Merge pull request #132 from signalapp/jack/remove-java-session-state
Remove SessionState
2021-01-06 13:20:41 -05:00
Jack Lloyd
40c73e412e Regenerate signal_ffi.h 2021-01-06 12:58:40 -05:00
Jack Lloyd
0a4f50f4df Remove SessionState from the Rust API 2021-01-06 12:57:41 -05:00
Jack Lloyd
8ae34e784b Remove SessionState from Java interface
With https://github.com/signalapp/Signal-Android-Private/pull/1279 merged,
Android no longer uses SessionState
2021-01-06 12:57:41 -05:00
Jack Lloyd
60c135f1b4
Merge pull request #124 from signalapp/jack/node-binding-curve
Add PublicKey and PrivateKey for Node
2021-01-04 17:10:48 -05:00
Jordan Rose
9a5dc1cf9f
Merge pull request #130 from signalapp/jrose/generate-signal_ffi.h-offline
Swift: Generate signal_ffi.h offline, like Native.java
2021-01-04 13:54:34 -08:00
Jordan Rose
baba4519de Swift: Generate signal_ffi.h offline, like Native.java
- Verify its correctness with build_ffi.sh --verify-ffi
- Regenerate with build_ffi.sh --generate-ffi

This simplifies the header search logic for both SwiftPM and
CocoaPods, as well as saving on build time by avoiding cbindgen.

The tweak to cbindgen.toml to prefer typedef-based structs and enums
is sidestepping an incompatibility between cbindgen 0.15.0 (which
GitHub has installed) and 0.16.0 (which allows reusing a release build
directory as well as a debug one).
2021-01-04 13:41:07 -08:00
Jordan Rose
e32862ef24
Merge pull request #129 from signalapp/jrose/gen_java_decl-verify
Add a --verify option to gen_java_decl.py
2021-01-04 13:03:59 -08:00
Jordan Rose
7b3093ddbb Add a --verify option to gen_java_decl.py
And bump the copyright years to 2021.
2021-01-04 12:08:26 -08:00
Jack Lloyd
f81e679926
Merge pull request #127 from AsamK/identitykeypair_deserialize
Implement IdentityKeyPair Deserialize for Java
2021-01-04 12:31:59 -05:00
Sebastian
b9cfddb97a Implement IdentityKeyPair Deserialize 2021-01-04 17:42:41 +01:00
Jack Lloyd
16dfd3acb0 Add PublicKey and PrivateKey operations to Node layer 2020-12-18 17:33:28 -05:00
Jack Lloyd
d1b8d4a6d4
Merge pull request #125 from signalapp/jack/proto2-fingerprint
Convert fingerprints to use proto2 encoding
2020-12-18 14:31:14 -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
3a33eb1205
Merge pull request #123 from signalapp/jrose/swift-xcode-big-sur
Swift: fix Xcode build on Big Sur
2020-12-17 09:51:17 -08:00
Jordan Rose
02899cac64 Swift: fix Xcode build on Big Sur
Rust build scripts and proc-macros are compiled for the host, rather
than the target, which means they need a search path to link against
the host's libraries. macOS Big Sur doesn't provide that in the
default search paths anymore, so we add one manually based on an
environment variable provided by Xcode.
2020-12-16 10:12:08 -08:00
Jack Lloyd
fcbca8fbf1
Merge pull request #121 from signalapp/jack/swift-use-correct-type
Use the correct handle
2020-12-14 18:11:35 -05:00
Jack Lloyd
f90d6e660d Remove leftover handle declaration 2020-12-14 18:00:53 -05:00
Jack Lloyd
2d5f46ae6b Use the correct handle
Fixes #120
2020-12-14 17:14:02 -05:00
Jack Lloyd
ee3b8c7bdd
Merge pull request #119 from signalapp/jack/ci-build-for-ios
Cross build the Rust code for iOS
2020-12-14 14:08:39 -05:00
Jack Lloyd
fbcdbaf3c4 Cross build the Rust code for iOS
Hopefully avoiding bugs like #117
2020-12-14 13:36:27 -05:00
Jordan Rose
984f538c9f
Merge pull request #117 from signalapp/jrose/duplicate-cpuid
AES: Fix duplicated aarch64-apple-ios helper method
2020-12-11 15:05:18 -08:00
Jordan Rose
a4d611935b AES: Fix duplicated aarch64-apple-ios helper method 2020-12-11 14:14:52 -08:00
Jordan Rose
8fae9eeb3e
Merge pull request #116 from signalapp/jrose/un-deny-warnings
Rust: Move deny-warnings behavior into CI
2020-12-10 15:19:47 -08: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
Jordan Rose
e4ad87fb85
Merge pull request #76 from signalapp/jrose/begin-merging-bridge-libraries
Begin merging bridge libraries (ffi and jni)
2020-12-10 13:12:33 -08:00
Jordan Rose
8a15b7397b Bridge: Avoid copies *and* unnecessary types with More Macros 2020-12-10 12:53:42 -08:00
Jordan Rose
64c1eac9ca Add string serialization as well 2020-12-10 12:51:15 -08:00
Jordan Rose
2d83e9a154 Move bytearray serialization into libsignal-bridge 2020-12-10 12:49:32 -08:00
Jordan Rose
bf0079fb90 Bridge: Combine FFI-only and JNI-only SessionRecord functions 2020-12-10 12:22:41 -08:00
Jordan Rose
7355f9b999 Bridge: Fix exclude-for-JNI-only logic 2020-12-10 11:30:47 -08:00
Jordan Rose
0e19342801 Build libsignal_jni.so with LTO when using it from Java
When building a cdylib, Rust currently doesn't export public symbols
on Linux if they come from a dependency. However, enabling LTO gets
around this by performing the filtering step after the merging.

https://github.com/rust-lang/rfcs/issues/2771
2020-12-10 11:29:42 -08:00
Jordan Rose
b2f8a255ec Reorganize libsignal-bridge platform-specific parts 2020-12-10 11:29:02 -08:00
Jordan Rose
a20860b144 Support libsignal-bridge with both "ffi" and "jni" turned on
This is useful for our Rust CI, which runs things like
`cargo test --all` by default. Cargo features are considered
additive, so in order to build libsignal-ffi and libsignal-jni, a
hybrid libsignal-bridge ends up getting built (instead of two copies)
2020-12-10 11:28:12 -08:00
Jordan Rose
97733572d2 Move deserialization into bridge/shared as well 2020-12-10 11:26:51 -08:00
Jordan Rose
99613a5f47 Adopt all destroyers in the shared bridge library
And reorganize a little in the support files.
2020-12-10 11:22:09 -08:00