mirror of
https://github.com/php/php-src.git
synced 2026-04-12 10:33:11 +02:00
* Modify php_hash_ops to contain the algorithm name and serialize and unserialize methods. * Implement __serialize and __unserialize magic methods on HashContext. Note that serialized HashContexts are not necessarily portable between PHP versions or from architecture to architecture. (Most are, though Keccak and slow SHA3s are not.) An exception is thrown when an unsupported serialization is attempted. Because of security concerns, HASH_HMAC contexts are not currently serializable; attempting to serialize one throws an exception. Serialization exposes the state of HashContext memory, so ensure that memory is zeroed before use by allocating it with a new php_hash_alloc_context function. Performance impact is negligible. Some hash internal states have logical pointers into a buffer, or sponge, that absorbs input provided in bytes rather than chunks. The unserialize functions for these hash functions must validate that the logical pointers are all within bounds, lest future hash operations cause out-of-bounds memory accesses. * Adler32, CRC32, FNV, joaat: simple state, no buffer positions * Gost, MD2, SHA3, Snefru, Tiger, Whirlpool: buffer positions must be validated * MD4, MD5, SHA1, SHA2, haval, ripemd: buffer positions encoded bitwise, forced to within bounds on use; no need to validate
61 lines
2.0 KiB
PHP
61 lines
2.0 KiB
PHP
<?php
|
|
|
|
/** @generate-function-entries */
|
|
|
|
function hash(string $algo, string $data, bool $raw_output = false): string|false {}
|
|
|
|
function hash_file(string $algo, string $filename, bool $raw_output = false): string|false {}
|
|
|
|
function hash_hmac(string $algo, string $data, string $key, bool $raw_output = false): string|false {}
|
|
|
|
function hash_hmac_file(string $algo, string $data, string $key, bool $raw_output = false): string|false {}
|
|
|
|
function hash_init(string $algo, int $options = 0, string $key = ""): HashContext {}
|
|
|
|
function hash_update(HashContext $context, string $data): bool {}
|
|
|
|
/** @param resource $handle */
|
|
function hash_update_stream(HashContext $context, $handle, int $length = -1): int {}
|
|
|
|
/** @param resource $stream_context */
|
|
function hash_update_file(HashContext $context, string $filename, $stream_context = null): bool {}
|
|
|
|
function hash_final(HashContext $context, bool $raw_output = false): string {}
|
|
|
|
function hash_copy(HashContext $context): HashContext {}
|
|
|
|
function hash_algos(): array {}
|
|
|
|
function hash_hmac_algos(): array {}
|
|
|
|
function hash_pbkdf2(string $algo, string $password, string $salt, int $iterations, int $length = 0, bool $raw_output = false): string {}
|
|
|
|
/**
|
|
* @param $known_string no type juggling is performed
|
|
* @param $user_string no type juggling is performed
|
|
*/
|
|
function hash_equals(string $known_string, string $user_string): bool {}
|
|
|
|
function hash_hkdf(string $algo, string $ikm, int $length = 0, string $info = '', string $salt = ''): string {}
|
|
|
|
#ifdef PHP_MHASH_BC
|
|
function mhash_get_block_size(int $hash): int|false {}
|
|
|
|
function mhash_get_hash_name(int $hash): string|false {}
|
|
|
|
function mhash_keygen_s2k(int $hash, string $input_password, string $salt, int $bytes): string|false {}
|
|
|
|
function mhash_count(): int {}
|
|
|
|
function mhash(int $hash, string $data, string $key = UNKNOWN): string|false {}
|
|
#endif
|
|
|
|
final class HashContext
|
|
{
|
|
private function __construct() {}
|
|
|
|
public function __serialize(): array {}
|
|
|
|
public function __unserialize(array $serialized): void {}
|
|
}
|