diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index 7ee2564720a..821060baa3e 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -38,6 +38,8 @@ function_entry mcrypt_functions[] = { PHP_FE(mcrypt_ecb, NULL) PHP_FE(mcrypt_cbc, NULL) + PHP_FE(mcrypt_get_block_size, NULL) + PHP_FE(mcrypt_get_key_size, NULL) {0}, }; @@ -85,6 +87,36 @@ static int php3_minit_mcrypt(INIT_FUNC_ARGS) return SUCCESS; } +/* proto mcrypt_get_key_size(int cipher) + get the key size of cipher */ +PHP_FUNCTION(mcrypt_get_key_size) +{ + pval *cipher; + + if(ARG_COUNT(ht) != 1 || getParameters(ht, 1, &cipher) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(cipher); + + RETURN_LONG(get_key_size(cipher->value.lval)); +} + +/* proto mcrypt_get_block_size(int cipher) + get the block size of cipher */ +PHP_FUNCTION(mcrypt_get_block_size) +{ + pval *cipher; + + if(ARG_COUNT(ht) != 1 || getParameters(ht, 1, &cipher) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(cipher); + + RETURN_LONG(get_block_size(cipher->value.lval)); +} + /* proto mcrypt_cbc(int cipher, string key, string data, int mode) CBC crypt/decrypt data using key key with cipher cipher */ PHP_FUNCTION(mcrypt_cbc) diff --git a/ext/mcrypt/php_mcrypt.h b/ext/mcrypt/php_mcrypt.h index 46cdb3dd7ed..6c59f4db4b0 100644 --- a/ext/mcrypt/php_mcrypt.h +++ b/ext/mcrypt/php_mcrypt.h @@ -8,6 +8,8 @@ extern zend_module_entry mcrypt_module_entry; PHP_FUNCTION(mcrypt_ecb); PHP_FUNCTION(mcrypt_cbc); +PHP_FUNCTION(mcrypt_get_block_size); +PHP_FUNCTION(mcrypt_get_key_size); #else #define mcrypt_module_ptr NULL