[PHP4BETA] CVS update: php4/ext/mcrypt

From: Date: Sun, 25 Apr 1999 21:32:53 +0000
Subject: [PHP4BETA] CVS update: php4/ext/mcrypt
Groups: php.version4 
Request: Send a blank email to php-version4+get-529@lists.php.net to get a copy of this message
Date: Sunday April 25, 1999 @ 17:32 Author: sas Update of /repository/php4/ext/mcrypt In directory php:/tmp/cvs-serv3751 Modified Files: mcrypt.c Log Message: make code more compact Index: php4/ext/mcrypt/mcrypt.c diff -u php4/ext/mcrypt/mcrypt.c:1.8 php4/ext/mcrypt/mcrypt.c:1.9 --- php4/ext/mcrypt/mcrypt.c:1.8 Sun Apr 25 17:24:07 1999 +++ php4/ext/mcrypt/mcrypt.c Sun Apr 25 17:32:52 1999 @@ -71,6 +71,22 @@ #endif +#define MCRYPT_ARGS2 \ + pval *cipher, *data, *key, *mode; \ + int td; \ + char *ndata; \ + size_t bsize; \ + size_t nr; \ + size_t nsize + +#define MCRYPT_ARGS MCRYPT_ARGS2; pval *iv + +#define MCRYPT_CONVERT \ + convert_to_long(cipher); \ + convert_to_long(mode); \ + convert_to_string(data); \ + convert_to_string(key) + #define MCRYPT_SIZE \ bsize = get_block_size(cipher->value.lval); \ nr = (data->value.str.len + bsize - 1) / bsize; \ @@ -212,22 +228,13 @@ OFB crypt/decrypt data using key key with cipher cipher starting with iv */ PHP_FUNCTION(mcrypt_ofb) { - pval *cipher, *data, *key, *mode, *iv; - int td; - char *ndata; - size_t bsize; - size_t nr; - size_t nsize; - + MCRYPT_ARGS; + if(ARG_COUNT(ht) != 5 || getParameters(ht, 5, &cipher, &key, &data, &mode, &iv) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_long(cipher); - convert_to_long(mode); - convert_to_string(data); - convert_to_string(key); - + MCRYPT_CONVERT; MCRYPT_SIZE; MCRYPT_CHECK_IV; @@ -242,22 +249,13 @@ CFB crypt/decrypt data using key key with cipher cipher starting with iv */ PHP_FUNCTION(mcrypt_cfb) { - pval *cipher, *data, *key, *mode, *iv; - int td; - char *ndata; - size_t bsize; - size_t nr; - size_t nsize; + MCRYPT_ARGS; if(ARG_COUNT(ht) != 5 || getParameters(ht, 5, &cipher, &key, &data, &mode, &iv) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_long(cipher); - convert_to_long(mode); - convert_to_string(data); - convert_to_string(key); - + MCRYPT_CONVERT; MCRYPT_SIZE; MCRYPT_CHECK_IV; @@ -273,24 +271,15 @@ CBC crypt/decrypt data using key key with cipher cipher using optional iv */ PHP_FUNCTION(mcrypt_cbc) { - pval *cipher, *data, *key, *mode, *iv; - int td; + MCRYPT_ARGS; int ac = ARG_COUNT(ht); - char *ndata; - size_t bsize; - size_t nr; - size_t nsize; if(ac < 4 || ac > 5 || getParameters(ht, ac, &cipher, &key, &data, &mode, &iv) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_long(cipher); - convert_to_long(mode); - convert_to_string(data); - convert_to_string(key); - + MCRYPT_CONVERT; MCRYPT_SIZE; if(ac > 4 && mode == 0) { MCRYPT_CHECK_IV; @@ -313,22 +302,13 @@ ECB crypt/decrypt data using key key with cipher cipher */ PHP_FUNCTION(mcrypt_ecb) { - pval *cipher, *data, *key, *mode; - int td; - char *ndata; - size_t bsize; - size_t nr; - size_t nsize; + MCRYPT_ARGS2; if(ARG_COUNT(ht) != 4 || getParameters(ht, 4, &cipher, &key, &data, &mode) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_long(cipher); - convert_to_long(mode); - convert_to_string(data); - convert_to_string(key); - + MCRYPT_CONVERT; MCRYPT_SIZE; td = init_mcrypt_ecb(cipher->value.lval, key->value.str.val, key->value.str.len); -- PHP 4 Beta

« previous php.version4 (#529) next »