Commit Graph

198 Commits

Author SHA1 Message Date
Jordan Rose
b8ec92d332 java: Update zkgroup license headers, remove codegen warnings 2021-11-08 11:06:31 -08:00
Jordan Rose
ef73a621f0 java: Get the zkgroup sources to build and pass tests
This is a pretty mechanical translation *except* for

- moving the RANDOM_LENGTH constant out of the obsolete Native class
  (libsignal-client has its own) into a new Constants class

- replacing the mocked SecureRandom with a custom subclass; Mockito
  was refusing to mock SecureRandom and honestly that's fair

- removing unused classes UUIDUtil and ZkGroupError

- updating to JUnit 4, which zkgroup's tests rely on
2021-11-08 11:06:31 -08:00
Jordan Rose
c2261d1701 java: Add the zkgroup sources verbatim (does not compile) 2021-11-08 11:04:58 -08:00
Jordan Rose
852069bdc9 bridge: Add zkgroup APIs
These APIs are designed to match the generated "simpleapi" entry
points in the original zkgroup repository, to make it easier to adapt
the existing Java, Swift, and TypeScript code to libsignal-client.

The cbindgen-generated signal_ffi.h now includes constants, so that
the fixed-size arrays used to serialize zkgroup types can use named
constants in Rust. This meant filtering out some constants that were
getting picked up but that should not be included.

Note that this commit makes references to Java exception types that
will be added in a later commit.
2021-11-08 11:04:41 -08:00
Jordan Rose
f1da238532 Merge pull request #411 from signalapp/jrose/android-save-unstripped-libraries
Android: upload unstripped libraries to Maven as well
2021-11-04 17:32:42 -07:00
Jordan Rose
4173865931 Android: upload unstripped libraries to Maven as well
This allows us to symbolicate native crash traces if necessary.
2021-11-03 16:32:02 -07:00
Jordan Rose
c65df8524d java: Build a "testable" signal-client-java as well
This is like signal-client-java, but also contains dylibs for Mac and
Windows for testing purposes. Gradle will automatically fetch these
artifacts from the corresponding GitHub release.
2021-11-01 16:54:46 -07:00
Jordan Rose
a00cfd1e90 GitHub: When a release is tagged, build and publish JNI artifacts
This will be used to build a "testable" signal-client-java.jar that
includes native libraries for macOS and Windows in addition to Linux.
This is something zkgroup already has; in particular it allows
developers working on the server to use the zkgroup APIs even if they
run macOS or Windows on their individual machines.
2021-11-01 12:53:56 -07:00
Jordan Rose
9a569f2ffe Standardize license headers
...to have a period after "Signal Messenger, LLC."

...except for the Java sources, which still need a cleanup pass.
2021-10-28 17:27:30 -07:00
Jordan Rose
a9012af8e2 Bump to version v0.9.8 2021-10-27 10:36:57 -07:00
Jordan Rose
ed2e5bce3a bridge: Update generated decls 2021-10-25 15:19:47 -07:00
Jordan Rose
ab48672d68 java: Change SignalProtocolAddress.toString to "UUID.device"
...instead of "UUID:device". Neither is inherently better than the
other but Desktop and the Rust library both use "UUID.device" already.
2021-10-19 13:03:26 -07:00
Jordan Rose
64f98ed87d java: Remove unused StaleKeyExchangeException 2021-10-19 13:03:14 -07:00
Jordan Rose
64ad39c54d Remove support for HKDF "versions"
Previously, we had HKDF-for-session-version-3, which matches RFC 5869,
and HKDF-for-session-version-2, which produced slightly different
results. However, nothing in the current versions of Signal uses
anything but the RFC-compliant version. Therefore, this commit removes
support for version 2 and deprecates the entry points that take a
version:

- Java: The HKDFv3 class is deprecated in favor of static methods on
  the HKDF class.
- Swift: The hkdf function that takes a 'version' parameter is
  deprecated in favor of a new overload that does not.
- TypeScript: The HKDF class is deprecated in favor of a top-level
  hkdf function.
- Rust: The libsignal-protocol implementation of HKDF has been removed
  entirely in favor of the hkdf crate.

There are no significant benchmark deltas from this change, and a
minimal code size increase that's the cost for removing our own
implementation of HKDF. The deprecations can be removed as a later
breaking change.
2021-10-14 16:02:56 -07:00
Jordan Rose
45fe852509 Bump to version v0.9.7 2021-10-14 15:59:42 -07:00
Jordan Rose
304a90fe56 Java: Ensure finalizers don't run until Native calls complete
If garbage collection happens at exactly the wrong time, the Java
wrapper around a Rust object (such as SessionRecord) can be finalized
while the Rust object is being used, via its opaque 'nativeHandle'
(address cast as integer). Avoid this by adding a NativeHandleGuard
type that keeps the wrapper alive, as well as a low-level entry point
`Native.keepAlive(...)` that does nothing but serve as a sort of GC
guard, similar to `Reference.reachabilityFence()` in Java 9.
2021-10-14 14:26:46 -07:00
Jordan Rose
72d3c97890 Java: Add a test for SSv2 with 1000s of recipients
This previously caused the JVM to crash because we ran out of local
reference slots.
2021-10-08 14:58:26 -07:00
Jordan Rose
169d4ca156 Gradle: Android tests should be run through Android, not JUnit 2021-10-08 14:58:26 -07:00
Jordan Rose
0bc74b32e2 Java: optimize for size over speed
This knocks about 10% off of the built binary for Android (per slice),
to balance out the increased size from the new toolchain and stdlib.
Applying the same `opt-level=s` option for `cargo bench` (on desktop)
gives a roughly 1% slowdown, a trade-off that's worth it.
2021-10-06 12:29:50 -07:00
Jordan Rose
5896c80aaf Bump version to v0.9.6 2021-10-01 16:46:56 -07:00
Jordan Rose
dc032ecb04 Java: adjust 'clean' behavior
- Run `cargo clean` when `gradlew clean` is invoked.
- But don't use `gradlew clean` in Docker except for publishing
2021-09-24 16:31:08 -07:00
Jordan Rose
f3a1dff371 Bump version to v0.9.5 2021-09-23 13:44:30 -07:00
Graeme Connell
9caa6615b9 JNI for HSM enclave client. 2021-09-21 16:37:07 -06:00
Ehren Kret
5b1d4fb0a3 Bump version to 0.9.4 2021-09-13 16:52:24 -05:00
Ehren Kret
53ecd6e589 Bump version to 0.9.3 2021-09-13 15:21:13 -05:00
Ehren Kret
2a8b4a2d97 Fix gradle build 2021-09-13 15:15:30 -05:00
Ehren Kret
a3578fa6d4 Bump version to 0.9.2 2021-09-10 10:24:54 -05:00
Ehren Kret
35eccb94d1 Bump version to 0.9.1 2021-09-09 13:07:09 -05:00
Jordan Rose
6026b8474e Bump version to 0.9.0 2021-08-31 14:50:01 -07:00
Jordan Rose
8c5b6af3fa Sealed sender v2: add an InvalidRegistrationId exception/error
This dedicated error is thrown when a recipient has a registration ID
that's out of the range used by Signal [0, 0x3FFF]. These IDs cannot
be encoded in the sealed sender v2 format and are not supported, even
though they don't cause any problems for 1:1 messages.
2021-08-31 13:11:10 -07:00
Jordan Rose
aa486c64a3 Java: preserve underlying exception as the cause of a ProtocolException
Otherwise we'll lose the "cause" message in stack traces.
2021-08-31 12:46:51 -07:00
Jordan Rose
eab0e57640 Java: don't eagerly strip libsignal_client.so; let gradle do it for us
This is a step towards saving the debug info somewhere for the builds
we actually ship.
2021-08-30 12:33:18 -07:00
Jordan Rose
72ba4e6959 Bump version to 0.8.4 2021-08-18 12:13:11 -07:00
Jordan Rose
528aec7e26 Merge pull request #336 from signalapp/cody/bugfix/hex-match-expected-output
Java: Make toStringCondensed match output from other Signal implementations.
2021-07-09 12:46:03 -07:00
Cody Henthorne
b8b6c285ad Java: Make toStringCondensed match output from other Signal implementations. 2021-07-09 15:23:58 -04:00
Jordan Rose
6021535fb5 Bump version to 0.8.3 2021-07-06 12:57:12 -07:00
Jordan Rose
b00c2e3847 Merge pull request #328 from signalapp/jrose/use-more-RustCrypto
Use more RustCrypto
2021-07-02 14:39:10 -07:00
Jordan Rose
1e55bae7db Java: Remove unused JCE-like interface for AES-256-GCM
Not only is it not sufficient for the streaming decryption used by
Android, but we forgot to mark it 'public'.
2021-07-02 10:29:20 -07:00
Jordan Rose
0e78c785ef Java: expose the tag size for Aes256GcmDecryption
If the tag is stored appended to the data (not unusual) it's the
caller's responsibility to split it off, and they need to know how
much to split.
2021-07-02 10:29:20 -07:00
Jordan Rose
d72047a245 Bridge: expose RustCrypto's AES-GCM-SIV instead of our own
Same as before, but for the wrapper exposed to the app languages.
2021-07-01 13:46:20 -07:00
Jordan Rose
9e168226f6 Docker: Fix typo in 3a3476b83: paths are relative to the repo root
This COPY command never should have worked, but the macOS Docker seems
to normalize ../foo to ./foo, so it passed my local testing.
2021-06-28 14:30:38 -07:00
Jordan Rose
348df2a268 Bump version to v0.8.2 2021-06-28 12:52:57 -07:00
Jordan Rose
3a3476b833 Docker: use the rust-toolchain file instead of hardcoding a version 2021-06-22 13:19:46 -07:00
Jordan Rose
b715e02aa9 Bump to version 0.8.1 2021-06-02 11:14:12 -07:00
Jordan Rose
08e72307ca Java: include the sealed sender groupId on sucessful decryption
This is useful for PlaintextContent messages (just
DecryptionErrorMessage for now), which can't include a group ID when
sent outside of sealed sender because it would reveal group
membership.
2021-05-28 10:06:31 -07:00
Jordan Rose
a095f6a1fc Bump version to 0.8.0 2021-05-27 14:32:06 -07:00
Jordan Rose
1867f75b07 Merge pull request #318 from signalapp/jrose/DecryptionErrorMessage-deviceId
Add a deviceId field to DecryptionErrorMessage
2021-05-27 14:08:06 -07:00
Jordan Rose
b54a830013 Java: put the UnidentifiedSenderMessageContent in a ProtocolException
That is, when there's an error decrypting the inner payload of a
sealed sender message, instead of just saving the sender (and more
recently the content hint and group ID), save the whole decrypted
contents of the sealed sender message. This is necessary so that the
app can make a DecryptedErrorMessage from that failed payload.

This is complicated somewhat by the fact that the app also uses the
"short" constructor for the various Protocol*Exceptions, so we have to
keep those working.
2021-05-27 12:27:48 -07:00
Jordan Rose
b780409c1b Add a deviceId field to DecryptionErrorMessage
This allows a device to know whether it's the one that sent a bad
message, and take action accordingly.

We could have a slightly more typesafe API here by using
ProtocolAddress and extracting the device ID, but that doesn't match
up with getting the device ID out of a sealed sender certificate.
2021-05-26 17:23:42 -07:00
Jordan Rose
4c0141c31f Fix merge conflict in Java and Swift tests too. 2021-05-26 16:43:11 -07:00