Skip to content

Commit

Permalink
#20 weak encryption + streaming does not set local CRC value to zero
Browse files Browse the repository at this point in the history
  • Loading branch information
pmqs committed Apr 30, 2024
1 parent 274f75c commit 7952c1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
11 changes: 10 additions & 1 deletion bin/zipdetails
Original file line number Diff line number Diff line change
Expand Up @@ -2038,8 +2038,17 @@ sub LocalHeader
my $lastMod = out_V "Modification Time", sub { LastModTime($_[0]) };

my $crc = out_V "CRC";

# Weak encryption if
# * encrypt flag (bit 0) set in General Purpose Flags
# * strong encrypt (bit ) not set in General Purpose Flags
# * not using AES encryption (compression method 99)
my $weakEncryption = ($gpFlag & ZIP_GP_FLAG_ALL_ENCRYPT) == ZIP_GP_FLAG_ENCRYPTED_MASK &&
$compressedMethod != 99;
# Weak encryption uses the CRC value even when streaming is in play.
# This conflicts with appnote 6.3.10 section 4.4.4
warning $FH->tell() - 4, "CRC field should be zero when streaming is enabled"
if $streaming && $crc != 0 ;
if $streaming && $crc != 0 && ! $weakEncryption;

my $compressedSize = out_V "Compressed Size";
# warning $FH->tell(), "Compressed Size should be zero when streaming is enabled";
Expand Down
5 changes: 0 additions & 5 deletions t/files/0009-infozip/iz-linux-encrypt/stdout
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
0008 Compression Method 0008 (8) 'Deflated'
000A Modification Time 52988571 (1385727345) 'Sat Apr 24 16:43:34 2021'
000E CRC F90EE7FF (4178503679)
#
# WARNING: Offset 0xE: CRC field should be zero when streaming is enabled
#
0012 Compressed Size 0000011A (282)
0016 Uncompressed Size 000001BE (446)
001A Filename Length 0009 (9)
Expand Down Expand Up @@ -82,6 +79,4 @@
01CC Offset to Central Dir 0000016D (365)
01D0 Comment Length 0000 (0)
#
# Warning Count: 1
#
# Done
5 changes: 0 additions & 5 deletions t/files/0009-infozip/iz-linux-encrypt/stdout-v
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
0008 0009 0002 08 00 Compression Method 0008 (8) 'Deflated'
000A 000D 0004 71 85 98 52 Modification Time 52988571 (1385727345) 'Sat Apr 24 16:43:34 2021'
000E 0011 0004 FF E7 0E F9 CRC F90EE7FF (4178503679)
#
# WARNING: Offset 0xE: CRC field should be zero when streaming is enabled
#
0012 0015 0004 1A 01 00 00 Compressed Size 0000011A (282)
0016 0019 0004 BE 01 00 00 Uncompressed Size 000001BE (446)
001A 001B 0002 09 00 Filename Length 0009 (9)
Expand Down Expand Up @@ -86,6 +83,4 @@
01CC 01CF 0004 6D 01 00 00 Offset to Central Dir 0000016D (365)
01D0 01D1 0002 00 00 Comment Length 0000 (0)
#
# Warning Count: 1
#
# Done

0 comments on commit 7952c1c

Please sign in to comment.