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

266 Commits

Author SHA1 Message Date
Alex Konradi
94432e2e32
Handle all CDSI server error codes
Match against all the error codes the documentation says the server can 
produce. Map these to error types in the app languages.
2024-03-26 16:41:12 -04:00
Alex Konradi
08513b208c
Determine ResultType from bridged fn signature
Examine the Rust signature to determine what the FFI output type should be. 
This lets us remove all usages of #[bridge_fn_void] since #[bridge_fn] now 
correctly detects the return type.
2024-03-26 15:56:53 -04:00
Alex Konradi
e87a1cba14
Handle "invalid token" response to CDSI request 2024-03-25 14:13:14 -04:00
Alex Konradi
ed19489470
Improve CDSI errors
Add bridging tests for all the CDSI error types, and diversify the types of 
exceptions that can be thrown from Java code.
2024-03-25 13:39:06 -04:00
Alex Konradi
26ebd007ab
Split up NetError type
Split up the NetError type into errors for specific services (CDSI, SVR3, 
Chat). Return these from their respective bridged functions.
2024-03-20 15:54:59 -04:00
Jordan Rose
5a05c936a7 GroupSendEndorsementsResponse: Weaken performance claims in docs
Right now the benefits of receiving GroupSendEndorsementsResponse
using member ciphertexts are balanced by the increased cost of
deserializing the full ciphertexts instead of just the part we need.
We can improve things here if needed, but for now let's just not claim
that the ciphertext approach is "significantly" better than the
alternative.
2024-03-18 09:59:16 -07:00
Jordan Rose
fca9196201 GroupSendEndorsements: don't fall over in the face of 1-person groups
Previously we'd attempt to create a combination of zero endorsements
for the everybody-but-me credential, and panic (throw an error). Now
we correctly create an endorsement that represents zero people, which
is better than returning some dummy value because it behaves
reasonably if endorsements from multiple groups are combined wholesale
(not something we plan to do, but something that shouldn't have weird
edge cases if we end up needing to).
2024-03-18 09:59:16 -07:00
Jordan Rose
37e68943d6 Add GroupSendEndorsement.toFullToken(...) convenience method
If apps want to cache these tokens, they should prefer to cache the
non-"full" version because it won't redundantly contain the
expiration, but if they don't, dealing with two token types is
unnecessary complexity.
2024-03-18 09:59:16 -07:00
Alex Konradi
3aa3c583bf Move CDSI code to libsignal-bridge::net::cdsi
Move the implementation of the CDSI service into its own module to provide
better scoping. Move the CdsiError that is used only for bridging out of
libsignal-net and into the bridging crate.
2024-03-18 09:57:16 -04:00
Jordan Rose
d2f7ba244b swift: Match debug/release when building benchmarks
Benchmarks should normally be run in the release configuration, but CI
just wants to make sure they still work by running them with a debug
libsignal_ffi.a. Instead of making that a fallback, make it
configuration-dependent, so you can't ever accidentally test the wrong
thing.
2024-03-15 09:58:02 -07:00
Jordan Rose
8ed2dc1195 Remove GroupSendCredential
Long live GroupSendEndorsements!
2024-03-14 12:31:30 -07:00
Jordan Rose
256f4742c7 bridge: Add tests for bridging arrays of bytestrings 2024-03-13 12:22:46 -07:00
Jordan Rose
f1fb1302b7 swift: Add a Benchmarks package for local profiling 2024-03-12 17:03:45 -07:00
Jordan Rose
a7f13d114e Swift: Add GroupSendEndorsement 2024-03-12 17:03:45 -07:00
Jordan Rose
8fb6cc31cf bridge: Make a combined endorsement for GroupSendEndorsementsResponse
Specifically, make this on the Rust side bridge layer, and tack it on
to the end of per-member endorsements for the app side to peel off
later, rather than the app layer calling back down to Rust to compute
it. This saves a fair amount of marshalling work.
2024-03-12 14:54:04 -07:00
Alex Konradi
60f066dbac
Remove AuthCredential
This hasn't been used in client code for some time.
2024-03-11 16:43:23 -04:00
Jordan Rose
cdef8228a2 bridge: Expose GroupSendEndorsement APIs 2024-03-11 13:41:48 -07:00
Jordan Rose
cdbbfdbd96 bridge: Add ArgTypeInfo for Vec<&[u8]>
This *could* be &[&[u8]], but that would complicate the
implementations, all of which use Vec internally anyway.
2024-03-11 13:41:48 -07:00
Jordan Rose
2bbca60eb5 bridge: Add ResultTypeInfo for Box<[Vec<u8>]>
Not actually distinct from Vec<Vec<u8>>, but works better with the
jni_result_type and ffi_result_type macros because `[Vec<u8>]` is a
single grouped token tree. Generalizes the string array helpers to
support bytestrings too.
2024-03-11 13:41:48 -07:00
Alex Konradi
f4f478fd06
Add authentication credential implemented with zkc
Add a new version of the existing auth credential used for groups, but 
implemented with the zkcredential crate instead of hand-written proofs. Expose 
issuance point for the server, and extend existing client methods to support it 
and the existing formats transparently.
2024-03-08 15:38:23 -05:00
Jordan Rose
1c8fd06486 zkgroup: Implement GroupSendEndorsements
This involves a family of new types that will be used for issuing and
verifying these endorsements.

This is a breaking change for zkgroup: it adds a new key to
ServerSecretParams and ServerPublicParams.
2024-03-06 12:22:38 -08:00
Jon Chambers
1d2d9d9254
Retire old SVR2 enclaves
Co-authored-by: Alex Konradi <akonradi@signal.org>
2024-03-01 15:05:07 -05:00
Alex Konradi
274b680ef4
Expose message backup purpose as an argument
Add a flag to the CLI validation tool and an argument to the bridged validation 
functions so users can specify whether a provided message backup should be 
validated according to the rules for device-to-device transfers or backups 
intended for remote storage.
2024-03-01 09:53:00 -05:00
moiseev-signal
d7d2576ae6
SVR3: FFI bridge 2024-02-29 18:22:59 -08:00
Sergey Skrobotov
ec49a9774b libsignal-net: ChatService node bridge 2024-02-27 11:07:57 -08:00
moiseev-signal
58f43107ab
Enforce Swift code formatting 2024-02-23 09:56:38 -08:00
moiseev-signal
6f783269db
SVR3: JNI bridge 2024-02-22 12:22:10 -08:00
Alex Konradi
5b5b85e715
Expose CDSI lookup via FFI 2024-02-22 10:31:01 -05:00
Alex Konradi
0676a89c90
Build Swift docs in CI
Fix existing documentation issues. Prevent backsliding on documentation by 
requiring cross-links to be correct for CI checks to pass.
2024-02-16 17:14:03 -05:00
Alex Konradi
ac538311e9
Use failOnError instead of try! in Swift
Replace existing usages of try! with the failOnError helper. Add guidance to 
the coding guidelines doc.
2024-02-16 14:31:34 -05:00
Alex Konradi
8959e64ed1
Build TESTING_ functions for Android test
Run tests that call native TESTING_ functions on Android. This requires 
building a separate version of libsignal_jni.so with the testing functions 
included. The test code is still omitted from the published artifacts.
2024-02-15 16:53:05 -05:00
Alex Konradi
d08adf19bb
Return username candidates as string array
Use the string bridging code introduced previously to provide string arrays to 
client directly instead of joining and splitting. This eliminates the use of a 
magic ',' character as a delimiter.
2024-02-06 09:46:06 -05:00
Alex Konradi
a628f0ec67 Fix Swift string array bridging slice bug
The Swift helper invokeFnReturningStringArray was using the wrong
indices when slicing up the concatenated strings to produce individual
values. Instead of advancing the base pointer by the N bytes read for a
given string, the base pointer was adjusted to point to LEN - N. This
wasn't detected by the bridging test case since it passed two strings
over, both of length three. For two strings with the same length, the
buggy and corrected code have the same behavior!

This patch adjusts the test case to include strings of different
lengths and fixes the now-revealed bug.
2024-02-05 17:00:47 -05:00
Alex Konradi
580913d225
Re-throw input stream errors in Swift and Java
Re-raise errors produced by an input stream after bubbling them through Rust 
code. This makes the interface less magic and avoids unnecessary 
stringification of error values.
2024-02-02 15:14:27 -05:00
Alex Konradi
7bacdd089a
Bridge message backup to Swift
Present a similar API to the Java client library.
2024-01-30 16:38:54 -05:00
Alex Konradi
c70b66dc8c
Bridge message backup validator to Java
Provide a simple API for validating message backups read from InputStream 
instances.
2024-01-26 13:33:36 -05:00
Jordan Rose
1f8701213b
zkgroup: Add GroupSendCredentialResponse::receive_with_ciphertexts
If a client already has the members of a group as ciphertexts, it's
more efficient to receive a GroupSendCredential that way, because then
they get to skip the conversion from ServiceId to UidStruct. If they
don't, however, the existing entry point is going to be both more
convenient and faster.

For Swift and Java, this is an overload of the existing receive()
method; for TypeScript, it's receiveWithCiphertexts.
2024-01-22 12:34:34 -08:00
Jordan Rose
b31ca0781c Remove length parameter for webpsan
The way images are displayed on Android makes it annoying to provide,
and the implementation of webpsan doesn't actually need it.
2024-01-18 12:36:31 -08:00
Jordan Rose
70a9662acd usernames: Expose Username.fromParts to app languages 2024-01-10 12:26:19 -08:00
Jordan Rose
0ef2c7cc54 usernames: Split up BadDiscriminator error into more specific errors
Rust: UsernameError now has more cases. ProofVerificationFailure is
also split off into its own error type, separate from structural
username errors.

Java: Subclasses of BadDiscriminatorException have been added.

Swift: Some error codes have been renamed and others have been added.

TypeScript: Some error codes have been renamed and others have been
added. Discriminator errors are now proper LibSignalErrors.
2024-01-10 12:26:19 -08:00
Jordan Rose
0d09a8352c
Add GroupSendCredential
This credential is issued by the group server and presented to the
chat server to prove that the holder is a member of *some* group with
a known list of people. This can be used to replace the access key
requirement for multi-recipient sealed sender sends.
2023-12-11 13:45:12 -08:00
Jordan Rose
16653ffea1 SSv2: Add send support for excluded recipients 2023-12-11 12:36:54 -08:00
Jordan Rose
0e7963f787 swift: Fix SenderKeyDistributionMessage.distributionId
Had the same problem as the Java version!
2023-12-08 12:11:25 -08:00
Jordan Rose
2c9e3e9d69 ffi: Use size_t to represent Rust usize instead of uintptr_t
Rust's usize serves the same purpose as both size_t and uintptr_t in
C, but for our uses it's always a buffer length or capacity rather
than something specifically the same size as a pointer or machine
register, so size_t is more accurate.

Swift, then, imports size_t as its currency type Int, even though
size_t is unsigned in C, because no buffer can actually fill up all of
memory. Swift, like Rust, doesn't have implicit numeric conversions,
so importing size_t as Int was deemed more useful in practice.
2023-12-07 17:42:34 -08:00
Jordan Rose
2364c268a0 ffi: Prefer std::ffi::* over libc::* for c_void, c_int, etc
And use usize for size_t:
- They're always equivalent in practice.
- When we're actually using it as a memory size, we're talking about
  the size of Rust objects, so usize is more accurate anyway.

This eliminates the use of the libc crate in the bridge layer. We
still use libc for time_t in attest and device_transfer, to interact
with BoringSSL.
2023-12-07 17:42:34 -08:00
Alex Konradi
1f2d761889
Allow returning handle types from Swift invokeAsyncFunction
Implement the Completable protocol for OpaquePointer and add a test that runs
futures that return handle types to prove that it works.
2023-12-04 16:39:32 -05:00
Alex Konradi
6b50a95bc9
Fix swift linting issues
Fix an existing issue caught by the linter and exclude files generated during
build from linting (since some of them are missing header comments required by
the linter).
2023-12-04 14:27:52 -05:00
Max Radermacher
05b88ad1d1
Adopt modern SignalCoreKit logging APIs 2023-11-28 11:17:54 -08:00
Jordan Rose
75b78438d5 Enable full LTO for Android, *disable* it for non-iOS Swift
And make sure CFLAGS has a matching flag, for maximum LTO.
2023-11-15 10:18:43 -08:00
Jordan Rose
d768f47020 usernames: Allow generating a new link buffer with existing entropy
This allows updating the encrypted username associated with a link
without rotating the link itself.
2023-11-02 15:02:36 -07:00