mirror of
https://github.com/signalapp/libsignal.git
synced 2026-04-25 17:25:18 +02:00
Format Rust using 2024 edition rules
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
imports_granularity = "Module"
|
||||
group_imports = "StdExternalCrate"
|
||||
style_edition = "2024"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
|
||||
use const_str::hex;
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
|
||||
pub fn hash(c: &mut Criterion) {
|
||||
// let mut group = c.benchmark_group("pin_hash");
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
//! SVR, so that a restorer can reconstruct the `BackupId`.
|
||||
|
||||
use hkdf::Hkdf;
|
||||
use libsignal_core::curve::PrivateKey;
|
||||
use libsignal_core::Aci;
|
||||
use libsignal_core::curve::PrivateKey;
|
||||
use partial_default::PartialDefault;
|
||||
use sha2::Sha256;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
//! 3. The string must then be [NFKD normalized](https://unicode.org/reports/tr15/#Norm_Forms)
|
||||
//!
|
||||
|
||||
use argon2::password_hash::{rand_core, Salt, SaltString};
|
||||
use argon2::password_hash::{Salt, SaltString, rand_core};
|
||||
use argon2::{
|
||||
Algorithm, Argon2, ParamsBuilder, PasswordHash, PasswordHasher, PasswordVerifier, Version,
|
||||
};
|
||||
@@ -131,7 +131,7 @@ mod test {
|
||||
use sha2::Sha256;
|
||||
|
||||
use super::*;
|
||||
use crate::hash::{local_pin_hash, verify_local_pin_hash, PinHash};
|
||||
use crate::hash::{PinHash, local_pin_hash, verify_local_pin_hash};
|
||||
|
||||
fn hmac_sha256(key: &[u8], data: &[u8]) -> [u8; 32] {
|
||||
type HmacSha256 = Hmac<Sha256>;
|
||||
@@ -193,7 +193,9 @@ mod test {
|
||||
hex!("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"),
|
||||
hex!("202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f"),
|
||||
hex!("ab7e8499d21f80a6600b3b9ee349ac6d72c07e3359fe885a934ba7aa844429f8"),
|
||||
hex!("3f33ce58eb25b40436592a30eae2a8fabab1899095f4e2fba6e2d0dc43b4a2d9cac5a3931748522393951e0e54dec769"),
|
||||
hex!(
|
||||
"3f33ce58eb25b40436592a30eae2a8fabab1899095f4e2fba6e2d0dc43b4a2d9cac5a3931748522393951e0e54dec769"
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -204,7 +206,9 @@ mod test {
|
||||
hex!("202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f"),
|
||||
hex!("88a787415a2ecd79da0d1016a82a27c5c695c9a19b88b0aa1d35683280aa9a67"),
|
||||
hex!("301d9dd1e96f20ce51083f67d3298fd37b97525de8324d5e12ed2d407d3d927b"),
|
||||
hex!("9d9b05402ea39c17ff1c9298c8a0e86784a352aa02a74943bf8bcf07ec0f4b574a5b786ad0182c8d308d9eb06538b8c9"),
|
||||
hex!(
|
||||
"9d9b05402ea39c17ff1c9298c8a0e86784a352aa02a74943bf8bcf07ec0f4b574a5b786ad0182c8d308d9eb06538b8c9"
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ use core::{fmt, str};
|
||||
|
||||
pub use backup::*;
|
||||
pub use error::{Error, Result};
|
||||
pub use hash::{local_pin_hash, verify_local_pin_hash, PinHash};
|
||||
pub use hash::{PinHash, local_pin_hash, verify_local_pin_hash};
|
||||
use hkdf::Hkdf;
|
||||
use rand::distr::slice;
|
||||
use rand::Rng;
|
||||
use rand::distr::slice;
|
||||
use sha2::Sha256;
|
||||
|
||||
pub const SVR_KEY_LEN: usize = 32;
|
||||
|
||||
@@ -10,7 +10,7 @@ use boring_signal::pkey::Public;
|
||||
use boring_signal::stack::{Stack, Stackable};
|
||||
use boring_signal::x509::crl::X509CRLRef;
|
||||
use boring_signal::x509::store::X509StoreRef;
|
||||
use boring_signal::x509::{X509StoreContext, X509};
|
||||
use boring_signal::x509::{X509, X509StoreContext};
|
||||
|
||||
use crate::error::ContextError;
|
||||
use crate::expireable::Expireable;
|
||||
@@ -169,9 +169,9 @@ pub mod testutil {
|
||||
use boring_signal::hash::MessageDigest;
|
||||
use boring_signal::nid::Nid;
|
||||
use boring_signal::pkey::{PKey, Private};
|
||||
use boring_signal::x509::crl::{X509CRLBuilder, X509Revoked, X509CRL};
|
||||
use boring_signal::x509::crl::{X509CRL, X509CRLBuilder, X509Revoked};
|
||||
use boring_signal::x509::extension::BasicConstraints;
|
||||
use boring_signal::x509::{X509Name, X509};
|
||||
use boring_signal::x509::{X509, X509Name};
|
||||
|
||||
use super::CertChain;
|
||||
|
||||
@@ -311,9 +311,9 @@ pub mod testutil {
|
||||
mod test {
|
||||
use assert_matches::assert_matches;
|
||||
use boring_signal::nid::Nid;
|
||||
use boring_signal::x509::X509Ref;
|
||||
use boring_signal::x509::store::{X509Store, X509StoreBuilder};
|
||||
use boring_signal::x509::verify::X509VerifyFlags;
|
||||
use boring_signal::x509::X509Ref;
|
||||
|
||||
use super::testutil::*;
|
||||
use super::*;
|
||||
@@ -422,9 +422,11 @@ mod test {
|
||||
let cert_chain = CertChain {
|
||||
certs: c.into_iter().map(|p| p.x509).collect(),
|
||||
};
|
||||
assert!(cert_chain
|
||||
.validate_chain(&trust, &[&intermediate_crl])
|
||||
.is_err())
|
||||
assert!(
|
||||
cert_chain
|
||||
.validate_chain(&trust, &[&intermediate_crl])
|
||||
.is_err()
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -436,9 +438,11 @@ mod test {
|
||||
let cert_chain = CertChain {
|
||||
certs: c.into_iter().map(|p| p.x509).collect(),
|
||||
};
|
||||
assert!(cert_chain
|
||||
.validate_chain(&trust, &[&intermediate_crl])
|
||||
.is_err())
|
||||
assert!(
|
||||
cert_chain
|
||||
.validate_chain(&trust, &[&intermediate_crl])
|
||||
.is_err()
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -34,7 +34,7 @@ use boring_signal::pkey::{PKey, PKeyRef, Public};
|
||||
use boring_signal::x509::crl::X509CRLRef;
|
||||
use boring_signal::x509::store::{X509Store, X509StoreBuilder};
|
||||
use boring_signal::x509::verify::X509VerifyFlags;
|
||||
use boring_signal::x509::{X509Ref, X509};
|
||||
use boring_signal::x509::{X509, X509Ref};
|
||||
use hex::ToHex;
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -760,14 +760,16 @@ mod test {
|
||||
let evidence_bytes = include_bytes!("../tests/data/dcap-expired.evidence");
|
||||
let endorsements_bytes = include_bytes!("../tests/data/dcap-expired.endorsements");
|
||||
|
||||
assert!(verify_remote_attestation(
|
||||
evidence_bytes.as_ref(),
|
||||
endorsements_bytes.as_ref(),
|
||||
&EXPECTED_MRENCLAVE,
|
||||
ACCEPTED_SW_ADVISORIES,
|
||||
current_time,
|
||||
)
|
||||
.is_err());
|
||||
assert!(
|
||||
verify_remote_attestation(
|
||||
evidence_bytes.as_ref(),
|
||||
endorsements_bytes.as_ref(),
|
||||
&EXPECTED_MRENCLAVE,
|
||||
ACCEPTED_SW_ADVISORIES,
|
||||
current_time,
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -19,7 +19,7 @@ use serde_json::value::RawValue;
|
||||
use strum::EnumCount;
|
||||
|
||||
use crate::cert_chain::CertChain;
|
||||
use crate::dcap::ecdsa::{deserialize_ecdsa_signature, EcdsaSigned};
|
||||
use crate::dcap::ecdsa::{EcdsaSigned, deserialize_ecdsa_signature};
|
||||
use crate::dcap::revocation_list::RevocationList;
|
||||
use crate::dcap::{Error, Expireable, Result};
|
||||
use crate::endian::UInt32LE;
|
||||
@@ -326,9 +326,11 @@ mod tests {
|
||||
TcbStatus::SWHardeningNeeded,
|
||||
tcb_info.tcb_levels[0].tcb_status
|
||||
);
|
||||
assert!(tcb_info.tcb_levels[0]
|
||||
.advisory_ids
|
||||
.contains(&"INTEL-SA-00657".to_owned()));
|
||||
assert!(
|
||||
tcb_info.tcb_levels[0]
|
||||
.advisory_ids
|
||||
.contains(&"INTEL-SA-00657".to_owned())
|
||||
);
|
||||
assert_eq!(
|
||||
[7, 9, 3, 3, 255, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
tcb_info.tcb_levels[0].tcb.components()
|
||||
|
||||
@@ -23,13 +23,13 @@ use boring_signal::nid::Nid;
|
||||
use boring_signal::pkey::{PKey, Private, Public};
|
||||
use chrono::Utc;
|
||||
|
||||
use crate::cert_chain::testutil::TestCert;
|
||||
use crate::cert_chain::CertChain;
|
||||
use crate::cert_chain::testutil::TestCert;
|
||||
use crate::dcap::ecdsa::EcdsaSigned;
|
||||
use crate::dcap::endorsements::SgxEndorsements;
|
||||
use crate::dcap::evidence::Evidence;
|
||||
use crate::dcap::revocation_list::RevocationList;
|
||||
use crate::dcap::{attest_impl, Attestation};
|
||||
use crate::dcap::{Attestation, attest_impl};
|
||||
|
||||
const EVIDENCE_BYTES: &[u8] = include_bytes!("../../tests/data/dcap.evidence");
|
||||
const ENDORSEMENT_BYTES: &[u8] = include_bytes!("../../tests/data/dcap.endorsements");
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::collections::HashSet;
|
||||
use std::time::SystemTime;
|
||||
|
||||
use boring_signal::nid::Nid;
|
||||
use boring_signal::x509::crl::{X509CRLRef, X509CRL};
|
||||
use boring_signal::x509::crl::{X509CRL, X509CRLRef};
|
||||
|
||||
use crate::dcap::{Error, Expireable, Result};
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ use sha2::Digest;
|
||||
use zerocopy::{FromBytes, Immutable, IntoBytes};
|
||||
|
||||
use crate::cert_chain::CertChain;
|
||||
use crate::dcap::ecdsa::{ecdsa_signature_from_bytes, EcdsaSigned};
|
||||
use crate::dcap::ecdsa::{EcdsaSigned, ecdsa_signature_from_bytes};
|
||||
use crate::dcap::sgx_report_body::SgxReportBody;
|
||||
use crate::dcap::sgx_x509::SgxPckExtension;
|
||||
use crate::dcap::{Error, Expireable};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use asn1::{oid, ObjectIdentifier, SequenceOf};
|
||||
use asn1::{ObjectIdentifier, SequenceOf, oid};
|
||||
use boring_signal::asn1::Asn1ObjectRef;
|
||||
use boring_signal::nid::Nid;
|
||||
|
||||
|
||||
@@ -145,23 +145,25 @@ mod tests {
|
||||
let mrenclave_bytes =
|
||||
hex!("38e01eff4fe357dc0b0e8ef7a44b4abc5489fbccba3a78780f3872c277f62bf3");
|
||||
|
||||
assert!(new_handshake_with_constants(
|
||||
&mrenclave_bytes,
|
||||
HANDSHAKE_BYTES,
|
||||
current_time,
|
||||
&[],
|
||||
&RaftConfig {
|
||||
min_voting_replicas: 3,
|
||||
max_voting_replicas: 5,
|
||||
super_majority: 0,
|
||||
group_id: 0, // wrong
|
||||
db_version: 2,
|
||||
attestation_timeout: 604800,
|
||||
simulated: false,
|
||||
},
|
||||
HandshakeType::PreQuantum,
|
||||
)
|
||||
.is_err());
|
||||
assert!(
|
||||
new_handshake_with_constants(
|
||||
&mrenclave_bytes,
|
||||
HANDSHAKE_BYTES,
|
||||
current_time,
|
||||
&[],
|
||||
&RaftConfig {
|
||||
min_voting_replicas: 3,
|
||||
max_voting_replicas: 5,
|
||||
super_majority: 0,
|
||||
group_id: 0, // wrong
|
||||
db_version: 2,
|
||||
attestation_timeout: 604800,
|
||||
simulated: false,
|
||||
},
|
||||
HandshakeType::PreQuantum,
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
fn matches(
|
||||
|
||||
@@ -7,9 +7,9 @@ use std::ffi::{c_char, c_uchar};
|
||||
use std::panic::AssertUnwindSafe;
|
||||
|
||||
use libsignal_bridge::ffi::{
|
||||
self, run_ffi_safe, write_result_to, NullPointerError, OwnedBufferOf, SignalFfiError,
|
||||
self, NullPointerError, OwnedBufferOf, SignalFfiError, run_ffi_safe, write_result_to,
|
||||
};
|
||||
use libsignal_bridge::{ffi_arg_type, ffi_result_type, IllegalArgumentError};
|
||||
use libsignal_bridge::{IllegalArgumentError, ffi_arg_type, ffi_result_type};
|
||||
use libsignal_bridge_macros::bridge_fn;
|
||||
use libsignal_core::ProtocolAddress;
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
#![allow(clippy::missing_safety_doc)]
|
||||
#![warn(clippy::unwrap_used)]
|
||||
|
||||
use std::ffi::{c_char, c_uchar, CString};
|
||||
use std::ffi::{CString, c_char, c_uchar};
|
||||
|
||||
use libsignal_bridge::ffi::{self, *};
|
||||
use libsignal_bridge::{ffi_arg_type, IllegalArgumentError};
|
||||
use libsignal_bridge::{IllegalArgumentError, ffi_arg_type};
|
||||
use libsignal_bridge_macros::bridge_fn;
|
||||
#[cfg(feature = "libsignal-bridge-testing")]
|
||||
#[allow(unused_imports)]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use std::ffi::{c_char, c_void, CString};
|
||||
use std::ffi::{CString, c_char, c_void};
|
||||
|
||||
#[repr(C)]
|
||||
pub enum LogLevel {
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
#![allow(clippy::missing_safety_doc)]
|
||||
#![deny(clippy::unwrap_used)]
|
||||
|
||||
use jni::JNIEnv;
|
||||
#[cfg(not(target_os = "android"))]
|
||||
use jni::objects::{AutoLocal, JList, JMap, JValue};
|
||||
use jni::objects::{JByteArray, JClass, JLongArray, JObject, JString};
|
||||
use jni::JNIEnv;
|
||||
use libsignal_bridge::jni::*;
|
||||
use libsignal_bridge::net::TokioAsyncContext;
|
||||
use libsignal_bridge::{jni_args, jni_signature};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use std::panic::{catch_unwind, AssertUnwindSafe};
|
||||
use std::panic::{AssertUnwindSafe, catch_unwind};
|
||||
use std::process::abort;
|
||||
|
||||
use jni::objects::{AutoLocal, GlobalRef, JClass, JObject, JStaticMethodID, JValue};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
use std::future::Future;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem;
|
||||
use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
|
||||
use std::panic::{AssertUnwindSafe, catch_unwind, resume_unwind};
|
||||
use std::pin::Pin;
|
||||
use std::sync::{Arc, Mutex, Weak};
|
||||
use std::task::{Poll, Waker};
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
use neon::prelude::*;
|
||||
|
||||
use crate::future::*;
|
||||
use crate::PersistentException;
|
||||
use crate::future::*;
|
||||
|
||||
/// Sets up a [JsFuture] using a builder pattern. See [JsFuture::get_promise].
|
||||
pub struct JsFutureBuilder<'a, F, T: 'static + Send>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
|
||||
use std::future::Future;
|
||||
use std::panic::{catch_unwind, AssertUnwindSafe, UnwindSafe};
|
||||
use std::panic::{AssertUnwindSafe, UnwindSafe, catch_unwind};
|
||||
|
||||
use futures_util::FutureExt;
|
||||
use neon::prelude::*;
|
||||
|
||||
@@ -10,8 +10,8 @@ use libsignal_bridge::node::{AssumedImmutableBuffer, ResultTypeInfo, SignalNodeE
|
||||
use libsignal_protocol::{IdentityKeyPair, SealedSenderV2SentMessage};
|
||||
use minidump::Minidump;
|
||||
use minidump_processor::ProcessorOptions;
|
||||
use minidump_unwind::symbols::string_symbol_supplier;
|
||||
use minidump_unwind::Symbolizer;
|
||||
use minidump_unwind::symbols::string_symbol_supplier;
|
||||
use neon::prelude::*;
|
||||
use neon::types::buffer::TypedArray;
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
use libsignal_bridge::node::SimpleArgTypeInfo;
|
||||
use neon::prelude::*;
|
||||
|
||||
@@ -8,8 +8,8 @@ use quote::*;
|
||||
use syn::*;
|
||||
use syn_mid::Signature;
|
||||
|
||||
use crate::util::{extract_arg_names_and_types, result_type};
|
||||
use crate::BridgingKind;
|
||||
use crate::util::{extract_arg_names_and_types, result_type};
|
||||
|
||||
pub(crate) fn bridge_fn(
|
||||
name: &str,
|
||||
|
||||
@@ -8,8 +8,8 @@ use quote::*;
|
||||
use syn::*;
|
||||
use syn_mid::Signature;
|
||||
|
||||
use crate::util::{extract_arg_names_and_types, result_type};
|
||||
use crate::BridgingKind;
|
||||
use crate::util::{extract_arg_names_and_types, result_type};
|
||||
|
||||
fn bridge_fn_body(orig_name: &Ident, input_args: &[(&Ident, &Type)]) -> TokenStream2 {
|
||||
// Scroll down to the end of the function to see the quote template.
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
//
|
||||
|
||||
use crypto_common::KeyInit;
|
||||
use hmac::digest::typenum::Unsigned;
|
||||
use hmac::digest::{crypto_common, OutputSizeUser};
|
||||
use hmac::Hmac;
|
||||
use hmac::digest::typenum::Unsigned;
|
||||
use hmac::digest::{OutputSizeUser, crypto_common};
|
||||
use libsignal_bridge_macros::*;
|
||||
use libsignal_bridge_types::incremental_mac::*;
|
||||
use libsignal_protocol::incremental_mac::{calculate_chunk_size, Incremental};
|
||||
use libsignal_protocol::incremental_mac::{Incremental, calculate_chunk_size};
|
||||
|
||||
use crate::support::*;
|
||||
use crate::*;
|
||||
|
||||
@@ -14,8 +14,8 @@ use libsignal_bridge_types::net::{ConnectionManager, TokioAsyncContext};
|
||||
use libsignal_bridge_types::support::AsType;
|
||||
use libsignal_net::auth::Auth;
|
||||
use libsignal_net::chat::{self, ConnectError, LanguageList, Response as ChatResponse, SendError};
|
||||
use libsignal_net_chat::api::usernames::UnauthenticatedChatApi;
|
||||
use libsignal_net_chat::api::RequestError;
|
||||
use libsignal_net_chat::api::usernames::UnauthenticatedChatApi;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::support::*;
|
||||
|
||||
@@ -11,11 +11,11 @@ pub use libsignal_bridge_types::net::{Environment, TokioAsyncContext};
|
||||
use libsignal_bridge_types::support::AsType;
|
||||
use libsignal_core::{Aci, E164};
|
||||
use libsignal_keytrans::{AccountData, LocalStateUpdate, StoredAccountData, StoredTreeHead};
|
||||
use libsignal_net_chat::api::keytrans::{
|
||||
monitor_and_search, Error, KeyTransparencyClient, MaybePartial, MonitorMode, SearchKey,
|
||||
UnauthenticatedChatApi as _, UsernameHash,
|
||||
};
|
||||
use libsignal_net_chat::api::Unauth;
|
||||
use libsignal_net_chat::api::keytrans::{
|
||||
Error, KeyTransparencyClient, MaybePartial, MonitorMode, SearchKey,
|
||||
UnauthenticatedChatApi as _, UsernameHash, monitor_and_search,
|
||||
};
|
||||
use libsignal_protocol::PublicKey;
|
||||
use prost::{DecodeError, Message};
|
||||
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use libsignal_bridge_macros::{bridge_fn, bridge_io};
|
||||
use libsignal_bridge_types::net::TokioAsyncContext;
|
||||
use libsignal_bridge_types::net::registration::{
|
||||
ConnectChatBridge, RegisterAccountInner, RegisterAccountRequest, RegistrationAccountAttributes,
|
||||
RegistrationCreateSessionRequest, RegistrationPushToken, RegistrationService,
|
||||
SignedPublicPreKey,
|
||||
};
|
||||
use libsignal_bridge_types::net::TokioAsyncContext;
|
||||
use libsignal_bridge_types::*;
|
||||
use libsignal_net::chat::LanguageList;
|
||||
use libsignal_net_chat::api::registration::*;
|
||||
use libsignal_net_chat::api::ChallengeOption;
|
||||
use libsignal_net_chat::api::registration::*;
|
||||
use libsignal_net_chat::registration::RequestError;
|
||||
use libsignal_protocol::*;
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use libsignal_account_keys::{BackupKey, BACKUP_FORWARD_SECRECY_TOKEN_LEN};
|
||||
use libsignal_account_keys::{BACKUP_FORWARD_SECRECY_TOKEN_LEN, BackupKey};
|
||||
use libsignal_bridge_macros::{bridge_fn, bridge_io};
|
||||
use libsignal_bridge_types::net::svrb::SvrBConnectImpl;
|
||||
use libsignal_bridge_types::net::{ConnectionManager, Environment, TokioAsyncContext};
|
||||
use libsignal_net::auth::Auth;
|
||||
use libsignal_net::svrb::{
|
||||
create_new_backup_chain, remove_backup, restore_backup, store_backup, BackupFileMetadataRef,
|
||||
BackupPreviousSecretDataRef, BackupRestoreResponse, BackupStoreResponse, Error as SvrbError,
|
||||
BackupFileMetadataRef, BackupPreviousSecretDataRef, BackupRestoreResponse, BackupStoreResponse,
|
||||
Error as SvrbError, create_new_backup_chain, remove_backup, restore_backup, store_backup,
|
||||
};
|
||||
|
||||
use crate::support::*;
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use ::usernames::{
|
||||
create_for_username, decrypt_username, NicknameLimits, Username, UsernameError,
|
||||
UsernameLinkError,
|
||||
NicknameLimits, Username, UsernameError, UsernameLinkError, create_for_username,
|
||||
decrypt_username,
|
||||
};
|
||||
use libsignal_bridge_macros::*;
|
||||
use rand::TryRngCore as _;
|
||||
|
||||
@@ -9,6 +9,7 @@ use libsignal_bridge_macros::*;
|
||||
use libsignal_bridge_types::zkgroup::validate_serialization;
|
||||
use libsignal_protocol::{Aci, Pni, ServiceId};
|
||||
use uuid::Uuid;
|
||||
pub(crate) use zkgroup::Timestamp;
|
||||
use zkgroup::auth::*;
|
||||
use zkgroup::backups::{
|
||||
BackupAuthCredential, BackupAuthCredentialPresentation, BackupAuthCredentialRequest,
|
||||
@@ -19,7 +20,6 @@ use zkgroup::generic_server_params::*;
|
||||
use zkgroup::groups::*;
|
||||
use zkgroup::profiles::*;
|
||||
use zkgroup::receipts::*;
|
||||
pub(crate) use zkgroup::Timestamp;
|
||||
use zkgroup::*;
|
||||
|
||||
use crate::support::*;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
use std::num::NonZeroU16;
|
||||
|
||||
use base64::prelude::{Engine as _, BASE64_STANDARD};
|
||||
use base64::prelude::{BASE64_STANDARD, Engine as _};
|
||||
use libsignal_bridge_macros::*;
|
||||
use libsignal_bridge_types::net::chat::ServerMessageAck;
|
||||
use libsignal_bridge_types::net::{ConnectionManager, TokioAsyncContext};
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
use bytes::Bytes;
|
||||
use http::{HeaderMap, HeaderName, HeaderValue, StatusCode};
|
||||
use libsignal_bridge_macros::*;
|
||||
use libsignal_bridge_types::net::TokioAsyncContext;
|
||||
use libsignal_bridge_types::net::chat::{
|
||||
AuthenticatedChatConnection, ChatListener, HttpRequest, UnauthenticatedChatConnection,
|
||||
};
|
||||
use libsignal_bridge_types::net::TokioAsyncContext;
|
||||
use libsignal_net::chat::fake::FakeChatRemote;
|
||||
use libsignal_net::chat::{
|
||||
ConnectError, RequestProto, Response as ChatResponse, ResponseProto, SendError,
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
use std::collections::HashSet;
|
||||
use std::time::Duration;
|
||||
|
||||
use futures_util::future::BoxFuture;
|
||||
use futures_util::FutureExt;
|
||||
use futures_util::future::BoxFuture;
|
||||
use libsignal_bridge_macros::*;
|
||||
use libsignal_bridge_types::net::TokioAsyncContext;
|
||||
use libsignal_bridge_types::net::registration::{
|
||||
ConnectChatBridge, RegistrationCreateSessionRequest, RegistrationService,
|
||||
};
|
||||
use libsignal_bridge_types::net::TokioAsyncContext;
|
||||
use libsignal_net::auth::Auth;
|
||||
use libsignal_net::chat::fake::FakeChatRemote;
|
||||
use libsignal_net::chat::ChatConnection;
|
||||
use libsignal_net::chat::fake::FakeChatRemote;
|
||||
use libsignal_net::infra::errors::RetryLater;
|
||||
use libsignal_net_chat::api::registration::*;
|
||||
use libsignal_net_chat::api::{ChallengeOption, RateLimitChallenge, Unauth};
|
||||
@@ -39,8 +39,8 @@ pub fn TESTING_RegistrationSessionInfoConvert() -> RegistrationSession {
|
||||
}
|
||||
|
||||
#[bridge_fn]
|
||||
pub fn TESTING_RegistrationService_CheckSvr2CredentialsResponseConvert(
|
||||
) -> CheckSvr2CredentialsResponse {
|
||||
pub fn TESTING_RegistrationService_CheckSvr2CredentialsResponseConvert()
|
||||
-> CheckSvr2CredentialsResponse {
|
||||
CheckSvr2CredentialsResponse {
|
||||
matches: [
|
||||
("username:pass-match", Svr2CredentialsResult::Match),
|
||||
|
||||
@@ -10,8 +10,8 @@ use const_str::ip_addr;
|
||||
use libsignal_net::chat::RECOMMENDED_CHAT_WS_CONFIG;
|
||||
use libsignal_net::enclave::{Cdsi, EnclaveEndpoint, EndpointParams, MrEnclave, SvrSgx};
|
||||
use libsignal_net::env::{ConnectionConfig, DomainConfig, Env, KeyTransConfig, SvrBEnv};
|
||||
use libsignal_net::infra::certs::RootCertificates;
|
||||
use libsignal_net::infra::RECOMMENDED_WS_CONFIG;
|
||||
use libsignal_net::infra::certs::RootCertificates;
|
||||
|
||||
const ENCLAVE_ID_MOCK_SERVER: &[u8] = b"0.20240911.184407";
|
||||
|
||||
|
||||
@@ -7,17 +7,17 @@ use std::ffi::{c_uchar, c_void};
|
||||
use std::panic::UnwindSafe;
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures_util::future::BoxFuture;
|
||||
use futures_util::FutureExt as _;
|
||||
use futures_util::future::BoxFuture;
|
||||
use libsignal_net::chat::server_requests::DisconnectCause;
|
||||
use libsignal_net::chat::{ChatConnection, ConnectError};
|
||||
use libsignal_net_chat::api::Unauth;
|
||||
use libsignal_net_chat::registration::ConnectUnauthChat;
|
||||
|
||||
use super::*;
|
||||
use crate::net::ConnectionManager;
|
||||
use crate::net::chat::{ChatListener, ServerMessageAck};
|
||||
use crate::net::registration::ConnectChatBridge;
|
||||
use crate::net::ConnectionManager;
|
||||
|
||||
type ReceivedIncomingMessage = extern "C" fn(
|
||||
ctx: *mut c_void,
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use std::ffi::{c_char, c_uchar, CStr};
|
||||
use std::ffi::{CStr, c_char, c_uchar};
|
||||
use std::fmt::Display;
|
||||
use std::num::{NonZeroU64, ParseIntError};
|
||||
use std::ops::Deref;
|
||||
|
||||
use itertools::Itertools as _;
|
||||
use libsignal_account_keys::{AccountEntropyPool, InvalidAccountEntropyPool};
|
||||
use libsignal_net_chat::api::registration::PushToken;
|
||||
use libsignal_net_chat::api::ChallengeOption;
|
||||
use libsignal_net_chat::api::registration::PushToken;
|
||||
use libsignal_protocol::*;
|
||||
use paste::paste;
|
||||
use uuid::Uuid;
|
||||
@@ -23,7 +23,7 @@ use crate::net::registration::{
|
||||
ConnectChatBridge, RegistrationCreateSessionRequest, RegistrationPushToken,
|
||||
};
|
||||
use crate::support::{
|
||||
extend_lifetime, AsType, FixedLengthBincodeSerializable, IllegalArgumentError, Serialized,
|
||||
AsType, FixedLengthBincodeSerializable, IllegalArgumentError, Serialized, extend_lifetime,
|
||||
};
|
||||
|
||||
/// Converts arguments from their FFI form to their Rust form.
|
||||
|
||||
@@ -12,15 +12,15 @@ use attest::hsm_enclave::Error as HsmEnclaveError;
|
||||
use device_transfer::Error as DeviceTransferError;
|
||||
use libsignal_account_keys::Error as PinError;
|
||||
use libsignal_net::infra::errors::LogSafeDisplay;
|
||||
use libsignal_net_chat::api::registration::{RegistrationLock, VerificationCodeNotDeliverable};
|
||||
use libsignal_net_chat::api::RateLimitChallenge;
|
||||
use libsignal_net_chat::api::registration::{RegistrationLock, VerificationCodeNotDeliverable};
|
||||
use libsignal_protocol::*;
|
||||
use signal_crypto::Error as SignalCryptoError;
|
||||
use usernames::{UsernameError, UsernameLinkError};
|
||||
use zkgroup::{ZkGroupDeserializationFailure, ZkGroupVerificationFailure};
|
||||
|
||||
use super::{FutureCancelled, NullPointerError, UnexpectedPanic};
|
||||
use crate::support::{describe_panic, IllegalArgumentError};
|
||||
use crate::support::{IllegalArgumentError, describe_panic};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[repr(C)]
|
||||
@@ -362,7 +362,7 @@ impl IntoFfiError for SignalProtocolError {
|
||||
fn into_ffi_error(self) -> impl Into<SignalFfiError> {
|
||||
let code = match &self {
|
||||
&Self::InvalidSenderKeySession { distribution_id } => {
|
||||
return SignalFfiError::from(InvalidSenderKeySession { distribution_id })
|
||||
return SignalFfiError::from(InvalidSenderKeySession { distribution_id });
|
||||
}
|
||||
Self::InvalidRegistrationId(_, _) => {
|
||||
// Re-match as owned.
|
||||
|
||||
@@ -166,7 +166,7 @@ impl AsyncRead for AsyncInput<'_> {
|
||||
AsyncInputState::Idle => self.stream.read(buf)?,
|
||||
AsyncInputState::Reading(read_future) => InputStreamRead::Pending(read_future),
|
||||
AsyncInputState::Skipping { .. } => {
|
||||
return Poll::Ready(Err(io::Error::other("cannot read while skipping")))
|
||||
return Poll::Ready(Err(io::Error::other("cannot read while skipping")));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -203,7 +203,7 @@ impl AsyncSkip for AsyncInput<'_> {
|
||||
AsyncInputState::Idle => self.stream.skip(amount),
|
||||
AsyncInputState::Skipping(skip_future) => skip_future,
|
||||
AsyncInputState::Reading { .. } => {
|
||||
return Poll::Ready(Err(io::Error::other("cannot skip while reading")))
|
||||
return Poll::Ready(Err(io::Error::other("cannot skip while reading")));
|
||||
}
|
||||
};
|
||||
match skip_future.poll_unpin(cx) {
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use jni::objects::{JClass, JMethodID, JObject, JStaticMethodID, JValueOwned};
|
||||
use jni::JNIEnv;
|
||||
use jni::objects::{JClass, JMethodID, JObject, JStaticMethodID, JValueOwned};
|
||||
|
||||
use crate::jni::{BridgeLayerError, HandleJniError as _, JniArgs};
|
||||
|
||||
@@ -144,9 +144,9 @@ fn check_exceptions_and_convert_result<'output, R: TryFrom<JValueOwned<'output>>
|
||||
}
|
||||
|
||||
mod check_annotations {
|
||||
use jni::JNIEnv;
|
||||
use jni::errors::Result;
|
||||
use jni::objects::{AutoLocal, JClass, JMethodID, JObject, JStaticMethodID};
|
||||
use jni::JNIEnv;
|
||||
|
||||
use super::jni_ext::JNIEnvExt as _;
|
||||
use crate::jni::{ClassName, JniArgs};
|
||||
@@ -253,10 +253,10 @@ mod check_annotations {
|
||||
}
|
||||
|
||||
mod jni_ext {
|
||||
use jni::JNIEnv;
|
||||
use jni::errors::Result;
|
||||
use jni::objects::{JClass, JMethodID, JObject, JStaticMethodID};
|
||||
use jni::sys::{JNI_FALSE, JNI_TRUE};
|
||||
use jni::JNIEnv;
|
||||
|
||||
// TODO once https://github.com/jni-rs/jni-rs/pull/579 is merged and in a
|
||||
// release, use the methods added there and remove this implementation.
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
use std::panic::UnwindSafe;
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures_util::future::BoxFuture;
|
||||
use futures_util::FutureExt;
|
||||
use libsignal_net::chat::server_requests::DisconnectCause;
|
||||
use futures_util::future::BoxFuture;
|
||||
use libsignal_net::chat::ChatConnection;
|
||||
use libsignal_net::chat::server_requests::DisconnectCause;
|
||||
use libsignal_net_chat::api::Unauth;
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// Copyright 2024 Signal Messenger, LLC.
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
use jni::objects::{GlobalRef, JClass, JMethodID, JObject, JValue};
|
||||
use jni::JNIEnv;
|
||||
use jni::objects::{GlobalRef, JClass, JMethodID, JObject, JValue};
|
||||
use libsignal_core::try_scoped;
|
||||
use once_cell::sync::OnceCell;
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
|
||||
use itertools::Itertools as _;
|
||||
use jni::objects::{AutoLocal, JByteBuffer, JMap, JObjectArray};
|
||||
use jni::sys::{jbyte, JNI_FALSE, JNI_TRUE};
|
||||
use jni::JNIEnv;
|
||||
use jni::objects::{AutoLocal, JByteBuffer, JMap, JObjectArray};
|
||||
use jni::sys::{JNI_FALSE, JNI_TRUE, jbyte};
|
||||
use libsignal_account_keys::{AccountEntropyPool, InvalidAccountEntropyPool};
|
||||
use libsignal_core::try_scoped;
|
||||
use libsignal_net::cdsi::LookupResponseEntry;
|
||||
@@ -23,7 +23,7 @@ use crate::message_backup::MessageBackupValidationOutcome;
|
||||
use crate::net::chat::ChatListener;
|
||||
use crate::net::registration::{ConnectChatBridge, RegistrationPushToken};
|
||||
use crate::protocol::KyberPublicKey;
|
||||
use crate::support::{extend_lifetime, Array, AsType, FixedLengthBincodeSerializable, Serialized};
|
||||
use crate::support::{Array, AsType, FixedLengthBincodeSerializable, Serialized, extend_lifetime};
|
||||
|
||||
/// Converts arguments from their JNI form to their Rust form.
|
||||
///
|
||||
@@ -1770,9 +1770,9 @@ fn make_object_array<'a, It>(
|
||||
) -> Result<JObjectArray<'a>, BridgeLayerError>
|
||||
where
|
||||
It: IntoIterator<
|
||||
Item: ResultTypeInfo<'a, ResultType: Into<JObject<'a>>>,
|
||||
IntoIter: ExactSizeIterator,
|
||||
>,
|
||||
Item: ResultTypeInfo<'a, ResultType: Into<JObject<'a>>>,
|
||||
IntoIter: ExactSizeIterator,
|
||||
>,
|
||||
{
|
||||
let it = it.into_iter();
|
||||
let len = it.len();
|
||||
|
||||
@@ -13,14 +13,14 @@ use attest::enclave::Error as EnclaveError;
|
||||
use attest::hsm_enclave::Error as HsmEnclaveError;
|
||||
use device_transfer::Error as DeviceTransferError;
|
||||
use http::uri::InvalidUri;
|
||||
pub use jni::JNIEnv;
|
||||
use jni::JavaVM;
|
||||
pub use jni::objects::{
|
||||
AutoElements, JByteArray, JClass, JLongArray, JObject, JObjectArray, JString, JValue,
|
||||
ReleaseMode,
|
||||
};
|
||||
use jni::objects::{GlobalRef, JThrowable, JValueOwned};
|
||||
pub use jni::sys::{jboolean, jint, jlong};
|
||||
pub use jni::JNIEnv;
|
||||
use jni::JavaVM;
|
||||
use libsignal_account_keys::Error as PinError;
|
||||
use libsignal_core::try_scoped;
|
||||
use libsignal_net::chat::{ConnectError as ChatConnectError, SendError as ChatSendError};
|
||||
@@ -576,12 +576,12 @@ mod registration {
|
||||
let message = match self {
|
||||
RequestError::Other(inner) => return inner.to_throwable(env),
|
||||
RequestError::Timeout => {
|
||||
return libsignal_net::chat::SendError::RequestTimedOut.to_throwable(env)
|
||||
return libsignal_net::chat::SendError::RequestTimedOut.to_throwable(env);
|
||||
}
|
||||
RequestError::RetryLater(retry_later) => return retry_later.to_throwable(env),
|
||||
RequestError::Unexpected { log_safe } => log_safe,
|
||||
RequestError::Challenge(rate_limit_challenge) => {
|
||||
return rate_limit_challenge.to_throwable(env)
|
||||
return rate_limit_challenge.to_throwable(env);
|
||||
}
|
||||
RequestError::ServerSideError => &self.to_string(),
|
||||
RequestError::Disconnected(d) => match *d {},
|
||||
|
||||
@@ -21,7 +21,7 @@ pub mod node;
|
||||
#[macro_use]
|
||||
pub mod support;
|
||||
|
||||
pub use support::{describe_panic, AsyncRuntime, ResultReporter};
|
||||
pub use support::{AsyncRuntime, ResultReporter, describe_panic};
|
||||
|
||||
pub mod cds2;
|
||||
pub mod crypto;
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
//
|
||||
|
||||
use libsignal_account_keys::{
|
||||
AccountEntropyPool, BackupForwardSecrecyToken, BackupId, BackupKey,
|
||||
BACKUP_FORWARD_SECRECY_TOKEN_LEN, BACKUP_KEY_LEN,
|
||||
AccountEntropyPool, BACKUP_FORWARD_SECRECY_TOKEN_LEN, BACKUP_KEY_LEN,
|
||||
BackupForwardSecrecyToken, BackupId, BackupKey,
|
||||
};
|
||||
use libsignal_message_backup::frame::ValidationError as FrameValidationError;
|
||||
use libsignal_message_backup::key::MessageBackupKey as MessageBackupKeyInner;
|
||||
use libsignal_message_backup::{backup, Error, FoundUnknownField};
|
||||
use libsignal_message_backup::{Error, FoundUnknownField, backup};
|
||||
use libsignal_protocol::Aci;
|
||||
|
||||
use crate::*;
|
||||
|
||||
@@ -11,8 +11,8 @@ use std::time::Duration;
|
||||
|
||||
use atomic_take::AtomicTake;
|
||||
use bytes::Bytes;
|
||||
use futures_util::future::BoxFuture;
|
||||
use futures_util::FutureExt as _;
|
||||
use futures_util::future::BoxFuture;
|
||||
use http::status::InvalidStatusCode;
|
||||
use http::uri::{InvalidUri, PathAndQuery};
|
||||
use http::{HeaderMap, HeaderName, HeaderValue};
|
||||
@@ -36,8 +36,8 @@ use libsignal_net_chat::api::Unauth;
|
||||
use libsignal_protocol::Timestamp;
|
||||
use static_assertions::assert_impl_all;
|
||||
|
||||
use crate::net::remote_config::RemoteConfigKey;
|
||||
use crate::net::ConnectionManager;
|
||||
use crate::net::remote_config::RemoteConfigKey;
|
||||
use crate::support::LimitedLifetimeRef;
|
||||
use crate::*;
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ use std::future::Future;
|
||||
use std::sync::atomic::AtomicU64;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use futures_util::future::BoxFuture;
|
||||
use futures_util::FutureExt as _;
|
||||
use futures_util::future::BoxFuture;
|
||||
|
||||
use crate::support::*;
|
||||
use crate::*;
|
||||
@@ -106,7 +106,9 @@ impl AsyncRuntimeBase for TokioAsyncContext {
|
||||
if maybe_cancel_tx.is_some() {
|
||||
log::trace!("cancelling task for {cancellation_token:?}");
|
||||
} else {
|
||||
log::trace!("ignoring cancellation for task {cancellation_token:?} (probably completed already)");
|
||||
log::trace!(
|
||||
"ignoring cancellation for task {cancellation_token:?} (probably completed already)"
|
||||
);
|
||||
}
|
||||
drop(maybe_cancel_tx);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ use std::panic::UnwindSafe;
|
||||
use std::sync::Arc;
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures_util::future::BoxFuture;
|
||||
use futures_util::FutureExt;
|
||||
use futures_util::future::BoxFuture;
|
||||
use libsignal_net::chat::server_requests::DisconnectCause;
|
||||
use libsignal_net::chat::{ChatConnection, ConnectError};
|
||||
use libsignal_net_chat::api::Unauth;
|
||||
@@ -21,8 +21,8 @@ use neon::prelude::{Context, Finalize, JsObject, Object};
|
||||
use neon::result::NeonResult;
|
||||
use signal_neon_futures::call_method;
|
||||
|
||||
use crate::net::chat::{ChatListener, ServerMessageAck};
|
||||
use crate::net::ConnectionManager;
|
||||
use crate::net::chat::{ChatListener, ServerMessageAck};
|
||||
use crate::node::{PersistentBorrowedJsBoxedBridgeHandle, ResultTypeInfo, SignalNodeError as _};
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
@@ -21,7 +21,7 @@ use crate::io::{InputStream, SyncInputStream};
|
||||
use crate::message_backup::MessageBackupValidationOutcome;
|
||||
use crate::net::chat::ChatListener;
|
||||
use crate::node::chat::NodeChatListener;
|
||||
use crate::support::{extend_lifetime, Array, AsType, FixedLengthBincodeSerializable, Serialized};
|
||||
use crate::support::{Array, AsType, FixedLengthBincodeSerializable, Serialized, extend_lifetime};
|
||||
|
||||
/// Converts arguments from their JavaScript form to their Rust form.
|
||||
///
|
||||
|
||||
@@ -487,7 +487,7 @@ impl SignalNodeError for libsignal_net::chat::ConnectError {
|
||||
Self::AppExpired => "AppExpired",
|
||||
Self::DeviceDeregistered => "DeviceDelinked",
|
||||
Self::RetryLater(retry_later) => {
|
||||
return retry_later.into_throwable(cx, module, operation_name)
|
||||
return retry_later.into_throwable(cx, module, operation_name);
|
||||
}
|
||||
Self::WebSocket(_)
|
||||
| Self::Timeout
|
||||
@@ -626,7 +626,7 @@ impl SignalNodeError for libsignal_net::cdsi::LookupError {
|
||||
) -> Handle<'a, JsError> {
|
||||
let name = match self {
|
||||
Self::RateLimited(retry_later) => {
|
||||
return retry_later.into_throwable(cx, module, operation_name)
|
||||
return retry_later.into_throwable(cx, module, operation_name);
|
||||
}
|
||||
Self::AttestationError(e) => return e.into_throwable(cx, module, operation_name),
|
||||
Self::InvalidArgument { server_reason: _ } => None,
|
||||
@@ -660,20 +660,20 @@ impl<E: SignalNodeError> SignalNodeError for libsignal_net_chat::api::RequestErr
|
||||
let io_error_message: Cow<'static, str> = match self {
|
||||
Self::Other(inner) => return inner.into_throwable(cx, module, operation_name),
|
||||
Self::Challenge(challenge) => {
|
||||
return challenge.into_throwable(cx, module, operation_name)
|
||||
return challenge.into_throwable(cx, module, operation_name);
|
||||
}
|
||||
Self::RetryLater(retry_later) => {
|
||||
return retry_later.into_throwable(cx, module, operation_name)
|
||||
return retry_later.into_throwable(cx, module, operation_name);
|
||||
}
|
||||
Self::Disconnected(disconnected) => {
|
||||
return disconnected.into_throwable(cx, module, operation_name)
|
||||
return disconnected.into_throwable(cx, module, operation_name);
|
||||
}
|
||||
Self::Timeout => {
|
||||
return libsignal_net::chat::SendError::RequestTimedOut.into_throwable(
|
||||
cx,
|
||||
module,
|
||||
operation_name,
|
||||
)
|
||||
);
|
||||
}
|
||||
Self::Unexpected { log_safe } => log_safe.into(),
|
||||
Self::ServerSideError => "server-side error".into(),
|
||||
@@ -724,7 +724,7 @@ mod registration {
|
||||
cx,
|
||||
module,
|
||||
operation_name,
|
||||
)
|
||||
);
|
||||
}
|
||||
e @ (RequestError::Unexpected { log_safe: _ } | RequestError::ServerSideError) => {
|
||||
return new_js_error(
|
||||
@@ -734,13 +734,13 @@ mod registration {
|
||||
&e.to_string(),
|
||||
operation_name,
|
||||
no_extra_properties,
|
||||
)
|
||||
);
|
||||
}
|
||||
RequestError::RetryLater(retry_later) => {
|
||||
return retry_later.into_throwable(cx, module, operation_name)
|
||||
return retry_later.into_throwable(cx, module, operation_name);
|
||||
}
|
||||
RequestError::Challenge(challenge) => {
|
||||
return challenge.into_throwable(cx, module, operation_name)
|
||||
return challenge.into_throwable(cx, module, operation_name);
|
||||
}
|
||||
RequestError::Disconnected(d) => match d {},
|
||||
};
|
||||
@@ -965,7 +965,7 @@ impl SignalNodeError for crate::keytrans::BridgeError {
|
||||
let message = self.to_string();
|
||||
let name = match self.into() {
|
||||
RequestError::Disconnected(inner) => {
|
||||
return inner.into_throwable(cx, module, operation_name)
|
||||
return inner.into_throwable(cx, module, operation_name);
|
||||
}
|
||||
RequestError::Timeout => IO_ERROR,
|
||||
RequestError::Other(libsignal_net_chat::api::keytrans::Error::VerificationFailed(
|
||||
|
||||
@@ -12,7 +12,7 @@ use signal_neon_futures::ChannelEx;
|
||||
|
||||
use super::*;
|
||||
use crate::support::{
|
||||
describe_panic, AsyncRuntime, AsyncRuntimeBase, CancellationId, ResultReporter,
|
||||
AsyncRuntime, AsyncRuntimeBase, CancellationId, ResultReporter, describe_panic,
|
||||
};
|
||||
|
||||
#[derive(Debug, thiserror::Error, displaydoc::Display)]
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
use ::zkgroup;
|
||||
use partial_default::PartialDefault;
|
||||
use serde::Deserialize;
|
||||
pub use zkgroup::Timestamp;
|
||||
use zkgroup::groups::*;
|
||||
use zkgroup::profiles::*;
|
||||
use zkgroup::receipts::*;
|
||||
pub use zkgroup::Timestamp;
|
||||
use zkgroup::*;
|
||||
|
||||
use crate::support::*;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use base64::prelude::BASE64_STANDARD;
|
||||
use base64::Engine as _;
|
||||
use base64::prelude::BASE64_STANDARD;
|
||||
use libsignal_core::{Aci, DeviceId, ServiceId};
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
use libsignal_core::curve::KeyPair;
|
||||
use rand::{rng, Rng};
|
||||
use rand::{Rng, rng};
|
||||
|
||||
pub fn generation(c: &mut Criterion) {
|
||||
let rng = &mut rng();
|
||||
|
||||
@@ -44,6 +44,8 @@ fn main() {
|
||||
if sign_bit == 0 {
|
||||
println!("signatures generated by this key will be directly validatable by libsignal");
|
||||
} else {
|
||||
println!("set the sign bit (0x80 in the final byte) of signatures generated by this key for validation by libsignal");
|
||||
println!(
|
||||
"set the sign bit (0x80 in the final byte) of signatures generated by this key for validation by libsignal"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,10 +584,10 @@ mod service_id_tests {
|
||||
ServiceId::parse_from_service_id_string("PNI:8c78cd2a16ff427d83dc1a5e36ce713d")
|
||||
.is_none()
|
||||
);
|
||||
assert!(ServiceId::parse_from_service_id_string(
|
||||
"PNI:{8c78cd2a-16ff-427d-83dc-1a5e36ce713d}"
|
||||
)
|
||||
.is_none());
|
||||
assert!(
|
||||
ServiceId::parse_from_service_id_string("PNI:{8c78cd2a-16ff-427d-83dc-1a5e36ce713d}")
|
||||
.is_none()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -356,8 +356,8 @@ impl TryFrom<PrivateKey> for KeyPair {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use assert_matches::assert_matches;
|
||||
use rand::rngs::OsRng;
|
||||
use rand::TryRngCore as _;
|
||||
use rand::rngs::OsRng;
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -377,8 +377,12 @@ mod tests {
|
||||
let public_key = key_pair.private_key.public_key()?;
|
||||
assert!(public_key.verify_signature(&message, &signature));
|
||||
|
||||
assert!(public_key
|
||||
.verify_signature_for_multipart_message(&[&message[..7], &message[7..]], &signature));
|
||||
assert!(
|
||||
public_key.verify_signature_for_multipart_message(
|
||||
&[&message[..7], &message[7..]],
|
||||
&signature
|
||||
)
|
||||
);
|
||||
|
||||
let signature = key_pair
|
||||
.private_key
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
|
||||
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
|
||||
|
||||
pub fn aes_gcm(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("AES-256-GCM");
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
|
||||
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
|
||||
use libsignal_core::curve::PrivateKey;
|
||||
use signal_crypto::{SimpleHpkeReceiver as _, SimpleHpkeSender as _};
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
use std::result::Result;
|
||||
|
||||
use aes::Aes256;
|
||||
use aes::cipher::block_padding::Pkcs7;
|
||||
use aes::cipher::{BlockDecryptMut, BlockEncryptMut, KeyIvInit};
|
||||
use aes::Aes256;
|
||||
|
||||
#[derive(Debug, displaydoc::Display, thiserror::Error)]
|
||||
pub enum EncryptionError {
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use aes::Aes256;
|
||||
use aes::cipher::typenum::Unsigned;
|
||||
use aes::cipher::{InnerIvInit, KeyInit, StreamCipher, StreamCipherSeek};
|
||||
use aes::Aes256;
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use aes::Aes256;
|
||||
use aes::cipher::generic_array::GenericArray;
|
||||
use aes::cipher::{BlockEncrypt, KeyInit};
|
||||
use aes::Aes256;
|
||||
use ghash::universal_hash::UniversalHash;
|
||||
use ghash::GHash;
|
||||
use ghash::universal_hash::UniversalHash;
|
||||
use subtle::ConstantTimeEq;
|
||||
|
||||
use crate::{Aes256Ctr32, Error, Result};
|
||||
|
||||
@@ -13,7 +13,7 @@ mod aes_cbc;
|
||||
mod aes_ctr;
|
||||
mod aes_gcm;
|
||||
|
||||
pub use aes_cbc::{aes_256_cbc_decrypt, aes_256_cbc_encrypt, DecryptionError, EncryptionError};
|
||||
pub use aes_cbc::{DecryptionError, EncryptionError, aes_256_cbc_decrypt, aes_256_cbc_encrypt};
|
||||
pub use aes_ctr::Aes256Ctr32;
|
||||
pub use aes_gcm::{Aes256GcmDecryption, Aes256GcmEncryption};
|
||||
pub use error::{Error, Result};
|
||||
|
||||
@@ -11,8 +11,12 @@ fn aes_ctr_smoke_test() -> Result<(), signal_crypto::Error> {
|
||||
let key = hex!("603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4");
|
||||
let nonce = hex!("F0F1F2F3F4F5F6F7F8F9FAFB");
|
||||
let init_ctr = 0xFCFDFEFF;
|
||||
let input = hex!("6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710");
|
||||
let output = hex!("601EC313775789A5B7A7F504BBF3D228F443E3CA4D62B59ACA84E990CACAF5C52B0930DAA23DE94CE87017BA2D84988DDFC9C58DB67AADA613C2DD08457941A6");
|
||||
let input = hex!(
|
||||
"6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710"
|
||||
);
|
||||
let output = hex!(
|
||||
"601EC313775789A5B7A7F504BBF3D228F443E3CA4D62B59ACA84E990CACAF5C52B0930DAA23DE94CE87017BA2D84988DDFC9C58DB67AADA613C2DD08457941A6"
|
||||
);
|
||||
|
||||
let mut aes_ctr = signal_crypto::Aes256Ctr32::from_key(&key, &nonce, init_ctr)?;
|
||||
|
||||
@@ -29,7 +33,9 @@ fn aes_ctr_long_test() -> Result<(), signal_crypto::Error> {
|
||||
let key = hex!("603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4");
|
||||
let nonce = hex!("FFFFFFFFFFFFFFFFFFFFFFFF");
|
||||
let init_ctr = 0x00000000;
|
||||
let output = hex!("FD4C14729F5004BA49D832AD7BE87C18F4FAFB58962B9A43C3BE41713DED93DBF854AC4CA26285B7F76E04B8F8D4E7D9F7548F9B465C8F713C106E9F63F54305331A4983A2F4B718DE29FA794DA12EEE808642FAEFF8271A0EA28E3CC80EEB65A8EB61F69D8BA97F6BF9054453F55EFB8F9422081F1620FE44ACF99E81122F73D3F921D5E3391654E9947904984375B725FDFBA895C5CDE3D225D7BE3A213C3965178A7DC1E3B552EC7B2FFD9C77EBCC243C4500DFDFBE3B7554AA427C01305BEC48D71AF27C5911D1E649C620D22CF5F3A5AEB9468651DA796F369522FAF91EFABF0FEBD33FCA41C9534606A4EA0199B904B243BA9CB8F37A792DF02EFAB8F0E2E0CF1D579DABA042CFE4C9430AD4EDA786052FCF15E7ACFA2736AAB4590F73675FA1805FE23892C63E0CD01D006935A6E3F8E105A754803D00D9857E49636AB034164156856D58A244EAD475300D93B31E44B5BE3BBF6994EDB895804B4F1BAD43ECFE08B4E130148B669FE620E4F73034FC3E748237870BEC3B1F517684654D1D6BC074DDF7B759A2405F78ED84D1006D25AF9BBC12D6C632F5D543DA0CBE9EA866B2C92126009C27AD59394B76337DE246B50895317E2E345DF3629A5F6227F64522866E7A39121CCC552E3DABC989DCE066DEA355F788C5D92ADA099917A297CFEFA867CE37656FAC6A50798C10B394D5BA54F85CF0F7EF1EEDDFCA1E53E93F1349888CC745190C196F84ECF0721287CC592D406F0A6CC5A55294BF7AA3B35F6CEFC61CAB794B12444312B5E50EC0712E221CC95E9E26E9C3D000881E792AFCB58641B1A94613D64EC72F3DB9AB65BA07A4F05B7E9EE7B335D86A06FCBDB8CBD695AEEF53964A965FFE4C6D7B4E580AB139F8422A702E09EACBEA5D512C31A955B3D60310BE2BBDD73484BAE6612791A19DA3C7B0FD1487E72131A8F9CB801790CE8A6E1E378662CEDCD5EE82BD390576ACFE5334ECD9D907273AEFE67058916388210638E5E60F20EE92389B3533FD6AFFD33095B23D169F0913657F033B8D5C4EA517F167C1D53E031787BBE6D5B577245FFF8151CD8FDCC5D6C32DF70FB8043D42F896CD513B4C85CFF292676CF13B6A1931E87727A561711A3105D9F3519B90C9429B5CD3EDAAE3EE334826A3FD74D6175B5589DB392F956A67C5E67BE59656F1CB37E52C636B2692A60C2044327472FA9AF651AFBCF55D8398A31D343074931A72D54833B29EF21FCB6EF419BB56313513E46C65D833677DBB0F2813E9CE5EF70676102CA0D3C14BBDD659A7498FA08CD359D428A803AEFCC660E9FC704E9BACC5F1D27F2528D46B3FCAA2D47DFA28BF4C");
|
||||
let output = hex!(
|
||||
"FD4C14729F5004BA49D832AD7BE87C18F4FAFB58962B9A43C3BE41713DED93DBF854AC4CA26285B7F76E04B8F8D4E7D9F7548F9B465C8F713C106E9F63F54305331A4983A2F4B718DE29FA794DA12EEE808642FAEFF8271A0EA28E3CC80EEB65A8EB61F69D8BA97F6BF9054453F55EFB8F9422081F1620FE44ACF99E81122F73D3F921D5E3391654E9947904984375B725FDFBA895C5CDE3D225D7BE3A213C3965178A7DC1E3B552EC7B2FFD9C77EBCC243C4500DFDFBE3B7554AA427C01305BEC48D71AF27C5911D1E649C620D22CF5F3A5AEB9468651DA796F369522FAF91EFABF0FEBD33FCA41C9534606A4EA0199B904B243BA9CB8F37A792DF02EFAB8F0E2E0CF1D579DABA042CFE4C9430AD4EDA786052FCF15E7ACFA2736AAB4590F73675FA1805FE23892C63E0CD01D006935A6E3F8E105A754803D00D9857E49636AB034164156856D58A244EAD475300D93B31E44B5BE3BBF6994EDB895804B4F1BAD43ECFE08B4E130148B669FE620E4F73034FC3E748237870BEC3B1F517684654D1D6BC074DDF7B759A2405F78ED84D1006D25AF9BBC12D6C632F5D543DA0CBE9EA866B2C92126009C27AD59394B76337DE246B50895317E2E345DF3629A5F6227F64522866E7A39121CCC552E3DABC989DCE066DEA355F788C5D92ADA099917A297CFEFA867CE37656FAC6A50798C10B394D5BA54F85CF0F7EF1EEDDFCA1E53E93F1349888CC745190C196F84ECF0721287CC592D406F0A6CC5A55294BF7AA3B35F6CEFC61CAB794B12444312B5E50EC0712E221CC95E9E26E9C3D000881E792AFCB58641B1A94613D64EC72F3DB9AB65BA07A4F05B7E9EE7B335D86A06FCBDB8CBD695AEEF53964A965FFE4C6D7B4E580AB139F8422A702E09EACBEA5D512C31A955B3D60310BE2BBDD73484BAE6612791A19DA3C7B0FD1487E72131A8F9CB801790CE8A6E1E378662CEDCD5EE82BD390576ACFE5334ECD9D907273AEFE67058916388210638E5E60F20EE92389B3533FD6AFFD33095B23D169F0913657F033B8D5C4EA517F167C1D53E031787BBE6D5B577245FFF8151CD8FDCC5D6C32DF70FB8043D42F896CD513B4C85CFF292676CF13B6A1931E87727A561711A3105D9F3519B90C9429B5CD3EDAAE3EE334826A3FD74D6175B5589DB392F956A67C5E67BE59656F1CB37E52C636B2692A60C2044327472FA9AF651AFBCF55D8398A31D343074931A72D54833B29EF21FCB6EF419BB56313513E46C65D833677DBB0F2813E9CE5EF70676102CA0D3C14BBDD659A7498FA08CD359D428A803AEFCC660E9FC704E9BACC5F1D27F2528D46B3FCAA2D47DFA28BF4C"
|
||||
);
|
||||
|
||||
let mut aes_ctr = signal_crypto::Aes256Ctr32::from_key(&key, &nonce, init_ctr)?;
|
||||
|
||||
|
||||
@@ -159,9 +159,13 @@ fn aes_gcm_wycheproof_kats() -> Result<(), signal_crypto::Error> {
|
||||
fn aes_gcm_smoke_test() -> Result<(), signal_crypto::Error> {
|
||||
let key = hex!("feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308");
|
||||
let nonce = hex!("cafebabefacedbaddecaf888");
|
||||
let input = hex!("d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39");
|
||||
let input = hex!(
|
||||
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"
|
||||
);
|
||||
let ad = hex!("feedfacedeadbeeffeedfacedeadbeefabaddad2");
|
||||
let output = hex!("522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f66276fc6ece0f4e1768cddf8853bb2d551b");
|
||||
let output = hex!(
|
||||
"522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f66276fc6ece0f4e1768cddf8853bb2d551b"
|
||||
);
|
||||
|
||||
let mut aes_gcm = signal_crypto::Aes256GcmEncryption::new(&key, &nonce, &ad)?;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ use boring::error::ErrorStack;
|
||||
use boring::hash::MessageDigest;
|
||||
use boring::pkey::{PKey, Private};
|
||||
use boring::rsa::Rsa;
|
||||
use boring::x509::{X509Builder, X509Name, X509NameBuilder, X509};
|
||||
use boring::x509::{X509, X509Builder, X509Name, X509NameBuilder};
|
||||
|
||||
/// Error types for device transfer.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use const_str::hex;
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
use libsignal_keytrans::{
|
||||
ChatSearchResponse, DeploymentMode, FullSearchResponse, KeyTransparency, PublicConfig,
|
||||
SearchContext, SlimSearchRequest, VerifyingKey, VrfPublicKey,
|
||||
|
||||
@@ -62,11 +62,7 @@ mod math {
|
||||
// Returns the other child of the node's parent.
|
||||
fn sibling(x: u64, n: u64) -> u64 {
|
||||
let p = parent(x, n);
|
||||
if x < p {
|
||||
right(p, n)
|
||||
} else {
|
||||
left(p)
|
||||
}
|
||||
if x < p { right(p, n) } else { left(p) }
|
||||
}
|
||||
|
||||
// Returns true if node x represents a full subtree.
|
||||
|
||||
@@ -13,15 +13,15 @@ use crate::commitments::verify as verify_commitment;
|
||||
use crate::guide::{InvalidState, ProofGuide};
|
||||
use crate::implicit::{full_monitoring_path, monitoring_path};
|
||||
use crate::log::{evaluate_batch_proof, verify_consistency_proof};
|
||||
use crate::prefix::{evaluate as evaluate_prefix, MalformedProof};
|
||||
use crate::prefix::{MalformedProof, evaluate as evaluate_prefix};
|
||||
use crate::proto::{
|
||||
CondensedTreeSearchResponse, FullTreeHead, MonitorKey, MonitorProof, MonitorRequest,
|
||||
MonitorResponse, ProofStep, TreeHead,
|
||||
};
|
||||
use crate::{
|
||||
guide, log, vrf, DeploymentMode, FullSearchResponse, LastTreeHead, MonitorContext,
|
||||
MonitorStateUpdate, MonitoringData, PublicConfig, SearchContext, SearchStateUpdate,
|
||||
SlimSearchRequest, TreeRoot, VerifiableTreeHead,
|
||||
DeploymentMode, FullSearchResponse, LastTreeHead, MonitorContext, MonitorStateUpdate,
|
||||
MonitoringData, PublicConfig, SearchContext, SearchStateUpdate, SlimSearchRequest, TreeRoot,
|
||||
VerifiableTreeHead, guide, log, vrf,
|
||||
};
|
||||
|
||||
/// The range of allowed timestamp values relative to "now".
|
||||
@@ -402,7 +402,7 @@ pub fn verify_distinguished(
|
||||
_ => {
|
||||
return Err(Error::BadData(
|
||||
"expected tree head not found in storage".to_string(),
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -633,7 +633,7 @@ pub fn verify_monitor<'a>(
|
||||
_ => {
|
||||
return Err(Error::VerificationFailed(
|
||||
"monitoring response is malformed: inclusion proof should be root".to_string(),
|
||||
))
|
||||
));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -963,8 +963,8 @@ mod test {
|
||||
use test_case::test_case;
|
||||
|
||||
use super::*;
|
||||
use crate::proto::PrefixProof;
|
||||
use crate::ChatSearchResponse;
|
||||
use crate::proto::PrefixProof;
|
||||
|
||||
const MAX_AHEAD: Duration = Duration::from_secs(42);
|
||||
const MAX_BEHIND: Duration = Duration::from_secs(42);
|
||||
|
||||
@@ -161,21 +161,27 @@ mod tests {
|
||||
pk: hex!("d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a"),
|
||||
alpha: &hex!(""),
|
||||
h: hex!("91bbed02a99461df1ad4c6564a5f5d829d0b90cfc7903e7a5797bd658abf3318"),
|
||||
pi: hex!("8657106690b5526245a92b003bb079ccd1a92130477671f6fc01ad16f26f723f26f8a57ccaed74ee1b190bed1f479d9727d2d0f9b005a6e456a35d4fb0daab1268a1b0db10836d9826a528ca76567805"),
|
||||
pi: hex!(
|
||||
"8657106690b5526245a92b003bb079ccd1a92130477671f6fc01ad16f26f723f26f8a57ccaed74ee1b190bed1f479d9727d2d0f9b005a6e456a35d4fb0daab1268a1b0db10836d9826a528ca76567805"
|
||||
),
|
||||
beta: hex!("90cf1df3b703cce59e2a35b925d411164068269d7b2d29f3301c03dd757876ff"),
|
||||
},
|
||||
TestVector {
|
||||
pk: hex!("3d4017c3e843895a92b70aa74d1b7ebc9c982ccf2ec4968cc0cd55f12af4660c"),
|
||||
alpha: &hex!("72"),
|
||||
h: hex!("5b659fc3d4e9263fd9a4ed1d022d75eaacc20df5e09f9ea937502396598dc551"),
|
||||
pi: hex!("f3141cd382dc42909d19ec5110469e4feae18300e94f304590abdced48aed5933bf0864a62558b3ed7f2fea45c92a465301b3bbf5e3e54ddf2d935be3b67926da3ef39226bbc355bdc9850112c8f4b02"),
|
||||
pi: hex!(
|
||||
"f3141cd382dc42909d19ec5110469e4feae18300e94f304590abdced48aed5933bf0864a62558b3ed7f2fea45c92a465301b3bbf5e3e54ddf2d935be3b67926da3ef39226bbc355bdc9850112c8f4b02"
|
||||
),
|
||||
beta: hex!("eb4440665d3891d668e7e0fcaf587f1b4bd7fbfe99d0eb2211ccec90496310eb"),
|
||||
},
|
||||
TestVector {
|
||||
pk: hex!("fc51cd8e6218a1a38da47ed00230f0580816ed13ba3303ac5deb911548908025"),
|
||||
alpha: &hex!("af82"),
|
||||
h: hex!("bf4339376f5542811de615e3313d2b36f6f53c0acfebb482159711201192576a"),
|
||||
pi: hex!("9bc0f79119cc5604bf02d23b4caede71393cedfbb191434dd016d30177ccbf8096bb474e53895c362d8628ee9f9ea3c0e52c7a5c691b6c18c9979866568add7a2d41b00b05081ed0f58ee5e31b3a970e"),
|
||||
pi: hex!(
|
||||
"9bc0f79119cc5604bf02d23b4caede71393cedfbb191434dd016d30177ccbf8096bb474e53895c362d8628ee9f9ea3c0e52c7a5c691b6c18c9979866568add7a2d41b00b05081ed0f58ee5e31b3a970e"
|
||||
),
|
||||
beta: hex!("645427e5d00c62a23fb703732fa5d892940935942101e456ecca7bb217c61c45"),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
use futures_util::AsyncRead;
|
||||
use mediasan_common::AsyncSkip;
|
||||
pub use mp4san::parse::ParseError;
|
||||
use mp4san::{sanitize_async_with_config, Config};
|
||||
use mp4san::{Config, sanitize_async_with_config};
|
||||
pub use mp4san::{InputSpan, SanitizedMetadata};
|
||||
|
||||
/// Error type returned by [`sanitize`].
|
||||
|
||||
@@ -9,19 +9,19 @@
|
||||
//! (but not all) of them can be run on an externally-provided backup file as well. See the
|
||||
//! `LIBSIGNAL_TESTING`-prefixed environment variables below.
|
||||
|
||||
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use futures::io::{BufReader, Cursor};
|
||||
use criterion::{BenchmarkId, Criterion, black_box, criterion_group, criterion_main};
|
||||
use futures::AsyncRead;
|
||||
use futures::io::{BufReader, Cursor};
|
||||
use libsignal_account_keys::{BackupForwardSecrecyToken, BackupKey};
|
||||
use libsignal_core::Aci;
|
||||
use libsignal_message_backup::BackupReader;
|
||||
use libsignal_message_backup::backup::{CompletedBackup, PartialBackup, ValidateOnly};
|
||||
use libsignal_message_backup::frame::{
|
||||
Aes256CbcReader, CursorFactory, FramesReader, MacReader, ReaderFactory, AES_IV_SIZE,
|
||||
AES_KEY_SIZE,
|
||||
AES_IV_SIZE, AES_KEY_SIZE, Aes256CbcReader, CursorFactory, FramesReader, MacReader,
|
||||
ReaderFactory,
|
||||
};
|
||||
use libsignal_message_backup::key::MessageBackupKey;
|
||||
use libsignal_message_backup::parse::VarintDelimitedReader;
|
||||
use libsignal_message_backup::BackupReader;
|
||||
use mediasan_common::AsyncSkip;
|
||||
use protobuf::Message as _;
|
||||
use sha2::Digest as _;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use std::io::{stdout, Write as _};
|
||||
use std::io::{Write as _, stdout};
|
||||
|
||||
use aes::cipher::crypto_common::rand_core::{OsRng, RngCore};
|
||||
use clap::{ArgAction, Parser};
|
||||
@@ -14,8 +14,8 @@ use libsignal_message_backup::export::{
|
||||
aes_cbc_encrypt, gzip_compress, hmac_checksum, pad_gzipped_bucketed,
|
||||
};
|
||||
use libsignal_message_backup::key::MessageBackupKey;
|
||||
use libsignal_svrb::proto::backup_metadata::{metadata_pb, MetadataPb};
|
||||
use libsignal_svrb::proto::Message as _;
|
||||
use libsignal_svrb::proto::backup_metadata::{MetadataPb, metadata_pb};
|
||||
|
||||
#[path = "../src/bin/support/mod.rs"]
|
||||
mod support;
|
||||
|
||||
@@ -8,12 +8,12 @@ use std::process::ExitCode;
|
||||
use clap::Parser;
|
||||
use clap_stdin::FileOrStdin;
|
||||
use futures::future::Either;
|
||||
use libsignal_message_backup::FoundUnknownField;
|
||||
use libsignal_message_backup::backup::{CompletedBackup, PartialBackup, Purpose, ValidateOnly};
|
||||
use libsignal_message_backup::frame::{FramesReader, ReaderFactory as _};
|
||||
use libsignal_message_backup::parse::VarintDelimitedReader;
|
||||
use libsignal_message_backup::scramble::Scrambler;
|
||||
use libsignal_message_backup::unknown::VisitUnknownFieldsExt as _;
|
||||
use libsignal_message_backup::FoundUnknownField;
|
||||
|
||||
#[path = "../src/bin/support/mod.rs"]
|
||||
mod support;
|
||||
@@ -123,7 +123,9 @@ fn main() -> ExitCode {
|
||||
match (original_result, new_result) {
|
||||
(Ok(original_unknown_fields), Ok(())) => {
|
||||
if original_unknown_fields.len() != new_unknown_fields.len() {
|
||||
log::warn!("scrambling may have removed some unknown fields in frame {frame_index}; here are the post-scrambling fields:");
|
||||
log::warn!(
|
||||
"scrambling may have removed some unknown fields in frame {frame_index}; here are the post-scrambling fields:"
|
||||
);
|
||||
for (path, value) in new_unknown_fields {
|
||||
log::info!(
|
||||
"{}",
|
||||
@@ -137,16 +139,22 @@ fn main() -> ExitCode {
|
||||
}
|
||||
}
|
||||
(Ok(_), Err(e)) => {
|
||||
log::error!("scrambling of frame {frame_index} introduced a new error: {e} (continuing anyway!)");
|
||||
log::error!(
|
||||
"scrambling of frame {frame_index} introduced a new error: {e} (continuing anyway!)"
|
||||
);
|
||||
exit_code = ExitCode::FAILURE;
|
||||
}
|
||||
(Err(old_error), Err(new_error)) => {
|
||||
if old_error.to_string() != new_error.to_string() {
|
||||
log::warn!("validation error for frame {frame_index} changed post-scrambling: {new_error}");
|
||||
log::warn!(
|
||||
"validation error for frame {frame_index} changed post-scrambling: {new_error}"
|
||||
);
|
||||
}
|
||||
}
|
||||
(Err(_), Ok(_)) => {
|
||||
log::error!("scrambling of frame {frame_index} removed an error; this may no longer be a suitable test case!");
|
||||
log::error!(
|
||||
"scrambling of frame {frame_index} removed an error; this may no longer be a suitable test case!"
|
||||
);
|
||||
exit_code = ExitCode::FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ use std::borrow::Cow;
|
||||
use heck::ToSnakeCase;
|
||||
use proc_macro::TokenStream;
|
||||
use proc_macro2::{Delimiter, Group, TokenStream as TokenStream2};
|
||||
use quote::{quote, ToTokens};
|
||||
use quote::{ToTokens, quote};
|
||||
use syn::spanned::Spanned;
|
||||
use syn::{
|
||||
self, parse2, parse_macro_input, Attribute, DeriveInput, Field, Ident, LitStr, MetaList,
|
||||
TypePath,
|
||||
self, Attribute, DeriveInput, Field, Ident, LitStr, MetaList, TypePath, parse_macro_input,
|
||||
parse2,
|
||||
};
|
||||
|
||||
macro_rules! tokens_alias {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::{hash_map, HashMap};
|
||||
use std::collections::{HashMap, hash_map};
|
||||
use std::fmt::Debug;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -78,7 +78,7 @@ pub trait ReferencedTypes {
|
||||
) -> &'a Self::RecipientReference;
|
||||
|
||||
fn is_same_reference(left: &Self::RecipientReference, right: &Self::RecipientReference)
|
||||
-> bool;
|
||||
-> bool;
|
||||
}
|
||||
|
||||
pub struct PartialBackup<M: Method + ReferencedTypes> {
|
||||
|
||||
@@ -7,17 +7,17 @@ use std::fmt::Debug;
|
||||
use std::num::NonZeroU32;
|
||||
|
||||
use derive_where::derive_where;
|
||||
use serde_with::{serde_as, DisplayFromStr};
|
||||
use serde_with::{DisplayFromStr, serde_as};
|
||||
use usernames::constants::USERNAME_LINK_ENTROPY_SIZE;
|
||||
use usernames::{Username, UsernameError};
|
||||
use uuid::Uuid;
|
||||
use zkgroup::api::backups::BackupLevel;
|
||||
use zkgroup::ProfileKeyBytes;
|
||||
use zkgroup::api::backups::BackupLevel;
|
||||
|
||||
use crate::backup::chat::chat_style::{ChatStyle, ChatStyleError, CustomColorMap};
|
||||
use crate::backup::method::Method;
|
||||
use crate::backup::time::{Duration, ReportUnusualTimestamp};
|
||||
use crate::backup::{serialize, ReferencedTypes, TryIntoWith};
|
||||
use crate::backup::{ReferencedTypes, TryIntoWith, serialize};
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
#[derive_where(Debug)]
|
||||
@@ -382,7 +382,7 @@ impl<M: Method + ReferencedTypes, C: ReportUnusualTimestamp> TryIntoWith<Account
|
||||
use proto::account_data::PhoneNumberSharingMode;
|
||||
let phone_number_sharing = match phoneNumberSharingMode.enum_value_or_default() {
|
||||
PhoneNumberSharingMode::UNKNOWN => {
|
||||
return Err(AccountDataError::UnknownPhoneNumberSharingMode)
|
||||
return Err(AccountDataError::UnknownPhoneNumberSharingMode);
|
||||
}
|
||||
PhoneNumberSharingMode::EVERYBODY => PhoneSharing::WithEverybody,
|
||||
PhoneNumberSharingMode::NOBODY => PhoneSharing::WithNobody,
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::backup::frame::RecipientId;
|
||||
use crate::backup::method::LookupPair;
|
||||
use crate::backup::recipient::{DestinationKind, MinimalRecipientData};
|
||||
use crate::backup::time::{ReportUnusualTimestamp, Timestamp, TimestampError};
|
||||
use crate::backup::{serialize, TryIntoWith};
|
||||
use crate::backup::{TryIntoWith, serialize};
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
/// Validated version of [`proto::AdHocCall`].
|
||||
@@ -325,10 +325,8 @@ impl<C: LookupPair<RecipientId, MinimalRecipientData, R> + ReportUnusualTimestam
|
||||
}
|
||||
}
|
||||
|
||||
impl<
|
||||
C: LookupPair<RecipientId, MinimalRecipientData, R> + ReportUnusualTimestamp,
|
||||
R: Clone + Debug,
|
||||
> TryIntoWith<AdHocCall<R>, C> for proto::AdHocCall
|
||||
impl<C: LookupPair<RecipientId, MinimalRecipientData, R> + ReportUnusualTimestamp, R: Clone + Debug>
|
||||
TryIntoWith<AdHocCall<R>, C> for proto::AdHocCall
|
||||
{
|
||||
type Error = CallError;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::backup::sticker::MessageStickerError;
|
||||
use crate::backup::time::{
|
||||
Duration, ReportUnusualTimestamp, Timestamp, TimestampError, TimestampOrForever,
|
||||
};
|
||||
use crate::backup::{likely_empty, BackupMeta, CallError, ReferencedTypes, TryIntoWith};
|
||||
use crate::backup::{BackupMeta, CallError, ReferencedTypes, TryIntoWith, likely_empty};
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
mod contact_message;
|
||||
@@ -457,12 +457,12 @@ pub enum OutgoingSendError {
|
||||
}
|
||||
|
||||
impl<
|
||||
M: Method + ReferencedTypes,
|
||||
C: LookupPair<RecipientId, MinimalRecipientData, M::RecipientReference>
|
||||
+ Lookup<PinOrder, M::RecipientReference>
|
||||
+ Lookup<CustomColorId, M::CustomColorReference>
|
||||
+ ReportUnusualTimestamp,
|
||||
> TryIntoWith<ChatData<M>, C> for proto::Chat
|
||||
M: Method + ReferencedTypes,
|
||||
C: LookupPair<RecipientId, MinimalRecipientData, M::RecipientReference>
|
||||
+ Lookup<PinOrder, M::RecipientReference>
|
||||
+ Lookup<CustomColorId, M::CustomColorReference>
|
||||
+ ReportUnusualTimestamp,
|
||||
> TryIntoWith<ChatData<M>, C> for proto::Chat
|
||||
{
|
||||
type Error = ChatError;
|
||||
|
||||
@@ -528,11 +528,11 @@ impl<
|
||||
}
|
||||
|
||||
impl<
|
||||
C: LookupPair<RecipientId, MinimalRecipientData, M::RecipientReference>
|
||||
+ AsRef<BackupMeta>
|
||||
+ ReportUnusualTimestamp,
|
||||
M: Method + ReferencedTypes,
|
||||
> TryIntoWith<ChatItemData<M>, C> for proto::ChatItem
|
||||
C: LookupPair<RecipientId, MinimalRecipientData, M::RecipientReference>
|
||||
+ AsRef<BackupMeta>
|
||||
+ ReportUnusualTimestamp,
|
||||
M: Method + ReferencedTypes,
|
||||
> TryIntoWith<ChatItemData<M>, C> for proto::ChatItem
|
||||
{
|
||||
type Error = ChatItemError;
|
||||
|
||||
@@ -1005,11 +1005,11 @@ impl<R: Clone, C: LookupPair<RecipientId, MinimalRecipientData, R> + ReportUnusu
|
||||
}
|
||||
|
||||
impl<
|
||||
C: LookupPair<RecipientId, MinimalRecipientData, M::RecipientReference>
|
||||
+ AsRef<BackupMeta>
|
||||
+ ReportUnusualTimestamp,
|
||||
M: Method + ReferencedTypes,
|
||||
> TryIntoWith<ChatItemMessage<M>, C> for proto::chat_item::Item
|
||||
C: LookupPair<RecipientId, MinimalRecipientData, M::RecipientReference>
|
||||
+ AsRef<BackupMeta>
|
||||
+ ReportUnusualTimestamp,
|
||||
M: Method + ReferencedTypes,
|
||||
> TryIntoWith<ChatItemMessage<M>, C> for proto::chat_item::Item
|
||||
{
|
||||
type Error = ChatItemError;
|
||||
|
||||
@@ -1065,10 +1065,10 @@ mod test {
|
||||
use test_case::test_case;
|
||||
|
||||
use super::*;
|
||||
use crate::backup::Purpose;
|
||||
use crate::backup::method::Store;
|
||||
use crate::backup::testutil::TestContext;
|
||||
use crate::backup::time::testutil::MillisecondsSinceEpoch;
|
||||
use crate::backup::Purpose;
|
||||
|
||||
impl proto::ChatItem {
|
||||
pub(crate) fn test_data() -> Self {
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::backup::file::{FilePointer, FilePointerError};
|
||||
use crate::backup::method::{Lookup, Method};
|
||||
use crate::backup::serialize::{SerializeOrder, UnorderedList};
|
||||
use crate::backup::time::ReportUnusualTimestamp;
|
||||
use crate::backup::{serialize, Color, ColorError, ReferencedTypes, TryIntoWith};
|
||||
use crate::backup::{Color, ColorError, ReferencedTypes, TryIntoWith, serialize};
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
@@ -276,8 +276,8 @@ impl TryFrom<proto::chat_style::custom_chat_color::Color> for CustomChatColor {
|
||||
type Error = ChatStyleError;
|
||||
|
||||
fn try_from(value: proto::chat_style::custom_chat_color::Color) -> Result<Self, Self::Error> {
|
||||
use proto::chat_style::custom_chat_color::Color as ColorProto;
|
||||
use proto::chat_style::Gradient;
|
||||
use proto::chat_style::custom_chat_color::Color as ColorProto;
|
||||
|
||||
Ok(match value {
|
||||
ColorProto::Gradient(gradient) => {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#[cfg(test)]
|
||||
use derive_where::derive_where;
|
||||
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::backup::chat::{ChatItemError, ReactionSet};
|
||||
use crate::backup::file::{FilePointer, FilePointerError};
|
||||
use crate::backup::frame::RecipientId;
|
||||
@@ -12,7 +13,6 @@ use crate::backup::method::LookupPair;
|
||||
use crate::backup::recipient::MinimalRecipientData;
|
||||
use crate::backup::serialize::SerializeOrder;
|
||||
use crate::backup::time::ReportUnusualTimestamp;
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
/// Validated version of [`proto::ContactMessage`].
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use zkgroup::receipts::ReceiptCredentialPresentation;
|
||||
use zkgroup::ZkGroupDeserializationFailure;
|
||||
use zkgroup::receipts::ReceiptCredentialPresentation;
|
||||
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ use crate::backup::serialize::UnorderedList;
|
||||
use crate::backup::time::Duration;
|
||||
use crate::backup::{serialize, uuid_bytes_to_aci};
|
||||
use crate::proto::backup::{
|
||||
self as proto, group_invitation_revoked_update, GenericGroupUpdate, GroupAdminStatusUpdate,
|
||||
GroupAnnouncementOnlyChangeUpdate, GroupAttributesAccessLevelChangeUpdate, GroupAvatarUpdate,
|
||||
GroupCreationUpdate, GroupDescriptionUpdate, GroupExpirationTimerUpdate,
|
||||
GroupInvitationAcceptedUpdate, GroupInvitationDeclinedUpdate, GroupInvitationRevokedUpdate,
|
||||
self as proto, GenericGroupUpdate, GroupAdminStatusUpdate, GroupAnnouncementOnlyChangeUpdate,
|
||||
GroupAttributesAccessLevelChangeUpdate, GroupAvatarUpdate, GroupCreationUpdate,
|
||||
GroupDescriptionUpdate, GroupExpirationTimerUpdate, GroupInvitationAcceptedUpdate,
|
||||
GroupInvitationDeclinedUpdate, GroupInvitationRevokedUpdate,
|
||||
GroupInviteLinkAdminApprovalUpdate, GroupInviteLinkDisabledUpdate,
|
||||
GroupInviteLinkEnabledUpdate, GroupInviteLinkResetUpdate, GroupJoinRequestApprovalUpdate,
|
||||
GroupJoinRequestCanceledUpdate, GroupJoinRequestUpdate, GroupMemberAddedUpdate,
|
||||
@@ -28,6 +28,7 @@ use crate::proto::backup::{
|
||||
GroupUnknownInviteeUpdate, GroupV2MigrationDroppedMembersUpdate,
|
||||
GroupV2MigrationInvitedMembersUpdate, GroupV2MigrationSelfInvitedUpdate,
|
||||
GroupV2MigrationUpdate, SelfInvitedOtherUserToGroupUpdate, SelfInvitedToGroupUpdate,
|
||||
group_invitation_revoked_update,
|
||||
};
|
||||
|
||||
/// Implements `TryFrom<$MESSAGE>` for [`GroupChatUpdate`].
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::backup::file::{FilePointer, FilePointerError};
|
||||
use crate::backup::time::{ReportUnusualTimestamp, Timestamp, TimestampError};
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
|
||||
@@ -9,7 +9,7 @@ use serde_with::hex::Hex;
|
||||
use serde_with::serde_as;
|
||||
|
||||
use crate::backup::time::{ReportUnusualTimestamp, Timestamp, TimestampError};
|
||||
use crate::backup::{serialize, TryIntoWith};
|
||||
use crate::backup::{TryIntoWith, serialize};
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
@@ -225,8 +225,8 @@ impl TryFrom<proto::payment_notification::transaction_details::FailedTransaction
|
||||
fn try_from(
|
||||
value: proto::payment_notification::transaction_details::FailedTransaction,
|
||||
) -> Result<Self, Self::Error> {
|
||||
use proto::payment_notification::transaction_details::failed_transaction::FailureReason;
|
||||
use proto::payment_notification::transaction_details::FailedTransaction as FailedTransactionProto;
|
||||
use proto::payment_notification::transaction_details::failed_transaction::FailureReason;
|
||||
|
||||
let FailedTransactionProto {
|
||||
reason,
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::backup::frame::RecipientId;
|
||||
use crate::backup::method::LookupPair;
|
||||
use crate::backup::recipient::{DestinationKind, MinimalRecipientData};
|
||||
use crate::backup::time::{ReportUnusualTimestamp, Timestamp, TimestampError};
|
||||
use crate::backup::{likely_empty, TryIntoWith};
|
||||
use crate::backup::{TryIntoWith, likely_empty};
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
/// Validated version of [`proto::Quote`]
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
use derive_where::derive_where;
|
||||
use intmap::IntMap;
|
||||
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::backup::frame::RecipientId;
|
||||
use crate::backup::method::LookupPair;
|
||||
use crate::backup::recipient::{DestinationKind, MinimalRecipientData};
|
||||
use crate::backup::serialize::{SerializeOrder, UnorderedList};
|
||||
use crate::backup::time::{ReportUnusualTimestamp, Timestamp, TimestampError};
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
/// Validated version of [`proto::Reaction`].
|
||||
@@ -183,8 +183,8 @@ mod test {
|
||||
use crate::backup::chat::StandardMessage;
|
||||
use crate::backup::recipient::FullRecipientData;
|
||||
use crate::backup::testutil::TestContext;
|
||||
use crate::backup::time::testutil::MillisecondsSinceEpoch;
|
||||
use crate::backup::time::Duration;
|
||||
use crate::backup::time::testutil::MillisecondsSinceEpoch;
|
||||
|
||||
impl proto::Reaction {
|
||||
pub(crate) fn test_data() -> Self {
|
||||
|
||||
@@ -15,7 +15,7 @@ use crate::backup::method::LookupPair;
|
||||
use crate::backup::recipient::MinimalRecipientData;
|
||||
use crate::backup::serialize::SerializeOrder;
|
||||
use crate::backup::time::ReportUnusualTimestamp;
|
||||
use crate::backup::{likely_empty, TryIntoWith};
|
||||
use crate::backup::{TryIntoWith, likely_empty};
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
/// Validated version of [`proto::StandardMessage`].
|
||||
@@ -115,8 +115,8 @@ mod test {
|
||||
use test_case::test_case;
|
||||
|
||||
use super::*;
|
||||
use crate::backup::chat::text::{TextError, MAX_BODY_LENGTH_WITH_LONG_TEXT_ATTACHMENT};
|
||||
use crate::backup::chat::Reaction;
|
||||
use crate::backup::chat::text::{MAX_BODY_LENGTH_WITH_LONG_TEXT_ATTACHMENT, TextError};
|
||||
use crate::backup::recipient::FullRecipientData;
|
||||
use crate::backup::testutil::TestContext;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#[cfg(test)]
|
||||
use derive_where::derive_where;
|
||||
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::backup::chat::{ChatItemError, ReactionSet};
|
||||
use crate::backup::frame::RecipientId;
|
||||
use crate::backup::method::LookupPair;
|
||||
@@ -12,7 +13,6 @@ use crate::backup::recipient::MinimalRecipientData;
|
||||
use crate::backup::serialize::SerializeOrder;
|
||||
use crate::backup::sticker::MessageSticker;
|
||||
use crate::backup::time::ReportUnusualTimestamp;
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
/// Validated version of [`proto::StickerMessage`].
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#[cfg(test)]
|
||||
use derive_where::derive_where;
|
||||
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::backup::chat::{MessageText, ReactionError, ReactionSet, TextError};
|
||||
use crate::backup::file::{FilePointer, FilePointerError};
|
||||
use crate::backup::frame::RecipientId;
|
||||
@@ -12,7 +13,6 @@ use crate::backup::method::LookupPair;
|
||||
use crate::backup::recipient::MinimalRecipientData;
|
||||
use crate::backup::serialize::SerializeOrder;
|
||||
use crate::backup::time::ReportUnusualTimestamp;
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
/// Validated version of a 1:1 story reply message [`proto::DirectStoryReplyMessage`].
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::backup::call::{GroupCall, IndividualCall};
|
||||
use crate::backup::chat::group::GroupChatUpdate;
|
||||
use crate::backup::chat::ChatItemError;
|
||||
use crate::backup::chat::group::GroupChatUpdate;
|
||||
use crate::backup::frame::RecipientId;
|
||||
use crate::backup::method::LookupPair;
|
||||
use crate::backup::recipient::{ChatItemAuthorKind, ChatRecipientKind, MinimalRecipientData, E164};
|
||||
use crate::backup::recipient::{ChatItemAuthorKind, ChatRecipientKind, E164, MinimalRecipientData};
|
||||
use crate::backup::time::{Duration, ReportUnusualTimestamp};
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
/// Validated version of [`proto::chat_update_message::Update`].
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#[cfg(test)]
|
||||
use derive_where::derive_where;
|
||||
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::backup::chat::{ReactionError, ReactionSet};
|
||||
use crate::backup::file::{MessageAttachment, MessageAttachmentError};
|
||||
use crate::backup::frame::RecipientId;
|
||||
@@ -12,7 +13,6 @@ use crate::backup::method::LookupPair;
|
||||
use crate::backup::recipient::MinimalRecipientData;
|
||||
use crate::backup::serialize::SerializeOrder;
|
||||
use crate::backup::time::ReportUnusualTimestamp;
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::proto::backup::{self as proto};
|
||||
|
||||
/// Validated version of a view-once message [`proto::ViewOnceMessage`].
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#[cfg(test)]
|
||||
use derive_where::derive_where;
|
||||
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::backup::chat::quote::{Quote, QuoteError};
|
||||
use crate::backup::chat::{ReactionError, ReactionSet};
|
||||
use crate::backup::file::{MessageAttachment, MessageAttachmentError};
|
||||
@@ -13,7 +14,6 @@ use crate::backup::method::LookupPair;
|
||||
use crate::backup::recipient::MinimalRecipientData;
|
||||
use crate::backup::serialize::SerializeOrder;
|
||||
use crate::backup::time::ReportUnusualTimestamp;
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
/// Validated version of a voice message [`proto::StandardMessage`].
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
use intmap::IntMap;
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::backup::frame::RecipientId;
|
||||
use crate::backup::method::LookupPair;
|
||||
use crate::backup::recipient::{DestinationKind, MinimalRecipientData};
|
||||
use crate::backup::serialize::{SerializeOrder, UnorderedList};
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
/// Validated version of [`proto::ChatFolder`].
|
||||
|
||||
@@ -8,7 +8,7 @@ use serde_with::serde_as;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::backup::time::{ReportUnusualTimestamp, Timestamp, TimestampError};
|
||||
use crate::backup::{serialize, TryIntoWith};
|
||||
use crate::backup::{TryIntoWith, serialize};
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
#[serde_as]
|
||||
|
||||
@@ -16,12 +16,12 @@ use serde_with::serde_as;
|
||||
use uuid::Uuid;
|
||||
use zkgroup::ProfileKeyBytes;
|
||||
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::backup::call::{CallLink, CallLinkError, CallLinkRootKey};
|
||||
use crate::backup::frame::RecipientId;
|
||||
use crate::backup::method::LookupPair;
|
||||
use crate::backup::serialize::{self, SerializeOrder, UnorderedList};
|
||||
use crate::backup::time::{ReportUnusualTimestamp, Timestamp, TimestampError};
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::proto::backup as proto;
|
||||
use crate::proto::backup::recipient::Destination as RecipientDestination;
|
||||
|
||||
@@ -230,7 +230,7 @@ pub struct FullRecipientData(Arc<(MinimalRecipientData, Destination<FullRecipien
|
||||
|
||||
impl serde::Serialize for FullRecipientData {
|
||||
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
self.0 .1.serialize(serializer)
|
||||
self.0.1.serialize(serializer)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ impl AsRef<DestinationKind> for MinimalRecipientData {
|
||||
impl std::ops::Deref for FullRecipientData {
|
||||
type Target = Destination<FullRecipientData>;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0 .1
|
||||
&self.0.1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ impl FullRecipientData {
|
||||
|
||||
impl AsRef<MinimalRecipientData> for FullRecipientData {
|
||||
fn as_ref(&self) -> &MinimalRecipientData {
|
||||
&self.0 .0
|
||||
&self.0.0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,7 +731,7 @@ impl<R: Clone, C: LookupPair<RecipientId, MinimalRecipientData, R> + ReportUnusu
|
||||
distribution_id == MY_STORY_UUID,
|
||||
) {
|
||||
(proto::distribution_list::PrivacyMode::UNKNOWN, _) => {
|
||||
return Err(RecipientError::DistributionListPrivacyUnknown)
|
||||
return Err(RecipientError::DistributionListPrivacyUnknown);
|
||||
}
|
||||
(proto::distribution_list::PrivacyMode::ONLY_WITH, _) => {
|
||||
PrivacyMode::OnlyWith(members)
|
||||
|
||||
@@ -10,7 +10,7 @@ use zkgroup::GroupMasterKeyBytes;
|
||||
|
||||
use crate::backup::serialize::{self, UnorderedList};
|
||||
use crate::backup::time::{Duration, ReportUnusualTimestamp, TimestampError};
|
||||
use crate::backup::{likely_empty, TryIntoWith};
|
||||
use crate::backup::{TryIntoWith, likely_empty};
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
mod members;
|
||||
|
||||
@@ -7,9 +7,9 @@ use libsignal_core::{Aci, ServiceId, WrongKindOfServiceIdError};
|
||||
use serde_with::serde_as;
|
||||
|
||||
use super::GroupError;
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::backup::serialize::{self, SerializeOrder};
|
||||
use crate::backup::time::{ReportUnusualTimestamp, Timestamp};
|
||||
use crate::backup::TryIntoWith;
|
||||
use crate::proto::backup as proto;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
|
||||
@@ -249,8 +249,8 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
use crate::backup::testutil::TestContext;
|
||||
use crate::backup::time::testutil::MillisecondsSinceEpoch;
|
||||
use crate::backup::time::TimestampError;
|
||||
use crate::backup::time::testutil::MillisecondsSinceEpoch;
|
||||
|
||||
impl proto::group::Member {
|
||||
pub(crate) fn test_data() -> Self {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user