crypto: Implement From<EncryptedFile> for EncryptionInfo
@@ -23,7 +23,7 @@ use aes_ctr::{
};
use base64::DecodeError;
use getrandom::getrandom;
-use matrix_sdk_common::events::room::{JsonWebKey, JsonWebKeyInit};
+use matrix_sdk_common::events::room::{EncryptedFile, JsonWebKey, JsonWebKeyInit};
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use thiserror::Error;
@@ -252,6 +252,12 @@ pub struct EncryptionInfo {
pub hashes: BTreeMap<String, String>,
}
+impl From<EncryptedFile> for EncryptionInfo {
+ fn from(file: EncryptedFile) -> Self {
+ Self { version: file.v, web_key: file.key, iv: file.iv, hashes: file.hashes }
+ }
+}
+
#[cfg(test)]
mod test {
use std::io::{Cursor, Read};
