matrix-sdk: Try to lower our compile times, at least in the crypto part for now.
parent
6509e72a74
commit
c40edcf2fc
|
@ -31,7 +31,7 @@ docs = ["encryption", "sqlite_cryptostore", "messages"]
|
||||||
async-trait = "0.1.41"
|
async-trait = "0.1.41"
|
||||||
dashmap = { version = "3.11.10", optional = true }
|
dashmap = { version = "3.11.10", optional = true }
|
||||||
http = "0.2.1"
|
http = "0.2.1"
|
||||||
serde_json = "1.0.58"
|
serde_json = "1.0.59"
|
||||||
thiserror = "1.0.21"
|
thiserror = "1.0.21"
|
||||||
tracing = "0.1.21"
|
tracing = "0.1.21"
|
||||||
url = "2.1.1"
|
url = "2.1.1"
|
||||||
|
@ -72,8 +72,8 @@ async-trait = "0.1.41"
|
||||||
async-std = { version = "1.6.5", features = ["unstable"] }
|
async-std = { version = "1.6.5", features = ["unstable"] }
|
||||||
dirs = "3.0.1"
|
dirs = "3.0.1"
|
||||||
matrix-sdk-test = { version = "0.1.0", path = "../matrix_sdk_test" }
|
matrix-sdk-test = { version = "0.1.0", path = "../matrix_sdk_test" }
|
||||||
tokio = { version = "0.2.22", features = ["rt-threaded", "macros"] }
|
tokio = { version = "0.2.22", default-features = false, features = ["rt-threaded", "macros"] }
|
||||||
serde_json = "1.0.58"
|
serde_json = "1.0.59"
|
||||||
tracing-subscriber = "0.2.13"
|
tracing-subscriber = "0.2.13"
|
||||||
tempfile = "3.1.0"
|
tempfile = "3.1.0"
|
||||||
mockito = "0.27.0"
|
mockito = "0.27.0"
|
||||||
|
|
|
@ -25,8 +25,8 @@ docs = ["encryption", "sqlite_cryptostore", "messages"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = "0.1.41"
|
async-trait = "0.1.41"
|
||||||
serde = "1.0.116"
|
serde = "1.0.117"
|
||||||
serde_json = "1.0.58"
|
serde_json = "1.0.59"
|
||||||
zeroize = "1.1.1"
|
zeroize = "1.1.1"
|
||||||
tracing = "0.1.21"
|
tracing = "0.1.21"
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ tempfile = "3.1.0"
|
||||||
mockito = "0.27.0"
|
mockito = "0.27.0"
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
||||||
tokio = { version = "0.2.22", features = ["rt-threaded", "macros"] }
|
tokio = { version = "0.2.22", default-features = false, features = ["rt-threaded", "macros"] }
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
||||||
wasm-bindgen-test = "0.3.18"
|
wasm-bindgen-test = "0.3.18"
|
||||||
|
|
|
@ -22,16 +22,17 @@ js_int = "0.1.9"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
git = "https://github.com/ruma/ruma"
|
git = "https://github.com/ruma/ruma"
|
||||||
rev = "50eb700571480d1440e15a387d10f98be8abab59"
|
rev = "50eb700571480d1440e15a387d10f98be8abab59"
|
||||||
features = ["client-api", "unstable-pre-spec", "unstable-exhaustive-types"]
|
default-features = false
|
||||||
|
features = ["client-api", "unstable-pre-spec", "unstable-synapse-quirks"]
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
uuid = { version = "0.8.1", features = ["v4", "serde"] }
|
uuid = { version = "0.8.1", default-features = false, features = ["v4", "serde"] }
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
|
||||||
version = "0.2.22"
|
version = "0.2.22"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["sync", "time", "fs"]
|
features = ["sync"]
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
futures-locks = { version = "0.6.0", default-features = false }
|
futures-locks = { version = "0.6.0", default-features = false }
|
||||||
uuid = { version = "0.8.1", features = ["v4", "wasm-bindgen"] }
|
uuid = { version = "0.8.1", default-features = false, features = ["v4", "wasm-bindgen"] }
|
||||||
|
|
|
@ -14,5 +14,5 @@ version = "0.1.0"
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
syn = "1.0.44"
|
syn = { version = "1.0.45", features = ["proc-macro"], default-features = false }
|
||||||
quote = "1.0.7"
|
quote = "1.0.7"
|
||||||
|
|
|
@ -27,9 +27,8 @@ matrix-sdk-common = { version = "0.1.0", path = "../matrix_sdk_common" }
|
||||||
|
|
||||||
olm-rs = { version = "1.0.0", features = ["serde"] }
|
olm-rs = { version = "1.0.0", features = ["serde"] }
|
||||||
getrandom = "0.2.0"
|
getrandom = "0.2.0"
|
||||||
serde = { version = "1.0.116", features = ["derive", "rc"] }
|
serde = { version = "1.0.117", features = ["derive", "rc"] }
|
||||||
serde_json = "1.0.58"
|
serde_json = "1.0.59"
|
||||||
cjson = "0.1.1"
|
|
||||||
zeroize = { version = "1.1.1", features = ["zeroize_derive"] }
|
zeroize = { version = "1.1.1", features = ["zeroize_derive"] }
|
||||||
url = "2.1.1"
|
url = "2.1.1"
|
||||||
|
|
||||||
|
@ -39,17 +38,12 @@ tracing = "0.1.21"
|
||||||
atomic = "0.5.0"
|
atomic = "0.5.0"
|
||||||
dashmap = "3.11.10"
|
dashmap = "3.11.10"
|
||||||
sha2 = "0.9.1"
|
sha2 = "0.9.1"
|
||||||
aes-ctr = "0.5.0"
|
aes-ctr = "0.6.0"
|
||||||
pbkdf2 = { version = "0.5.0", default-features = false }
|
pbkdf2 = { version = "0.6.0", default-features = false }
|
||||||
hmac = "0.9.0"
|
hmac = "0.10.1"
|
||||||
base64 = "0.13.0"
|
base64 = "0.13.0"
|
||||||
byteorder = "1.3.4"
|
byteorder = "1.3.4"
|
||||||
|
|
||||||
[dependencies.tracing-futures]
|
|
||||||
version = "0.2.4"
|
|
||||||
default-features = false
|
|
||||||
features = ["std", "std-future"]
|
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.sqlx]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.sqlx]
|
||||||
version = "0.3.5"
|
version = "0.3.5"
|
||||||
optional = true
|
optional = true
|
||||||
|
@ -57,10 +51,10 @@ default-features = false
|
||||||
features = ["runtime-tokio", "sqlite", "macros"]
|
features = ["runtime-tokio", "sqlite", "macros"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "0.2.22", features = ["rt-threaded", "macros"] }
|
tokio = { version = "0.2.22", default-features = false, features = ["rt-threaded", "macros"] }
|
||||||
futures = "0.3.6"
|
futures = "0.3.6"
|
||||||
proptest = "0.10.1"
|
proptest = "0.10.1"
|
||||||
serde_json = "1.0.58"
|
serde_json = "1.0.59"
|
||||||
tempfile = "3.1.0"
|
tempfile = "3.1.0"
|
||||||
http = "0.2.1"
|
http = "0.2.1"
|
||||||
matrix-sdk-test = { version = "0.1.0", path = "../matrix_sdk_test" }
|
matrix-sdk-test = { version = "0.1.0", path = "../matrix_sdk_test" }
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use cjson::Error as CjsonError;
|
|
||||||
use matrix_sdk_common::identifiers::{DeviceId, Error as IdentifierError, UserId};
|
use matrix_sdk_common::identifiers::{DeviceId, Error as IdentifierError, UserId};
|
||||||
use olm_rs::errors::{OlmGroupSessionError, OlmSessionError};
|
use olm_rs::errors::{OlmGroupSessionError, OlmSessionError};
|
||||||
use serde_json::Error as SerdeError;
|
use serde_json::Error as SerdeError;
|
||||||
|
@ -145,11 +144,11 @@ pub enum SignatureError {
|
||||||
#[error("the provided JSON object doesn't contain a signatures field")]
|
#[error("the provided JSON object doesn't contain a signatures field")]
|
||||||
NoSignatureFound,
|
NoSignatureFound,
|
||||||
|
|
||||||
#[error("the provided JSON object can't be converted to a canonical representation")]
|
|
||||||
CanonicalJsonError(CjsonError),
|
|
||||||
|
|
||||||
#[error("the signature didn't match the provided key")]
|
#[error("the signature didn't match the provided key")]
|
||||||
VerificationError,
|
VerificationError,
|
||||||
|
|
||||||
|
#[error(transparent)]
|
||||||
|
JsonError(#[from] SerdeError),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
|
@ -174,9 +173,3 @@ pub(crate) enum SessionCreationError {
|
||||||
#[error("Error creating new Olm session for {0} {1}: {2:?}")]
|
#[error("Error creating new Olm session for {0} {1}: {2:?}")]
|
||||||
OlmError(UserId, Box<DeviceId>, OlmSessionError),
|
OlmError(UserId, Box<DeviceId>, OlmSessionError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CjsonError> for SignatureError {
|
|
||||||
fn from(error: CjsonError) -> Self {
|
|
||||||
Self::CanonicalJsonError(error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ use matrix_sdk_common::events::room::JsonWebKey;
|
||||||
use getrandom::getrandom;
|
use getrandom::getrandom;
|
||||||
|
|
||||||
use aes_ctr::{
|
use aes_ctr::{
|
||||||
stream_cipher::{NewStreamCipher, SyncStreamCipher},
|
cipher::{NewStreamCipher, SyncStreamCipher},
|
||||||
Aes256Ctr,
|
Aes256Ctr,
|
||||||
};
|
};
|
||||||
use base64::DecodeError;
|
use base64::DecodeError;
|
||||||
|
|
|
@ -20,7 +20,7 @@ use byteorder::{BigEndian, ReadBytesExt};
|
||||||
use getrandom::getrandom;
|
use getrandom::getrandom;
|
||||||
|
|
||||||
use aes_ctr::{
|
use aes_ctr::{
|
||||||
stream_cipher::{NewStreamCipher, SyncStreamCipher},
|
cipher::{NewStreamCipher, SyncStreamCipher},
|
||||||
Aes256Ctr,
|
Aes256Ctr,
|
||||||
};
|
};
|
||||||
use hmac::{Hmac, Mac, NewMac};
|
use hmac::{Hmac, Mac, NewMac};
|
||||||
|
|
|
@ -25,7 +25,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use serde_json::value::to_raw_value;
|
use serde_json::value::to_raw_value;
|
||||||
use std::{collections::BTreeMap, sync::Arc};
|
use std::{collections::BTreeMap, sync::Arc};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tracing::{error, info, instrument, trace, warn};
|
use tracing::{error, info, trace, warn};
|
||||||
|
|
||||||
use matrix_sdk_common::{
|
use matrix_sdk_common::{
|
||||||
api::r0::to_device::DeviceIdOrAllDevices,
|
api::r0::to_device::DeviceIdOrAllDevices,
|
||||||
|
@ -294,7 +294,6 @@ impl KeyRequestMachine {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle a single incoming key request.
|
/// Handle a single incoming key request.
|
||||||
#[instrument]
|
|
||||||
async fn handle_key_request(
|
async fn handle_key_request(
|
||||||
&self,
|
&self,
|
||||||
event: &ToDeviceEvent<RoomKeyRequestEventContent>,
|
event: &ToDeviceEvent<RoomKeyRequestEventContent>,
|
||||||
|
@ -314,6 +313,9 @@ impl KeyRequestMachine {
|
||||||
}
|
}
|
||||||
// We ignore cancellations here since there's nothing to serve.
|
// We ignore cancellations here since there's nothing to serve.
|
||||||
Action::CancelRequest => return Ok(()),
|
Action::CancelRequest => return Ok(()),
|
||||||
|
// There is no other action defined, but ruma makes all enums
|
||||||
|
// non-exhaustive.
|
||||||
|
_ => return Ok(()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let session = self
|
let session = self
|
||||||
|
|
|
@ -17,7 +17,7 @@ use std::path::Path;
|
||||||
use std::{collections::BTreeMap, mem, sync::Arc};
|
use std::{collections::BTreeMap, mem, sync::Arc};
|
||||||
|
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use tracing::{debug, error, info, instrument, trace, warn};
|
use tracing::{debug, error, info, trace, warn};
|
||||||
|
|
||||||
use matrix_sdk_common::{
|
use matrix_sdk_common::{
|
||||||
api::r0::{
|
api::r0::{
|
||||||
|
@ -214,7 +214,6 @@ impl OlmMachine {
|
||||||
///
|
///
|
||||||
/// * `device_id` - The unique id of the device that owns this machine.
|
/// * `device_id` - The unique id of the device that owns this machine.
|
||||||
#[cfg(feature = "sqlite_cryptostore")]
|
#[cfg(feature = "sqlite_cryptostore")]
|
||||||
#[instrument(skip(path, passphrase))]
|
|
||||||
#[cfg_attr(feature = "docs", doc(cfg(r#sqlite_cryptostore)))]
|
#[cfg_attr(feature = "docs", doc(cfg(r#sqlite_cryptostore)))]
|
||||||
pub async fn new_with_default_store(
|
pub async fn new_with_default_store(
|
||||||
user_id: &UserId,
|
user_id: &UserId,
|
||||||
|
@ -351,7 +350,6 @@ impl OlmMachine {
|
||||||
///
|
///
|
||||||
/// * `response` - The keys upload response of the request that the client
|
/// * `response` - The keys upload response of the request that the client
|
||||||
/// performed.
|
/// performed.
|
||||||
#[instrument]
|
|
||||||
async fn receive_keys_upload_response(
|
async fn receive_keys_upload_response(
|
||||||
&self,
|
&self,
|
||||||
response: &upload_keys::Response,
|
response: &upload_keys::Response,
|
||||||
|
@ -666,7 +664,6 @@ impl OlmMachine {
|
||||||
/// * `response` - The sync latest sync response.
|
/// * `response` - The sync latest sync response.
|
||||||
///
|
///
|
||||||
/// [`decrypt_room_event`]: #method.decrypt_room_event
|
/// [`decrypt_room_event`]: #method.decrypt_room_event
|
||||||
#[instrument(skip(response))]
|
|
||||||
pub async fn receive_sync_response(&self, response: &mut SyncResponse) {
|
pub async fn receive_sync_response(&self, response: &mut SyncResponse) {
|
||||||
self.verification_machine.garbage_collect();
|
self.verification_machine.garbage_collect();
|
||||||
|
|
||||||
|
|
|
@ -669,9 +669,7 @@ impl ReadOnlyAccount {
|
||||||
///
|
///
|
||||||
/// Panics if the json value can't be serialized.
|
/// Panics if the json value can't be serialized.
|
||||||
pub async fn sign_json(&self, json: &Value) -> String {
|
pub async fn sign_json(&self, json: &Value) -> String {
|
||||||
let canonical_json = cjson::to_string(json)
|
self.sign(&json.to_string()).await
|
||||||
.unwrap_or_else(|_| panic!(format!("Can't serialize {} to canonical JSON", json)));
|
|
||||||
self.sign(&canonical_json).await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate, sign and prepare one-time keys to be uploaded.
|
/// Generate, sign and prepare one-time keys to be uploaded.
|
||||||
|
|
|
@ -240,12 +240,7 @@ impl OutboundGroupSession {
|
||||||
"type": content.event_type(),
|
"type": content.event_type(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let plaintext = cjson::to_string(&json_content).unwrap_or_else(|_| {
|
let plaintext = json_content.to_string();
|
||||||
panic!(format!(
|
|
||||||
"Can't serialize {} to canonical JSON",
|
|
||||||
json_content
|
|
||||||
))
|
|
||||||
});
|
|
||||||
|
|
||||||
let ciphertext = self.encrypt_helper(plaintext).await;
|
let ciphertext = self.encrypt_helper(plaintext).await;
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ impl Session {
|
||||||
"content": content,
|
"content": content,
|
||||||
});
|
});
|
||||||
|
|
||||||
let plaintext = cjson::to_string(&payload)
|
let plaintext = serde_json::to_string(&payload)
|
||||||
.unwrap_or_else(|_| panic!(format!("Can't serialize {} to canonical JSON", payload)));
|
.unwrap_or_else(|_| panic!(format!("Can't serialize {} to canonical JSON", payload)));
|
||||||
|
|
||||||
let ciphertext = self.encrypt_helper(&plaintext).await.to_tuple();
|
let ciphertext = self.encrypt_helper(&plaintext).await.to_tuple();
|
||||||
|
|
|
@ -63,7 +63,7 @@ impl Utility {
|
||||||
let unsigned = json_object.remove("unsigned");
|
let unsigned = json_object.remove("unsigned");
|
||||||
let signatures = json_object.remove("signatures");
|
let signatures = json_object.remove("signatures");
|
||||||
|
|
||||||
let canonical_json = cjson::to_string(json_object)?;
|
let canonical_json = serde_json::to_string(json_object)?;
|
||||||
|
|
||||||
if let Some(u) = unsigned {
|
if let Some(u) = unsigned {
|
||||||
json_object.insert("unsigned".to_string(), u);
|
json_object.insert("unsigned".to_string(), u);
|
||||||
|
|
|
@ -351,7 +351,7 @@ impl SasState<Created> {
|
||||||
let accepted_protocols =
|
let accepted_protocols =
|
||||||
AcceptedProtocols::try_from(content.clone()).map_err(|c| self.clone().cancel(c))?;
|
AcceptedProtocols::try_from(content.clone()).map_err(|c| self.clone().cancel(c))?;
|
||||||
|
|
||||||
let json_start_content = cjson::to_string(&self.as_content())
|
let json_start_content = serde_json::to_string(&self.as_content())
|
||||||
.expect("Can't deserialize start event content");
|
.expect("Can't deserialize start event content");
|
||||||
|
|
||||||
Ok(SasState {
|
Ok(SasState {
|
||||||
|
@ -396,7 +396,8 @@ impl SasState<Started> {
|
||||||
let sas = OlmSas::new();
|
let sas = OlmSas::new();
|
||||||
let utility = OlmUtility::new();
|
let utility = OlmUtility::new();
|
||||||
|
|
||||||
let json_content = cjson::to_string(&event.content).expect("Can't serialize content");
|
let json_content =
|
||||||
|
serde_json::to_string(&event.content).expect("Can't serialize content");
|
||||||
let pubkey = sas.public_key();
|
let pubkey = sas.public_key();
|
||||||
let commitment = utility.sha256_utf8_msg(&format!("{}{}", pubkey, json_content));
|
let commitment = utility.sha256_utf8_msg(&format!("{}{}", pubkey, json_content));
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@ repository = "https://github.com/matrix-org/matrix-rust-sdk"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_json = "1.0.58"
|
serde_json = "1.0.59"
|
||||||
http = "0.2.1"
|
http = "0.2.1"
|
||||||
matrix-sdk-common = { version = "0.1.0", path = "../matrix_sdk_common" }
|
matrix-sdk-common = { version = "0.1.0", path = "../matrix_sdk_common" }
|
||||||
matrix-sdk-test-macros = { version = "0.1.0", path = "../matrix_sdk_test_macros" }
|
matrix-sdk-test-macros = { version = "0.1.0", path = "../matrix_sdk_test_macros" }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
serde = "1.0.116"
|
serde = "1.0.117"
|
||||||
|
|
Loading…
Reference in New Issue