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

43 Commits

Author SHA1 Message Date
Jordan Rose
9f53f3d1e7 BackupAuthCredential: verify the redemption time on receive
This is passed both within the credential response and outside it, so
it's important to make sure the two times match.
2024-04-19 13:41:59 -07:00
ravi-signal
9204831745
Use an enum for BackupAuthCredential's level 2024-04-19 11:46:49 -07:00
Jordan Rose
4b87577969 java: Print all test outcomes as they run (not just passes)
Failures would still have been caught in the aggregate test results;
but if we're going to print successes we should print skips and
failures too. (This was just an oversight.)
2024-04-17 10:21:41 -07:00
Jordan Rose
f896129db9 Java: Update to Gradle 8.4, Android Gradle Plugin 8.3, SDK 34, Java 17
Each of these updates is required for the following update, and the
final one allows us to use 'record'.

The target SDK version is set to 33, matching the Android app.
2024-03-08 10:34:18 -08:00
Jordan Rose
4f4d21a8ca java: Mark all bridge_fns that return Result as throws Exception
Then, use FilterExceptions to filter out any exceptions that aren't
declared in the calling method's exception spec. Note that this isn't
perfect: Java's checks for typed exceptions prevents an *extra*
exception from being thrown this way, but it's still possible to
forget to *allow* an exception using FilterExceptions.

This is 99% a mechanical change; the interesting bit is in
gen_java_decl.py and one unusual pattern in NativeErrorsTest.java. No
exception specs were changed here.
2024-02-22 13:34:57 -08: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
72ccec8cdd
Fix java tests
- use int instead of promoting to long
- add missing return type to fix compilation
 - run auto-formatter

Also add the check that would have caught all of these to CI
2024-01-10 14:48:13 -05:00
Jonathan Klabunde Tomer
c3cb6ed0bf expose non-copying method on SealedSenderMultiRecipientMessage to get message size for a recipient 2024-01-09 11:28:12 -08:00
Alex Konradi
1c6e8e512d
Fix CompletableFuture error handling
Fix the behavior of CompletableFuture.thenApply so that if the applied function
throws an exception, the pending future receives the exception (instead of never
completing). Add tests.
2023-11-30 15:38:22 -05:00
Jordan Rose
caf3dade92 Java: Add -Xcheck:jni to host testing
This can give better error messages for JNI mistakes that might
otherwise crash or go unnoticed. Tested by introducing such a mistake.
(Though it's hard to do with the jni crate's safe interfaces, which is
a good thing!)

The Android Emulator always has its equivalent checks on, so the Slow
Tests are also giving us some confidence about our JNI usage.
2023-11-15 10:17:26 -08:00
Alex Konradi
4c78373114
Expose libsignal-net function for CDSI via JNI
Expose the existing CDSI lookup async function to Java clients. Provide a small
library that can be easily integrated into the existing codebase.
2023-11-15 10:00:46 -05:00
akonradi-signal
3d8933ec96
Add CompletableFuture.thenApply method
Add the ability to chain futures by applying arbitrary functions. Mirrors
CompletableFuture.thenApply in the Java standard library.
2023-11-13 15:06:40 -05:00
Jordan Rose
9839a5be79 Always use the original SSv2 version byte, 0x22, for ReceivedMessages
The format hasn't changed, so we don't need to bump the version number
for the messages the server sends to recipients.

This is implemented in two places: the Rust side for round-trip
testing, and the Java side for what the server actually does. (Both
are implemented to avoid unnecessary copies and unfortunately the two
aren't conveniently compatible with one another, but it's a simple
implementation anyway.)
2023-11-10 09:30:39 -08:00
Jordan Rose
0c13580240 SSv2: Add receive support for excluded recipients
These are encoded as having a device ID of zero. Rust-level tests will
come with the send support, so we can do round-trip tests.
2023-11-07 16:25:22 -08:00
Jordan Rose
b618fd58e7 SSv2: Require known versions in SealedSenderV2SentMessage::parse
And if we're not trying to be open to future versions, we can validate
that there's enough bytes for the ephemeral public key as well.
2023-11-07 16:25:22 -08:00
Jordan Rose
418886c599 SSv2: Add server receive support for compact device lists
This takes advantage of the fact that multiple devices for the same
user will have the same identity key and therefore will use the same
per-recipient SSv2 data anyway.

This commit also enforces (on the server side) that device IDs are in
the range 1..=127 for destinations of a SSv2 message; previously they
were varint-encoded.

When send support is added, the round-trip Rust tests will
automatically start testing this as well.
2023-11-07 16:25:22 -08:00
Jordan Rose
64d5996825 Expose SSv2 message parsing in libsignal-server 2023-11-07 12:19:14 -08:00
ravi-signal
9c79bc97cb
zkgroup: move java BackupAuthTest to server lib
This test does base64 decoding which differs between android 21 and
non-android platforms.
2023-10-26 13:15:25 -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
ae47f039fa bridge: Add a bridge_io macro that expects a runtime
For now, the "runtime" is spawning a thread that then uses
now_or_never, but eventually this will be a persistent tokio runtime
of some kind.

Also for now, this is only implemented for Java. Swift and Node
support coming soon.
2023-10-02 14:08:10 -07:00
Jordan Rose
5fde77a631 Don't include the Future testing APIs when building for Android 2023-09-27 06:48:21 -07:00
Jordan Rose
a563c9b93d Java: Add a bare-bones Future implementation for upcoming async APIs 2023-09-27 06:48:21 -07:00
Jordan Rose
3810154436 Automate the Android and Server publishing to Sonatype 2023-08-25 12:33:56 -07:00
Jordan Rose
e11a825fe3 Gradle: Adopt Nexus plugin to automatically close releases on Sonatype 2023-08-24 12:21:25 -07:00
Jordan Rose
b27f5c0f2e Gradle: Set version and group info in the root project
This will be necessary to adopt the Gradle Nexus publishing plugin,
but it's also just simpler.
2023-08-24 12:21:25 -07:00
moiseev-signal
f9471c9c68
Set up and apply code formatting for Java 2023-08-22 09:15:23 -07:00
Jordan Rose
761c8080ee java: Reorganize tests 2023-07-27 15:40:44 -07:00
Jordan Rose
6800244a53
protocol: Add the ServiceId, Aci, and Pni types
Co-authored-by: Max Moiseev <moiseev@signal.org>
2023-07-13 13:54:53 -07:00
Sergey Skrobotov
ca262db5ec bridge for username links 2023-07-06 15:51:52 -07:00
moiseev-signal
7d37b1c2f8
Better handle incremental mac edge case 2023-06-28 10:56:25 -07:00
moiseev-signal
2b46ae1e85
Implement incremental MAC 2023-05-09 12:29:25 -07:00
Ravi Khadiwala
1f8c279622 pin: Add pin hashing and an svr2 client
- Add a new SGX client that can be used for testing svr2
- Add pin hashing that can be used with svr1 and svr2
2023-03-29 13:59:28 -05:00
Max Moiseev
0bd497d5e8 Make tests more deterministic 2023-02-13 11:06:49 -08:00
Max Moiseev
f1b6c63e34 Make Java API for username hashing more idiomatic 2023-02-09 11:18:24 -08:00
Max Moiseev
33d8421ca9 Bridge username hashing APIs to all client platforms 2023-02-03 17:44:29 -08:00
Ravi Khadiwala
93cdd47a30 cds2: add jni binding for attestation metrics
Adds a java method for libsignal-server that enables extracting
attestation metrics from serialized evidence and endorsements.
Certificate and endorsement validity periods are exposed, so servers
can track if any attestation material is overly stale.
2022-08-04 10:26:47 -07:00
Jordan Rose
0542686e70 Update artifact/package/module names across all three app languages
- Java: org.whispersystems:signal-client-java ->
    org.signal:libsignal-client
- Java: org.whispersystems:signal-client-android ->
    org.signal:libsignal-android
- Java: org.whispersystems:libsignal-server ->
    org.signal:libsignal-server
- Swift: SignalClient -> LibSignalClient
- NPM: @signalapp/signal-client -> @signalapp/libsignal-client
- Repository: github.com/signalapp/libsignal-client ->
    github.com/signalapp/libsignal
2022-03-23 10:49:09 -07:00
Jordan Rose
526cbab04f Gradle: Fix conditional execution of :downloadNonLinuxLibraries
This helper task was supposed to only execute when publishing the
client or server artifacts, but at the point where that was checked
the task graph *hasn't been built yet*. Instead, add the task to the
task graph unconditionally, but disable it by default, and have its
dependents enable it only when publishing.
2022-03-22 10:19:47 -07:00
Jordan Rose
bd30563044 Java: use the artifact name as the human-readable name when publishing
This matches the (explicitly-specified) name in the previous Gradle
configuration.
2022-03-11 13:31:13 -08:00
Jordan Rose
43054913ed Java: Always include Mac and Windows support when publishing
Rather than have a separate "testable" artifact, always include Mac
and Windows versions of libsignal_jni.so when publishing
signal-client-java *and* libsignal_server (though not when just
building locally).

Also, finally attach these tasks to the correct step (processResources
rather than compileJava).
2022-03-10 13:36:26 -08:00
Jordan Rose
821d72d65a Java: add back missing repository information
I deleted this for simplicity when updating to Gradle 7.4 and then
forgot to put it back.
2022-03-10 13:36:26 -08:00
Jordan Rose
7931bf0812 java: Build a separate libsignal-server artifact
Reorganize the Gradle build with three targets:

- signal-client-java (client/)
- signal-client-android (android/)
- libsignal-server (server/)

plus an additional shared/ directory for sources shared between
client/ and server/.

This maintains the distinction between signal-client-java (the Java
parts, plus a Linux libsignal_jni.so for running tests outside of the
Android emulator) and signal-client-android (contains the Android JNI
libraries, plus any Android-specific code, which for now is just
AndroidSignalProtocolLogger, which the app doesn't even use).

The new libsignal-server is built very similarly to
signal-client-java, but only contains the Java sources relevant for
the server...plus the base org.whispersystems.libsignal classes from
the original libsignal-protocol-java, because some of them are
referenced directly in our generated Native.java. (We can improve on
this in the future.) The "testable" artifact that includes macOS and
Windows versions of libsignal_jni.so is now only built for
libsignal-server, not signal-client-java; our Android development
happens on Linux, but server development happens on multiple
platforms.

Tests were recently reorganized into a top-level tests/ directory, but
now there's been another reorganization:

- client/src/test/ - tests to run on any clients
- android/src/androidTest/ - tests to run only on Android devices /
  emulators (currently none)
- server/src/test/ - tests to run specifically for the server
  (currently none)
- shared/test/ - does not exist to avoid running the same tests twice

There are no tests to run "only not on Android devices", and it's
currently assumed that all server functionality is tested by the
client tests. The Android device tests run all the client tests as
well (by direct path reference). This may not be the "best" Gradle
layout, but it's at least straightforward to read the Gradle files.

For now there's still only one native library built for both
signal-client-java and libsignal-server, but that could change in the
future.
2022-03-10 09:14:55 -08:00