crypto: Implement From<EncryptedFile> for EncryptionInfo

master
Kévin Commaille 2021-05-25 21:33:38 +02:00
parent c318a6e847
commit 0c8e870bff
No known key found for this signature in database
GPG Key ID: 296D60AE1E61661C
1 changed files with 7 additions and 1 deletions

View File

@ -23,7 +23,7 @@ use aes_ctr::{
}; };
use base64::DecodeError; use base64::DecodeError;
use getrandom::getrandom; 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 serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use thiserror::Error; use thiserror::Error;
@ -252,6 +252,12 @@ pub struct EncryptionInfo {
pub hashes: BTreeMap<String, String>, 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)] #[cfg(test)]
mod test { mod test {
use std::io::{Cursor, Read}; use std::io::{Cursor, Read};