crypto: Use a constant for the attachment encryption version.

master
Damir Jelić 2020-09-16 12:39:23 +02:00
parent 428b28a985
commit 849934b180
2 changed files with 3 additions and 4 deletions

View File

@ -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<AttachmentDecryptor<'a, R>, 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,

View File

@ -1,4 +1,3 @@
#[allow(dead_code)]
mod attachments;
mod key_export;