Commit Graph

28 Commits

Author SHA1 Message Date
andrew-signal
de881ddde4 backups: Exporter now returns [Result<String, Error>] instead of a serialized JSON array object
Co-authored-by: Jordan Rose <jrose@signal.org>
2025-11-11 16:52:47 -05:00
moiseev-signal
76cea46935 backups: Improve tooling and documentation for tests 2025-11-07 16:47:17 -08:00
Jordan Rose
9cba9f1baf backup_stats: Break out some more specific frame types 2025-10-28 10:01:33 -07:00
Jordan Rose
19f850ab3f backup: Add backup_stats example (quick and dirty statistics) 2025-10-27 15:04:36 -07:00
Alex Bakon
4ea5b762ba Format Rust using 2024 edition rules 2025-09-03 14:22:08 -04:00
Jordan Rose
f1b9c072b9 backup: Enforce lengths of ct and pw_salt fields in metadata pb 2025-08-04 17:49:35 -07:00
gram-signal
aacbc74cc0 Fix IV reuse in (as-yet-unused) SVRB encyrpted_key_salt encryption. 2025-07-30 12:06:26 -07:00
gram-signal
a86de4aad3 Switch svrb to use protobuf instead of prost, so metadata can be checked within message-backup. 2025-07-25 14:39:35 -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
Jordan Rose
81f58c74b2 backup: Make FramesReader accept both the old and new formats 2025-07-18 15:28:30 -07:00
Jordan Rose
b538947ca1 Introduce libsignal-net-chat (and libsignal-cli-utils)
libsignal-net-chat builds higher-level APIs on top of libsignal-net's
ChatConnection, while also abstracting for a future using a
non-WebSocket-message-based transport for these requests. It will
likely change a fair bit as more APIs get filled in, and existing
high-level APIs in libsignal-net may get moved here (specifically
keytrans and registration).

libsignal-cli-utils is a common place to put helpers for our example
binaries; it's not (at this time) meant for the bridge libraries we
ship as our main products.
2025-05-21 16:15:17 -07:00
Jordan Rose
826d2f1285 Update clap-stdin to 0.6.0
Note that it has support for AsyncRead via tokio, but it doesn't line
up with how we use it.
2025-02-12 11:36:16 -08:00
Jordan Rose
2ba89c4b4f backup: Introduce a "scramble" CLI tool
`scramble` replaces the most obvious identifying information in an backup.

The backup will still be identifiable in practice (e.g. from its
timestamps), but all text, names, ACIs, etc will be scrambled. The
input can be encrypted or unencrypted; the output (on stdout) is
unencrypted binproto.
2024-12-02 17:21:21 -08:00
Jordan Rose
e25a1555aa json_to_binproto: The json5 crate expects certain chars to be escaped 2024-12-02 10:43:14 -08:00
Jordan Rose
0e28a08401 backup: Factor out key-parsing logic for tools
This allows decrypt_backup and encrypt_backup to use the full set of
options for specifying key material as the main validator CLI, though
they will continue to use a fallback AEP and ACI if no key material is
provided. The upcoming scrambler tool will likewise use the same
options for decrypting.
2024-12-02 09:58:29 -08:00
Jordan Rose
f73b2ed33c backup: Add benchmarks for the various parts of validation 2024-11-22 10:36:02 -08:00
Jordan Rose
3d0406dc0e Give BackupKey a VERSION parameter
This tracks whether we are using the old "master key" rules for
derived keys, or the new "account entropy pool" ones. Clients of
BackupKey have been audited:

- MessageBackupKey supports both sets of rules for now.

- The message-backup tests continue to use the old keys for now,
  because they share their encrypted test case with the app
  language tests.

- The CLI validator and the encrypt_backup and decrypt_backup tools
  support both the old and new rules; however, the "default key" for
  the encryption tools now uses the new rules.

- zkgroup's BackupAuthCredentialRequestContext supports both sets of
  rules.

- All bridge functions continue to use the old keys for now.
2024-10-21 13:11:20 -07:00
Jordan Rose
6876bf5699 Enable clippy::cast_possible_truncation for all libraries
...and deal with the fallout (usually switching to TryFrom,
occasionally allowing the lint)
2024-10-18 12:34:52 -07:00
Jordan Rose
9962537f65 Move BackupKey and BackupId to new libsignal-account-keys
...formerly "signal-pin", leaving MessageBackupKey in 
libsignal-message-backup.

BackupKey and BackupId are more general parts of the backup system, 
and don't just apply to the message backup files. More concretely,
this allows removing the redundant implementation of derive_backup_id
in zkgroup (libsignal-message-backup already depends on zkgroup). The
stronger types aren't (yet) used in the bridge layer since they're not
exposed to apps.

Further changes to backup keys and backup IDs will come shortly.
2024-10-16 11:58:13 -07:00
Jordan Rose
c1551667ec backup: Reference libsignal_core directly 2024-08-19 12:56:17 -07:00
Alex Konradi
fc4e1dbcd6 Switch to JSON5 for backup .jsonproto parsing 2024-06-26 15:35:40 -04:00
Alex Konradi
12f886bff0 backup: prepend IV in example binary 2024-06-04 09:49:40 -04:00
Alex Konradi
f18b39f5b0 Revert "Move message backup proto and I/O to new crate"
This reverts commit 55536686be.
2024-05-20 16:50:03 -04:00
Alex Konradi
55536686be Move message backup proto and I/O to new crate
Add a new crate, libsignal-message-backup-io, and move the existing code that 
handles backup decryption, deframing, and protobuf deserialization there. Keep 
the actual validation of the protobuf contents in the libsignal-message-backup 
crate.

This allows the existing example binproto<->json binaries to be built with 
local modifications to the backup.proto file without also requiring all the 
validation code to be modified.
2024-05-15 14:10:53 -04:00
Alex Konradi
6114bb7962 Use the first bytes of a backup as the AES IV
Treat the first 16 bytes of the stream as the IV for the AES block cipher. This 
is incompatible with the previous scheme, where the IV was derived from the 
master key.
2024-04-15 16:37:46 -04:00
Alex Konradi
0904a624dd Handle padding in encrypted message backup
Handle encrypted & compressed message backup files with additional padding 
after the compressed contents (the padding bytes are encrypted, but not 
compressed). Update the example encrypter binary to add padding by default.
2024-04-11 16:01:52 -04:00
Alex Konradi
467b0f17b9 Add message backup validation negative tests
Add the ability to write tests that check error messages produced during
validation. Add a couple test cases.
2024-02-15 14:59:08 -05:00
Alex Konradi
dc7c4eab1f Test validation of encrypted message backup files
Add a utility binary that compresses and encrypts backup files per the spec. 
Use the encryptor binary to encrypt the unencrypted test case file and include 
it as an additional golden test. Check that, in addition to calling via the 
library, the binary also accepts valid test files.
2024-01-24 09:38:28 -05:00