Add openssl argon2 password hash support for PHP 8.5

This commit is contained in:
crazywhalecc 2025-07-30 23:02:28 +08:00
parent 9ed3c8b498
commit 5f5d934d58
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
5 changed files with 37 additions and 3 deletions

View File

@ -26,6 +26,14 @@ class openssl extends Extension
public function getUnixConfigureArg(bool $shared = false): string public function getUnixConfigureArg(bool $shared = false): string
{ {
$openssl_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : ' --with-openssl-dir=' . BUILD_ROOT_PATH; $openssl_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : ' --with-openssl-dir=' . BUILD_ROOT_PATH;
return '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir; $args = '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir;
if (
$this->builder->getPHPVersionID() >= 80500 &&
($ver = $this->builder->getLib('openssl')->getLibVersion()) &&
version_compare($ver, '3.2.0', '>=')
) {
$args .= ' --with-openssl-argon2 OPENSSL_LIBS="-lz"';
}
return $args;
} }
} }

View File

@ -29,6 +29,8 @@ use SPC\store\FileSystem;
class openssl extends LinuxLibraryBase class openssl extends LinuxLibraryBase
{ {
use \SPC\builder\unix\library\openssl;
public const NAME = 'openssl'; public const NAME = 'openssl';
/** /**
@ -38,8 +40,6 @@ class openssl extends LinuxLibraryBase
*/ */
public function build(): void public function build(): void
{ {
[,,$destdir] = SEPARATED_PATH;
$extra = ''; $extra = '';
$ex_lib = '-ldl -pthread'; $ex_lib = '-ldl -pthread';
$arch = getenv('SPC_ARCH'); $arch = getenv('SPC_ARCH');

View File

@ -28,6 +28,8 @@ use SPC\store\FileSystem;
class openssl extends MacOSLibraryBase class openssl extends MacOSLibraryBase
{ {
use \SPC\builder\unix\library\openssl;
public const NAME = 'openssl'; public const NAME = 'openssl';
/** /**

View File

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
trait openssl
{
public function getLibVersion(): ?string
{
// get openssl version from source directory
if (file_exists("{$this->source_dir}/VERSION.dat")) {
// parse as INI
$version = parse_ini_file("{$this->source_dir}/VERSION.dat");
if ($version !== false) {
return "{$version['MAJOR']}.{$version['MINOR']}.{$version['PATCH']}";
}
}
return null;
}
}

View File

@ -7,3 +7,6 @@ assert(openssl_digest('123456', 'md5') === 'e10adc3949ba59abbe56e057f20f883e');
if (file_exists('/etc/ssl/openssl.cnf')) { if (file_exists('/etc/ssl/openssl.cnf')) {
assert(file_get_contents('https://captive.apple.com/') !== false); assert(file_get_contents('https://captive.apple.com/') !== false);
} }
if (PHP_VERSION_ID >= 80500 && defined('OPENSSL_VERSION_NUMBER') && OPENSSL_VERSION_NUMBER >= 0x30200000) {
assert(function_exists('openssl_password_hash'));
}