From a83767f9fbd51df654901b52bdba7838f6a10bf9 Mon Sep 17 00:00:00 2001 From: Igor Tolmachev Date: Tue, 16 Jul 2024 01:59:53 +0900 Subject: Add traditional PKWARE decryption. - Compression and encryption may not work together - Password check is not yet implemented - Unoptimized crc32 function --- src/zip/error.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/zip/error.rs') diff --git a/src/zip/error.rs b/src/zip/error.rs index 3eb68b8..9ec0956 100644 --- a/src/zip/error.rs +++ b/src/zip/error.rs @@ -11,15 +11,18 @@ pub enum ZipError { InvalidFileHeaderSignature, InvalidCDRSignature, - InvalidCompressionMethod, - UnsupportedCompressionMethod, + InvalidCompressionMethod(u16), + UnsupportedCompressionMethod(u16), + UnsupportedEncryptionMethod, InvalidDate, InvalidTime, InvalidFileName, InvalidFileComment, FileNotFound, + PasswordIsNotSpecified, CompressedDataIsUnseekable, + EncryptedDataIsUnseekable, } impl From for ArchiveError { @@ -48,15 +51,24 @@ impl Display for ZipError { write!(f, "Invalid signature of central directory record") } - Self::InvalidCompressionMethod => writeln!(f, "Invalid compression method"), - Self::UnsupportedCompressionMethod => writeln!(f, "Unsupported compression method"), + Self::InvalidCompressionMethod(id) => { + writeln!(f, "Invalid compression method {}", id) + } + Self::UnsupportedCompressionMethod(id) => { + writeln!(f, "Unsupported compression method {}", id) + } + Self::UnsupportedEncryptionMethod => { + writeln!(f, "Unsupported encryption method") + } Self::InvalidDate => write!(f, "Invalid date"), Self::InvalidTime => write!(f, "Invalid time"), Self::InvalidFileName => write!(f, "Invalid file name"), Self::InvalidFileComment => write!(f, "Invalid file comment"), Self::FileNotFound => write!(f, "File not found"), + Self::PasswordIsNotSpecified => write!(f, "Password is not specified"), Self::CompressedDataIsUnseekable => write!(f, "Compressed data is unseekable"), + Self::EncryptedDataIsUnseekable => write!(f, "Encrypted data is unseekable"), } } } -- cgit v1.2.3