From 51929e453296c4b31dc26dae0498cc12587878e8 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 13 Jun 2019 11:44:38 +0200 Subject: [PATCH] src/backup/data_chunk.rs - decode: make crypt_config optional --- src/backup/data_chunk.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/backup/data_chunk.rs b/src/backup/data_chunk.rs index 2baba71a..6f91026d 100644 --- a/src/backup/data_chunk.rs +++ b/src/backup/data_chunk.rs @@ -95,7 +95,7 @@ impl DataChunk { } /// Decode chunk data - pub fn decode(self, config: &CryptConfig) -> Result, Error> { + pub fn decode(self, config: Option<&CryptConfig>) -> Result, Error> { let magic = self.magic(); @@ -107,10 +107,13 @@ impl DataChunk { return Ok(data); } else if magic == &ENCR_COMPR_CHUNK_MAGIC_1_0 || magic == &ENCRYPTED_CHUNK_MAGIC_1_0 { + if let Some(config) = config { + let data = config.decode_chunk(&self.raw_data)?; - let data = config.decode_chunk(&self.raw_data)?; - - return Ok(data); + return Ok(data); + } else { + bail!("unable to decrypt chunk - missing CryptConfig"); + } } else { bail!("Invalid chunk magic number."); }