xref: /PHP-5.5/ext/mcrypt/php_mcrypt.h (revision c02c4aca)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 5                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2015 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    | Authors: Sascha Schumann <sascha@schumann.cx>                        |
16    |          Derick Rethans <derick@derickrethans.nl>                    |
17    +----------------------------------------------------------------------+
18  */
19 /* $Id$ */
20 
21 #ifndef PHP_MCRYPT_H
22 #define PHP_MCRYPT_H
23 
24 #if HAVE_LIBMCRYPT
25 
26 #ifdef ZTS
27 #include "TSRM.h"
28 #endif
29 
30 extern zend_module_entry mcrypt_module_entry;
31 #define mcrypt_module_ptr &mcrypt_module_entry
32 
33 /* Functions for both old and new API */
34 PHP_FUNCTION(mcrypt_ecb);
35 PHP_FUNCTION(mcrypt_cbc);
36 PHP_FUNCTION(mcrypt_cfb);
37 PHP_FUNCTION(mcrypt_ofb);
38 PHP_FUNCTION(mcrypt_get_cipher_name);
39 PHP_FUNCTION(mcrypt_get_block_size);
40 PHP_FUNCTION(mcrypt_get_key_size);
41 PHP_FUNCTION(mcrypt_create_iv);
42 
43 /* Support functions for old API */
44 PHP_FUNCTION(mcrypt_list_algorithms);
45 PHP_FUNCTION(mcrypt_list_modes);
46 PHP_FUNCTION(mcrypt_get_iv_size);
47 PHP_FUNCTION(mcrypt_encrypt);
48 PHP_FUNCTION(mcrypt_decrypt);
49 
50 /* Functions for new API */
51 PHP_FUNCTION(mcrypt_module_open);
52 PHP_FUNCTION(mcrypt_generic_init);
53 PHP_FUNCTION(mcrypt_generic);
54 PHP_FUNCTION(mdecrypt_generic);
55 PHP_FUNCTION(mcrypt_generic_deinit);
56 
57 PHP_FUNCTION(mcrypt_enc_self_test);
58 PHP_FUNCTION(mcrypt_enc_is_block_algorithm_mode);
59 PHP_FUNCTION(mcrypt_enc_is_block_algorithm);
60 PHP_FUNCTION(mcrypt_enc_is_block_mode);
61 PHP_FUNCTION(mcrypt_enc_get_block_size);
62 PHP_FUNCTION(mcrypt_enc_get_key_size);
63 PHP_FUNCTION(mcrypt_enc_get_supported_key_sizes);
64 PHP_FUNCTION(mcrypt_enc_get_iv_size);
65 PHP_FUNCTION(mcrypt_enc_get_algorithms_name);
66 PHP_FUNCTION(mcrypt_enc_get_modes_name);
67 PHP_FUNCTION(mcrypt_module_self_test);
68 PHP_FUNCTION(mcrypt_module_is_block_algorithm_mode);
69 PHP_FUNCTION(mcrypt_module_is_block_algorithm);
70 PHP_FUNCTION(mcrypt_module_is_block_mode);
71 PHP_FUNCTION(mcrypt_module_get_algo_block_size);
72 PHP_FUNCTION(mcrypt_module_get_algo_key_size);
73 PHP_FUNCTION(mcrypt_module_get_supported_key_sizes);
74 PHP_FUNCTION(mcrypt_module_close);
75 
76 ZEND_BEGIN_MODULE_GLOBALS(mcrypt)
77 	int le_h;
78 	char *modes_dir;
79 	char *algorithms_dir;
80 	int fd[2]; // RANDOM = 0, URANDOM = 1
81 ZEND_END_MODULE_GLOBALS(mcrypt)
82 
83 #ifdef ZTS
84 # define MCG(v)    TSRMG(mcrypt_globals_id, zend_mcrypt_globals *, v)
85 #else
86 # define MCG(v)    (mcrypt_globals.v)
87 #endif
88 
89 #else
90 #define mcrypt_module_ptr NULL
91 #endif
92 
93 #define phpext_mcrypt_ptr mcrypt_module_ptr
94 
95 #endif
96