From 849934b180f6e081d05011edc9db6d6e35e863a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Wed, 16 Sep 2020 12:39:23 +0200 Subject: [PATCH] crypto: Use a constant for the attachment encryption version. --- matrix_sdk_crypto/src/file_encryption/attachments.rs | 6 +++--- matrix_sdk_crypto/src/file_encryption/mod.rs | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/matrix_sdk_crypto/src/file_encryption/attachments.rs b/matrix_sdk_crypto/src/file_encryption/attachments.rs index b5ed0c1e..b6636d68 100644 --- a/matrix_sdk_crypto/src/file_encryption/attachments.rs +++ b/matrix_sdk_crypto/src/file_encryption/attachments.rs @@ -37,7 +37,7 @@ use super::{decode, decode_url_safe, encode, encode_url_safe}; const IV_SIZE: usize = 16; const KEY_SIZE: usize = 32; -const VERSION: u8 = 1; +const VERSION: &str = "v2"; /// A wrapper that transparently encrypts anything that implements `Read` as an /// Matrix attachment. @@ -126,7 +126,7 @@ impl<'a, R: Read + 'a> AttachmentDecryptor<'a, R> { input: &'a mut R, info: EncryptionInfo, ) -> Result, DecryptorError> { - if info.version != "v2" { + if info.version != VERSION { return Err(DecryptorError::UnknownVersion); } @@ -249,7 +249,7 @@ impl<'a, R: Read + 'a> AttachmentEncryptor<'a, R> { .or_insert_with(|| encode(hash)); EncryptionInfo { - version: "v2".to_string(), + version: VERSION.to_string(), hashes: self.hashes, iv: self.iv, web_key: self.web_key, diff --git a/matrix_sdk_crypto/src/file_encryption/mod.rs b/matrix_sdk_crypto/src/file_encryption/mod.rs index 58752a5c..3c644bd9 100644 --- a/matrix_sdk_crypto/src/file_encryption/mod.rs +++ b/matrix_sdk_crypto/src/file_encryption/mod.rs @@ -1,4 +1,3 @@ -#[allow(dead_code)] mod attachments; mod key_export;