Skip to content

Commit b839c42

Browse files
authored
Sign the Phar with SHA-512 instead of SHA-256 (#1149)
1 parent dd11f5a commit b839c42

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎features/make-phar.feature‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,14 @@ Feature: Check `utils/make-phar.php` output
5555
Error: Couldn't find plugin-status.mustache
5656
"""
5757
And the return code should be 0
58+
59+
Scenario: Phar is signed with SHA-512
60+
Given an empty directory
61+
And a new Phar with the same version
62+
63+
When I run `cp {PHAR_PATH} signed.phar`
64+
And I run `php -r 'echo (new Phar( "signed.phar" ))->getSignature()["hash_type"];'`
65+
Then STDOUT should be:
66+
"""
67+
SHA-512
68+
"""

‎utils/make-phar.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,10 @@ function get_composer_versions( $current_version ) {
326326
EOB
327327
);
328328

329+
// PHP verifies the signature over the whole archive on every invocation, and
330+
// SHA-512 is noticeably faster to compute than the SHA-256 default on 64-bit CPUs.
331+
$phar->setSignatureAlgorithm( Phar::SHA512 );
332+
329333
$phar->stopBuffering();
330334

331335
chmod( DEST_PATH, 0755 ); // Make executable.

0 commit comments

Comments
 (0)