xref: /PHP-7.0/ext/mcrypt/php_mcrypt.h (revision 478f119a)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2017 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 #include "php_version.h"
34 #define PHP_MCRYPT_VERSION PHP_VERSION
35 
36 /* Functions for both old and new API */
37 PHP_FUNCTION(mcrypt_ecb);
38 PHP_FUNCTION(mcrypt_cbc);
39 PHP_FUNCTION(mcrypt_cfb);
40 PHP_FUNCTION(mcrypt_ofb);
41 PHP_FUNCTION(mcrypt_get_cipher_name);
42 PHP_FUNCTION(mcrypt_get_block_size);
43 PHP_FUNCTION(mcrypt_get_key_size);
44 PHP_FUNCTION(mcrypt_create_iv);
45 
46 /* Support functions for old API */
47 PHP_FUNCTION(mcrypt_list_algorithms);
48 PHP_FUNCTION(mcrypt_list_modes);
49 PHP_FUNCTION(mcrypt_get_iv_size);
50 PHP_FUNCTION(mcrypt_encrypt);
51 PHP_FUNCTION(mcrypt_decrypt);
52 
53 /* Functions for new API */
54 PHP_FUNCTION(mcrypt_module_open);
55 PHP_FUNCTION(mcrypt_generic_init);
56 PHP_FUNCTION(mcrypt_generic);
57 PHP_FUNCTION(mdecrypt_generic);
58 PHP_FUNCTION(mcrypt_generic_deinit);
59 
60 PHP_FUNCTION(mcrypt_enc_self_test);
61 PHP_FUNCTION(mcrypt_enc_is_block_algorithm_mode);
62 PHP_FUNCTION(mcrypt_enc_is_block_algorithm);
63 PHP_FUNCTION(mcrypt_enc_is_block_mode);
64 PHP_FUNCTION(mcrypt_enc_get_block_size);
65 PHP_FUNCTION(mcrypt_enc_get_key_size);
66 PHP_FUNCTION(mcrypt_enc_get_supported_key_sizes);
67 PHP_FUNCTION(mcrypt_enc_get_iv_size);
68 PHP_FUNCTION(mcrypt_enc_get_algorithms_name);
69 PHP_FUNCTION(mcrypt_enc_get_modes_name);
70 PHP_FUNCTION(mcrypt_module_self_test);
71 PHP_FUNCTION(mcrypt_module_is_block_algorithm_mode);
72 PHP_FUNCTION(mcrypt_module_is_block_algorithm);
73 PHP_FUNCTION(mcrypt_module_is_block_mode);
74 PHP_FUNCTION(mcrypt_module_get_algo_block_size);
75 PHP_FUNCTION(mcrypt_module_get_algo_key_size);
76 PHP_FUNCTION(mcrypt_module_get_supported_key_sizes);
77 PHP_FUNCTION(mcrypt_module_close);
78 
79 ZEND_BEGIN_MODULE_GLOBALS(mcrypt)
80 	int le_h;
81 	char *modes_dir;
82 	char *algorithms_dir;
83 	int fd[2]; // RANDOM = 0, URANDOM = 1
84 ZEND_END_MODULE_GLOBALS(mcrypt)
85 
86 #define MCG(v) ZEND_MODULE_GLOBALS_ACCESSOR(mcrypt, v)
87 
88 #else
89 #define mcrypt_module_ptr NULL
90 #endif
91 
92 #define phpext_mcrypt_ptr mcrypt_module_ptr
93 
94 #endif
95