Annotation of embedaddon/php/ext/hash/php_hash.h, revision 1.1.1.1
1.1 misho 1: /*
2: +----------------------------------------------------------------------+
3: | PHP Version 5 |
4: +----------------------------------------------------------------------+
5: | Copyright (c) 1997-2012 The PHP Group |
6: +----------------------------------------------------------------------+
7: | This source file is subject to version 3.01 of the PHP license, |
8: | that is bundled with this package in the file LICENSE, and is |
9: | available through the world-wide-web at the following url: |
10: | http://www.php.net/license/3_01.txt |
11: | If you did not receive a copy of the PHP license and are unable to |
12: | obtain it through the world-wide-web, please send a note to |
13: | license@php.net so we can mail you a copy immediately. |
14: +----------------------------------------------------------------------+
15: | Author: Sara Golemon <pollita@php.net> |
16: +----------------------------------------------------------------------+
17: */
18:
19: /* $Id: php_hash.h 321634 2012-01-01 13:15:04Z felipe $ */
20:
21: #ifndef PHP_HASH_H
22: #define PHP_HASH_H
23:
24: #include "php.h"
25: #include "php_hash_types.h"
26:
27: #define PHP_HASH_EXTNAME "hash"
28: #define PHP_HASH_EXTVER "1.0"
29: #define PHP_HASH_RESNAME "Hash Context"
30:
31: #define PHP_HASH_HMAC 0x0001
32:
33: typedef void (*php_hash_init_func_t)(void *context);
34: typedef void (*php_hash_update_func_t)(void *context, const unsigned char *buf, unsigned int count);
35: typedef void (*php_hash_final_func_t)(unsigned char *digest, void *context);
36: typedef int (*php_hash_copy_func_t)(const void *ops, void *orig_context, void *dest_context);
37:
38: typedef struct _php_hash_ops {
39: php_hash_init_func_t hash_init;
40: php_hash_update_func_t hash_update;
41: php_hash_final_func_t hash_final;
42: php_hash_copy_func_t hash_copy;
43:
44: int digest_size;
45: int block_size;
46: int context_size;
47: } php_hash_ops;
48:
49: typedef struct _php_hash_data {
50: const php_hash_ops *ops;
51: void *context;
52:
53: long options;
54: unsigned char *key;
55: } php_hash_data;
56:
57: extern const php_hash_ops php_hash_md2_ops;
58: extern const php_hash_ops php_hash_md4_ops;
59: extern const php_hash_ops php_hash_md5_ops;
60: extern const php_hash_ops php_hash_sha1_ops;
61: extern const php_hash_ops php_hash_sha224_ops;
62: extern const php_hash_ops php_hash_sha256_ops;
63: extern const php_hash_ops php_hash_sha384_ops;
64: extern const php_hash_ops php_hash_sha512_ops;
65: extern const php_hash_ops php_hash_ripemd128_ops;
66: extern const php_hash_ops php_hash_ripemd160_ops;
67: extern const php_hash_ops php_hash_ripemd256_ops;
68: extern const php_hash_ops php_hash_ripemd320_ops;
69: extern const php_hash_ops php_hash_whirlpool_ops;
70: extern const php_hash_ops php_hash_3tiger128_ops;
71: extern const php_hash_ops php_hash_3tiger160_ops;
72: extern const php_hash_ops php_hash_3tiger192_ops;
73: extern const php_hash_ops php_hash_4tiger128_ops;
74: extern const php_hash_ops php_hash_4tiger160_ops;
75: extern const php_hash_ops php_hash_4tiger192_ops;
76: extern const php_hash_ops php_hash_snefru_ops;
77: extern const php_hash_ops php_hash_gost_ops;
78: extern const php_hash_ops php_hash_adler32_ops;
79: extern const php_hash_ops php_hash_crc32_ops;
80: extern const php_hash_ops php_hash_crc32b_ops;
81: extern const php_hash_ops php_hash_salsa10_ops;
82: extern const php_hash_ops php_hash_salsa20_ops;
83:
84: #define PHP_HASH_HAVAL_OPS(p,b) extern const php_hash_ops php_hash_##p##haval##b##_ops;
85:
86: PHP_HASH_HAVAL_OPS(3,128)
87: PHP_HASH_HAVAL_OPS(3,160)
88: PHP_HASH_HAVAL_OPS(3,192)
89: PHP_HASH_HAVAL_OPS(3,224)
90: PHP_HASH_HAVAL_OPS(3,256)
91:
92: PHP_HASH_HAVAL_OPS(4,128)
93: PHP_HASH_HAVAL_OPS(4,160)
94: PHP_HASH_HAVAL_OPS(4,192)
95: PHP_HASH_HAVAL_OPS(4,224)
96: PHP_HASH_HAVAL_OPS(4,256)
97:
98: PHP_HASH_HAVAL_OPS(5,128)
99: PHP_HASH_HAVAL_OPS(5,160)
100: PHP_HASH_HAVAL_OPS(5,192)
101: PHP_HASH_HAVAL_OPS(5,224)
102: PHP_HASH_HAVAL_OPS(5,256)
103:
104: extern zend_module_entry hash_module_entry;
105: #define phpext_hash_ptr &hash_module_entry
106:
107: #ifdef PHP_WIN32
108: # define PHP_HASH_API __declspec(dllexport)
109: #elif defined(__GNUC__) && __GNUC__ >= 4
110: # define PHP_HASH_API __attribute__ ((visibility("default")))
111: #else
112: # define PHP_HASH_API
113: #endif
114:
115: #ifdef ZTS
116: #include "TSRM.h"
117: #endif
118:
119: PHP_FUNCTION(hash);
120: PHP_FUNCTION(hash_file);
121: PHP_FUNCTION(hash_hmac);
122: PHP_FUNCTION(hash_hmac_file);
123: PHP_FUNCTION(hash_init);
124: PHP_FUNCTION(hash_update);
125: PHP_FUNCTION(hash_update_stream);
126: PHP_FUNCTION(hash_update_file);
127: PHP_FUNCTION(hash_final);
128: PHP_FUNCTION(hash_algos);
129:
130: PHP_HASH_API const php_hash_ops *php_hash_fetch_ops(const char *algo, int algo_len);
131: PHP_HASH_API void php_hash_register_algo(const char *algo, const php_hash_ops *ops);
132: PHP_HASH_API int php_hash_copy(const void *ops, void *orig_context, void *dest_context);
133:
134: static inline void php_hash_bin2hex(char *out, const unsigned char *in, int in_len)
135: {
136: static const char hexits[17] = "0123456789abcdef";
137: int i;
138:
139: for(i = 0; i < in_len; i++) {
140: out[i * 2] = hexits[in[i] >> 4];
141: out[(i * 2) + 1] = hexits[in[i] & 0x0F];
142: }
143: }
144:
145: #endif /* PHP_HASH_H */
146:
147:
148: /*
149: * Local variables:
150: * tab-width: 4
151: * c-basic-offset: 4
152: * End:
153: * vim600: noet sw=4 ts=4 fdm=marker
154: * vim<600: noet sw=4 ts=4
155: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>