crypto: Bump the olm-rs version

master
Damir Jelić 2021-07-19 13:18:25 +02:00
parent 725fd817c2
commit 96e26651bc
4 changed files with 15 additions and 15 deletions

View File

@ -24,7 +24,7 @@ matrix-qrcode = { version = "0.1.0", path = "../matrix_qrcode" }
matrix-sdk-common = { version = "0.3.0", path = "../matrix_sdk_common" } matrix-sdk-common = { version = "0.3.0", path = "../matrix_sdk_common" }
ruma = { version = "0.3.0", features = ["client-api-c", "unstable-pre-spec"] } ruma = { version = "0.3.0", features = ["client-api-c", "unstable-pre-spec"] }
olm-rs = { version = "1.0.1", features = ["serde"] } olm-rs = { version = "2.0", features = ["serde"] }
getrandom = "0.2.3" getrandom = "0.2.3"
serde = { version = "1.0.126", features = ["derive", "rc"] } serde = { version = "1.0.126", features = ["derive", "rc"] }
serde_json = "1.0.64" serde_json = "1.0.64"

View File

@ -249,7 +249,7 @@ impl OutboundGroupSession {
pub(crate) async fn encrypt_helper(&self, plaintext: String) -> String { pub(crate) async fn encrypt_helper(&self, plaintext: String) -> String {
let session = self.inner.lock().await; let session = self.inner.lock().await;
self.message_count.fetch_add(1, Ordering::SeqCst); self.message_count.fetch_add(1, Ordering::SeqCst);
session.encrypt(plaintext) session.encrypt(&plaintext)
} }
/// Encrypt a room message for the given room. /// Encrypt a room message for the given room.

View File

@ -108,13 +108,6 @@ pub struct PickledSelfSigning {
public_key: CrossSigningKey, public_key: CrossSigningKey,
} }
impl Signature {
#[cfg(test)]
pub fn as_str(&self) -> &str {
&self.0
}
}
impl PickledSigning { impl PickledSigning {
pub fn as_str(&self) -> &str { pub fn as_str(&self) -> &str {
&self.0 &self.0
@ -288,6 +281,12 @@ pub struct PickledSignings {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Signature(String); pub struct Signature(String);
impl std::fmt::Display for Signature {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PickledSigning(String); pub struct PickledSigning(String);
@ -298,7 +297,7 @@ impl Signing {
} }
pub fn from_seed(seed: Vec<u8>) -> Self { pub fn from_seed(seed: Vec<u8>) -> Self {
let inner = OlmPkSigning::new(seed.clone()).expect("Unable to create pk signing object"); let inner = OlmPkSigning::new(&seed).expect("Unable to create pk signing object");
let public_key = PublicSigningKey(inner.public_key().into()); let public_key = PublicSigningKey(inner.public_key().into());
Signing { Signing {
@ -366,7 +365,7 @@ impl Signing {
signature: &Signature, signature: &Signature,
) -> Result<bool, OlmUtilityError> { ) -> Result<bool, OlmUtilityError> {
let utility = OlmUtility::new(); let utility = OlmUtility::new();
utility.ed25519_verify(self.public_key.as_str(), message, signature.as_str()) utility.ed25519_verify(self.public_key.as_str(), message, signature.to_string())
} }
pub async fn sign_json(&self, mut json: Value) -> Result<Signature, SignatureError> { pub async fn sign_json(&self, mut json: Value) -> Result<Signature, SignatureError> {

View File

@ -75,7 +75,8 @@ impl Utility {
signature.get(key_id.to_string()).ok_or(SignatureError::NoSignatureFound)?; signature.get(key_id.to_string()).ok_or(SignatureError::NoSignatureFound)?;
let signature = signature.as_str().ok_or(SignatureError::NoSignatureFound)?; let signature = signature.as_str().ok_or(SignatureError::NoSignatureFound)?;
let ret = match self.inner.ed25519_verify(signing_key, &canonical_json, signature) { let ret =
match self.inner.ed25519_verify(signing_key, &canonical_json, signature.to_owned()) {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(_) => Err(SignatureError::VerificationError), Err(_) => Err(SignatureError::VerificationError),
}; };