Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/bootstrap-inventory-lint-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -5166,8 +5166,8 @@
"lib/JIT/Builtin/StringHashCryptoJit.php": [
"Cannot use PHPCompiler\\JIT\\Context as Context because the name is already in use on line 7"
],
"lib/JIT/Builtin/StringHashCryptoNativeJit.php": [
"Cannot use PHPCompiler\\JIT\\BasicBlockHelper as BasicBlockHelper because the name is already in use on line 7"
"lib/JIT/Builtin/StringHashCryptoPhp.php": [
"Cannot use PHPCompiler\\JIT\\Context as Context because the name is already in use on line 8"
],
"lib/JIT/Builtin/StringHashEquals.php": [
"Cannot use PHPCompiler\\JIT\\BasicBlockHelper as BasicBlockHelper because the name is already in use on line 7"
Expand Down
12 changes: 9 additions & 3 deletions docs/bootstrap-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ Rank live CFG gaps across inventory files: `php script/bootstrap-inventory-triag
| `ext/standard/GetoptJitHelper.php` | 0 | 1 |
| `ext/standard/GetrusageJitHelper.php` | 0 | 1 |
| `ext/standard/HashEqualsJitHelper.php` | 0 | 1 |
| `ext/standard/HashCryptoJitHelper.php` | 0 | 1 |
| `ext/standard/HebrevJitHelper.php` | 0 | 1 |
| `ext/standard/HighlightEngine.php` | 0 | 2 |
| `ext/standard/HighlightJitHelper.php` | 0 | 1 |
Expand Down Expand Up @@ -2174,7 +2175,7 @@ Rank live CFG gaps across inventory files: `php script/bootstrap-inventory-triag
| `lib/JIT/Builtin/StringGmmktime.php` | 0 | 1 |
| `lib/JIT/Builtin/StringHashCrypto.php` | 0 | 1 |
| `lib/JIT/Builtin/StringHashCryptoJit.php` | 0 | 1 |
| `lib/JIT/Builtin/StringHashCryptoNativeJit.php` | 0 | 1 |
| `lib/JIT/Builtin/StringHashCryptoPhp.php` | 0 | 1 |
| `lib/JIT/Builtin/StringHashEquals.php` | 0 | 3 |
| `lib/JIT/Builtin/StringHashHmacAlgos.php` | 0 | 1 |
| `lib/JIT/Builtin/StringHrtime.php` | 0 | 1 |
Expand Down Expand Up @@ -5015,6 +5016,11 @@ Rank live CFG gaps across inventory files: `php script/bootstrap-inventory-triag
**Warnings** (review for bootstrap subset):
- 1 class method(s)

### `ext/standard/HashCryptoJitHelper.php`

**Warnings** (review for bootstrap subset):
- 4 class method(s)

### `ext/standard/HebrevJitHelper.php`

**Warnings** (review for bootstrap subset):
Expand Down Expand Up @@ -17072,10 +17078,10 @@ Rank live CFG gaps across inventory files: `php script/bootstrap-inventory-triag
**Warnings** (review for bootstrap subset):
- 2 class method(s)

### `lib/JIT/Builtin/StringHashCryptoNativeJit.php`
### `lib/JIT/Builtin/StringHashCryptoPhp.php`

**Warnings** (review for bootstrap subset):
- 56 class method(s)
- 8 class method(s)

### `lib/JIT/Builtin/StringHashEquals.php`

Expand Down
2 changes: 1 addition & 1 deletion docs/bootstrap-profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@
"lib/JIT/Builtin/StringGmmktime.php",
"lib/JIT/Builtin/StringHashCrypto.php",
"lib/JIT/Builtin/StringHashCryptoJit.php",
"lib/JIT/Builtin/StringHashCryptoNativeJit.php",
"lib/JIT/Builtin/StringHashCryptoPhp.php",
"lib/JIT/Builtin/StringHashEquals.php",
"lib/JIT/Builtin/StringHashHmacAlgos.php",
"lib/JIT/Builtin/StringHrtime.php",
Expand Down
45 changes: 45 additions & 0 deletions ext/standard/HashCryptoJitHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace PHPCompiler\ext\standard;

/**
* hash() / hash_hmac() / hash_pbkdf2() / hash_hkdf() for compiled JIT/AOT modules (#9164, php-in-PHP).
*
* SSOT: {@see VmHash}
* php-src: ext/standard/hash.c, ext/standard/hash_hmac.c
*/
final class HashCryptoJitHelper
{
public static function hash(string $algo, string $data, bool $raw): string
{
return VmHash::hash($algo, $data, $raw);
}

public static function hashHmac(string $algo, string $data, string $key, bool $raw): string|false
{
return VmHash::hashHmac($algo, $data, $key, $raw);
}

public static function hashPbkdf2(
string $algo,
string $password,
string $salt,
int $iterations,
int $length,
bool $raw
): string {
return VmHash::hashPbkdf2($algo, $password, $salt, $iterations, $length, $raw);
}

public static function hashHkdf(
string $algo,
string $key,
int $length,
string $info,
string $salt
): string {
return VmHash::hashHkdf($algo, $key, $length, $info, $salt);
}
}
4 changes: 2 additions & 2 deletions lib/JIT/Builtin/StringHashCryptoJit.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* LLVM lowering for hash() / hash_hmac() / hash_pbkdf2() / hash_equals() / hash_hmac_algos().
*
* Digest helpers lowered in PHP LLVM via {@see StringHashCryptoNativeJit} (#7189, #7437).
* Digest helpers via {@see StringHashCryptoPhp} → HashCryptoJitHelper → VmHash (#9164).
* hash_equals / hash_hmac_algos via {@see StringHashEquals} / {@see StringHashHmacAlgos} (#7189).
*/
final class StringHashCryptoJit
Expand All @@ -28,7 +28,7 @@ public static function implement(Context $context): void
{
StringHashEquals::ensureLinked($context);
StringHashHmacAlgos::ensureLinked($context);
StringHashCryptoNativeJit::implement($context);
StringHashCryptoPhp::implement($context);

self::registerLinkedRuntime($context);
}
Expand Down
Loading