mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-12 11:25:35 +08:00
28 lines
1.0 KiB
PHP
28 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Package\Artifact;
|
|
|
|
use StaticPHP\Attribute\Artifact\AfterSourceExtract;
|
|
use StaticPHP\Attribute\PatchDescription;
|
|
use StaticPHP\Util\FileSystem;
|
|
|
|
class gmssl
|
|
{
|
|
#[AfterSourceExtract('gmssl')]
|
|
#[PatchDescription('Patch gmssl hex.c to rename OPENSSL functions to GMSSL')]
|
|
public function patch(string $target_path): void
|
|
{
|
|
FileSystem::replaceFileStr($target_path . '/src/hex.c', 'unsigned char *OPENSSL_hexstr2buf(const char *str, size_t *len)', 'unsigned char *GMSSL_hexstr2buf(const char *str, size_t *len)');
|
|
FileSystem::replaceFileStr($target_path . '/src/hex.c', 'OPENSSL_hexchar2int', 'GMSSL_hexchar2int');
|
|
}
|
|
|
|
#[AfterSourceExtract('ext-gmssl')]
|
|
#[PatchDescription('Rename pbkdf2_hmac_sm3_genkey() to sm3_pbkdf2() (renamed upstream in GmSSL 3.2+; identical signature)')]
|
|
public function patchExt(string $target_path): void
|
|
{
|
|
FileSystem::replaceFileStr($target_path . '/gmssl.c', 'pbkdf2_hmac_sm3_genkey(', 'sm3_pbkdf2(');
|
|
}
|
|
}
|