[PHP-DEV] cvs: /php3/functions mcrypt.c From: Sascha Schumann (sascha <email protected>)
Date: 10/31/99

sas Sun Oct 31 08:00:23 1999 EDT

  Modified files:
    /php3/functions mcrypt.c
  Log:
  Support current mcrypt. Tested with libmcrypt-2.2.4
  
  
Index: php3/functions/mcrypt.c
diff -u php3/functions/mcrypt.c:1.10 php3/functions/mcrypt.c:1.11
--- php3/functions/mcrypt.c:1.10 Thu Jul 29 17:07:17 1999
+++ php3/functions/mcrypt.c Sun Oct 31 08:00:22 1999
@@ -90,7 +90,7 @@
         convert_to_string(key)
 
 #define MCRYPT_SIZE \
- bsize = get_block_size(cipher->value.lval); \
+ bsize = mcrypt_get_block_size(cipher->value.lval); \
         nr = (data->value.str.len + bsize - 1) / bsize; \
         nsize = nr * bsize
 
@@ -119,7 +119,9 @@
 #define MCRYPT_IV_WRONG_SIZE "The IV paramater must be as long as the blocksize"
 #define MCRYPT_FAILED "mcrypt initialization failed"
 
-#define MCRYPT_ENTRY(a) REGISTER_LONG_CONSTANT("MCRYPT_" #a, a, CONST_PERSISTENT)
+#define MCRYPT_ENTRY_NAMED(a,b) REGISTER_LONG_CONSTANT("MCRYPT_" #a, b, CONST_PERSISTENT)
+#define MCRYPT_ENTRY2(a) MCRYPT_ENTRY_NAMED(a, MCRYPT_##a)
+#define MCRYPT_ENTRY(a) MCRYPT_ENTRY_NAMED(a, a)
 
 static int php_minit_mcrypt(INIT_FUNC_ARGS)
 {
@@ -133,35 +135,42 @@
         REGISTER_LONG_CONSTANT("MCRYPT_RAND", 2, CONST_PERSISTENT);
         
         /* ciphers */
- MCRYPT_ENTRY(BLOWFISH);
- MCRYPT_ENTRY(DES);
- MCRYPT_ENTRY(TripleDES);
- MCRYPT_ENTRY(ThreeWAY);
- MCRYPT_ENTRY(GOST);
-#ifdef CRYPT
- MCRYPT_ENTRY(CRYPT);
+#if defined(MCRYPT_API_VERSION) && MCRYPT_API_VERSION == 19991015
+ MCRYPT_ENTRY2(BLOWFISH_448);
+ MCRYPT_ENTRY2(DES);
+ MCRYPT_ENTRY2(3DES);
+ MCRYPT_ENTRY2(3WAY);
+ MCRYPT_ENTRY2(GOST);
+ MCRYPT_ENTRY2(SAFER_64);
+ MCRYPT_ENTRY2(SAFER_128);
+ MCRYPT_ENTRY2(CAST_128);
+ MCRYPT_ENTRY2(XTEA);
+ MCRYPT_ENTRY2(RC2_1024);
+ MCRYPT_ENTRY2(TWOFISH_128);
+ MCRYPT_ENTRY2(TWOFISH_192);
+ MCRYPT_ENTRY2(TWOFISH_256);
+ MCRYPT_ENTRY2(BLOWFISH_128);
+ MCRYPT_ENTRY2(BLOWFISH_192);
+ MCRYPT_ENTRY2(BLOWFISH_256);
+ MCRYPT_ENTRY2(CAST_256);
+ MCRYPT_ENTRY2(SAFERPLUS);
+ MCRYPT_ENTRY2(LOKI97);
+ MCRYPT_ENTRY2(SERPENT_128);
+ MCRYPT_ENTRY2(SERPENT_192);
+ MCRYPT_ENTRY2(SERPENT_256);
+ MCRYPT_ENTRY2(RIJNDAEL_128);
+ MCRYPT_ENTRY2(RIJNDAEL_192);
+ MCRYPT_ENTRY2(RIJNDAEL_256);
+ MCRYPT_ENTRY2(RC2_256);
+ MCRYPT_ENTRY2(RC2_128);
+ MCRYPT_ENTRY2(RC6_256);
+ MCRYPT_ENTRY2(IDEA);
+ MCRYPT_ENTRY2(RC6_128);
+ MCRYPT_ENTRY2(RC6_192);
+ MCRYPT_ENTRY2(RC4);
+#else
+#error Please update your mcrypt library
 #endif
-#ifdef DES_COMPAT
- MCRYPT_ENTRY(DES_COMPAT);
-#endif
- MCRYPT_ENTRY(SAFER64);
- MCRYPT_ENTRY(SAFER128);
- MCRYPT_ENTRY(CAST128);
- MCRYPT_ENTRY(TEAN);
- MCRYPT_ENTRY(RC2);
-#ifdef TWOFISH
- MCRYPT_ENTRY(TWOFISH);
-#elif defined(TWOFISH128)
- MCRYPT_ENTRY(TWOFISH128);
- MCRYPT_ENTRY(TWOFISH192);
- MCRYPT_ENTRY(TWOFISH256);
-#endif
-#ifdef RC6
- MCRYPT_ENTRY(RC6);
-#endif
-#ifdef IDEA
- MCRYPT_ENTRY(IDEA);
-#endif
         
         return SUCCESS;
 }
@@ -231,7 +240,7 @@
 
         convert_to_long(cipher);
 
- str = get_algorithms_name(cipher->value.lval);
+ str = mcrypt_get_algorithms_name(cipher->value.lval);
         if(!str) {
                 RETURN_FALSE;
         }
@@ -254,7 +263,7 @@
 
         convert_to_long(cipher);
 
- RETURN_LONG(get_key_size(cipher->value.lval));
+ RETURN_LONG(mcrypt_get_key_size(cipher->value.lval));
 }
 /* }}} */
 
@@ -270,7 +279,7 @@
 
         convert_to_long(cipher);
 
- RETURN_LONG(get_block_size(cipher->value.lval));
+ RETURN_LONG(mcrypt_get_block_size(cipher->value.lval));
 }
 /* }}} */
 

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>