Skip to content

Commit 7154fc7

Browse files
committed
Detect AES via compression=99
1 parent 91be845 commit 7154fc7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/main/php/io/archive/zip/AbstractZipReaderImpl.class.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php namespace io\archive\zip;
22

33
use io\streams\InputStream;
4-
use lang\{FormatException, IllegalArgumentException};
4+
use lang\{FormatException, IllegalArgumentException, MethodNotImplementedException};
55
use util\Date;
66

77
/**
@@ -226,8 +226,14 @@ public function currentEntry() {
226226
$this->skip= $header['compressed']+ 16;
227227
}
228228

229-
// Bit 1: The file is encrypted
230-
if ($header['flags'] & 1) {
229+
// AES vs. traditional PKZIP cipher
230+
if (99 === $header['compression']) {
231+
$aes= unpack('vheader/vsize/vversion/a2vendor/cstrength/vcompression', $extra);
232+
233+
// TODO: Implement
234+
235+
throw new MethodNotImplementedException('Not yet implemented', 'AES');
236+
} else if ($header['flags'] & 1) {
231237
$cipher= new ZipCipher($this->password);
232238
$preamble= $cipher->decipher($this->streamRead(12));
233239

src/test/php/io/archive/zip/unittest/vendors/SevenZipFileTest.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function zipCryptoPasswordProtected() {
8282
$this->assertSecuredEntriesIn($this->archiveReaderFor($this->vendor(), 'zip-crypto'));
8383
}
8484

85-
#[Test, Ignore('Not yet supported')]
85+
#[Test]
8686
public function aes256PasswordProtected() {
8787
$this->assertSecuredEntriesIn($this->archiveReaderFor($this->vendor(), 'aes-256'));
8888
}

0 commit comments

Comments
 (0)