/*
   +----------------------------------------------------------------------+
   | Copyright (c) 2002-2005 J Smith <dark_panda@hushmail.com>            |
   | Crypto++ sources (not included) copyright (c) 1995-2003 Wei Dai      |
   +----------------------------------------------------------------------+
   | Check out COPYING for the exact license.                             |
   +----------------------------------------------------------------------+

$Id: php_cryptopp.h,v 1.31 2005/01/06 18:16:43 jay Exp $
*/

#ifndef PHP_CRYPTOPP_H
#define PHP_CRYPTOPP_H

extern zend_module_entry cryptopp_module_entry;
#define phpext_cryptopp_ptr &cryptopp_module_entry

#ifdef PHP_WIN32
#define PHP_CRYPTOPP_API __declspec(dllexport)
#else
#define PHP_CRYPTOPP_API
#endif

#ifdef ZTS
#include "TSRM.h"
#endif

PHP_MINIT_FUNCTION(cryptopp);
PHP_MSHUTDOWN_FUNCTION(cryptopp);
PHP_MINFO_FUNCTION(cryptopp);


// cipher functions...

PHP_FUNCTION(cryptopp_create_cipher);
PHP_FUNCTION(cryptopp_destroy_cipher);
PHP_FUNCTION(cryptopp_set_rand_iv);
PHP_FUNCTION(cryptopp_set_iv);
PHP_FUNCTION(cryptopp_get_iv);
PHP_FUNCTION(cryptopp_set_mode);
PHP_FUNCTION(cryptopp_get_mode);
PHP_FUNCTION(cryptopp_set_padding);
PHP_FUNCTION(cryptopp_get_padding);
PHP_FUNCTION(cryptopp_set_rng);
PHP_FUNCTION(cryptopp_get_rng);
PHP_FUNCTION(cryptopp_srand);
PHP_FUNCTION(cryptopp_set_plaintext);
PHP_FUNCTION(cryptopp_get_plaintext);
PHP_FUNCTION(cryptopp_set_ciphertext);
PHP_FUNCTION(cryptopp_get_ciphertext);
PHP_FUNCTION(cryptopp_set_key);
PHP_FUNCTION(cryptopp_get_key);
PHP_FUNCTION(cryptopp_set_key_length);
PHP_FUNCTION(cryptopp_get_key_length);
PHP_FUNCTION(cryptopp_get_default_key_length);
PHP_FUNCTION(cryptopp_get_max_key_length);
PHP_FUNCTION(cryptopp_get_min_key_length);
PHP_FUNCTION(cryptopp_get_mult_key_length);
PHP_FUNCTION(cryptopp_get_valid_key_length);
PHP_FUNCTION(cryptopp_get_block_size);
PHP_FUNCTION(cryptopp_set_rounds);
PHP_FUNCTION(cryptopp_get_rounds);
PHP_FUNCTION(cryptopp_get_cipher_name);
PHP_FUNCTION(cryptopp_get_mode_name);
PHP_FUNCTION(cryptopp_get_padding_name);
PHP_FUNCTION(cryptopp_get_rng_name);
PHP_FUNCTION(cryptopp_get_cipher_type);
PHP_FUNCTION(cryptopp_cipher_enabled);
PHP_FUNCTION(cryptopp_rng_available);
PHP_FUNCTION(cryptopp_encrypt);
PHP_FUNCTION(cryptopp_decrypt);
PHP_FUNCTION(cryptopp_encrypt_file);
PHP_FUNCTION(cryptopp_decrypt_file);


// functions specific to the RC2 algorithm...

PHP_FUNCTION(cryptopp_set_effective_key_length);
PHP_FUNCTION(cryptopp_get_effective_key_length);


// hash functions...

PHP_FUNCTION(cryptopp_create_hash);
PHP_FUNCTION(cryptopp_destroy_hash);
PHP_FUNCTION(cryptopp_set_hash_plaintext);
PHP_FUNCTION(cryptopp_get_hash_plaintext);
PHP_FUNCTION(cryptopp_set_hashtext);
PHP_FUNCTION(cryptopp_get_hashtext);
PHP_FUNCTION(cryptopp_get_digest_size);
PHP_FUNCTION(cryptopp_hash);
PHP_FUNCTION(cryptopp_hash_file);
PHP_FUNCTION(cryptopp_validate_hash);
PHP_FUNCTION(cryptopp_get_hash_name);
PHP_FUNCTION(cryptopp_get_hash_type);
PHP_FUNCTION(cryptopp_hash_enabled);


// functions for setting HMAC keys...

PHP_FUNCTION(cryptopp_set_hmac_key);
PHP_FUNCTION(cryptopp_get_hmac_key);
PHP_FUNCTION(cryptopp_set_hmac_key_length);
PHP_FUNCTION(cryptopp_get_hmac_key_length);


// for some reason, Windows isn't liking long here. No idea
// what's going on there.
#ifdef PHP_WIN32
#define CRYPTOPP_INI_TYPE bool
#else
#define CRYPTOPP_INI_TYPE long
#endif

ZEND_BEGIN_MODULE_GLOBALS(cryptopp)
	CRYPTOPP_INI_TYPE ini_disable_exceptions;

	CRYPTOPP_INI_TYPE ini_disable_3way;
	CRYPTOPP_INI_TYPE ini_disable_aes;
	CRYPTOPP_INI_TYPE ini_disable_blowfish;
	CRYPTOPP_INI_TYPE ini_disable_camellia;
	CRYPTOPP_INI_TYPE ini_disable_cast128;
	CRYPTOPP_INI_TYPE ini_disable_cast256;
	CRYPTOPP_INI_TYPE ini_disable_des;
	CRYPTOPP_INI_TYPE ini_disable_des_ede2;
	CRYPTOPP_INI_TYPE ini_disable_des_ede3;
	CRYPTOPP_INI_TYPE ini_disable_des_xex3;
	CRYPTOPP_INI_TYPE ini_disable_diamond2;
	CRYPTOPP_INI_TYPE ini_disable_diamond2_lite;
	CRYPTOPP_INI_TYPE ini_disable_gost;
	CRYPTOPP_INI_TYPE ini_disable_idea;
	CRYPTOPP_INI_TYPE ini_disable_mars;
	CRYPTOPP_INI_TYPE ini_disable_rc2;
	CRYPTOPP_INI_TYPE ini_disable_rc5;
	CRYPTOPP_INI_TYPE ini_disable_rc6;
	CRYPTOPP_INI_TYPE ini_disable_safer_k;
	CRYPTOPP_INI_TYPE ini_disable_safer_sk;
	CRYPTOPP_INI_TYPE ini_disable_shark;
	CRYPTOPP_INI_TYPE ini_disable_shacal2;
	CRYPTOPP_INI_TYPE ini_disable_serpent;
	CRYPTOPP_INI_TYPE ini_disable_skipjack;
	CRYPTOPP_INI_TYPE ini_disable_square;
	CRYPTOPP_INI_TYPE ini_disable_tea;
	CRYPTOPP_INI_TYPE ini_disable_twofish;

	CRYPTOPP_INI_TYPE ini_disable_arc4;
	CRYPTOPP_INI_TYPE ini_disable_marc4;
	CRYPTOPP_INI_TYPE ini_disable_panama_le_cipher;
	CRYPTOPP_INI_TYPE ini_disable_panama_be_cipher;
	CRYPTOPP_INI_TYPE ini_disable_seal_le;
	CRYPTOPP_INI_TYPE ini_disable_seal_be;

	CRYPTOPP_INI_TYPE ini_disable_haval;
	CRYPTOPP_INI_TYPE ini_disable_haval3;
	CRYPTOPP_INI_TYPE ini_disable_haval4;
	CRYPTOPP_INI_TYPE ini_disable_haval5;
	CRYPTOPP_INI_TYPE ini_disable_md2;
	CRYPTOPP_INI_TYPE ini_disable_md4;
	CRYPTOPP_INI_TYPE ini_disable_md5;
	CRYPTOPP_INI_TYPE ini_disable_panama_le_hash;
	CRYPTOPP_INI_TYPE ini_disable_panama_be_hash;
	CRYPTOPP_INI_TYPE ini_disable_ripemd128;
	CRYPTOPP_INI_TYPE ini_disable_ripemd160;
	CRYPTOPP_INI_TYPE ini_disable_ripemd256;
	CRYPTOPP_INI_TYPE ini_disable_ripemd320;
	CRYPTOPP_INI_TYPE ini_disable_sha1;
	CRYPTOPP_INI_TYPE ini_disable_sha256;
	CRYPTOPP_INI_TYPE ini_disable_sha384;
	CRYPTOPP_INI_TYPE ini_disable_sha512;
	CRYPTOPP_INI_TYPE ini_disable_tiger;
	CRYPTOPP_INI_TYPE ini_disable_whirlpool;

	CRYPTOPP_INI_TYPE ini_disable_md2_hmac;
	CRYPTOPP_INI_TYPE ini_disable_md4_hmac;
	CRYPTOPP_INI_TYPE ini_disable_md5_hmac;
	CRYPTOPP_INI_TYPE ini_disable_ripemd128_hmac;
	CRYPTOPP_INI_TYPE ini_disable_ripemd160_hmac;
	CRYPTOPP_INI_TYPE ini_disable_ripemd256_hmac;
	CRYPTOPP_INI_TYPE ini_disable_ripemd320_hmac;
	CRYPTOPP_INI_TYPE ini_disable_sha1_hmac;
	CRYPTOPP_INI_TYPE ini_disable_sha256_hmac;
	CRYPTOPP_INI_TYPE ini_disable_sha384_hmac;
	CRYPTOPP_INI_TYPE ini_disable_sha512_hmac;
	CRYPTOPP_INI_TYPE ini_disable_tiger_hmac;
	CRYPTOPP_INI_TYPE ini_disable_whirlpool_hmac;

	CRYPTOPP_INI_TYPE ini_disable_adler32;
	CRYPTOPP_INI_TYPE ini_disable_crc32;
ZEND_END_MODULE_GLOBALS(cryptopp)


#ifdef ZTS
#define CRYPTOPP_G(v) TSRMG(cryptopp_globals_id, zend_cryptopp_globals *, v)
#else
#define CRYPTOPP_G(v) (cryptopp_globals.v)
#endif

#define CRYPTOPP_GET_INI(v) CRYPTOPP_G(v)

#define CRYPTOPP_SET_INI(x) \
	STD_PHP_INI_BOOLEAN("cryptopp.disable_" # x, "0", PHP_INI_SYSTEM | PHP_INI_PERDIR, OnUpdateBool, ini_disable_ ## x, zend_cryptopp_globals, cryptopp_globals)

#define CRYPTOPP_REGISTER_CONST(type, name, const) \
	REGISTER_LONG_CONSTANT("CRYPTOPP_" # type "_" # name, const, CONST_CS | CONST_PERSISTENT);

#endif	/* PHP_CRYPTOPP_H */


/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * indent-tabs-mode: t
 * End:
 */
