1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 5                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 2013-2016 Jakub Zelenka                                |
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: Jakub Zelenka <bukka@php.net>                                |
16   +----------------------------------------------------------------------+
17 */
18 
19 #ifndef PHP_CRYPTO_BASE64_H
20 #define PHP_CRYPTO_BASE64_H
21 
22 #include "php.h"
23 #include "php_crypto.h"
24 
25 #include <openssl/evp.h>
26 
27 typedef enum {
28 	PHP_CRYPTO_BASE64_STATUS_CLEAR,
29 	PHP_CRYPTO_BASE64_STATUS_ENCODE,
30 	PHP_CRYPTO_BASE64_STATUS_DECODE
31 } php_crypto_base64_status;
32 
33 PHPC_OBJ_STRUCT_BEGIN(crypto_base64)
34 	php_crypto_base64_status status;
35 	EVP_ENCODE_CTX *ctx;
36 PHPC_OBJ_STRUCT_END()
37 
38 /* Base64 macros for endoding and decoding context size */
39 #define PHP_CRYPTO_BASE64_DECODING_SIZE_MIN 50
40 #define PHP_CRYPTO_BASE64_ENCODING_SIZE_MIN 66
41 
42 /* Exceptions */
43 PHP_CRYPTO_EXCEPTION_EXPORT(Base64)
44 /* Error info */
45 PHP_CRYPTO_ERROR_INFO_EXPORT(Base64)
46 
47 /* Class entries */
48 extern PHP_CRYPTO_API zend_class_entry *php_crypto_base64_ce;
49 
50 /* Module init for Crypto Base64 */
51 PHP_MINIT_FUNCTION(crypto_base64);
52 
53 /* Base64 methods */
54 PHP_CRYPTO_METHOD(Base64, encode);
55 PHP_CRYPTO_METHOD(Base64, decode);
56 PHP_CRYPTO_METHOD(Base64, __construct);
57 PHP_CRYPTO_METHOD(Base64, encodeUpdate);
58 PHP_CRYPTO_METHOD(Base64, encodeFinish);
59 PHP_CRYPTO_METHOD(Base64, decodeUpdate);
60 PHP_CRYPTO_METHOD(Base64, decodeFinish);
61 
62 #endif	/* PHP_CRYPTO_BASE64_H */
63 
64 /*
65  * Local variables:
66  * tab-width: 4
67  * c-basic-offset: 4
68  * End:
69  * vim600: noet sw=4 ts=4 fdm=marker
70  * vim<600: noet sw=4 ts=4
71  */
72