Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump libsignal client to 0.62 #345

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ license = "AGPL-3.0"
readme = "README.md"

[dependencies]
libsignal-protocol = { git = "https://github.com/signalapp/libsignal", tag = "v0.56.1" }
zkgroup = { git = "https://github.com/signalapp/libsignal", tag = "v0.56.1" }
libsignal-protocol = { git = "https://github.com/signalapp/libsignal", tag = "v0.62.0" }
zkgroup = { git = "https://github.com/signalapp/libsignal", tag = "v0.62.0" }

aes = "0.8"
aes-gcm = "0.10"
Expand Down
23 changes: 13 additions & 10 deletions src/account_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
use hmac::digest::Output;
use hmac::{Hmac, Mac};
use libsignal_protocol::{
kem, Aci, GenericSignedPreKey, IdentityKey, IdentityKeyPair,
kem, Aci, DeviceId, GenericSignedPreKey, IdentityKey, IdentityKeyPair,
IdentityKeyStore, KeyPair, KyberPreKeyRecord, PrivateKey, ProtocolStore,
PublicKey, SenderKeyStore, ServiceIdKind, SignedPreKeyRecord, Timestamp,
PublicKey, SenderKeyStore, ServiceId, ServiceIdKind, SignedPreKeyRecord,
Timestamp,
};
use prost::Message;
use serde::{Deserialize, Serialize};
Expand All @@ -35,7 +36,6 @@
DEFAULT_DEVICE_ID,
};
use crate::sender::OutgoingPushMessage;
use crate::service_address::ServiceIdExt;
use crate::session_store::SessionStoreExt;
use crate::timestamp::TimestampExt as _;
use crate::utils::{random_length_padding, BASE64_RELAXED};
Expand Down Expand Up @@ -685,17 +685,20 @@
HashMap::<String, u32>::with_capacity(local_device_ids.len());

let signature_valid_on_each_signed_pre_key = true;
for local_device_id in
std::iter::once(DEFAULT_DEVICE_ID).chain(local_device_ids)
for local_device_id in std::iter::once(DEFAULT_DEVICE_ID)
.chain(local_device_ids)
.map(DeviceId::from)
{
let is_default_device_id =
local_device_id == DeviceId::from(DEFAULT_DEVICE_ID);
let local_protocol_address =
local_aci.to_protocol_address(local_device_id);
ServiceId::from(local_aci).to_protocol_address(local_device_id);
let span = tracing::trace_span!(
"filtering devices",
address = %local_protocol_address
);
// Skip if we don't have a session with the device
if (local_device_id != DEFAULT_DEVICE_ID)
if is_default_device_id
&& aci_protocol_store
.load_session(&local_protocol_address)
.instrument(span)
Expand All @@ -713,7 +716,7 @@
signed_pre_key,
_kyber_pre_keys,
last_resort_kyber_prekey,
) = if local_device_id == DEFAULT_DEVICE_ID {
) = if is_default_device_id {
crate::pre_keys::replenish_pre_keys(
pni_protocol_store,
csprng,
Expand Down Expand Up @@ -754,7 +757,7 @@
)
};

let registration_id = if local_device_id == DEFAULT_DEVICE_ID {
let registration_id = if is_default_device_id {
pni_protocol_store.get_local_registration_id().await?
} else {
loop {
Expand Down Expand Up @@ -784,7 +787,7 @@
assert!(_pre_keys.is_empty());
assert!(_kyber_pre_keys.is_empty());

if local_device_id == DEFAULT_DEVICE_ID {
if is_default_device_id {
// This is the primary device
// We don't need to send a message to the primary device
continue;
Expand Down Expand Up @@ -814,7 +817,7 @@
.create_encrypted_message(
&local_aci.into(),
None,
local_device_id.into(),

Check warning on line 820 in src/account_manager.rs

View workflow job for this annotation

GitHub Actions / clippy

useless conversion to the same type: `libsignal_protocol::DeviceId`

warning: useless conversion to the same type: `libsignal_protocol::DeviceId` --> src/account_manager.rs:820:21 | 820 | local_device_id.into(), | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `local_device_id` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` on by default
&content.into_proto().encode_to_vec(),
)
.await?;
Expand Down
1 change: 0 additions & 1 deletion src/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use crate::{
sender::OutgoingPushMessage,
session_store::SessionStoreExt,
utils::BASE64_RELAXED,
ServiceIdExt,
};
/// Decrypts incoming messages and encrypts outgoing messages.
///
Expand Down
3 changes: 1 addition & 2 deletions src/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub use crate::{
SyncMessage, TypingMessage,
},
push_service::ServiceError,
ServiceIdExt,
};

mod data_message;
Expand Down Expand Up @@ -50,7 +49,7 @@ impl fmt::Display for Metadata {

impl Metadata {
pub(crate) fn protocol_address(&self) -> ProtocolAddress {
self.sender.to_protocol_address(self.sender_device)
self.sender.to_protocol_address(self.sender_device.into())
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub mod provisioning;
pub mod push_service;
pub mod receiver;
pub mod sender;
pub mod service_address;
pub mod session_store;
mod timestamp;
pub mod unidentified_access;
Expand All @@ -35,7 +34,6 @@ pub mod websocket;
pub use crate::account_manager::{
decrypt_device_name, AccountManager, Profile, ProfileManagerError,
};
pub use crate::service_address::*;

pub const USER_AGENT: &str =
concat!(env!("CARGO_PKG_NAME"), "-rs-", env!("CARGO_PKG_VERSION"));
Expand Down
7 changes: 4 additions & 3 deletions src/push_service/keys.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::collections::HashMap;

use libsignal_protocol::{
IdentityKey, PreKeyBundle, SenderCertificate, ServiceId, ServiceIdKind,
DeviceId, IdentityKey, PreKeyBundle, SenderCertificate, ServiceId,
ServiceIdKind,
};
use reqwest::Method;
use serde::Deserialize;
Expand Down Expand Up @@ -67,12 +68,12 @@ impl PushService {
pub async fn get_pre_key(
&mut self,
destination: &ServiceId,
device_id: u32,
device_id: DeviceId,
) -> Result<PreKeyBundle, ServiceError> {
let path = format!(
"/v2/keys/{}/{}",
destination.service_id_string(),
device_id
u32::from(device_id),
);

let mut pre_key_response: PreKeyResponse = self
Expand Down
20 changes: 11 additions & 9 deletions src/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use crate::{
AttachmentPointer, SyncMessage,
},
push_service::*,
service_address::ServiceIdExt,
session_store::SessionStoreExt,
unidentified_access::UnidentifiedAccess,
utils::serde_service_id,
Expand Down Expand Up @@ -600,28 +599,30 @@ where
Err(ServiceError::MismatchedDevicesException(ref m)) => {
tracing::debug!("{:?}", m);
for extra_device_id in &m.extra_devices {
let extra_device_id = DeviceId::from(*extra_device_id);
tracing::debug!(
"dropping session with device {}",
extra_device_id
);
self.protocol_store
.delete_service_addr_device_session(
&recipient
.to_protocol_address(*extra_device_id),
&recipient.to_protocol_address(extra_device_id),
)
.await?;
}

for missing_device_id in &m.missing_devices {
let missing_device_id =
DeviceId::from(*missing_device_id);
tracing::debug!(
"creating session with missing device {}",
missing_device_id
);
let remote_address =
recipient.to_protocol_address(*missing_device_id);
recipient.to_protocol_address(missing_device_id);
let pre_key = self
.service
.get_pre_key(&recipient, *missing_device_id)
.get_pre_key(&recipient, missing_device_id)
.await?;

process_prekey_bundle(
Expand All @@ -644,14 +645,14 @@ where
Err(ServiceError::StaleDevices(ref m)) => {
tracing::debug!("{:?}", m);
for extra_device_id in &m.stale_devices {
let stale_device_id = DeviceId::from(*extra_device_id);
tracing::debug!(
"dropping session with device {}",
extra_device_id
stale_device_id
);
self.protocol_store
.delete_service_addr_device_session(
&recipient
.to_protocol_address(*extra_device_id),
&recipient.to_protocol_address(stale_device_id),
)
.await?;
}
Expand Down Expand Up @@ -943,7 +944,8 @@ where
used_identity_key: self
.protocol_store
.get_identity(
&recipient.to_protocol_address(DEFAULT_DEVICE_ID),
&recipient
.to_protocol_address(DEFAULT_DEVICE_ID.into()),
)
.await?
.ok_or(MessageSenderError::UntrustedIdentity {
Expand Down
39 changes: 0 additions & 39 deletions src/service_address.rs

This file was deleted.

Loading