Skip to content

Commit e32e96a

Browse files
committed
chore: backport of PR 14
Signed-off-by: Vitor Mattos <[email protected]>
1 parent b1fe557 commit e32e96a

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

composer/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PSS.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ public static function load($key, $password = '')
110110
$result['hash'] = \str_replace('id-', '', $params['hashAlgorithm']['algorithm']);
111111
$result['MGFHash'] = \str_replace('id-', '', $params['maskGenAlgorithm']['parameters']['algorithm']);
112112
if (isset($params['saltLength'])) {
113-
$result['saltLength'] = (int) $params['saltLength']->toString();
113+
if (is_int($params['saltLength'])) {
114+
$result['saltLength'] = $params['saltLength'];
115+
} else {
116+
$result['saltLength'] = (int) $params['saltLength']->toString();
117+
}
114118
}
115119
if (isset($key['meta'])) {
116120
$result['meta'] = $key['meta'];

composer/phpseclib/phpseclib/phpseclib/File/X509.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2127,7 +2127,7 @@ public function saveSPKAC(array $spkac, $format = self::FORMAT_PEM)
21272127
/**
21282128
* Load a Certificate Revocation List
21292129
*
2130-
* @param string $crl
2130+
* @param string|array $crl
21312131
* @param int $mode
21322132
* @return mixed
21332133
*/

scoper.inc.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,33 @@ static function (string $filePath, string $prefix, string $content): string {
8585
$s_prefix = str_replace('\\', '\\\\', $prefix);
8686
$content = str_replace("'phpseclib3\\\\", "'\\\\" . $s_prefix . '\\\\phpseclib3\\\\', $content);
8787
$content = str_replace("'\\\\phpseclib3", "'\\\\" . $s_prefix . '\\\\phpseclib3', $content);
88+
89+
// Specific patch for Crypt/RSA/Formats/Keys/PSS.php: handle saltLength being an int or an object
90+
if (str_contains($filePath, 'Crypt/RSA/Formats/Keys/PSS.php')) {
91+
$search = '$result[\'saltLength\'] = (int) $params[\'saltLength\']->toString();';
92+
$replace = <<<'PHP'
93+
if (is_int($params['saltLength'])) {
94+
$result['saltLength'] = $params['saltLength'];
95+
} else {
96+
$result['saltLength'] = (int) $params['saltLength']->toString();
97+
}
98+
PHP;
99+
if (strpos($content, $search) !== false) {
100+
$content = str_replace($search, $replace, $content);
101+
} else {
102+
$content = preg_replace(
103+
'/\$result\\[\\\'saltLength\\\']\\s*=\\s*\\(int\\)\\s*\\$params\\[\\\'saltLength\\\']\\->toString\\(\\);/m',
104+
$replace,
105+
$content
106+
);
107+
}
108+
}
109+
110+
// Specific patch for File/X509.php: update docblock param type for $crl to string|array
111+
if (str_contains($filePath, 'File/X509.php')) {
112+
$content = str_replace('@param string $crl', '@param string|array $crl', $content);
113+
}
114+
88115
return $content;
89116
},
90117
// patchers for pdfparser

0 commit comments

Comments
 (0)