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

901 Commits

Author SHA1 Message Date
Alex Konradi
551ed722b0
Update nightly rust to recent version
Fix a bunch of issues revealed by the upgraded clippy

- update UUID library for improved uuid! parser macro
- make #[cfg(test)] block the last thing in a file
- call .to_string() instead of format! without interpolation
- use infallible conversion instead of try_into().expect
- remove redundant "Error" suffix from enum variant names
- remove unused type
2024-01-12 13:58:55 -05:00
Jordan Rose
d0879d7150 Bump to version v0.39.1 (Node-only release) 2024-01-10 17:18:20 -08:00
Alex Konradi
3afe5bfe58
Implement protobuf unknown field detection using field descriptors
Implement protobuf unknown field search by walking the tree of field
descriptors.
2024-01-10 17:08:13 -05:00
Jordan Rose
897051d97c protocol: Disable mlkem1024 for slightly faster non-test compiles
Previously we had the feature off but listed the dependency on
pqcrypto-kyber as non-optional, which was wasted work.

Note that the two versions of pqcrypto-kyber don't actually coexist
today! This should be treated as an API proof-of-concept, much like
our Kyber768 wrapper.
2024-01-10 13:19:06 -08:00
Jordan Rose
455b3bf7a0 Bump to version v0.39.0 2024-01-10 13:17:40 -08:00
Alex Konradi
6e88a0169f
Check backup recipient frame values
Check that a Frame that contains a Recipient proto contains valid data.
This adds validation for the `destination` field, which was previously
ignored.
2024-01-10 15:51:51 -05:00
moiseev-signal
94292db235
Use external RNG for random scalar in OPRF client 2024-01-10 12:28:32 -08:00
Jordan Rose
70a9662acd usernames: Expose Username.fromParts to app languages 2024-01-10 12:26:19 -08:00
Jordan Rose
0ef2c7cc54 usernames: Split up BadDiscriminator error into more specific errors
Rust: UsernameError now has more cases. ProofVerificationFailure is
also split off into its own error type, separate from structural
username errors.

Java: Subclasses of BadDiscriminatorException have been added.

Swift: Some error codes have been renamed and others have been added.

TypeScript: Some error codes have been renamed and others have been
added. Discriminator errors are now proper LibSignalErrors.
2024-01-10 12:26:19 -08:00
Jordan Rose
c7e60b8e5b usernames: Add Username::from_parts method
This applies the NicknameLimits that were previously only checked in
Username::candidates_from, in addition to validating other aspects of
the username.
2024-01-10 12:26:19 -08:00
moiseev-signal
9bbb981756
Implement generic Svr3Connection::connect 2024-01-08 15:09:25 -08:00
Alex Konradi
fa166ecf8b Push Option down into argument groups
When groups of arguments are used together, it seems like it makes sense
to put them in a single struct and include the struct as a field wrapped
in an Option with a flatten annotation at the top level. Unfortunately,
there is a bug in clap that pevents this from working as intended. This
patch pushes the optionality down at the cost of making the handling
code more verbose.
2024-01-08 16:56:55 -05:00
Alex Konradi
e3289db3ba
Add message backup validator executable
Add an executable target that reads backup files from disk or from stdin (by 
buffering the contents in memory to allow seeking), decrypts the contents if 
keys are provided, validates, and prints the output if requested.
2024-01-08 14:52:27 -05:00
Jordan Rose
0ed36f62e0 usernames: Refuse to generate hashes for nicknames over 48 chars long
The scalars associated with these nicknames would be out of range of
the Ristretto group's prime order, meaning curve25519_dalek's Scalar
won't be able to hold them. Previously the value silently wrapped
around to the start of the group, but that would conflict with a
shorter nickname's scalar.
2024-01-08 09:49:36 -08:00
moiseev-signal
26e589fc4d
Add length checks to low-level PPSS operations 2024-01-05 16:26:38 -08:00
moiseev-signal
23a68fb021
Make it harder to forget to clear pending session state fields 2024-01-05 16:23:06 -08:00
Alex Konradi
60b7c42d71
Add basic message backup protobuf validation
Check for duplicate records and foreign keys. Checking for unknown fields is 
deferred for a future change.
2024-01-05 16:09:29 -05:00
Jordan Rose
4a69727457 Bump to version v0.38.0 2024-01-05 11:04:43 -08:00
Jordan Rose
62aacf553d Avoid using div_ceil to maintain compatibility with Rust 1.72 2024-01-05 10:46:48 -08:00
moiseev-signal
1657f09745
Implement SVR3 and its SGX connection using libsignal-net 2024-01-03 15:20:14 -08:00
Alex Konradi
b3a6a8884d
Add streaming decoder for encrypted gzipped files
Add a reader that wraps a seekable stream and decrypts and decompresses it after
checking that the trailing HMAC is correct.
2024-01-03 13:56:04 -05:00
moiseev-signal
c86c74c288
Generalize Handshake type for different enclaves 2023-12-22 13:10:24 -08:00
Jordan Rose
d394f30644 protocol: Add a 'kem' example that can run through KEM operations 2023-12-20 16:22:21 -08:00
moiseev-signal
931691ffcf
Allow specifying certificates when creating CdsiEndpointConnection 2023-12-20 15:16:19 -08:00
Alex Konradi
e7e9ae5860
Add length-delimited message parser
Add a parser for length-delimited messages read from a stream. For message 
backup, these will be decrypted protobufs.
2023-12-20 17:07:08 -05:00
Jordan Rose
54dfd7a395 Allow mixed comparisons between ServiceId and Aci/Pni 2023-12-20 12:44:00 -08:00
Jordan Rose
33aca3ad7b Expose ServiceId::kind method as pub 2023-12-20 12:44:00 -08:00
Jordan Rose
534df59163 usernames: Use hmac crate directly 2023-12-18 11:30:57 -08:00
Alex Konradi
4733aceef4
Start message-backup crate with protos and keys
Introduce the message-backup crate with protobuf definitions and code to derive 
keys used to encrypt, store, and decrypt backups.
2023-12-15 18:15:07 -05:00
moiseev-signal
3fb7048330
Add high level PPSS API 2023-12-14 16:27:22 -08:00
Jordan Rose
31babcbd68 Bump to version v0.37.0 2023-12-13 15:57:14 -08:00
Jordan Rose
75811b90dc Move ServiceId + ProtocolAddress to new libsignal-core crate
...as well as related types Aci, Pni, ServiceId,
ServiceIdFixedWidthBinaryBytes, ServiceIdKind, and DeviceId.

...so that zkgroup and libsignal-net don't have to depend on
libsignal-protocol (and indirectly on Kyber).

The types are still exported from libsignal-protocol, so this is not a
source-breaking change.

ProtocolAddress is still defined as a (String, DeviceId) pair; a
switch to (ServiceId, DeviceId) will probably still happen in the
future, but not in this commit.
2023-12-13 09:20:19 -08:00
Alex Konradi
55b304cc4b Use SimpleArgTypeInfo for E164s
Remove duplicated parsing dispatch code from bridged functions that take
E164s by using the existing argument conversion machinery.
2023-12-13 10:06:45 -05:00
Alex Konradi
776d11c37b Use panic in place of ServerExitStatus
Use completion of the websocket handler as an indication of success and
any error, e.g. from a panic, as a cause of failure.
2023-12-12 16:51:20 -05:00
Jordan Rose
0d09a8352c
Add GroupSendCredential
This credential is issued by the group server and presented to the
chat server to prove that the holder is a member of *some* group with
a known list of people. This can be used to replace the access key
requirement for multi-recipient sealed sender sends.
2023-12-11 13:45:12 -08:00
Jordan Rose
bc18bb0ecf SSv2: Parallelize the generation of per-recipient key material
This uses the Rayon library to perform a MapReduce-like operation of
computing key material on recipients and folding them together into
intermediate buffers, with one final collection step at the end. As
written this uses Rayon's default thread pool, which will be lazily
initialized with one worker thread per logical core. We're not trying
to share thread pools with either libsignal-net's tokio contexts,
RingRTC's dedicated threads, or a platform-specific work queue like
iOS's Dispatch; let's keep things simple for now.

As a downside, the code now has to fetch all of the recipients'
identity keys up front, since it's not guaranteed that loading from
the IdentityKeyStore is thread-safe. However, the significant
improvement in wall time spent generating key material for large
recipient lists on even a dual-core system makes this worth it.
2023-12-11 12:36:54 -08:00
Jordan Rose
16653ffea1 SSv2: Add send support for excluded recipients 2023-12-11 12:36:54 -08:00
Jordan Rose
4e6e8c24a7 SSv2: Add send support for the compact device list format
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 client send side) that device IDs
are in the range 1..=127 for destinations of a SSv2 message.
2023-12-11 12:36:54 -08: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
7c5010a33a jni: Make sure to clean up local JNI references when logging
While neither Oracle's JRE nor Android's misbehaves if you go over
your limit of local references, it may result in the local frame
growing arbitrarily large. We don't want that.
2023-12-08 14:19:20 -08:00
moiseev-signal
6e5e3b0b9f
Use uninhabited types for KeyKind markers 2023-12-08 14:08:22 -08:00
Alex Konradi
e13d9ff8d6
Include more detail in websocket errors
Include more details about what went wrong in the error messages without 
revealing user data.
2023-12-08 17:03:46 -05:00
Alex Konradi
c94b0dd03f
Improve chat websocket debuggability
Add some debug logging and derive Debug for several types.
2023-12-08 16:33:31 -05:00
Jordan Rose
4bf90bc71a bridge: Move symbol prefixes to env variables set in build.rs
A small step towards separating `bridge_fn` into its own reusable
crate.
2023-12-08 10:50:07 -08:00
Jordan Rose
2c9e3e9d69 ffi: Use size_t to represent Rust usize instead of uintptr_t
Rust's usize serves the same purpose as both size_t and uintptr_t in
C, but for our uses it's always a buffer length or capacity rather
than something specifically the same size as a pointer or machine
register, so size_t is more accurate.

Swift, then, imports size_t as its currency type Int, even though
size_t is unsigned in C, because no buffer can actually fill up all of
memory. Swift, like Rust, doesn't have implicit numeric conversions,
so importing size_t as Int was deemed more useful in practice.
2023-12-07 17:42:34 -08:00
Jordan Rose
2364c268a0 ffi: Prefer std::ffi::* over libc::* for c_void, c_int, etc
And use usize for size_t:
- They're always equivalent in practice.
- When we're actually using it as a memory size, we're talking about
  the size of Rust objects, so usize is more accurate anyway.

This eliminates the use of the libc crate in the bridge layer. We
still use libc for time_t in attest and device_transfer, to interact
with BoringSSL.
2023-12-07 17:42:34 -08:00
Max Moiseev
126f87b73c Bump to version 0.36.1 2023-12-06 15:20:54 -08:00
Alex Konradi
a7cae88e2c
Update curve25519-dalek to 4.1.1 2023-12-06 14:58:14 -08:00
Alex Konradi
07337e2145
Wrap response to server push in MessageProto 2023-12-06 14:47:37 -08:00
Jordan Rose
b7bbabd228 Bump to version v0.36.0 2023-12-05 13:00:53 -08:00