markKyberPreKeyUsed only deleted one-time Kyber pre-keys. For a last
resort key libsignal expects the store to record the
(kyberPreKeyId, signedPreKeyId, baseKey) tuple and to throw
ReusedBaseKeyException when the same tuple is used again.
Record the tuples in a new kyber_pre_key_used table (database version
33). They are removed together with their Kyber pre-key through a
cascading delete.
Co-authored-by: Claude <noreply@anthropic.com>
The SSE event buffer only started recording an account when the first
client connected to /api/v1/events. With --receive-mode on-start the
account is already receiving before that, so the events of that window
were never kept and a client that reconnects after a restart with an
unknown Last-Event-ID got nothing, although it should get all kept events.
Record all accounts when the HTTP server starts, and accounts added later
in multi-account mode.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The account of JSON-RPC requests is normalized with
AccountIdentifier.normalize, so an ACI without dashes or in upper case
works there. The account query parameter of /api/v1/events was not, so
the same account identifier was rejected for the events.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
An ACI was only recognized with dashes. Without them it was passed to
the phone number formatter, which removes all letters, so its digits
were used as a phone number instead of failing.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Signal clients drop a message with a body range that ends after its
text (EnvelopeContentValidator: "Body range with out-of-bounds
start/length!"), while the sender gets a successful send result.
Check the ranges against the message length in UTF-16 code units, as
the clients do, and fail with a user error instead.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Like the attachment dimensions, the numbers matched by \d+ were parsed
with Integer.parseInt, so a value outside the int range failed with a
NumberFormatException instead of the command's UserErrorException.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
JSON-RPC params that take a single value were read with
Namespace.getString, which turns a list into its toString form. A
recipient passed as ["<ACI>"], like for the send commands, became
"[<ACI>]", was no longer recognized as an ACI, and its digits were
used as a phone number.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
MessageEnvelope already knows whether a message was sent with sealed
sender, but the JSON output didn't include it.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Let the caller choose the timestamp of a sent message instead of using
the current time. Signal clients identify a message by its author and
timestamp, so this lets a caller know the timestamp before the send
returns, or reuse the timestamp of an earlier attempt.
The value must be positive and strictly in the past. A supplied
timestamp does not update the last generated timestamp, so a value equal
to the current time could be the same as the one generated for a
concurrent send.
The option is rejected together with --edit-timestamp or --end-session,
and over D-Bus, which has no way to pass it.
Closes#1390
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
signal-cli rotated its own sender key for a group only when it was older
than 14 days or after some send errors. A member who left or was removed
kept the key and could decrypt group messages sent after that, if they got
hold of them, until it expired. Like in the official clients, the key is
now rotated when a stored group state loses a full member, and before
each sender key send if it was shared with someone who is no longer a
member. Only current members are sender key targets, so the new key never
reaches anyone else.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Add --tls-proxy to connect through a Signal TLS proxy
Networks that block Signal can be passed with a Signal TLS proxy, as in
the official apps. The new global option (config key tlsProxy) takes a
host, host:port or a https://signal.tube/#host link and sets the proxy
for the service configuration and for libsignal's Network. Behind the
proxy only the proxy host is resolved, so that the Signal host names
don't reach the local resolver.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fix the TLS named groups of the native image at build time
Through a TLS proxy, Java's TLS negotiates X25519MLKEM768 and looks for
a KEM in all providers, including BouncyCastle, which is registered at
run time and rejected by the native image ("Failed to get provisioning
URL"). A run-time jdk.tls.namedGroups is ignored by the native image.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The record gained reregister, recoveryKey and totp, but the reflection
metadata still listed only the old 2- and 3-arg constructors, so JSON-RPC
register failed in the native build with MissingReflectionRegistrationError.
Co-authored-by: Zack Polizzi <5598968+zplizzi@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
removeReceiveHandler removed the handler before it stopped the receive
thread. An envelope the thread was handling then was already cached and
acknowledged to the server; it reached no handler, and the cache dropped it
once handled, so it was lost. While removing the last handler stops the
thread, the handler stays in drainingHandlers: it still gets that envelope,
but doesn't keep the thread receiving.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
An invitation by phone number lists the account's PNI as the pending member. acceptInvite compared pending members only with the self ACI address and failed with 'Cannot find service ID for self to accept invite'. It now matches either the ACI or the PNI, makes the change as the ACI, and for a PNI promotion decrypts the server's signed change, since the locally built action has no member ciphertexts to decrypt.
* Fix race between stopping and starting the receive thread
When the last receive handler was removed, receiveThread was cleared
before the thread had stopped. A handler added in that window, e.g. by
a client reconnecting to the daemon in on-connection receive mode,
started a second receive thread. While the stop request for the old
thread was still set, each new thread ended immediately and started the
next one. When the old thread ended, it cleared the reference to the
newer thread and started yet another one, leaving two receive loops on
the same websocket. The unreferenced loop was never stopped and kept
receiving and acknowledging messages after all clients had gone.
Keep receiveThread set until the receive thread has finished and only
let the thread itself clear it. Its end block already starts a new
receive thread if handlers were added in the meantime. Clear a stop
request right before a new receive loop is started instead of when a
loop ends, so it can neither be cleared by another loop nor stop a
later one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Add test for adding a receive handler while the receive thread stops
The receive loop is replaced by a fake one that can be held while it
stops, so the test doesn't connect to the server.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: iddo <917594+iddo@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Fix voice calls from linked devices
(cherry picked from commit f3e22de14e)
* Verify primary and linked call configuration through account state
---------
Co-authored-by: Daniel <dan@gainengineering.com.au>