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

248 Commits

Author SHA1 Message Date
Sergey Skrobotov
4388fac6a7 Revert "zkgroup: Implement GroupSendEndorsements"
This reverts commit 1c8fd06486.
2024-03-08 15:56:46 -08: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
Jordan Rose
25ddb75fd8 Appease swiftlint by writing cases on separate lines 2023-10-31 13:27:17 -07:00
Jessa
7af14c6b06
Add WebP sanitizer
This adds integration bits for the new webpsan, a WebP image sanitizer -- which
currently simply checks the validity of a WebP file input, so that passing a
malformed file to an unsafe parser can be avoided. The integration pretty much
just leverages the integration work that was already done for mp4san.
2023-10-26 15:16:59 -04:00
ravi-signal
790db2383e
zkgroup: add backup auth credential
Allows a client to request a credential for a backup-id without
revealing the backup-id to the issuing server. Later, the client may use
this to make requests for the backup-id without identifying themselves
to the server.
2023-10-25 17:26:58 -05:00
Jordan Rose
55a1958a15 Test various error and panic scenarios for bridge_fn and bridge_io 2023-10-12 12:23:22 -07:00
Jordan Rose
17d97859ec bridge: Implement bridge_io for Swift
On the Rust side, this expects a typical C callback function with a
"context" parameter. On the Swift side, we pass a manually-refcounted
object as that "context" which can be used to complete a
CheckedContinuation, bridging into the language 'async' functionality.

The main obstacle to this approach is that Swift does not allow C
function pointers to be used in generic ways, due to its run-time
generics model. AsyncUtils.swift describes the workarounds needed to
deal with this.
2023-10-10 11:52:45 -07:00
Jordan Rose
7219104cc9 build_ffi.sh: Avoid setting RUSTFLAGS when not cross-compiling
RUSTFLAGS (correctly) goes into the incremental build hash used by
Cargo and by extension rust-analyzer, and having your IDE and build
script disagree results in a fresh build every time.
2023-10-05 09:37:29 -07:00
moiseev-signal
6abe26a0c1
Improve incremental MAC API 2023-08-31 15:28:39 -07:00
Jordan Rose
4331c12ce6 iOS: Stop building for Catalyst
This commit retains minimal *support* to build for Catalyst, but since
we won't be testing it anymore it could break at any time.
2023-08-25 12:22:13 -07:00
Jordan Rose
9aad792fc6
Update all the RustCrypto crates 2023-08-25 11:28:49 -07:00
Jordan Rose
024c618f20 protocol: Throw SessionNotFound for an expired unacknowledged session
For the most part this should happen transparently without any
explicit adoption, like the previous change, but for Java code the
NoSessionException is now properly declared on SessionCipher.encrypt.
(This was always technically possible, but clients were expected to
have previously checked for session validity before using
SessionCipher; now that there's an expiration involved, that's not
strictly possible.)
2023-08-22 17:00:35 -07:00
Jordan Rose
a04c4f27a6 protocol: Check expiration in hasSenderChain/hasCurrentState
And consolidate the implementations of these two separate checks; now
they both check for a valid session by looking for a sender chain
instead of just *some* current session, in addition to the new check
for an expired unacknowledged session. At the Rust level, this is now
one check named has_usable_sender_chain; at the app levels, the old
names of hasSenderChain (Java) and hasCurrentState (Swift, TypeScript)
have been preserved.

Tests to come in the next commit.
2023-08-22 17:00:35 -07:00
Jordan Rose
9ca91fe2c0 protocol: Record the timestamp when a pre-key bundle is processed 2023-08-22 17:00:35 -07:00
Jordan Rose
0df9163aae swift/build_ffi.sh: only set IPHONEOS_DEPLOYMENT_TARGET for iOS
Otherwise, local builds on macOS hosts try to build some CMake-based
dependencies for Catalyst.
2023-08-17 16:44:19 -07:00
Jordan Rose
ff81905fc6 Add senderAci() to SenderCertificate and DecryptionResult
Like ProtocolAddresses in 88a2d5c, these APIs will eventually only
support ACIs, so introducing strong types now helps move in that
direction. However, the existing APIs that produce strings have not
been removed yet.
2023-08-02 17:51:23 -07:00
Jordan Rose
45fb135880 Add {Aci,Pni}.parseFromServiceId{String,Binary}
These work the same as the equivalent factory methods on ServiceId,
but throw if the resulting parsed ServiceId doesn't match the specific
type you were trying to parse.
2023-08-02 17:51:23 -07:00
Jordan Rose
4f3305fc35 Bump iOS deployment target to 13
This was already set in the podspec, but hadn't been bumped in the
build script.
2023-08-01 17:19:23 -07:00
Jordan Rose
008fad966e protocol: Rip "Context" out of the Rust layer
Only the iOS client ever used this extra parameter, and it's one
that's easily stored alongside the reference to a store. This is
massively simpler than having it threaded down to the Rust
libsignal_protocol and back up through the bridging layer.
2023-07-27 15:40:44 -07:00
Jordan Rose
231aa16510 Give AuthCredentialWithPni "PniAsServiceId" and "PniAsAci" variants
The former is what we want going forward; the latter is equivalent to
the old format for compatibility with previous client builds.
2023-07-20 12:28:19 -07:00