php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
php_hash.h
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: Sara Golemon <pollita@php.net> |
14 +----------------------------------------------------------------------+
15*/
16
17#ifndef PHP_HASH_H
18#define PHP_HASH_H
19
20#include "php.h"
21
22#define PHP_HASH_EXTNAME "hash"
23#define PHP_HASH_VERSION PHP_VERSION
24#define PHP_MHASH_VERSION PHP_VERSION
25
26#define PHP_HASH_HMAC 0x0001
27
28#define PHP_HASH_SERIALIZE_MAGIC_SPEC 2
29
30#define L64 INT64_C
31
33
35typedef void (*php_hash_update_func_t)(void *context, const unsigned char *buf, size_t count);
36typedef void (*php_hash_final_func_t)(unsigned char *digest, void *context);
37typedef zend_result (*php_hash_copy_func_t)(const void *ops, const void *orig_context, void *dest_context);
40
56
66
67static inline php_hashcontext_object *php_hashcontext_from_object(zend_object *obj) {
68 return ((php_hashcontext_object*)(obj + 1)) - 1;
69}
70
115
116#define PHP_HASH_HAVAL_OPS(p,b) extern const php_hash_ops php_hash_##p##haval##b##_ops;
117
123
129
135
137#define phpext_hash_ptr &hash_module_entry
138
139#ifdef PHP_WIN32
140# define PHP_HASH_API __declspec(dllexport)
141#elif defined(__GNUC__) && __GNUC__ >= 4
142# define PHP_HASH_API __attribute__ ((visibility("default")))
143#else
144# define PHP_HASH_API
145#endif
146
149PHP_HASH_API void php_hash_register_algo(const char *algo, const php_hash_ops *ops);
150PHP_HASH_API zend_result php_hash_copy(const void *ops, const void *orig_context, void *dest_context);
155
156static inline void *php_hash_alloc_context(const php_hash_ops *ops) {
157 /* Zero out context memory so serialization doesn't expose internals */
158 return ecalloc(1, ops->context_size);
159}
160
161static inline void php_hash_bin2hex(char *out, const unsigned char *in, size_t in_len)
162{
163 static const char hexits[17] = "0123456789abcdef";
164 size_t i;
165
166 for(i = 0; i < in_len; i++) {
167 out[i * 2] = hexits[in[i] >> 4];
168 out[(i * 2) + 1] = hexits[in[i] & 0x0F];
169 }
170}
171
172#endif /* PHP_HASH_H */
count(Countable|array $value, int $mode=COUNT_NORMAL)
zval * zv
Definition ffi.c:3975
zend_ffi_ctype_name_buf buf
Definition ffi.c:4685
const php_stream_filter_ops * ops
Definition filters.c:1899
zend_module_entry hash_module_entry
Definition hash.c:1707
zend_class_entry * php_hashcontext_ce
Definition hash.c:45
hash(string $algo, string $data, bool $binary=false, array $options=[])
Definition hash.stub.php:12
const php_hash_ops php_hash_adler32_ops
const php_hash_ops php_hash_crc32c_ops
Definition hash_crc32.c:123
const php_hash_ops php_hash_crc32b_ops
Definition hash_crc32.c:108
const php_hash_ops php_hash_crc32_ops
Definition hash_crc32.c:93
const php_hash_ops php_hash_fnv1a32_ops
Definition hash_fnv.c:38
const php_hash_ops php_hash_fnv1a64_ops
Definition hash_fnv.c:68
const php_hash_ops php_hash_fnv132_ops
Definition hash_fnv.c:23
const php_hash_ops php_hash_fnv164_ops
Definition hash_fnv.c:53
const php_hash_ops php_hash_gost_crypto_ops
Definition hash_gost.c:335
const php_hash_ops php_hash_gost_ops
Definition hash_gost.c:320
const php_hash_ops php_hash_joaat_ops
Definition hash_joaat.c:24
const php_hash_ops php_hash_md2_ops
Definition hash_md.c:52
const php_hash_ops php_hash_md4_ops
Definition hash_md.c:35
const php_hash_ops php_hash_md5_ops
Definition hash_md.c:20
const php_hash_ops php_hash_murmur3c_ops
Definition hash_murmur.c:86
const php_hash_ops php_hash_murmur3f_ops
const php_hash_ops php_hash_murmur3a_ops
Definition hash_murmur.c:24
const php_hash_ops php_hash_ripemd128_ops
Definition hash_ripemd.c:24
const php_hash_ops php_hash_ripemd160_ops
Definition hash_ripemd.c:39
const php_hash_ops php_hash_ripemd320_ops
Definition hash_ripemd.c:69
const php_hash_ops php_hash_ripemd256_ops
Definition hash_ripemd.c:54
const php_hash_ops php_hash_sha256_ops
Definition hash_sha.c:83
const php_hash_ops php_hash_sha384_ops
Definition hash_sha.c:615
const php_hash_ops php_hash_sha1_ops
Definition hash_sha.c:66
const php_hash_ops php_hash_sha512_224_ops
Definition hash_sha.c:824
const php_hash_ops php_hash_sha224_ops
Definition hash_sha.c:98
const php_hash_ops php_hash_sha512_256_ops
Definition hash_sha.c:809
const php_hash_ops php_hash_sha512_ops
Definition hash_sha.c:794
const php_hash_ops php_hash_snefru_ops
const php_hash_ops php_hash_whirlpool_ops
const php_hash_ops php_hash_xxh32_ops
Definition hash_xxhash.c:25
const php_hash_ops php_hash_xxh3_128_ops
const php_hash_ops php_hash_xxh3_64_ops
const php_hash_ops php_hash_xxh64_ops
Definition hash_xxhash.c:92
PHP_HASH_API zend_result php_hash_copy(const void *ops, const void *orig_context, void *dest_context)
Definition hash.c:124
zend_result(* php_hash_serialize_func_t)(const php_hashcontext_object *hash, zend_long *magic, zval *zv)
Definition php_hash.h:38
void(* php_hash_final_func_t)(unsigned char *digest, void *context)
Definition php_hash.h:36
PHP_HASH_API zend_result php_hash_serialize_spec(const php_hashcontext_object *context, zval *zv, const char *spec)
Definition hash.c:232
#define PHP_HASH_HAVAL_OPS(p, b)
Definition php_hash.h:116
const php_hash_ops php_hash_sha3_256_ops
const php_hash_ops php_hash_sha3_224_ops
zend_result(* php_hash_copy_func_t)(const void *ops, const void *orig_context, void *dest_context)
Definition php_hash.h:37
struct _php_hashcontext_object php_hashcontext_object
Definition php_hash.h:32
const php_hash_ops php_hash_4tiger128_ops
const php_hash_ops php_hash_3tiger128_ops
void(* php_hash_init_func_t)(void *context, HashTable *args)
Definition php_hash.h:34
void(* php_hash_update_func_t)(void *context, const unsigned char *buf, size_t count)
Definition php_hash.h:35
const php_hash_ops php_hash_3tiger192_ops
#define PHP_HASH_API
Definition php_hash.h:144
PHP_HASH_API void php_hash_register_algo(const char *algo, const php_hash_ops *ops)
Definition hash.c:115
const php_hash_ops php_hash_4tiger160_ops
PHP_HASH_API int php_hash_unserialize_spec(php_hashcontext_object *hash, const zval *zv, const char *spec)
Definition hash.c:280
const php_hash_ops php_hash_sha3_384_ops
const php_hash_ops php_hash_4tiger192_ops
const php_hash_ops php_hash_3tiger160_ops
PHP_HASH_API int php_hash_unserialize(php_hashcontext_object *context, zend_long magic, const zval *zv)
Definition hash.c:345
struct _php_hash_ops php_hash_ops
PHP_HASH_API zend_result php_hash_serialize(const php_hashcontext_object *context, zend_long *magic, zval *zv)
Definition hash.c:334
int(* php_hash_unserialize_func_t)(php_hashcontext_object *hash, zend_long magic, const zval *zv)
Definition php_hash.h:39
PHP_HASH_API const php_hash_ops * php_hash_fetch_ops(zend_string *algo)
Definition hash.c:105
const php_hash_ops php_hash_sha3_512_ops
const char * serialize_spec
Definition php_hash.h:49
size_t block_size
Definition php_hash.h:52
unsigned is_crypto
Definition php_hash.h:54
php_hash_update_func_t hash_update
Definition php_hash.h:44
php_hash_copy_func_t hash_copy
Definition php_hash.h:46
const char * algo
Definition php_hash.h:42
php_hash_unserialize_func_t hash_unserialize
Definition php_hash.h:48
size_t context_size
Definition php_hash.h:53
php_hash_serialize_func_t hash_serialize
Definition php_hash.h:47
php_hash_init_func_t hash_init
Definition php_hash.h:43
size_t digest_size
Definition php_hash.h:51
php_hash_final_func_t hash_final
Definition php_hash.h:45
unsigned char * key
Definition php_hash.h:62
const php_hash_ops * ops
Definition php_hash.h:58
Definition dce.c:49
Definition file.h:202
#define ecalloc(nmemb, size)
Definition zend_alloc.h:158
struct _zval_struct zval
zval * args
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)
int32_t zend_long
Definition zend_long.h:42
struct _zend_string zend_string
struct _zend_module_entry zend_module_entry
struct _zend_class_entry zend_class_entry
struct _zend_object zend_object
struct _zend_array HashTable
Definition zend_types.h:386
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
out($f, $s)