Commit Graph

352 Commits

Author SHA1 Message Date
Jordan Rose
0a65e4d311 Run some benchmarks fewer times in "test" mode (instead of "bench")
This should help a bit when smoke-testing in CI, while not affecting
the actual benchmarking at all.
2025-10-21 15:21:45 -07:00
Jordan Rose
279390b4f2 Incremental MAC: Check digest length when initializing ValidatingMac 2025-10-14 16:30:10 -07:00
gram-signal
533d11dd7c Remove usePqRatchet from client-facing code, defaulting to always use. 2025-10-02 11:32:36 -07:00
Jordan Rose
e516d8e227 Bump the toolchain to nightly-2025-09-24 2025-09-29 12:22:31 -07:00
Jordan Rose
15af92c93d protocol: Record signed prekey and base key used with a Kyber prekey 2025-09-16 15:33:59 -07:00
Jordan Rose
23cb1a230a protocol: Use base64 for the sealed sender trust roots
This is how all three apps specify them; we should be consistent.
2025-09-15 12:22:19 -07:00
Jordan Rose
e67003db0e protocol: Add pre-key-related session benchmarks 2025-09-15 09:52:43 -07:00
Jordan Rose
b9d380f046 protocol: Clarify session benchmark names 2025-09-15 09:52:43 -07:00
Jordan Rose
baf0b937a2 protocol: Don't log for each server certificate / trust root mismatch
This is a problem when there are multiple trust roots. The simplest
thing to do is flip which method calls which.
2025-09-11 10:23:59 -07:00
Rolfe Schmidt
5293caa6ca protocol: Check that base keys are torsion free and in range
Co-authored-by: Jordan Rose <jrose@signal.org>
2025-09-09 15:37:37 -07:00
Jordan Rose
94f91c5b19 protocol: Add support for sealed sender server certificate references
Rather than embedding a server certificate inside every sender
certificate, future sender certificates will be able to reference
their server certificate by ID as long as all receivers have a version
of libsignal containing that certificate.

This change also handles the sender ACI being represented as bytes
instead of a string.
2025-09-09 14:13:23 -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
Alex Bakon
4ea5b762ba Format Rust using 2024 edition rules 2025-09-03 14:22:08 -04:00
andrew-signal
4c40e851b2 Bump MSRV to 1.85 2025-08-28 20:32:01 -04:00
andrew-signal
01d3d4ed30 Future-proof sealed sender trust root handling.
Co-authored-by: Jordan Rose <jrose@signal.org>
2025-08-27 12:03:28 -04:00
Jordan Rose
5c7227b0d8 Placate new mismatched_lifetime_syntaxes warning 2025-08-26 09:32:28 -07:00
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
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
Alex Bakon
e4972e9fa5 Use zerocopy to skip fallible unwraps 2025-07-21 13:42:04 -04:00
Jordan Rose
95612be1ba Remove some crates from our build
- arrayref can be replaced by split_first_chunk -- not quite as
  concisely, but actually a little safer, and no macros involved

- array-concat has an equivalent in const_str

- num_enum has already been replaced by derive_more

- The test using regex has been removed
2025-07-15 15:45:03 -07:00
Jordan Rose
0760d3bc5d cross-version: Add a test for sealed sender messages 2025-06-17 11:17:30 -07:00
Jordan Rose
1ed212371e cross-version: Remove redundant work
- Current<->Current is already tested
- The versions in use are already logged
2025-06-17 11:17:30 -07:00
Jordan Rose
c2f99663a8 cross-version: Move some helpers into the library proper
...in preparation for more tests that are otherwise independent.
2025-06-17 11:17:30 -07:00
Jordan Rose
e15fb72146 cross-version: Fix some Clippy lints 2025-06-17 11:17:30 -07:00
Jordan Rose
2879220e93 Require Kyber keys/ciphertexts throughout all XDH APIs 2025-06-13 16:06:07 -07:00
Alex Bakon
3157a9be55 Fix device ID construction in cross-version tests 2025-06-13 17:24:01 -04:00
Jordan Rose
69bb363840 protocol: Reject X3DH PreKey messages
- Drop X3DH tests

- Drop cross-version tests with libsignal v0.12 and v0.21

- Change session benchmarks to use PQXDH, which is relevant if doing
  comparisons before/after this commit.
2025-06-13 12:19:04 -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
3d677ee3d7 Test for PQR state and message contents. 2025-06-12 11:21:42 -07:00
Jordan Rose
a280bc6555 Resolve an age-old X3DH test inconsistency
This known-answer test was originally ported over from
libsignal-protocol-java, but did not produce the same results. Why?
Because one of the private keys chosen by libsignal-protocol-java for
its test was unclamped, while libsignal-the-Rust-implementation always
clamps private keys as part of deserialization, not just generation.
Consequently, the public key didn't actually correspond to the private
key according to our modern libsignal.

Rather than try to line up exactly with what libsignal-protocol-java
was coincidentally doing, this commit clamps the private key, computes
the resulting public key, and verifies a new
consistent-between-both-sides outcome.
2025-06-10 16:20:08 -07:00
gram-signal
61827e1cfe Fix cross-version test compilation. 2025-06-04 12:50:11 -07: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
8a9e18b6c6 Remove unused #[allow], replace with #[expect] 2025-06-03 16:07:06 -04:00
Alex Bakon
b56f448167 Remove some #[allow]s by addressing them 2025-06-03 16:04:36 -04:00
Alex Bakon
7ea82a72b9 Bump MSRV to 1.83.0 2025-05-30 17:32:04 -04:00
Alex Bakon
151c96e52b Apply lint fixes from latest clippy 2025-05-23 10:29:25 -04:00
Jordan Rose
7d1cacbaa8 protocol: Eagerly promote sessions during pre-key processing
This fixes a bug introduced by cd36118 where starting a new session
locally would prevent incoming messages on a previous session from
being decrypted if that session hadn't advanced past the "pre-key"
stage. Fix this by promoting the session *before* successful
decryption instead of after; since we won't *save* the promotion
unless the message decrypts successfully, there's ultimately no change
in either the failure or success cases *except* when hitting this bug.
2025-05-14 16:52:18 -07:00
Jordan Rose
ac99c0950d protocol: Dump sessions on a PreKey decryption failure, just in case
Logging change only.
2025-05-14 16:52:18 -07:00
Alex Bakon
2f1112c999 Persist pre-key message sender identity after message decryption 2025-04-29 16:19:55 -04:00
Alex Bakon
13b2b8aff4 Take RNG as a parameter when generating kyber keys 2025-04-29 10:54:21 -04:00
Alex Bakon
076e9dd34f Return an error on kyber en-/de-capsulation failure 2025-04-29 09:49:47 -04:00
Alex Bakon
00ca3f4fd8 Replace pqclean crate usages with libcrux 2025-04-29 09:22:09 -04:00
Alex Bakon
8f1baf561c Use an enum value for IdentityKeyStore.saveIdentity in libraries 2025-04-25 12:52:58 -04:00
Alex Bakon
aeb2f2a561 Bump rand dependency to 0.9 2025-04-24 13:12:56 -04:00
Alex Bakon
f6aacba338 Remove num_enum dependency 2025-04-23 15:57:25 -04:00
Max Moiseev
13a997e11b Stop using hardcoded key type for all Kyber generate benchmarks 2025-04-23 09:01:09 -07:00
Alex Bakon
9392062a7e Return enum from IdentityKeyStore::save_identity 2025-04-23 09:16:51 -04:00
Jordan Rose
3a2c29277e cargo update, update to zerocopy 0.8
Held back for MSRV:
- base64ct v1.6.0
- half v2.4.1
- home v0.5.9
- litemap v0.7.4
- zerofrom v0.1.5 (and zerofrom-derive)
2025-04-07 11:14:54 -07:00
Alex Bakon
03a739a95c Use const_str::hex instead of hex_literal::hex 2025-03-28 14:48:19 -04:00