Skip to content

Commit fa5a4cc

Browse files
authored
Merge pull request #16 from LibreSign/backport/14/stable31
chore: backport of PR 14
2 parents 898ff0c + bb7b21c commit fa5a4cc

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
@@ -93,6 +93,33 @@ static function (string $filePath, string $prefix, string $content): string {
9393
$s_prefix = str_replace('\\', '\\\\', $prefix);
9494
$content = str_replace("'phpseclib3\\\\", "'\\\\" . $s_prefix . '\\\\phpseclib3\\\\', $content);
9595
$content = str_replace("'\\\\phpseclib3", "'\\\\" . $s_prefix . '\\\\phpseclib3', $content);
96+
97+
// Specific patch for Crypt/RSA/Formats/Keys/PSS.php: handle saltLength being an int or an object
98+
if (str_contains($filePath, 'Crypt/RSA/Formats/Keys/PSS.php')) {
99+
$search = '$result[\'saltLength\'] = (int) $params[\'saltLength\']->toString();';
100+
$replace = <<<'PHP'
101+
if (is_int($params['saltLength'])) {
102+
$result['saltLength'] = $params['saltLength'];
103+
} else {
104+
$result['saltLength'] = (int) $params['saltLength']->toString();
105+
}
106+
PHP;
107+
if (strpos($content, $search) !== false) {
108+
$content = str_replace($search, $replace, $content);
109+
} else {
110+
$content = preg_replace(
111+
'/\$result\\[\\\'saltLength\\\']\\s*=\\s*\\(int\\)\\s*\\$params\\[\\\'saltLength\\\']\\->toString\\(\\);/m',
112+
$replace,
113+
$content
114+
);
115+
}
116+
}
117+
118+
// Specific patch for File/X509.php: update docblock param type for $crl to string|array
119+
if (str_contains($filePath, 'File/X509.php')) {
120+
$content = str_replace('@param string $crl', '@param string|array $crl', $content);
121+
}
122+
96123
return $content;
97124
},
98125
// patchers for pdfparser

0 commit comments

Comments
 (0)