Skip to content

Commit 8bb0c74

Browse files
committed
switch phar to use sha256 signature by default
1 parent 1417318 commit 8bb0c74

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

ext/phar/phar/pharcommand.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class PharCommand extends CLICommand
9292
'typ' => 'select',
9393
'val' => NULL,
9494
'inf' => '<method> Selects the hash algorithm.',
95-
'select' => array('md5' => 'MD5','sha1' => 'SHA1')
95+
'select' => array('md5' => 'MD5','sha1' => 'SHA1', 'sha256' => 'SHA256', 'sha512' => 'SHA512', 'openssl' => 'OPENSSL')
9696
),
9797
'i' => array(
9898
'typ' => 'regex',

ext/phar/tests/create_new_and_modify.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ include $pname . '/b.php';
4949
<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
5050
--EXPECTF--
5151
brand new!
52-
string(40) "%s"
53-
string(40) "%s"
52+
string(%d) "%s"
53+
string(%d) "%s"
5454
bool(true)
5555
modified!
5656
another!

ext/phar/tests/create_new_phar_c.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var_dump($phar->getSignature());
2020
--EXPECTF--
2121
array(2) {
2222
["hash"]=>
23-
string(40) "%s"
23+
string(64) "%s"
2424
["hash_type"]=>
25-
string(5) "SHA-1"
25+
string(7) "SHA-256"
2626
}

ext/phar/tests/phar_setsignaturealgo2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ array(2) {
5353
["hash"]=>
5454
string(%d) "%s"
5555
["hash_type"]=>
56-
string(5) "SHA-1"
56+
string(7) "SHA-256"
5757
}
5858
array(2) {
5959
["hash"]=>

ext/phar/tests/tar/phar_setsignaturealgo2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ array(2) {
5252
["hash"]=>
5353
string(%d) "%s"
5454
["hash_type"]=>
55-
string(5) "SHA-1"
55+
string(7) "SHA-256"
5656
}
5757
array(2) {
5858
["hash"]=>

ext/phar/tests/zip/phar_setsignaturealgo2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ array(2) {
7979
["hash"]=>
8080
string(%d) "%s"
8181
["hash_type"]=>
82-
string(5) "SHA-1"
82+
string(7) "SHA-256"
8383
}
8484
array(2) {
8585
["hash"]=>

ext/phar/util.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,9 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signat
17981798
*signature_length = 64;
17991799
break;
18001800
}
1801+
default:
1802+
phar->sig_flags = PHAR_SIG_SHA256;
1803+
ZEND_FALLTHROUGH;
18011804
case PHAR_SIG_SHA256: {
18021805
unsigned char digest[32];
18031806
PHP_SHA256_CTX context;
@@ -1894,9 +1897,6 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signat
18941897
*signature_length = siglen;
18951898
}
18961899
break;
1897-
default:
1898-
phar->sig_flags = PHAR_SIG_SHA1;
1899-
ZEND_FALLTHROUGH;
19001900
case PHAR_SIG_SHA1: {
19011901
unsigned char digest[20];
19021902
PHP_SHA1_CTX context;

ext/phar/zip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, zend_long len, int
14201420

14211421
memcpy(eocd.signature, "PK\5\6", 4);
14221422
if (!phar->is_data && !phar->sig_flags) {
1423-
phar->sig_flags = PHAR_SIG_SHA1;
1423+
phar->sig_flags = PHAR_SIG_SHA256;
14241424
}
14251425
if (phar->sig_flags) {
14261426
PHAR_SET_16(eocd.counthere, zend_hash_num_elements(&phar->manifest) + 1);

0 commit comments

Comments
 (0)