Commit Graph

288 Commits

Author SHA1 Message Date
Jordan Rose
8fdb2778bc protocol: Split FingerprintError out from SignalProtocolError
The "fingerprint" / safety number operations *are* tied to the
"protocol" in that they provide a way to verify identity keys, but
they are also completely distinct from the message handling that the
rest of SignalProtocolError is used for.
2025-08-15 12:21:25 -07:00
Jordan Rose
54e81cda4f java: System.runFinalization() in GC cleanup testing
This makes this particular test more reliable even though no
'finalize' methods are involved in this one.
2025-08-13 13:31:23 -07:00
Jordan Rose
b4cd040474 Add SvrB.remove(), use it for app-level integration tests 2025-08-13 12:35:52 -07:00
Jordan Rose
374301ab46 java: Include a timestamp in the testing StderrLogger
Before
> I libsignal: rust/bridge/shared/types/src/net.rs:132: Initializing connection manager for Staging...

After
> [11:03:32.956965 libsignal] I rust/bridge/shared/types/src/net.rs:132: Initializing connection manager for Staging...
2025-08-13 11:43:12 -07:00
Jordan Rose
7bae76f25e java: Use the slightly-nicer StderrLogger in TestLogger 2025-08-13 11:43:12 -07:00
Jordan Rose
996f6bb250 jni: explicitly clean up local refs on background threads
- Use a local frame for bridge_io when completing futures
- Use a local frame for ChatListener callbacks
- Use AutoLocal for exception formatting callbacks
2025-08-12 10:49:30 -07:00
moiseev-signal
b53ed51263 keytrans: Stop falling back to search if _self_ monitor detects a new version 2025-08-11 15:34:01 -07:00
Jordan Rose
ea343a89ab jni: Native.java -> Native.kt
Improvements included in this first iteration:
- Nullable/non-nullable!
- ObjectHandle typealias for Long
- Fixed handling for CompletableFuture<Void> (previously translated
  without generics at all in some cases)

Co-authored-by: Alex Bakon <akonradi@signal.org>
2025-08-08 14:41:22 -07:00
Jordan Rose
36916db152 Gradle: Make Spotless a top-level task, be precise about inputs
Previously, we used a per-project directory glob for Kotlin and Java
sources, which (1) was overly general, (2) ran afoul of Gradle's rules
about "if you look in a directory you must depend on it", and (3)
required us to make a fake subproject in the shared/ folder because
Spotless doesn't like sources outside the project directory.

Now, we delay complete evaluation of the root project until
subprojects are complete, and then add a single Spotless operation at
the top level that uses the subprojects' compile tasks to find exactly
the files to format.
2025-08-08 13:08:31 -07:00
Jordan Rose
aee436a43c java: Update Spotless to 7.2.1 2025-08-07 13:46:28 -07:00
Jordan Rose
be9e9a3ab6 Expose SvrB.createNewBackupChain(), make secret data non-optional 2025-07-31 12:37:02 -07:00
gram-signal
72935510d4 Immediately after a restore, use the same enc_salt/pw_salt for the next backup.
Co-authored-by: Jordan Rose <jrose@signal.org>
2025-07-30 20:14:26 -07:00
Alex Bakon
bb05cc016e Streamline bridging of SVR-B function arguments 2025-07-29 14:18:16 -04:00
Jordan Rose
9e9c375db9 Expose BackupForwardSecrecyToken-aware MessageBackupKey derivation 2025-07-28 13:53:19 -07:00
Alex Bakon
303b6313bd Expose SVR-B logic from Rust 2025-07-25 17:36:12 -04:00
Jordan Rose
d225a1008d Add CompletableFuture.handle
Co-authored-by: Andrew <andrew@signal.org>
2025-07-25 14:09:07 -07:00
Jordan Rose
a881fcf0f3 java: Align CompletableFuture cancellation behavior with OpenJDK's 2025-07-25 13:24:29 -07:00
gram-signal
3ae977841f Modify backup forward-secrecy-token storage to be more resilient to SVRB communication failures.
Co-authored-by: Alex Bakon <akonradi@signal.org>
2025-07-25 12:35:01 -07:00
andrew-signal
ec3c273219 Expose Rust API for SVR-B 2025-07-23 18:59:54 -04:00
Jordan Rose
821dee54e5 java: Add CompletableFuture.completedFuture()
Matches java.util.concurrent.CompletableFuture's method.
2025-07-17 18:27:39 -07:00
Jordan Rose
a410849578 crypto: Add a stripped-down HPKE API for our Curve25519 keys 2025-07-15 16:17:23 -07:00
andrew-signal
7167436147 Expand InvalidSessionException to take a cause 2025-07-02 04:55:16 -04:00
moiseev-signal
71c44d47e1 java: Fix incremental mac finalization. Again. 2025-06-30 18:54:21 -07:00
Jordan Rose
2f6e1cca98 jni: Explicitly keep bridge_handle objects alive while using them
As a bonus, we get a partial check for misuse of mutating APIs.
2025-06-30 15:54:24 -07:00
Alex Bakon
a7f823771f Combine CreateSession push_token, push_token_type
These fields should always be present or absent together.
2025-06-26 17:19:05 -07:00
moiseev-signal
f395e1cb7d java: Make CertificateValidator inheritable for tests 2025-06-25 15:19:36 -07:00
Jordan Rose
8070d6a4e6 Send Accept-Language when connecting a chat socket 2025-06-25 13:16:37 -07:00
Jordan Rose
9a468837b8 java: Clean up javadoc issues 2025-06-24 09:56:18 -07:00
Jordan Rose
cfa7bb8d45 java: Move CompletableFuture test to the right directory 2025-06-23 14:10:16 -07:00
Jordan Rose
333d2be846 java: Fix CalledFromNative target annotations
"TYPE" is for type *uses*, not type *definitions*.
2025-06-23 10:37:55 -07:00
Jordan Rose
4e304bf167 javadoc-isms -> KDoc 2025-06-20 10:15:51 -07:00
Alex Bakon
8f671bd2d0 Make BackupLevel.value public 2025-06-18 14:22:14 -04:00
Jordan Rose
2879220e93 Require Kyber keys/ciphertexts throughout all XDH APIs 2025-06-13 16:06:07 -07:00
Alex Bakon
2b01021d7e Add offset/length constructor for Java ECPublicKey and KEMPublicKey 2025-06-13 16:26:26 -04:00
Alex Bakon
02b786b07e Limit device ID to the range 1-127
This is already required for sealed sender messages and enforced by the server.
2025-06-13 14:18:16 -04:00
Jordan Rose
5001df1ee4 Kotlin: use explicitApi() mode 2025-06-13 10:27:37 -07:00
Alex Bakon
881b3a4c8e Port some Java classes to Kotlin 2025-06-12 18:24:15 -04:00
Alex Bakon
a32aca9bce Remove Java Curve class 2025-06-12 17:24:31 -04:00
moiseev-signal
44c470f388 java: Synchronize close for incremental mac streams 2025-06-12 14:14:45 -07:00
Alex Bakon
3c89a5fa07 Colocate Kotlin sources with Java 2025-06-12 16:00:05 -04:00
gram-signal
b7b8040e3a Integrate post-quantum ratchet SPQR.
This PR integrates a post-quantum ratchet (SPQR) into libsignal, using an API that maintains its own internal chain and provides per-message keys.  In doing so, it also aims to be fully backwards-compatible with current clients and stored session state.

## Backwards compatibility with current clients

Remote clients that connect to us or that we connect to may not have this integration.  If they don't, their SignalMessage wire format should still deserialize, and in doing so we'll receive an empty pq_ratchet field.  SQPR handles this internally, by downgrading the protocol version to "version 0" or "don't do anything".  Note that should we eventually want to disallow this, we can do so via increasing the `min_version` field passed into the SQPR init functions to V1.  This is also the method by which we would upgrade SQPR from v1 to a future v2, etc.

## Opt-in

The publicly facing API calls for this now expose an explicit opt-in via a passed-in `use_pq_ratchet` bool (and associated enums in language-specific APIs).  If false, they default to SQPR `v0`, IE: none.  If true, they try to set up SPQR on new sessions, but will downgrade if the remote party cannot or will not do the same.
2025-06-04 11:18:12 -07:00
Alex Bakon
8782d0a406 Add bridging tests for optional UUID return 2025-06-03 13:50:26 -04:00
Alex Bakon
033abcf96f Support checking Java @CalledFromNative annotation 2025-06-02 13:02:41 -04:00
andrew-signal
6968a0b9ee Java: Fix CalledFromNative.kt compatibility with Android 5.0 2025-06-02 09:50:56 -04:00
moiseev-signal
bf096c449d keytrans: Improve errors 2025-05-30 16:00:06 -07:00
Alex Bakon
f09c862e7d Add CalledFromNative.Enforcement to check annotations 2025-05-30 13:23:35 -04:00
Alex Bakon
eea11499fd Expand Java keep rule for exception constructors
Instead of fuzzy name matching, use inheritance from Exception as the
determiniant for whether an annotated type is a libsignal exception.
2025-05-28 17:12:00 -04:00
andrew-signal
73ba569f66 Java: Fix libsignal submodule build after refactor of Curve.java to Kotlin
Sets Kotlin compiler output to JDK_17 and makes the changes to the Curve object non-breaking
2025-05-27 09:36:32 -04:00
Alex Bakon
14adc1c74d Introduce Kotlin to the libsignal Java library 2025-05-23 09:57:41 -04:00
andrew-signal
65686e681c Java: Fix error that caused CompletableFuture to be stripped by apps using ProGuard/R8 2025-05-21 21:18:11 -04:00