Commit Graph

27 Commits

Author SHA1 Message Date
gram-signal
533d11dd7c Remove usePqRatchet from client-facing code, defaulting to always use. 2025-10-02 11:32:36 -07:00
Alex Bakon
fb33f261bf Upgrade crates to Rust 2024 edition
Co-authored-by: Andrew <andrew@signal.org>
2025-09-03 15:12:59 -04:00
andrew-signal
4c40e851b2 Bump MSRV to 1.85 2025-08-28 20:32:01 -04:00
Jordan Rose
47a142fde8 protocol: Generialize has_usable_sender_chain checking
It can now also check whether a session was established with PQXDH and
whether it's using SPQR.
2025-07-31 09:42:15 -07:00
Alex Bakon
c811b2174a Pin sorted-vec to 0.8.6 to fix fuzz target build 2025-07-28 14:38:21 -04:00
Jordan Rose
2879220e93 Require Kyber keys/ciphertexts throughout all XDH APIs 2025-06-13 16:06:07 -07: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
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
aeb2f2a561 Bump rand dependency to 0.9 2025-04-24 13:12:56 -04:00
Alex Konradi
cc821295e7 Revert "Pin the arbitrary crate in fuzzer to 1.3.x"
The arbitrary crate has released a v1.4.1 that fixes the bug that caused us to pin.
2024-11-05 13:40:18 -05:00
Alex Konradi
8e66d77ef1 Pin the arbitrary crate in fuzzer to 1.3.x 2024-11-04 15:24:51 -05:00
Jordan Rose
85e0de9207 Update Rust dependencies
`cargo update` performed with Cargo 1.72 to avoid advancing our MSRV. assert_cmd, clap, protobuf, and protobuf-json-mapping needed to be manually held back.

Plus, explicit bumps for
- env_logger 0.11
- heck 0.5
- itertools 0.13
- num_enum 0.7
- prost 0.13
- tungstenite 0.23

And disallowing downgrading curve25519-dalek below the security update in 4.1.3.
2024-07-25 13:33:09 -07:00
Alex Konradi
09bffd5ab4 Use a named type for protocol timestamp 2024-04-30 16:33:11 -04:00
Alex Konradi
9b34467614 Use taplo to auto-format TOML files
Use https://github.com/tamasfe/taplo to auto-format TOML files. Add a config 
file to force reordering of dependencies in Cargo.toml files. Run taplo in CI 
to check formatting.
2024-03-26 16:06:45 -04:00
Jordan Rose
2019a4a2b8 Fuzz test fixes related to pre_key_id and archived sessions count
- Ensure positive, unique (signed_)pre_key_id values.
- Limit archiving more strictly based on sum of me/them.archive_count.

Co-authored-by: Jonathan Moody <103143855+moodyjon@users.noreply.github.com>
2023-12-11 10:38:44 -08:00
Jordan Rose
f1b573f2fc protocol: Add an SSv2 SentMessage parsing fuzz target 2023-11-07 12:19:14 -08:00
akonradi-signal
58a16be1b3 Bump all crates to Rust 2021 2023-10-31 13:43:33 -04: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
moiseev-signal
c07da6f938 Update x25519-dalek to v2.0.0 2023-08-15 12:02:37 -07:00
moiseev-signal
716e683324 Update dependencies following curve25519-dalek 4.0.0 release
Co-authored-by: Jordan Rose <jrose@signal.org>
2023-08-09 15:04:41 -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
Rolfe Schmidt
ff09619432 Add Kyber KEM and implement PQXDH protocol
Co-authored-by: Jordan Rose <jrose@signal.org>
Co-authored-by: Max Moiseev <moiseev@signal.org>
2023-05-09 16:44:40 -07:00
Danny McClanahan
ec3c2d32bc [#289] introduce wrapper structs for DeviceId, SignedPreKeyId, and PreKeyId 2022-07-20 13:10:43 -07:00
Jordan Rose
1d99ef0580 Clean up fuzz test, and correctly guard against over-archiving 2021-10-04 18:09:45 -07:00
Jordan Rose
e80339c15f protocol: Add a fuzz target that runs interactions between two clients
Based on the fuzzing input, this simulates message sends and receives,
out-of-order delivery, dropped messages, and session resets, solely to
find bugs in happy-path interaction between two clients.
2021-08-13 16:09:04 -07:00