Back to index

php5  5.3.10
php_hash.h
Go to the documentation of this file.
00001 /*
00002   +----------------------------------------------------------------------+
00003   | PHP Version 5                                                        |
00004   +----------------------------------------------------------------------+
00005   | Copyright (c) 1997-2012 The PHP Group                                |
00006   +----------------------------------------------------------------------+
00007   | This source file is subject to version 3.01 of the PHP license,      |
00008   | that is bundled with this package in the file LICENSE, and is        |
00009   | available through the world-wide-web at the following url:           |
00010   | http://www.php.net/license/3_01.txt                                  |
00011   | If you did not receive a copy of the PHP license and are unable to   |
00012   | obtain it through the world-wide-web, please send a note to          |
00013   | license@php.net so we can mail you a copy immediately.               |
00014   +----------------------------------------------------------------------+
00015   | Author: Sara Golemon <pollita@php.net>                               |
00016   +----------------------------------------------------------------------+
00017 */
00018 
00019 /* $Id: php_hash.h 321634 2012-01-01 13:15:04Z felipe $ */
00020 
00021 #ifndef PHP_HASH_H
00022 #define PHP_HASH_H
00023 
00024 #include "php.h"
00025 #include "php_hash_types.h"
00026 
00027 #define PHP_HASH_EXTNAME    "hash"
00028 #define PHP_HASH_EXTVER            "1.0"
00029 #define PHP_HASH_RESNAME    "Hash Context"
00030 
00031 #define PHP_HASH_HMAC              0x0001
00032 
00033 typedef void (*php_hash_init_func_t)(void *context);
00034 typedef void (*php_hash_update_func_t)(void *context, const unsigned char *buf, unsigned int count);
00035 typedef void (*php_hash_final_func_t)(unsigned char *digest, void *context);
00036 typedef int  (*php_hash_copy_func_t)(const void *ops, void *orig_context, void *dest_context);
00037 
00038 typedef struct _php_hash_ops {
00039        php_hash_init_func_t hash_init;
00040        php_hash_update_func_t hash_update;
00041        php_hash_final_func_t hash_final;
00042        php_hash_copy_func_t hash_copy;
00043 
00044        int digest_size;
00045        int block_size;
00046        int context_size;
00047 } php_hash_ops;
00048 
00049 typedef struct _php_hash_data {
00050        const php_hash_ops *ops;
00051        void *context;
00052 
00053        long options;
00054        unsigned char *key;
00055 } php_hash_data;
00056 
00057 extern const php_hash_ops php_hash_md2_ops;
00058 extern const php_hash_ops php_hash_md4_ops;
00059 extern const php_hash_ops php_hash_md5_ops;
00060 extern const php_hash_ops php_hash_sha1_ops;
00061 extern const php_hash_ops php_hash_sha224_ops;
00062 extern const php_hash_ops php_hash_sha256_ops;
00063 extern const php_hash_ops php_hash_sha384_ops;
00064 extern const php_hash_ops php_hash_sha512_ops;
00065 extern const php_hash_ops php_hash_ripemd128_ops;
00066 extern const php_hash_ops php_hash_ripemd160_ops;
00067 extern const php_hash_ops php_hash_ripemd256_ops;
00068 extern const php_hash_ops php_hash_ripemd320_ops;
00069 extern const php_hash_ops php_hash_whirlpool_ops;
00070 extern const php_hash_ops php_hash_3tiger128_ops;
00071 extern const php_hash_ops php_hash_3tiger160_ops;
00072 extern const php_hash_ops php_hash_3tiger192_ops;
00073 extern const php_hash_ops php_hash_4tiger128_ops;
00074 extern const php_hash_ops php_hash_4tiger160_ops;
00075 extern const php_hash_ops php_hash_4tiger192_ops;
00076 extern const php_hash_ops php_hash_snefru_ops;
00077 extern const php_hash_ops php_hash_gost_ops;
00078 extern const php_hash_ops php_hash_adler32_ops;
00079 extern const php_hash_ops php_hash_crc32_ops;
00080 extern const php_hash_ops php_hash_crc32b_ops;
00081 extern const php_hash_ops php_hash_salsa10_ops;
00082 extern const php_hash_ops php_hash_salsa20_ops;
00083 
00084 #define PHP_HASH_HAVAL_OPS(p,b)    extern const php_hash_ops php_hash_##p##haval##b##_ops;
00085 
00086 PHP_HASH_HAVAL_OPS(3,128)
00087 PHP_HASH_HAVAL_OPS(3,160)
00088 PHP_HASH_HAVAL_OPS(3,192)
00089 PHP_HASH_HAVAL_OPS(3,224)
00090 PHP_HASH_HAVAL_OPS(3,256)
00091 
00092 PHP_HASH_HAVAL_OPS(4,128)
00093 PHP_HASH_HAVAL_OPS(4,160)
00094 PHP_HASH_HAVAL_OPS(4,192)
00095 PHP_HASH_HAVAL_OPS(4,224)
00096 PHP_HASH_HAVAL_OPS(4,256)
00097 
00098 PHP_HASH_HAVAL_OPS(5,128)
00099 PHP_HASH_HAVAL_OPS(5,160)
00100 PHP_HASH_HAVAL_OPS(5,192)
00101 PHP_HASH_HAVAL_OPS(5,224)
00102 PHP_HASH_HAVAL_OPS(5,256)
00103 
00104 extern zend_module_entry hash_module_entry;
00105 #define phpext_hash_ptr &hash_module_entry
00106 
00107 #ifdef PHP_WIN32
00108 #      define PHP_HASH_API __declspec(dllexport)
00109 #elif defined(__GNUC__) && __GNUC__ >= 4
00110 #      define PHP_HASH_API __attribute__ ((visibility("default")))
00111 #else
00112 #      define PHP_HASH_API
00113 #endif
00114 
00115 #ifdef ZTS
00116 #include "TSRM.h"
00117 #endif
00118 
00119 PHP_FUNCTION(hash);
00120 PHP_FUNCTION(hash_file);
00121 PHP_FUNCTION(hash_hmac);
00122 PHP_FUNCTION(hash_hmac_file);
00123 PHP_FUNCTION(hash_init);
00124 PHP_FUNCTION(hash_update);
00125 PHP_FUNCTION(hash_update_stream);
00126 PHP_FUNCTION(hash_update_file);
00127 PHP_FUNCTION(hash_final);
00128 PHP_FUNCTION(hash_algos);
00129 
00130 PHP_HASH_API const php_hash_ops *php_hash_fetch_ops(const char *algo, int algo_len);
00131 PHP_HASH_API void php_hash_register_algo(const char *algo, const php_hash_ops *ops);
00132 PHP_HASH_API int php_hash_copy(const void *ops, void *orig_context, void *dest_context);
00133 
00134 static inline void php_hash_bin2hex(char *out, const unsigned char *in, int in_len)
00135 {
00136        static const char hexits[17] = "0123456789abcdef";
00137        int i;
00138 
00139        for(i = 0; i < in_len; i++) {
00140               out[i * 2]       = hexits[in[i] >> 4];
00141               out[(i * 2) + 1] = hexits[in[i] &  0x0F];
00142        }
00143 }
00144 
00145 #endif /* PHP_HASH_H */
00146 
00147 
00148 /*
00149  * Local variables:
00150  * tab-width: 4
00151  * c-basic-offset: 4
00152  * End:
00153  * vim600: noet sw=4 ts=4 fdm=marker
00154  * vim<600: noet sw=4 ts=4
00155  */