cvs: phpdoc /en/reference/mcrypt reference.xml /en/reference/mcrypt/functions mcrypt-cbc.xml mcrypt-cfb.xml mcrypt-create-iv.xml mcrypt-decrypt.xml
mcrypt-ecb.xml mcrypt-enc-get-algorithms-name.xml mcrypt-enc-get-block-size.xml mcrypt-enc-get-key-size.xml mcrypt-enc-get-modes-name.xml
mcrypt-enc-get-supported-key-sizes.xml mcrypt-enc-is-block-algorithm-mode.xml mcrypt-enc-is-block-algorithm.xml mcrypt-enc-is-block-mode.xml
mcrypt-enc-self-test.xml mcrypt-encrypt.xml mcrypt-generic-deinit.xml mcrypt-generic-end.xml mcrypt-generic-init.xml mcrypt-generic.xml
mcrypt-get-block-size.xml mcrypt-get-cipher-name.xml mcrypt-get-iv-size.xml mcrypt-get-key-size.xml mcrypt-list-algorithms.xml mcrypt-list-modes.xml
mcrypt-module-close.xml mcrypt-module-get-supported-key-sizes.xml mcrypt-module-is-block-algorithm-mode.xml mcrypt-module-is-block-algorithm.xml
mcrypt-module-is-block-mode.xml mcrypt-module-open.xml mcrypt-module-self-test.xml mcrypt-ofb.xml mdecrypt-generic.xml
| From: | Derick Rethans | Date: | Sun, 12 May 2002 21:00:20 +0000 |
| Subject: | cvs: phpdoc /en/reference/mcrypt reference.xml /en/reference/mcrypt/functions mcrypt-cbc.xml mcrypt-cfb.xml mcrypt-create-iv.xml mcrypt-decrypt.xml mcrypt-ecb.xml mcrypt-enc-get-algorithms-name.xml mcrypt-enc-get-block-size.xml mcrypt-enc-get-key-size.xml mcrypt-enc-get-modes-name.xml mcrypt-enc-get-supported-key-sizes.xml mcrypt-enc-is-block-algorithm-mode.xml mcrypt-enc-is-block-algorithm.xml mcrypt-enc-is-block-mode.xml mcrypt-enc-self-test.xml mcrypt-encrypt.xml mcrypt-generic-deinit.xml mcrypt-generic-end.xml mcrypt-generic-init.xml mcrypt-generic.xml mcrypt-get-block-size.xml mcrypt-get-cipher-name.xml mcrypt-get-iv-size.xml mcrypt-get-key-size.xml mcrypt-list-algorithms.xml mcrypt-list-modes.xml mcrypt-module-close.xml mcrypt-module-get-supported-key-sizes.xml mcrypt-module-is-block-algorithm-mode.xml mcrypt-module-is-block-algorithm.xml mcrypt-module-is-block-mode.xml mcrypt-module-open.xml mcrypt-module-self-test.xml mcrypt-ofb.xml mdecrypt-generic.xml |
||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969345539@lists.php.net to get a copy of this message | ||
derick Sun May 12 17:00:20 2002 EDT
Modified files:
/phpdoc/en/reference/mcrypt reference.xml
/phpdoc/en/reference/mcrypt/functions mcrypt-cbc.xml mcrypt-cfb.xml
mcrypt-create-iv.xml
mcrypt-decrypt.xml
mcrypt-ecb.xml
mcrypt-enc-get-algorithms-name.xml
mcrypt-enc-get-block-size.xml
mcrypt-enc-get-key-size.xml
mcrypt-enc-get-modes-name.xml
mcrypt-enc-get-supported-key-sizes.xml
mcrypt-enc-is-block-algorithm-mode.xml
mcrypt-enc-is-block-algorithm.xml
mcrypt-enc-is-block-mode.xml
mcrypt-enc-self-test.xml
mcrypt-encrypt.xml
mcrypt-generic-deinit.xml
mcrypt-generic-end.xml
mcrypt-generic-init.xml
mcrypt-generic.xml
mcrypt-get-block-size.xml
mcrypt-get-cipher-name.xml
mcrypt-get-iv-size.xml
mcrypt-get-key-size.xml
mcrypt-list-algorithms.xml
mcrypt-list-modes.xml
mcrypt-module-close.xml
mcrypt-module-get-supported-key-sizes.xml
mcrypt-module-is-block-algorithm-mode.xml
mcrypt-module-is-block-algorithm.xml
mcrypt-module-is-block-mode.xml
mcrypt-module-open.xml
mcrypt-module-self-test.xml
mcrypt-ofb.xml
mdecrypt-generic.xml
Log:
- Overhaul of the mcrypt docs, including new examples, corrected entries and
newly documented functions
Index: phpdoc/en/reference/mcrypt/reference.xml diff -u phpdoc/en/reference/mcrypt/reference.xml:1.2 phpdoc/en/reference/mcrypt/reference.xml:1.3 --- phpdoc/en/reference/mcrypt/reference.xml:1.2 Mon Apr 15 14:56:45 2002 +++ phpdoc/en/reference/mcrypt/reference.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <reference id="ref.mcrypt"> <title>Mcrypt Encryption Functions</title> <titleabbrev>mcrypt</titleabbrev> @@ -36,40 +36,40 @@ <literal>$encrypted_data</literal>. </para> <para> - If you linked against libmcrypt 2.4.x, these functions are still + If you linked against libmcrypt 2.4.x or 2.5.x, these functions are still available, but it is recommended that you use the advanced functions. <example> - <title>Encrypt an input value with TripleDES under 2.4.x in ECB mode</title> + <title>Encrypt an input value with TripleDES under 2.4.x and higher in ECB mode</title> <programlisting role="php"> <![CDATA[ <?php -$key = "this is a very secret key"; -$input = "Let us meet at 9 o'clock at the secret place."; + $key = "this is a very secret key"; + $input = "Let us meet at 9 o'clock at the secret place."; -$td = mcrypt_module_open (MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, ""); -$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); -mcrypt_generic_init ($td, $key, $iv); -$encrypted_data = mcrypt_generic ($td, $input); -mcrypt_generic_end ($td); + $td = mcrypt_module_open ('tripledes', '', 'ecb', ''); + $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); + mcrypt_generic_init ($td, $key, $iv); + $encrypted_data = mcrypt_generic ($td, $input); + mcrypt_generic_end ($td); ?> ]]> </programlisting> </example> This example will give you the encrypted data as a string in - <literal>$encrypted_data</literal>. + <literal>$encrypted_data</literal>. For a full example see + <function>mcrypt_module_open</function>. </para> <section id="mcrypt.requirements"> <title>Requirements</title> <para> - These functions work using <ulink - url="&url.mcrypt;">mcrypt</ulink>. + These functions work using <ulink url="&url.mcrypt;">mcrypt</ulink>. </para> <para> - If you linked against libmcrypt 2.4.x, the following additional + If you linked against libmcrypt 2.4.x or higher, the following additional block algorithms are supported: CAST, LOKI97, RIJNDAEL, SAFERPLUS, - SERPENT and the following stream ciphers: ENIGMA (crypt), PANAMA, - RC4 and WAKE. With libmcrypt 2.4.x another cipher mode is also + SERPENT and the following stream ciphers: ENIGMA (crypt), PANAMA, RC4 and + WAKE. With libmcrypt 2.4.x or higher another cipher mode is also available; nOFB. </para> </section> @@ -78,11 +78,11 @@ <title>Installation</title> <para> To use it, download libmcrypt-x.x.tar.gz from <ulink - url="&url.mcrypt;">here</ulink> and follow the included - installation instructions. You need to compile PHP with the - <option role="configure">--with-mcrypt</option> parameter to - enable this extension. Make sure you compile libmcrypt with the - option <option role="configure">--disable-posix-threads</option>. + url="&url.mcrypt;">here</ulink> and follow the included installation + instructions. You need to compile PHP with the <option + role="configure">--with-mcrypt</option> parameter to enable this + extension. Make sure you compile libmcrypt with the option <option + role="configure">--disable-posix-threads</option>. </para> </section> @@ -103,7 +103,7 @@ <para> Mcrypt can operate in four block cipher modes (CBC, OFB, CFB, and - ECB). If linked against libmcrypt-2.4.x mcrypt can also operate + ECB). If linked against libmcrypt-2.4.x or higher the functions can also operate in the block cipher mode nOFB and in STREAM mode. Below you find a list with all supported encryption modes together with the constants that are defines for the encryption mode. For a more complete reference and @@ -157,51 +157,51 @@ extension. For a complete list of supported ciphers, see the defines at the end of <filename>mcrypt.h</filename>. The general rule with the mcrypt-2.2.x API is that you can access the cipher from PHP with - MCRYPT_ciphername. With the mcrypt-2.4.x API these constants also work, + MCRYPT_ciphername. With the libmcrypt-2.4.x and libmcrypt-2.5.x API these constants also work, but it is possible to specify the name of the cipher as a string with a call to <function>mcrypt_module_open</function>. <itemizedlist> <listitem><simpara>MCRYPT_3DES</simpara></listitem> - <listitem><simpara>MCRYPT_ARCFOUR_IV (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_ARCFOUR (libmcrypt 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_ARCFOUR_IV (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_ARCFOUR (libmcrypt > 2.4.x only)</simpara></listitem> <listitem><simpara>MCRYPT_BLOWFISH</simpara></listitem> <listitem><simpara>MCRYPT_CAST_128</simpara></listitem> <listitem><simpara>MCRYPT_CAST_256</simpara></listitem> <listitem><simpara>MCRYPT_CRYPT</simpara></listitem> <listitem><simpara>MCRYPT_DES</simpara></listitem> <listitem><simpara>MCRYPT_DES_COMPAT (libmcrypt 2.2.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_ENIGMA (libmcrypt 2.4.x only, alias for MCRYPT_CRYPT)</simpara></listitem> + <listitem><simpara>MCRYPT_ENIGMA (libmcrypt > 2.4.x only, alias for MCRYPT_CRYPT)</simpara></listitem> <listitem><simpara>MCRYPT_GOST</simpara></listitem> <listitem><simpara>MCRYPT_IDEA (non-free)</simpara></listitem> - <listitem><simpara>MCRYPT_LOKI97 (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_MARS (libmcrypt 2.4.x only, non-free)</simpara></listitem> - <listitem><simpara>MCRYPT_PANAMA (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_RIJNDAEL_128 (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_RIJNDAEL_192 (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_RIJNDAEL_256 (libmcrypt 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_LOKI97 (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_MARS (libmcrypt > 2.4.x only, non-free)</simpara></listitem> + <listitem><simpara>MCRYPT_PANAMA (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_RIJNDAEL_128 (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_RIJNDAEL_192 (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_RIJNDAEL_256 (libmcrypt > 2.4.x only)</simpara></listitem> <listitem><simpara>MCRYPT_RC2</simpara></listitem> <listitem><simpara>MCRYPT_RC4 (libmcrypt 2.2.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_RC6 (libmcrypt 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_RC6 (libmcrypt > 2.4.x only)</simpara></listitem> <listitem><simpara>MCRYPT_RC6_128 (libmcrypt 2.2.x only)</simpara></listitem> <listitem><simpara>MCRYPT_RC6_192 (libmcrypt 2.2.x only)</simpara></listitem> <listitem><simpara>MCRYPT_RC6_256 (libmcrypt 2.2.x only)</simpara></listitem> <listitem><simpara>MCRYPT_SAFER64</simpara></listitem> <listitem><simpara>MCRYPT_SAFER128</simpara></listitem> - <listitem><simpara>MCRYPT_SAFERPLUS (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_SERPENT(libmcrypt 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_SAFERPLUS (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_SERPENT(libmcrypt > 2.4.x only)</simpara></listitem> <listitem><simpara>MCRYPT_SERPENT_128 (libmcrypt 2.2.x only)</simpara></listitem> <listitem><simpara>MCRYPT_SERPENT_192 (libmcrypt 2.2.x only)</simpara></listitem> <listitem><simpara>MCRYPT_SERPENT_256 (libmcrypt 2.2.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_SKIPJACK (libmcrypt 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_SKIPJACK (libmcrypt > 2.4.x only)</simpara></listitem> <listitem><simpara>MCRYPT_TEAN (libmcrypt 2.2.x only)</simpara></listitem> <listitem><simpara>MCRYPT_THREEWAY</simpara></listitem> - <listitem><simpara>MCRYPT_TRIPLEDES (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_TWOFISH (for older mcrypt 2.x versions, or mcrypt 2.4.x )</simpara></listitem> + <listitem><simpara>MCRYPT_TRIPLEDES (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_TWOFISH (for older mcrypt 2.x versions, or mcrypt > 2.4.x )</simpara></listitem> <listitem><simpara>MCRYPT_TWOFISH128 (TWOFISHxxx are available in newer 2.x versions, but not in the 2.4.x versions)</simpara></listitem> <listitem><simpara>MCRYPT_TWOFISH192</simpara></listitem> <listitem><simpara>MCRYPT_TWOFISH256</simpara></listitem> - <listitem><simpara>MCRYPT_WAKE (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_XTEA (libmcrypt 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_WAKE (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_XTEA (libmcrypt > 2.4.x only)</simpara></listitem> </itemizedlist> </para> <para> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-cbc.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-cbc.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-cbc.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-cbc.xml:1.2 Wed Apr 17 02:40:11 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-cbc.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-cbc"> <refnamediv> @@ -26,36 +26,12 @@ </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or higher. </para> <para> - <function>mcrypt_cbc</function> encrypts or decrypts (depending - on <parameter>mode</parameter>) the <parameter>data</parameter> - with <parameter>cipher</parameter> and <parameter>key</parameter> - in CBC cipher mode and returns the resulting string. - </para> - <para> - <parameter>Cipher</parameter> is one of the MCRYPT_ciphername - constants. - </para> - <para> - <parameter>Key</parameter> is the key supplied to the - algorithm. It must be kept secret. - </para> - <para> - <parameter>Data</parameter> is the data which shall be - encrypted/decrypted. - </para> - <para> - <parameter>Mode</parameter> is MCRYPT_ENCRYPT or MCRYPT_DECRYPT. - </para> - <para> - <parameter>IV</parameter> is the optional initialization vector. - </para> - <para> - See also: <function>mcrypt_cfb</function>, - <function>mcrypt_ecb</function>, and - <function>mcrypt_ofb</function>. + This function should not be used anymore, see + <function>mcrypt_generic</function> and + <function>mdecrypt_generic</function> for replacements. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-cfb.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-cfb.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-cfb.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-cfb.xml:1.2 Wed Apr 17 02:40:11 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-cfb.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-cfb"> <refnamediv> @@ -26,36 +26,12 @@ </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or higher. </para> <para> - <function>mcrypt_cfb</function> encrypts or decrypts (depending - on <parameter>mode</parameter>) the <parameter>data</parameter> - with <parameter>cipher</parameter> and <parameter>key</parameter> - in CFB cipher mode and returns the resulting string. - </para> - <para> - <parameter>Cipher</parameter> is one of the MCRYPT_ciphername - constants. - </para> - <para> - <parameter>Key</parameter> is the key supplied to the - algorithm. It must be kept secret. - </para> - <para> - <parameter>Data</parameter> is the data which shall be - encrypted/decrypted. - </para> - <para> - <parameter>Mode</parameter> is MCRYPT_ENCRYPT or MCRYPT_DECRYPT. - </para> - <para> - <parameter>IV</parameter> is the initialization vector. - </para> - <para> - See also: <function>mcrypt_cbc</function>, - <function>mcrypt_ecb</function>, and - <function>mcrypt_ofb</function>. + This function should not be used anymore, see + <function>mcrypt_generic</function> and + <function>mdecrypt_generic</function> for replacements. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-create-iv.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-create-iv.xml:1.3 phpdoc/en/reference/mcrypt/functions/mcrypt-create-iv.xml:1.4 --- phpdoc/en/reference/mcrypt/functions/mcrypt-create-iv.xml:1.3 Thu Apr 18 05:25:10 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-create-iv.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-create-iv"> <refnamediv> @@ -36,9 +36,8 @@ <programlisting role="php"> <![CDATA[ <?php -$cipher = MCRYPT_TripleDES; -$block_size = mcrypt_get_block_size ($cipher); -$iv = mcrypt_create_iv ($block_size, MCRYPT_DEV_RANDOM); + $size = mcrypt_get_iv_size (MCRYPT_CAST_256, MCRYPT_MODE_CFB); + $iv = mcrypt_create_iv ($size, MCRYPT_DEV_RANDOM); ?> ]]> </programlisting> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-decrypt.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-decrypt.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-decrypt.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-decrypt.xml:1.2 Wed Apr 17 02:40:11 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-decrypt.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-decrypt"> <refnamediv> @@ -14,9 +14,7 @@ <methodparam><type>string</type><parameter>key</parameter></methodparam> <methodparam><type>string</type><parameter>data</parameter></methodparam> <methodparam><type>string</type><parameter>mode</parameter></methodparam> - <methodparam choice="opt"><type>string</type><parameter> - iv - </parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>iv</parameter></methodparam> </methodsynopsis> <para> <function>mcrypt_decrypt</function> decrypts the data Index: phpdoc/en/reference/mcrypt/functions/mcrypt-ecb.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-ecb.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-ecb.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-ecb.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-ecb.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-ecb"> <refnamediv> @@ -25,33 +25,12 @@ </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or higher. </para> <para> - <function>mcrypt_ecb</function> encrypts or decrypts (depending - on <parameter>mode</parameter>) the <parameter>data</parameter> - with <parameter>cipher</parameter> and <parameter>key</parameter> - in ECB cipher mode and returns the resulting string. - </para> - <para> - <parameter>Cipher</parameter> is one of the MCRYPT_ciphername - constants. - </para> - <para> - <parameter>Key</parameter> is the key supplied to the - algorithm. It must be kept secret. - </para> - <para> - <parameter>Data</parameter> is the data which shall be - encrypted/decrypted. - </para> - <para> - <parameter>Mode</parameter> is MCRYPT_ENCRYPT or MCRYPT_DECRYPT. - </para> - <para> - See also: <function>mcrypt_cbc</function>, - <function>mcrypt_cfb</function>, and - <function>mcrypt_ofb</function>. + This function should not be used anymore, see + <function>mcrypt_generic</function> and + <function>mdecrypt_generic</function> for replacements. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-algorithms-name.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-algorithms-name.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-algorithms-name.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-algorithms-name.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-algorithms-name.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-get-algorithms-name"> <refnamediv> @@ -14,6 +14,26 @@ </methodsynopsis> <para> This function returns the name of the algorithm. + </para> + <para> + <example> + <title><function>mcrypt_enc_get_algorithms_name</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + $td = mcrypt_module_open (MCRYPT_CAST_256, '', MCRYPT_MODE_CFB, ''); + echo mcrypt_enc_get_algorithms_name($td). "\n"; + + $td = mcrypt_module_open ('cast-256', '', MCRYPT_MODE_CFB, ''); + echo mcrypt_enc_get_algorithms_name($td). "\n"; +?> + +Prints: +CAST-256 +CAST-256 +]]> + </programlisting> + </example> </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-block-size.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-block-size.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-block-size.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-block-size.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-block-size.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-get-block-size"> <refnamediv> @@ -14,7 +14,7 @@ </methodsynopsis> <para> This function returns the block size of the algorithm specified by - the encryption descriptor td in bytes. + the encryption descriptor <parameter>td</parameter> in bytes. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-key-size.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-key-size.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-key-size.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-key-size.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-key-size.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-get-key-size"> <refnamediv> @@ -14,7 +14,8 @@ </methodsynopsis> <para> This function returns the maximum supported key size of the - algorithm specified by the encryption descriptor td in bytes. + algorithm specified by the encryption descriptor + <parameter>td</parameter> in bytes. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-modes-name.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-modes-name.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-modes-name.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-modes-name.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-modes-name.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-get-modes-name"> <refnamediv> @@ -14,6 +14,26 @@ </methodsynopsis> <para> This function returns the name of the mode. + </para> + <para> + <example> + <title><function>mcrypt_enc_get_modes_name</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + $td = mcrypt_module_open (MCRYPT_CAST_256, '', MCRYPT_MODE_CFB, ''); + echo mcrypt_enc_get_modes_name($td). "\n"; + + $td = mcrypt_module_open ('cast-256', '', 'ecb', ''); + echo mcrypt_enc_get_modes_name($td). "\n"; +?> + +Prints: +CFB +ECB +]]> + </programlisting> + </example> </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-supported-key-sizes.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-supported-key-sizes.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-supported-key-sizes.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-supported-key-sizes.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-supported-key-sizes.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-get-supported-key-sizes"> <refnamediv> @@ -18,6 +18,31 @@ array then all key sizes between 1 and <function>mcrypt_enc_get_key_size</function> are supported by the algorithm. + </para> + <para> + <example> + <title><function>mcrypt_enc_get_supported_key_sizes</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + $td = mcrypt_module_open ('rijndael-256', '', 'ecb', ''); + var_dump (mcrypt_enc_get_supported_key_sizes($td)); +?> + +This will print: + +array(3) { + [0]=> + int(16) + [1]=> + int(24) + [2]=> + int(32) +} +?> +]]> + </programlisting> + </example> </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm-mode.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm-mode.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm-mode.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm-mode.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm-mode.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-is-block-algorithm-mode"> <refnamediv> @@ -9,12 +9,12 @@ <refsect1> <title>Description</title> <methodsynopsis> - <type>int</type><methodname>mcrypt_enc_is_block_algorithm_mode</methodname> + <type>bool</type><methodname>mcrypt_enc_is_block_algorithm_mode</methodname> <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> - This function returns 1 if the mode is for use with block algorithms, - otherwise it returns 0. (eg. 0 for stream, and 1 for cbc, cfb, ofb). + This function returns &true; if the mode is for use with block algorithms, + otherwise it returns &false;. (eg. &false; for stream, and &true; for cbc, cfb, ofb). </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-is-block-algorithm"> <refnamediv> @@ -9,12 +9,12 @@ <refsect1> <title>Description</title> <methodsynopsis> - <type>int</type><methodname>mcrypt_enc_is_block_algorithm</methodname> + <type>bool</type><methodname>mcrypt_enc_is_block_algorithm</methodname> <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> - This function returns 1 if the algorithm is a block algorithm, - or 0 if it is a stream algorithm. + This function returns &true; if the algorithm is a block algorithm, + or &false; if it is a stream algorithm. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-mode.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-mode.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-mode.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-mode.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-mode.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-is-block-mode"> <refnamediv> @@ -9,12 +9,12 @@ <refsect1> <title>Description</title> <methodsynopsis> - <type>int</type><methodname>mcrypt_enc_is_block_mode</methodname> + <type>bool</type><methodname>mcrypt_enc_is_block_mode</methodname> <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> - This function returns 1 if the mode outputs blocks of bytes or - 0 if it outputs bytes. (eg. 1 for cbc and ecb, and 0 for cfb and + This function returns &true; if the mode outputs blocks of bytes or + &false; if it outputs bytes. (eg. &true; for cbc and ecb, and &false; for cfb and stream). </para> </refsect1> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-self-test.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-self-test.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-self-test.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-self-test.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-self-test.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-self-test"> <refnamediv> @@ -9,13 +9,13 @@ <refsect1> <title>Description</title> <methodsynopsis> - <type>int</type><methodname>mcrypt_enc_self_test</methodname> + <type>bool</type><methodname>mcrypt_enc_self_test</methodname> <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> This function runs the self test on the algorithm specified by the - descriptor td. If the self test succeeds it returns zero. In case - of an error, it returns 1. + descriptor <parameter>td</parameter>. If the self test succeeds it returns &false;. In case + of an error, it returns &true;. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-encrypt.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-encrypt.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-encrypt.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-encrypt.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-encrypt.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-encrypt"> <refnamediv> @@ -14,9 +14,7 @@ <methodparam><type>string</type><parameter>key</parameter></methodparam> <methodparam><type>string</type><parameter>data</parameter></methodparam> <methodparam><type>string</type><parameter>mode</parameter></methodparam> - <methodparam choice="opt"><type>string</type><parameter> - iv - </parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>iv</parameter></methodparam> </methodsynopsis> <para> <function>mcrypt_encrypt</function> encrypts the data @@ -58,13 +56,13 @@ <programlisting role="php"> <![CDATA[ <?php -$iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); -$key = "This is a very secret key"; -$text = "Meet me at 11 o'clock behind the monument."; -echo strlen ($text)."\n"; + $iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); + $key = "This is a very secret key"; + $text = "Meet me at 11 o'clock behind the monument."; + echo strlen ($text)."\n"; -$crypttext = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv); -echo strlen ($crypttext)."\n"; + $crypttext = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv); + echo strlen ($crypttext)."\n"; ?> ]]> </programlisting> @@ -78,6 +76,10 @@ </screen> </para> </example> + </para> + <para> + See also <function>mcrypt_module_open</function> for a more advanced API + and an example. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-generic-deinit.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-generic-deinit.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-generic-deinit.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-generic-deinit.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-generic-deinit.xml Sun May 12 17:00:19 2002 @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.27 --> <refentry id='function.mcrypt-generic-deinit'> <refnamediv> <refname>mcrypt_generic_deinit</refname> <refpurpose> - This function terminates encrypt specified by the descriptor td + This function deinitializes an encryption module </refpurpose> </refnamediv> <refsect1> @@ -15,7 +15,16 @@ <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> - &warn.undocumented.func; + This function terminates encryption specified by the encryption + descriptor (<parameter>td</parameter>). It clears all buffers, but does + not close the module. You need to call + <function>mcrypt_module_close</function> yourself. (But PHP does this for + you at the end of the script. Returns &false; on error, or &true; on + succes. + </para> + <para> + See for an example <function>mcrypt_module_open</function> and the + entry on <function>mcrypt_generic_init</function>. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-generic-end.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-generic-end.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-generic-end.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-generic-end.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-generic-end.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-generic-end"> <refnamediv> @@ -13,9 +13,16 @@ <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> + This function is deprecated, use + <function>mcrypt_generic_deinit</function> instead. It can cause crashes + when used with <function>mcrypt_module_close</function> due to multiple + buffer frees. + </para> + <para> This function terminates encryption specified by the encryption - descriptor (td). Actually it clears all buffers, and closes - all the modules used. Returns &false; on error, or &true; on succes. + descriptor (<parameter>td</parameter>). Actually it clears all buffers, + and closes all the modules used. Returns &false; on error, or &true; on + succes. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-generic-init.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-generic-init.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-generic-init.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-generic-init.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-generic-init.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-generic-init"> <refnamediv> @@ -27,9 +27,13 @@ recommended. The function returns a negative value on error. </para> <para> - You need to call this function before every + You need to call this function before every call to <function>mcrypt_generic</function> or <function>mdecrypt_generic</function>. + </para> + <para> + See for an example <function>mcrypt_module_open</function> and the + entry on <function>mcrypt_generic_deinit</function>. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-generic.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-generic.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-generic.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-generic.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-generic.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-generic"> <refnamediv> @@ -19,6 +19,18 @@ function returns the encrypted data. Note that the length of the returned string can in fact be longer then the input, due to the padding of the data. + </para> + <para> + The encryption handle should alwayws be initialized with + <function>mcrypt_generic_init</function> with a key and an IV before + calling this function. Where the encryption is done, you should free the + encryption buffers by calling <function>mcrypt_generic_deinit</function>. + See <function>mcrypt_module_open</function> for an example. + </para> + <para> + See also <function>mdecrypt_generic</function>, + <function>mcrypt_generic_init</function> and + <function>mcrypt_generic_deinit</function>. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-get-block-size.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-get-block-size.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-get-block-size.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-get-block-size.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-get-block-size.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-get-block-size"> <refnamediv> @@ -19,19 +19,33 @@ </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or 2.5.x. </para> <para> <function>mcrypt_get_block_size</function> is used to get the - size of a block of the specified <parameter>cipher</parameter>. + size of a block of the specified <parameter>cipher</parameter> (in + combination with an encryption mode). </para> <para> - <function>mcrypt_get_block_size</function> takes one or two - arguments, the <parameter>cipher</parameter> and - <parameter>module</parameter>, and returns the size in bytes. - </para> + This example shows how to use this function when linked against libmcrypt + 2.4.x and 2.5.x. + <example> + <title><function>mcrypt_get_block_size</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + echo mcrypt_get_block_size ('tripledes', 'ecb'); +?> + +Prints: +8 +]]> + </programlisting> + </example> + </para> <para> - See also: <function>mcrypt_get_key_size</function>. + See also: <function>mcrypt_get_key_size</function> and + <function>mcrypt_encrypt</function>. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-get-cipher-name.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-get-cipher-name.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-get-cipher-name.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-get-cipher-name.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-get-cipher-name.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-get-cipher-name"> <refnamediv> @@ -23,7 +23,7 @@ <para> <function>mcrypt_get_cipher_name</function> takes the cipher number as an argument (libmcrypt 2.2.x) or takes the cipher name - as an argument (libmcrypt 2.4.x) and returns the name of the cipher + as an argument (libmcrypt 2.4.x or higher) and returns the name of the cipher or &false;, if the cipher does not exist. </para> <para> @@ -32,9 +32,9 @@ <programlisting role="php"> <![CDATA[ <?php -$cipher = MCRYPT_TripleDES; + $cipher = MCRYPT_TripleDES; -print mcrypt_get_cipher_name ($cipher); + echo mcrypt_get_cipher_name ($cipher); ?> ]]> </programlisting> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-get-iv-size.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-get-iv-size.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-get-iv-size.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-get-iv-size.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-get-iv-size.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-get-iv-size"> <refnamediv> @@ -10,16 +10,16 @@ <title>Description</title> <methodsynopsis> <type>int</type><methodname>mcrypt_get_iv_size</methodname> - <methodparam><type>string</type><parameter>cipher</parameter></methodparam> - <methodparam><type>string</type><parameter>mode</parameter></methodparam> + <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <methodsynopsis> <type>int</type><methodname>mcrypt_get_iv_size</methodname> - <methodparam><type>resource</type><parameter>td</parameter></methodparam> + <methodparam><type>string</type><parameter>cipher</parameter></methodparam> + <methodparam><type>string</type><parameter>mode</parameter></methodparam> </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or higher. </para> <para> <function>mcrypt_get_iv_size</function> returns the size of @@ -28,16 +28,34 @@ combination zero is returned. </para> <para> - <parameter>Cipher</parameter> is one of the MCRYPT_ciphername + <parameter>cipher</parameter> is one of the MCRYPT_ciphername constants of the name of the algorithm as string. </para> <para> - <parameter>Mode</parameter> is one of the MCRYPT_MODE_modename + <parameter>mode</parameter> is one of the MCRYPT_MODE_modename constants of one of "ecb", "cbc", "cfb", "ofb", "nofb" or "stream". </para> <para> - <parameter>Td</parameter> is the algorithm specified. + <parameter>td</parameter> is the resource that is returned by + <function>mcrypt_module_open</function>. + </para> + <para> + <example> + <title><function>mcrypt_create_iv</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + $size = mcrypt_get_iv_size (MCRYPT_CAST_256, MCRYPT_MODE_CFB); + + $size = mcrypt_get_iv_size ('des', 'ecb'); +?> +]]> + </programlisting> + </example> + </para> + <para> + See also: <function>mcrypt_create_iv</function> </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-get-key-size.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-get-key-size.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-get-key-size.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-get-key-size.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-get-key-size.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-get-key-size"> <refnamediv> @@ -19,20 +19,35 @@ </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or 2.5.x. </para> <para> <function>mcrypt_get_key_size</function> is used to get the size - of a key of the specified <parameter>cipher</parameter>. + of a key of the specified <parameter>cipher</parameter> (in + combination with an encryption mode). </para> <para> - <function>mcrypt_get_key_size</function> takes one or two - arguments, the <parameter>cipher</parameter> and - <parameter>module</parameter>, and returns the size in bytes. - </para> + This example shows how to use this function when linked against libmcrypt + 2.4.x and 2.5.x. + <example> + <title><function>mcrypt_get_block_size</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + echo mcrypt_get_key_size ('tripledes', 'ecb'); +?> + +Prints: +24 +]]> + </programlisting> + </example> + </para> <para> - See also: <function>mcrypt_get_block_size</function>. + See also: <function>mcrypt_get_block_size</function> and + <function>mcrypt_encrypt</function>. </para> + </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-list-algorithms.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-list-algorithms.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-list-algorithms.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-list-algorithms.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-list-algorithms.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-list-algorithms"> <refnamediv> @@ -10,20 +10,17 @@ <title>Description</title> <methodsynopsis> <type>array</type><methodname>mcrypt_list_algorithms</methodname> - <methodparam choice="opt"><type>string</type><parameter> - lib_dir - </parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>lib_dir</parameter></methodparam> </methodsynopsis> <para> <function>mcrypt_list_algorithms</function> is used to get an - array of all supported algorithms in the + array of all supported algorithms in the <parameter>lib_dir</parameter> parameter. </para> <para> - <parameter>lib_dir</parameter>. - <function>mcrypt_list_algorithms</function> takes as optional - parameter a directory which specifies the directory where all - algorithms are located. If not specifies, the value of the - mcrypt.algorithms_dir &php.ini; directive is used. + <function>mcrypt_list_algorithms</function> takes an optional + <parameter>lib_dir</parameter> parameter which specifies the directory + where all algorithms are located. If not specifies, the value of the + mcrypt.algorithms_dir &php.ini; directive is used. </para> <para> <example> @@ -31,11 +28,11 @@ <programlisting role="php"> <![CDATA[ <?php -$algorithms = mcrypt_list_algorithms ("/usr/local/lib/libmcrypt"); + $algorithms = mcrypt_list_algorithms ("/usr/local/lib/libmcrypt"); -foreach ($algorithms as $cipher) { - echo $cipher."/n"; -} + foreach ($algorithms as $cipher) { + echo "$cipher<br />\n"; + } ?> ]]> </programlisting> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-list-modes.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-list-modes.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-list-modes.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-list-modes.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-list-modes.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-list-modes"> <refnamediv> @@ -10,9 +10,7 @@ <title>Description</title> <methodsynopsis> <type>array</type><methodname>mcrypt_list_modes</methodname> - <methodparam choice="opt"><type>string</type><parameter> - lib_dir - </parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>lib_dir</parameter></methodparam> </methodsynopsis> <para> <function>mcrypt_list_modes</function> is used to get an @@ -23,7 +21,7 @@ <function>mcrypt_list_modes</function> takes as optional parameter a directory which specifies the directory where all modes are located. If not specifies, the value of the - mcrypt.modes_dir &php.ini; directive is used. + mcrypt.modes_dir &php.ini; directive is used. </para> <para> <example> @@ -31,11 +29,11 @@ <programlisting role="php"> <![CDATA[ <?php -$modes = mcrypt_list_modes (); + $modes = mcrypt_list_modes (); -foreach ($modes as $mode) { - echo "$mode <br/>"; -} + foreach ($modes as $mode) { + echo "$mode <br />\n"; + } ?> ]]> </programlisting> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-close.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-close.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-close.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-close.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-close.xml Sun May 12 17:00:19 2002 @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.27 --> <refentry id='function.mcrypt-module-close'> <refnamediv> <refname>mcrypt_module_close</refname> <refpurpose> - Free the descriptor td + Close the mcrypt module </refpurpose> </refnamediv> <refsect1> @@ -15,7 +15,10 @@ <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> - &warn.undocumented.func; + This function closes the specified encryption handle. + </para> + <para> + See <function>mcrypt_module_open</function> for an example. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-get-supported-key-sizes.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-get-supported-key-sizes.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-get-supported-key-sizes.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-get-supported-key-sizes.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-get-supported-key-sizes.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-module-get-supported-key-sizes"> <refnamediv> @@ -14,12 +14,15 @@ <methodparam choice="opt"><type>string</type><parameter>lib_dir</parameter></methodparam> </methodsynopsis> <para> - Returns an array with the key sizes supported by the specified - algorithm. If it returns an empty array then all key sizes - between 1 and <function>mcrypt_module_get_algo_key_size</function> - are supported by the algorithm. The optional - <parameter>lib_dir</parameter> parameter can contain the - location where the mode module is on the system. + Returns an array with the key sizes supported by the specified algorithm. + If it returns an empty array then all key sizes between 1 and + <function>mcrypt_module_get_algo_key_size</function> are supported by the + algorithm. The optional <parameter>lib_dir</parameter> parameter can + contain the location where the mode module is on the system. + </para> + <para> + See also <function>mcrypt_enc_get_supported_key_sizes</function> which is + used on open encryption modules. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm-mode.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm-mode.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm-mode.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm-mode.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm-mode.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-module-is-block-algorithm-mode"> <refnamediv> @@ -14,10 +14,11 @@ <methodparam choice="opt"><type>string</type><parameter>lib_dir</parameter></methodparam> </methodsynopsis> <para> - This function returns &true; if the mode is for use with block algorithms, - otherwise it returns 0. (eg. 0 for stream, and 1 for cbc, cfb, ofb). - The optional <parameter>lib_dir</parameter> parameter can contain - the location where the mode module is on the system. + This function returns &true; if the mode is for use with block + algorithms, otherwise it returns &false;. (eg. &false; for stream, and + &true; for cbc, cfb, ofb). The optional <parameter>lib_dir</parameter> + parameter can contain the location where the mode module is on the + system. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm.xml:1.2 Wed Apr 17 02:40:14 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm.xml Sun May 12 17:00:20 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-module-is-block-algorithm"> <refnamediv> @@ -15,9 +15,9 @@ </methodsynopsis> <para> This function returns &true; if the specified algorithm is a block - algorithm, or &false; is it is a stream algorithm. - The optional <parameter>lib_dir</parameter> parameter can contain - the location where the algorithm module is on the system. + algorithm, or &false; is it is a stream algorithm. The optional + <parameter>lib_dir</parameter> parameter can contain the location where + the algorithm module is on the system. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-mode.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-mode.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-mode.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-mode.xml:1.2 Wed Apr 17 02:40:14 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-mode.xml Sun May 12 17:00:20 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-module-is-block-mode"> <refnamediv> @@ -15,9 +15,10 @@ </methodsynopsis> <para> This function returns &true; if the mode outputs blocks of bytes or - &false; if it outputs just bytes. (eg. 1 for cbc and ecb, and 0 for cfb - and stream). The optional <parameter>lib_dir</parameter> parameter - can contain the location where the mode module is on the system. + &false; if it outputs just bytes. (eg. &true; for cbc and ecb, and + &false; for cfb and stream). The optional <parameter>lib_dir</parameter> + parameter can contain the location where the mode module is on the + system. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-open.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-open.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-open.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-open.xml:1.2 Wed Apr 17 02:40:14 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-open.xml Sun May 12 17:00:20 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-module-open"> <refnamediv> @@ -16,24 +16,21 @@ <methodparam><type>string</type><parameter>mode_directory</parameter></methodparam> </methodsynopsis> <para> - This function opens the module of the algorithm and the mode - to be used. The name of the algorithm is specified in algorithm, - eg "twofish" or is one of the MCRYPT_ciphername constants. - The library is closed by calling - <function>mcrypt_module_close</function>, but there is no need - to call that function if <function>mcrypt_generic_end</function> - is called. Normally it returns an encryption descriptor, or - &false; on error. + This function opens the module of the algorithm and the mode to be used. + The name of the algorithm is specified in algorithm, eg. "twofish" or is + one of the MCRYPT_ciphername constants. The module is closed by calling + <function>mcrypt_module_close</function>. Normally it returns an + encryption descriptor, or &false; on error. </para> <para> The <parameter>algorithm_directory</parameter> and - <parameter>mode_directory</parameter> are used to locate the - encryption modules. When you supply a directory name, it is used. - When you set one of these to the empty string (""), the value set - by the <parameter>mcrypt.algorithms_dir</parameter> or - <parameter>mcrypt.modes_dir</parameter> ini-directive is used. - When these are not set, the default directory are used that are - compiled in into libmcrypt (usally /usr/local/lib/libmcrypt). + <parameter>mode_directory</parameter> are used to locate the encryption + modules. When you supply a directory name, it is used. When you set one + of these to the empty string (""), the value set by the + <parameter>mcrypt.algorithms_dir</parameter> or + <parameter>mcrypt.modes_dir</parameter> ini-directive is used. When + these are not set, the default directories that are used are the ones + that were compiled in into libmcrypt (usally /usr/local/lib/libmcrypt). </para> <para> <example> @@ -41,16 +38,75 @@ <programlisting role="php"> <![CDATA[ <?php -$td = mcrypt_module_open (MCRYPT_DES, "", MCRYPT_MODE_ECB, "/usr/lib/mcrypt-modes"); + $td = mcrypt_module_open (MCRYPT_DES, '', MCRYPT_MODE_ECB, '/usr/lib/mcrypt-modes'); + $td = mcrypt_module_open ('rijndael-256', '', 'ofb', ''); ?> ]]> </programlisting> - <para> - The above example will try to open the DES cipher - from the default directory and the EBC mode from the directory - <filename>/usr/lib/mcrypt-modes</filename>. - </para> </example> + </para> + <para> + The first line in the example above will try to open the DES cipher from + the default directory and the EBC mode from the directory + <filename>/usr/lib/mcrypt-modes</filename>. The second example uses + strings as name for the cipher an dmode, this only works when the + extension is linked against libmcrypt 2.4.x or 2.5.x. + </para> + <para> + <example> + <title>Using <function>mcrypt_module_open</function> in encryption</title> + <programlisting role="php"> +<![CDATA[ +<?php + /* Open the cipher */ + $td = mcrypt_module_open ('rijndael-256', '', 'ofb', ''); + + /* Create the IV and determine the keysize length */ + $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM); + $ks = mcrypt_enc_get_key_size ($td); + + /* Create key */ + $key = substr (md5 ('very secret key'), 0, $ks); + + /* Intialize encryption */ + mcrypt_generic_init ($td, $key, $iv); + + /* Encrypt data */ + $encrypted = mcrypt_generic ($td, 'This is very important data'); + + /* Terminate encryption handler */ + mcrypt_generic_deinit ($td); + + /* Initialize encryption module for decryption */ + mcrypt_generic_init ($td, $key, $iv); + + /* Decrypt encrypted string */ + $decrypted = mdecrypt_generic ($td, $encrypted); + + /* Terminate decryption handle and close module */ + mcrypt_generic_deinit ($td); + mcrypt_module_close ($td); + + /* Show string */ + echo trim ($decrypted)."\n"; +?> +]]> + </programlisting> + </example> + </para> + <para> + The first line in the example above will try to open the DES cipher from + the default directory and the EBC mode from the directory + <filename>/usr/lib/mcrypt-modes</filename>. The second example uses + strings as name for the cipher an dmode, this only works when the + extension is linked against libmcrypt 2.4.x or 2.5.x. + </para> + <para> + See also <function>mcrypt_module_close</function>, + <function>mcrypt_generic</function>, + <function>mdecrypt_generic</function>, + <function>mcrypt_generic_init</function> and + <function>mcrypt_generic_deinit</function>. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-self-test.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-self-test.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-self-test.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-self-test.xml:1.2 Wed Apr 17 02:40:14 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-self-test.xml Sun May 12 17:00:20 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-module-self-test"> <refnamediv> @@ -14,13 +14,13 @@ <methodparam choice="opt"><type>string</type><parameter>lib_dir</parameter></methodparam> </methodsynopsis> <para> - This function runs the self test on the algorithm specified. - The optional <parameter>lib_dir</parameter> parameter can contain - the location of where the algorithm module is on the system. + This function runs the self test on the algorithm specified. The + optional <parameter>lib_dir</parameter> parameter can contain the + location of where the algorithm module is on the system. </para> <para> - The function returns &true; if the self test succeeds, or &false; when - if fails. + The function returns &true; if the self test succeeds, or &false; when if + fails. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-ofb.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-ofb.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-ofb.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-ofb.xml:1.2 Wed Apr 17 02:40:14 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-ofb.xml Sun May 12 17:00:20 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-ofb"> <refnamediv> @@ -26,36 +26,12 @@ </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or higher. </para> <para> - <function>mcrypt_ofb</function> encrypts or decrypts (depending - on <parameter>mode</parameter>) the <parameter>data</parameter> - with <parameter>cipher</parameter> and <parameter>key</parameter> - in OFB cipher mode and returns the resulting string. - </para> - <para> - <parameter>Cipher</parameter> is one of the MCRYPT_ciphername - constants. - </para> - <para> - <parameter>Key</parameter> is the key supplied to the - algorithm. It must be kept secret. - </para> - <para> - <parameter>Data</parameter> is the data which shall be - encrypted/decrypted. - </para> - <para> - <parameter>Mode</parameter> is MCRYPT_ENCRYPT or MCRYPT_DECRYPT. - </para> - <para> - <parameter>IV</parameter> is the initialization vector. - </para> - <para> - See also: <function>mcrypt_cbc</function>, - <function>mcrypt_cfb</function>, and - <function>mcrypt_ecb</function>. + This function should not be used anymore, see + <function>mcrypt_generic</function> and + <function>mdecrypt_generic</function> for replacements. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mdecrypt-generic.xml diff -u phpdoc/en/reference/mcrypt/functions/mdecrypt-generic.xml:1.2 phpdoc/en/reference/mcrypt/functions/mdecrypt-generic.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mdecrypt-generic.xml:1.2 Wed Apr 17 02:40:14 2002 +++ phpdoc/en/reference/mcrypt/functions/mdecrypt-generic.xml Sun May 12 17:00:20 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mdecrypt-generic"> <refnamediv> @@ -14,9 +14,9 @@ <methodparam><type>string</type><parameter>data</parameter></methodparam> </methodsynopsis> <para> - This function decrypts data. Note that the length of the - returned string can in fact be longer then the unencrypted - string, due to the padding of the data. + This function decrypts data. Note that the length of the returned string + can in fact be longer then the unencrypted string, due to the padding of + the data. </para> <para> <example> @@ -24,27 +24,60 @@ <programlisting role="php"> <![CDATA[ <?php -$iv_size = mcrypt_enc_get_iv_size ($td)); -$iv = @mcrypt_create_iv ($iv_size, MCRYPT_RAND); + /* Data */ + $key = 'this is a very long key, even too long for the cipher'; + $plain_text = 'very important data'; + + /* Open module, and create IV */ + $td = mcrypt_module_open ('des', '', 'ecb', ''); + $key = substr ($key, 0, mcrypt_enc_get_key_size ($td)); + $iv_size = mcrypt_enc_get_iv_size ($td); + $iv = mcrypt_create_iv ($iv_size, MCRYPT_RAND); -if (@mcrypt_generic_init ($td, $key, $iv) != -1) -{ - $c_t = mcrypt_generic ($td, $plain_text); - @mcrypt_generic_init ($td, $key, $iv); - $p_t = mdecrypt_generic ($td, $c_t); -} -if (strncmp ($p_t, $plain_text, strlen($plain_text)) == 0) - echo "ok"; -else - echo "error"; + /* Initialize encryption handle */ + if (mcrypt_generic_init ($td, $key, $iv) != -1) { + + /* Encrypt data */ + $c_t = mcrypt_generic ($td, $plain_text); + mcrypt_generic_deinit ($td); + + /* Reinitialize buffers for decryption */ + mcrypt_generic_init ($td, $key, $iv); + $p_t = mdecrypt_generic ($td, $c_t); + + /* Clean up */ + mcrypt_generic_deinit ($td); + mcrypt_module_close ($td); + } + + if (strncmp ($p_t, $plain_text, strlen($plain_text)) == 0) { + echo "ok\n"; + } else { + echo "error\n"; + } ?> ]]> </programlisting> - <para> - The above example shows how to check if the data before the - encryption is the same as the data after the decryption. - </para> </example> + </para> + <para> + The above example shows how to check if the data before the encryption is + the same as the data after the decryption. It is very important to + reinitialize the encryption buffer with + <function>mcrypt_generic_init</function> before you try to decrypt the + data. + </para> + <para> + The decryption handle should alwayws be initialized with + <function>mcrypt_generic_init</function> with a key and an IV before + calling this function. Where the encryption is done, you should free the + encryption buffers by calling <function>mcrypt_generic_deinit</function>. + See <function>mcrypt_module_open</function> for an example. + </para> + <para> + See also <function>mcrypt_generic</function>, + <function>mcrypt_generic_init</function> and + <function>mcrypt_generic_deinit</function>. </para> </refsect1> </refentry>
Index: phpdoc/en/reference/mcrypt/reference.xml diff -u phpdoc/en/reference/mcrypt/reference.xml:1.2 phpdoc/en/reference/mcrypt/reference.xml:1.3 --- phpdoc/en/reference/mcrypt/reference.xml:1.2 Mon Apr 15 14:56:45 2002 +++ phpdoc/en/reference/mcrypt/reference.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <reference id="ref.mcrypt"> <title>Mcrypt Encryption Functions</title> <titleabbrev>mcrypt</titleabbrev> @@ -36,40 +36,40 @@ <literal>$encrypted_data</literal>. </para> <para> - If you linked against libmcrypt 2.4.x, these functions are still + If you linked against libmcrypt 2.4.x or 2.5.x, these functions are still available, but it is recommended that you use the advanced functions. <example> - <title>Encrypt an input value with TripleDES under 2.4.x in ECB mode</title> + <title>Encrypt an input value with TripleDES under 2.4.x and higher in ECB mode</title> <programlisting role="php"> <![CDATA[ <?php -$key = "this is a very secret key"; -$input = "Let us meet at 9 o'clock at the secret place."; + $key = "this is a very secret key"; + $input = "Let us meet at 9 o'clock at the secret place."; -$td = mcrypt_module_open (MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, ""); -$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); -mcrypt_generic_init ($td, $key, $iv); -$encrypted_data = mcrypt_generic ($td, $input); -mcrypt_generic_end ($td); + $td = mcrypt_module_open ('tripledes', '', 'ecb', ''); + $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); + mcrypt_generic_init ($td, $key, $iv); + $encrypted_data = mcrypt_generic ($td, $input); + mcrypt_generic_end ($td); ?> ]]> </programlisting> </example> This example will give you the encrypted data as a string in - <literal>$encrypted_data</literal>. + <literal>$encrypted_data</literal>. For a full example see + <function>mcrypt_module_open</function>. </para> <section id="mcrypt.requirements"> <title>Requirements</title> <para> - These functions work using <ulink - url="&url.mcrypt;">mcrypt</ulink>. + These functions work using <ulink url="&url.mcrypt;">mcrypt</ulink>. </para> <para> - If you linked against libmcrypt 2.4.x, the following additional + If you linked against libmcrypt 2.4.x or higher, the following additional block algorithms are supported: CAST, LOKI97, RIJNDAEL, SAFERPLUS, - SERPENT and the following stream ciphers: ENIGMA (crypt), PANAMA, - RC4 and WAKE. With libmcrypt 2.4.x another cipher mode is also + SERPENT and the following stream ciphers: ENIGMA (crypt), PANAMA, RC4 and + WAKE. With libmcrypt 2.4.x or higher another cipher mode is also available; nOFB. </para> </section> @@ -78,11 +78,11 @@ <title>Installation</title> <para> To use it, download libmcrypt-x.x.tar.gz from <ulink - url="&url.mcrypt;">here</ulink> and follow the included - installation instructions. You need to compile PHP with the - <option role="configure">--with-mcrypt</option> parameter to - enable this extension. Make sure you compile libmcrypt with the - option <option role="configure">--disable-posix-threads</option>. + url="&url.mcrypt;">here</ulink> and follow the included installation + instructions. You need to compile PHP with the <option + role="configure">--with-mcrypt</option> parameter to enable this + extension. Make sure you compile libmcrypt with the option <option + role="configure">--disable-posix-threads</option>. </para> </section> @@ -103,7 +103,7 @@ <para> Mcrypt can operate in four block cipher modes (CBC, OFB, CFB, and - ECB). If linked against libmcrypt-2.4.x mcrypt can also operate + ECB). If linked against libmcrypt-2.4.x or higher the functions can also operate in the block cipher mode nOFB and in STREAM mode. Below you find a list with all supported encryption modes together with the constants that are defines for the encryption mode. For a more complete reference and @@ -157,51 +157,51 @@ extension. For a complete list of supported ciphers, see the defines at the end of <filename>mcrypt.h</filename>. The general rule with the mcrypt-2.2.x API is that you can access the cipher from PHP with - MCRYPT_ciphername. With the mcrypt-2.4.x API these constants also work, + MCRYPT_ciphername. With the libmcrypt-2.4.x and libmcrypt-2.5.x API these constants also work, but it is possible to specify the name of the cipher as a string with a call to <function>mcrypt_module_open</function>. <itemizedlist> <listitem><simpara>MCRYPT_3DES</simpara></listitem> - <listitem><simpara>MCRYPT_ARCFOUR_IV (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_ARCFOUR (libmcrypt 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_ARCFOUR_IV (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_ARCFOUR (libmcrypt > 2.4.x only)</simpara></listitem> <listitem><simpara>MCRYPT_BLOWFISH</simpara></listitem> <listitem><simpara>MCRYPT_CAST_128</simpara></listitem> <listitem><simpara>MCRYPT_CAST_256</simpara></listitem> <listitem><simpara>MCRYPT_CRYPT</simpara></listitem> <listitem><simpara>MCRYPT_DES</simpara></listitem> <listitem><simpara>MCRYPT_DES_COMPAT (libmcrypt 2.2.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_ENIGMA (libmcrypt 2.4.x only, alias for MCRYPT_CRYPT)</simpara></listitem> + <listitem><simpara>MCRYPT_ENIGMA (libmcrypt > 2.4.x only, alias for MCRYPT_CRYPT)</simpara></listitem> <listitem><simpara>MCRYPT_GOST</simpara></listitem> <listitem><simpara>MCRYPT_IDEA (non-free)</simpara></listitem> - <listitem><simpara>MCRYPT_LOKI97 (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_MARS (libmcrypt 2.4.x only, non-free)</simpara></listitem> - <listitem><simpara>MCRYPT_PANAMA (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_RIJNDAEL_128 (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_RIJNDAEL_192 (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_RIJNDAEL_256 (libmcrypt 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_LOKI97 (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_MARS (libmcrypt > 2.4.x only, non-free)</simpara></listitem> + <listitem><simpara>MCRYPT_PANAMA (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_RIJNDAEL_128 (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_RIJNDAEL_192 (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_RIJNDAEL_256 (libmcrypt > 2.4.x only)</simpara></listitem> <listitem><simpara>MCRYPT_RC2</simpara></listitem> <listitem><simpara>MCRYPT_RC4 (libmcrypt 2.2.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_RC6 (libmcrypt 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_RC6 (libmcrypt > 2.4.x only)</simpara></listitem> <listitem><simpara>MCRYPT_RC6_128 (libmcrypt 2.2.x only)</simpara></listitem> <listitem><simpara>MCRYPT_RC6_192 (libmcrypt 2.2.x only)</simpara></listitem> <listitem><simpara>MCRYPT_RC6_256 (libmcrypt 2.2.x only)</simpara></listitem> <listitem><simpara>MCRYPT_SAFER64</simpara></listitem> <listitem><simpara>MCRYPT_SAFER128</simpara></listitem> - <listitem><simpara>MCRYPT_SAFERPLUS (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_SERPENT(libmcrypt 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_SAFERPLUS (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_SERPENT(libmcrypt > 2.4.x only)</simpara></listitem> <listitem><simpara>MCRYPT_SERPENT_128 (libmcrypt 2.2.x only)</simpara></listitem> <listitem><simpara>MCRYPT_SERPENT_192 (libmcrypt 2.2.x only)</simpara></listitem> <listitem><simpara>MCRYPT_SERPENT_256 (libmcrypt 2.2.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_SKIPJACK (libmcrypt 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_SKIPJACK (libmcrypt > 2.4.x only)</simpara></listitem> <listitem><simpara>MCRYPT_TEAN (libmcrypt 2.2.x only)</simpara></listitem> <listitem><simpara>MCRYPT_THREEWAY</simpara></listitem> - <listitem><simpara>MCRYPT_TRIPLEDES (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_TWOFISH (for older mcrypt 2.x versions, or mcrypt 2.4.x )</simpara></listitem> + <listitem><simpara>MCRYPT_TRIPLEDES (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_TWOFISH (for older mcrypt 2.x versions, or mcrypt > 2.4.x )</simpara></listitem> <listitem><simpara>MCRYPT_TWOFISH128 (TWOFISHxxx are available in newer 2.x versions, but not in the 2.4.x versions)</simpara></listitem> <listitem><simpara>MCRYPT_TWOFISH192</simpara></listitem> <listitem><simpara>MCRYPT_TWOFISH256</simpara></listitem> - <listitem><simpara>MCRYPT_WAKE (libmcrypt 2.4.x only)</simpara></listitem> - <listitem><simpara>MCRYPT_XTEA (libmcrypt 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_WAKE (libmcrypt > 2.4.x only)</simpara></listitem> + <listitem><simpara>MCRYPT_XTEA (libmcrypt > 2.4.x only)</simpara></listitem> </itemizedlist> </para> <para> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-cbc.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-cbc.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-cbc.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-cbc.xml:1.2 Wed Apr 17 02:40:11 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-cbc.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-cbc"> <refnamediv> @@ -26,36 +26,12 @@ </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or higher. </para> <para> - <function>mcrypt_cbc</function> encrypts or decrypts (depending - on <parameter>mode</parameter>) the <parameter>data</parameter> - with <parameter>cipher</parameter> and <parameter>key</parameter> - in CBC cipher mode and returns the resulting string. - </para> - <para> - <parameter>Cipher</parameter> is one of the MCRYPT_ciphername - constants. - </para> - <para> - <parameter>Key</parameter> is the key supplied to the - algorithm. It must be kept secret. - </para> - <para> - <parameter>Data</parameter> is the data which shall be - encrypted/decrypted. - </para> - <para> - <parameter>Mode</parameter> is MCRYPT_ENCRYPT or MCRYPT_DECRYPT. - </para> - <para> - <parameter>IV</parameter> is the optional initialization vector. - </para> - <para> - See also: <function>mcrypt_cfb</function>, - <function>mcrypt_ecb</function>, and - <function>mcrypt_ofb</function>. + This function should not be used anymore, see + <function>mcrypt_generic</function> and + <function>mdecrypt_generic</function> for replacements. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-cfb.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-cfb.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-cfb.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-cfb.xml:1.2 Wed Apr 17 02:40:11 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-cfb.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-cfb"> <refnamediv> @@ -26,36 +26,12 @@ </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or higher. </para> <para> - <function>mcrypt_cfb</function> encrypts or decrypts (depending - on <parameter>mode</parameter>) the <parameter>data</parameter> - with <parameter>cipher</parameter> and <parameter>key</parameter> - in CFB cipher mode and returns the resulting string. - </para> - <para> - <parameter>Cipher</parameter> is one of the MCRYPT_ciphername - constants. - </para> - <para> - <parameter>Key</parameter> is the key supplied to the - algorithm. It must be kept secret. - </para> - <para> - <parameter>Data</parameter> is the data which shall be - encrypted/decrypted. - </para> - <para> - <parameter>Mode</parameter> is MCRYPT_ENCRYPT or MCRYPT_DECRYPT. - </para> - <para> - <parameter>IV</parameter> is the initialization vector. - </para> - <para> - See also: <function>mcrypt_cbc</function>, - <function>mcrypt_ecb</function>, and - <function>mcrypt_ofb</function>. + This function should not be used anymore, see + <function>mcrypt_generic</function> and + <function>mdecrypt_generic</function> for replacements. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-create-iv.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-create-iv.xml:1.3 phpdoc/en/reference/mcrypt/functions/mcrypt-create-iv.xml:1.4 --- phpdoc/en/reference/mcrypt/functions/mcrypt-create-iv.xml:1.3 Thu Apr 18 05:25:10 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-create-iv.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-create-iv"> <refnamediv> @@ -36,9 +36,8 @@ <programlisting role="php"> <![CDATA[ <?php -$cipher = MCRYPT_TripleDES; -$block_size = mcrypt_get_block_size ($cipher); -$iv = mcrypt_create_iv ($block_size, MCRYPT_DEV_RANDOM); + $size = mcrypt_get_iv_size (MCRYPT_CAST_256, MCRYPT_MODE_CFB); + $iv = mcrypt_create_iv ($size, MCRYPT_DEV_RANDOM); ?> ]]> </programlisting> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-decrypt.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-decrypt.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-decrypt.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-decrypt.xml:1.2 Wed Apr 17 02:40:11 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-decrypt.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-decrypt"> <refnamediv> @@ -14,9 +14,7 @@ <methodparam><type>string</type><parameter>key</parameter></methodparam> <methodparam><type>string</type><parameter>data</parameter></methodparam> <methodparam><type>string</type><parameter>mode</parameter></methodparam> - <methodparam choice="opt"><type>string</type><parameter> - iv - </parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>iv</parameter></methodparam> </methodsynopsis> <para> <function>mcrypt_decrypt</function> decrypts the data Index: phpdoc/en/reference/mcrypt/functions/mcrypt-ecb.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-ecb.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-ecb.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-ecb.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-ecb.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-ecb"> <refnamediv> @@ -25,33 +25,12 @@ </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or higher. </para> <para> - <function>mcrypt_ecb</function> encrypts or decrypts (depending - on <parameter>mode</parameter>) the <parameter>data</parameter> - with <parameter>cipher</parameter> and <parameter>key</parameter> - in ECB cipher mode and returns the resulting string. - </para> - <para> - <parameter>Cipher</parameter> is one of the MCRYPT_ciphername - constants. - </para> - <para> - <parameter>Key</parameter> is the key supplied to the - algorithm. It must be kept secret. - </para> - <para> - <parameter>Data</parameter> is the data which shall be - encrypted/decrypted. - </para> - <para> - <parameter>Mode</parameter> is MCRYPT_ENCRYPT or MCRYPT_DECRYPT. - </para> - <para> - See also: <function>mcrypt_cbc</function>, - <function>mcrypt_cfb</function>, and - <function>mcrypt_ofb</function>. + This function should not be used anymore, see + <function>mcrypt_generic</function> and + <function>mdecrypt_generic</function> for replacements. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-algorithms-name.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-algorithms-name.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-algorithms-name.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-algorithms-name.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-algorithms-name.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-get-algorithms-name"> <refnamediv> @@ -14,6 +14,26 @@ </methodsynopsis> <para> This function returns the name of the algorithm. + </para> + <para> + <example> + <title><function>mcrypt_enc_get_algorithms_name</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + $td = mcrypt_module_open (MCRYPT_CAST_256, '', MCRYPT_MODE_CFB, ''); + echo mcrypt_enc_get_algorithms_name($td). "\n"; + + $td = mcrypt_module_open ('cast-256', '', MCRYPT_MODE_CFB, ''); + echo mcrypt_enc_get_algorithms_name($td). "\n"; +?> + +Prints: +CAST-256 +CAST-256 +]]> + </programlisting> + </example> </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-block-size.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-block-size.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-block-size.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-block-size.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-block-size.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-get-block-size"> <refnamediv> @@ -14,7 +14,7 @@ </methodsynopsis> <para> This function returns the block size of the algorithm specified by - the encryption descriptor td in bytes. + the encryption descriptor <parameter>td</parameter> in bytes. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-key-size.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-key-size.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-key-size.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-key-size.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-key-size.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-get-key-size"> <refnamediv> @@ -14,7 +14,8 @@ </methodsynopsis> <para> This function returns the maximum supported key size of the - algorithm specified by the encryption descriptor td in bytes. + algorithm specified by the encryption descriptor + <parameter>td</parameter> in bytes. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-modes-name.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-modes-name.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-modes-name.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-modes-name.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-modes-name.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-get-modes-name"> <refnamediv> @@ -14,6 +14,26 @@ </methodsynopsis> <para> This function returns the name of the mode. + </para> + <para> + <example> + <title><function>mcrypt_enc_get_modes_name</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + $td = mcrypt_module_open (MCRYPT_CAST_256, '', MCRYPT_MODE_CFB, ''); + echo mcrypt_enc_get_modes_name($td). "\n"; + + $td = mcrypt_module_open ('cast-256', '', 'ecb', ''); + echo mcrypt_enc_get_modes_name($td). "\n"; +?> + +Prints: +CFB +ECB +]]> + </programlisting> + </example> </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-supported-key-sizes.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-supported-key-sizes.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-supported-key-sizes.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-supported-key-sizes.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-get-supported-key-sizes.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-get-supported-key-sizes"> <refnamediv> @@ -18,6 +18,31 @@ array then all key sizes between 1 and <function>mcrypt_enc_get_key_size</function> are supported by the algorithm. + </para> + <para> + <example> + <title><function>mcrypt_enc_get_supported_key_sizes</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + $td = mcrypt_module_open ('rijndael-256', '', 'ecb', ''); + var_dump (mcrypt_enc_get_supported_key_sizes($td)); +?> + +This will print: + +array(3) { + [0]=> + int(16) + [1]=> + int(24) + [2]=> + int(32) +} +?> +]]> + </programlisting> + </example> </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm-mode.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm-mode.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm-mode.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm-mode.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm-mode.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-is-block-algorithm-mode"> <refnamediv> @@ -9,12 +9,12 @@ <refsect1> <title>Description</title> <methodsynopsis> - <type>int</type><methodname>mcrypt_enc_is_block_algorithm_mode</methodname> + <type>bool</type><methodname>mcrypt_enc_is_block_algorithm_mode</methodname> <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> - This function returns 1 if the mode is for use with block algorithms, - otherwise it returns 0. (eg. 0 for stream, and 1 for cbc, cfb, ofb). + This function returns &true; if the mode is for use with block algorithms, + otherwise it returns &false;. (eg. &false; for stream, and &true; for cbc, cfb, ofb). </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-algorithm.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-is-block-algorithm"> <refnamediv> @@ -9,12 +9,12 @@ <refsect1> <title>Description</title> <methodsynopsis> - <type>int</type><methodname>mcrypt_enc_is_block_algorithm</methodname> + <type>bool</type><methodname>mcrypt_enc_is_block_algorithm</methodname> <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> - This function returns 1 if the algorithm is a block algorithm, - or 0 if it is a stream algorithm. + This function returns &true; if the algorithm is a block algorithm, + or &false; if it is a stream algorithm. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-mode.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-mode.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-mode.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-mode.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-is-block-mode.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-is-block-mode"> <refnamediv> @@ -9,12 +9,12 @@ <refsect1> <title>Description</title> <methodsynopsis> - <type>int</type><methodname>mcrypt_enc_is_block_mode</methodname> + <type>bool</type><methodname>mcrypt_enc_is_block_mode</methodname> <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> - This function returns 1 if the mode outputs blocks of bytes or - 0 if it outputs bytes. (eg. 1 for cbc and ecb, and 0 for cfb and + This function returns &true; if the mode outputs blocks of bytes or + &false; if it outputs bytes. (eg. &true; for cbc and ecb, and &false; for cfb and stream). </para> </refsect1> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-enc-self-test.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-enc-self-test.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-enc-self-test.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-enc-self-test.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-enc-self-test.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-enc-self-test"> <refnamediv> @@ -9,13 +9,13 @@ <refsect1> <title>Description</title> <methodsynopsis> - <type>int</type><methodname>mcrypt_enc_self_test</methodname> + <type>bool</type><methodname>mcrypt_enc_self_test</methodname> <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> This function runs the self test on the algorithm specified by the - descriptor td. If the self test succeeds it returns zero. In case - of an error, it returns 1. + descriptor <parameter>td</parameter>. If the self test succeeds it returns &false;. In case + of an error, it returns &true;. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-encrypt.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-encrypt.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-encrypt.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-encrypt.xml:1.2 Wed Apr 17 02:40:12 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-encrypt.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-encrypt"> <refnamediv> @@ -14,9 +14,7 @@ <methodparam><type>string</type><parameter>key</parameter></methodparam> <methodparam><type>string</type><parameter>data</parameter></methodparam> <methodparam><type>string</type><parameter>mode</parameter></methodparam> - <methodparam choice="opt"><type>string</type><parameter> - iv - </parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>iv</parameter></methodparam> </methodsynopsis> <para> <function>mcrypt_encrypt</function> encrypts the data @@ -58,13 +56,13 @@ <programlisting role="php"> <![CDATA[ <?php -$iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); -$key = "This is a very secret key"; -$text = "Meet me at 11 o'clock behind the monument."; -echo strlen ($text)."\n"; + $iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); + $key = "This is a very secret key"; + $text = "Meet me at 11 o'clock behind the monument."; + echo strlen ($text)."\n"; -$crypttext = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv); -echo strlen ($crypttext)."\n"; + $crypttext = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv); + echo strlen ($crypttext)."\n"; ?> ]]> </programlisting> @@ -78,6 +76,10 @@ </screen> </para> </example> + </para> + <para> + See also <function>mcrypt_module_open</function> for a more advanced API + and an example. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-generic-deinit.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-generic-deinit.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-generic-deinit.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-generic-deinit.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-generic-deinit.xml Sun May 12 17:00:19 2002 @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.27 --> <refentry id='function.mcrypt-generic-deinit'> <refnamediv> <refname>mcrypt_generic_deinit</refname> <refpurpose> - This function terminates encrypt specified by the descriptor td + This function deinitializes an encryption module </refpurpose> </refnamediv> <refsect1> @@ -15,7 +15,16 @@ <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> - &warn.undocumented.func; + This function terminates encryption specified by the encryption + descriptor (<parameter>td</parameter>). It clears all buffers, but does + not close the module. You need to call + <function>mcrypt_module_close</function> yourself. (But PHP does this for + you at the end of the script. Returns &false; on error, or &true; on + succes. + </para> + <para> + See for an example <function>mcrypt_module_open</function> and the + entry on <function>mcrypt_generic_init</function>. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-generic-end.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-generic-end.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-generic-end.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-generic-end.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-generic-end.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-generic-end"> <refnamediv> @@ -13,9 +13,16 @@ <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> + This function is deprecated, use + <function>mcrypt_generic_deinit</function> instead. It can cause crashes + when used with <function>mcrypt_module_close</function> due to multiple + buffer frees. + </para> + <para> This function terminates encryption specified by the encryption - descriptor (td). Actually it clears all buffers, and closes - all the modules used. Returns &false; on error, or &true; on succes. + descriptor (<parameter>td</parameter>). Actually it clears all buffers, + and closes all the modules used. Returns &false; on error, or &true; on + succes. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-generic-init.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-generic-init.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-generic-init.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-generic-init.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-generic-init.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-generic-init"> <refnamediv> @@ -27,9 +27,13 @@ recommended. The function returns a negative value on error. </para> <para> - You need to call this function before every + You need to call this function before every call to <function>mcrypt_generic</function> or <function>mdecrypt_generic</function>. + </para> + <para> + See for an example <function>mcrypt_module_open</function> and the + entry on <function>mcrypt_generic_deinit</function>. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-generic.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-generic.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-generic.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-generic.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-generic.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-generic"> <refnamediv> @@ -19,6 +19,18 @@ function returns the encrypted data. Note that the length of the returned string can in fact be longer then the input, due to the padding of the data. + </para> + <para> + The encryption handle should alwayws be initialized with + <function>mcrypt_generic_init</function> with a key and an IV before + calling this function. Where the encryption is done, you should free the + encryption buffers by calling <function>mcrypt_generic_deinit</function>. + See <function>mcrypt_module_open</function> for an example. + </para> + <para> + See also <function>mdecrypt_generic</function>, + <function>mcrypt_generic_init</function> and + <function>mcrypt_generic_deinit</function>. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-get-block-size.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-get-block-size.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-get-block-size.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-get-block-size.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-get-block-size.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-get-block-size"> <refnamediv> @@ -19,19 +19,33 @@ </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or 2.5.x. </para> <para> <function>mcrypt_get_block_size</function> is used to get the - size of a block of the specified <parameter>cipher</parameter>. + size of a block of the specified <parameter>cipher</parameter> (in + combination with an encryption mode). </para> <para> - <function>mcrypt_get_block_size</function> takes one or two - arguments, the <parameter>cipher</parameter> and - <parameter>module</parameter>, and returns the size in bytes. - </para> + This example shows how to use this function when linked against libmcrypt + 2.4.x and 2.5.x. + <example> + <title><function>mcrypt_get_block_size</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + echo mcrypt_get_block_size ('tripledes', 'ecb'); +?> + +Prints: +8 +]]> + </programlisting> + </example> + </para> <para> - See also: <function>mcrypt_get_key_size</function>. + See also: <function>mcrypt_get_key_size</function> and + <function>mcrypt_encrypt</function>. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-get-cipher-name.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-get-cipher-name.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-get-cipher-name.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-get-cipher-name.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-get-cipher-name.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-get-cipher-name"> <refnamediv> @@ -23,7 +23,7 @@ <para> <function>mcrypt_get_cipher_name</function> takes the cipher number as an argument (libmcrypt 2.2.x) or takes the cipher name - as an argument (libmcrypt 2.4.x) and returns the name of the cipher + as an argument (libmcrypt 2.4.x or higher) and returns the name of the cipher or &false;, if the cipher does not exist. </para> <para> @@ -32,9 +32,9 @@ <programlisting role="php"> <![CDATA[ <?php -$cipher = MCRYPT_TripleDES; + $cipher = MCRYPT_TripleDES; -print mcrypt_get_cipher_name ($cipher); + echo mcrypt_get_cipher_name ($cipher); ?> ]]> </programlisting> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-get-iv-size.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-get-iv-size.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-get-iv-size.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-get-iv-size.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-get-iv-size.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-get-iv-size"> <refnamediv> @@ -10,16 +10,16 @@ <title>Description</title> <methodsynopsis> <type>int</type><methodname>mcrypt_get_iv_size</methodname> - <methodparam><type>string</type><parameter>cipher</parameter></methodparam> - <methodparam><type>string</type><parameter>mode</parameter></methodparam> + <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <methodsynopsis> <type>int</type><methodname>mcrypt_get_iv_size</methodname> - <methodparam><type>resource</type><parameter>td</parameter></methodparam> + <methodparam><type>string</type><parameter>cipher</parameter></methodparam> + <methodparam><type>string</type><parameter>mode</parameter></methodparam> </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or higher. </para> <para> <function>mcrypt_get_iv_size</function> returns the size of @@ -28,16 +28,34 @@ combination zero is returned. </para> <para> - <parameter>Cipher</parameter> is one of the MCRYPT_ciphername + <parameter>cipher</parameter> is one of the MCRYPT_ciphername constants of the name of the algorithm as string. </para> <para> - <parameter>Mode</parameter> is one of the MCRYPT_MODE_modename + <parameter>mode</parameter> is one of the MCRYPT_MODE_modename constants of one of "ecb", "cbc", "cfb", "ofb", "nofb" or "stream". </para> <para> - <parameter>Td</parameter> is the algorithm specified. + <parameter>td</parameter> is the resource that is returned by + <function>mcrypt_module_open</function>. + </para> + <para> + <example> + <title><function>mcrypt_create_iv</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + $size = mcrypt_get_iv_size (MCRYPT_CAST_256, MCRYPT_MODE_CFB); + + $size = mcrypt_get_iv_size ('des', 'ecb'); +?> +]]> + </programlisting> + </example> + </para> + <para> + See also: <function>mcrypt_create_iv</function> </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-get-key-size.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-get-key-size.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-get-key-size.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-get-key-size.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-get-key-size.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-get-key-size"> <refnamediv> @@ -19,20 +19,35 @@ </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or 2.5.x. </para> <para> <function>mcrypt_get_key_size</function> is used to get the size - of a key of the specified <parameter>cipher</parameter>. + of a key of the specified <parameter>cipher</parameter> (in + combination with an encryption mode). </para> <para> - <function>mcrypt_get_key_size</function> takes one or two - arguments, the <parameter>cipher</parameter> and - <parameter>module</parameter>, and returns the size in bytes. - </para> + This example shows how to use this function when linked against libmcrypt + 2.4.x and 2.5.x. + <example> + <title><function>mcrypt_get_block_size</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + echo mcrypt_get_key_size ('tripledes', 'ecb'); +?> + +Prints: +24 +]]> + </programlisting> + </example> + </para> <para> - See also: <function>mcrypt_get_block_size</function>. + See also: <function>mcrypt_get_block_size</function> and + <function>mcrypt_encrypt</function>. </para> + </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-list-algorithms.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-list-algorithms.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-list-algorithms.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-list-algorithms.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-list-algorithms.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-list-algorithms"> <refnamediv> @@ -10,20 +10,17 @@ <title>Description</title> <methodsynopsis> <type>array</type><methodname>mcrypt_list_algorithms</methodname> - <methodparam choice="opt"><type>string</type><parameter> - lib_dir - </parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>lib_dir</parameter></methodparam> </methodsynopsis> <para> <function>mcrypt_list_algorithms</function> is used to get an - array of all supported algorithms in the + array of all supported algorithms in the <parameter>lib_dir</parameter> parameter. </para> <para> - <parameter>lib_dir</parameter>. - <function>mcrypt_list_algorithms</function> takes as optional - parameter a directory which specifies the directory where all - algorithms are located. If not specifies, the value of the - mcrypt.algorithms_dir &php.ini; directive is used. + <function>mcrypt_list_algorithms</function> takes an optional + <parameter>lib_dir</parameter> parameter which specifies the directory + where all algorithms are located. If not specifies, the value of the + mcrypt.algorithms_dir &php.ini; directive is used. </para> <para> <example> @@ -31,11 +28,11 @@ <programlisting role="php"> <![CDATA[ <?php -$algorithms = mcrypt_list_algorithms ("/usr/local/lib/libmcrypt"); + $algorithms = mcrypt_list_algorithms ("/usr/local/lib/libmcrypt"); -foreach ($algorithms as $cipher) { - echo $cipher."/n"; -} + foreach ($algorithms as $cipher) { + echo "$cipher<br />\n"; + } ?> ]]> </programlisting> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-list-modes.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-list-modes.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-list-modes.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-list-modes.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-list-modes.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-list-modes"> <refnamediv> @@ -10,9 +10,7 @@ <title>Description</title> <methodsynopsis> <type>array</type><methodname>mcrypt_list_modes</methodname> - <methodparam choice="opt"><type>string</type><parameter> - lib_dir - </parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>lib_dir</parameter></methodparam> </methodsynopsis> <para> <function>mcrypt_list_modes</function> is used to get an @@ -23,7 +21,7 @@ <function>mcrypt_list_modes</function> takes as optional parameter a directory which specifies the directory where all modes are located. If not specifies, the value of the - mcrypt.modes_dir &php.ini; directive is used. + mcrypt.modes_dir &php.ini; directive is used. </para> <para> <example> @@ -31,11 +29,11 @@ <programlisting role="php"> <![CDATA[ <?php -$modes = mcrypt_list_modes (); + $modes = mcrypt_list_modes (); -foreach ($modes as $mode) { - echo "$mode <br/>"; -} + foreach ($modes as $mode) { + echo "$mode <br />\n"; + } ?> ]]> </programlisting> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-close.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-close.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-close.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-close.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-close.xml Sun May 12 17:00:19 2002 @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.27 --> <refentry id='function.mcrypt-module-close'> <refnamediv> <refname>mcrypt_module_close</refname> <refpurpose> - Free the descriptor td + Close the mcrypt module </refpurpose> </refnamediv> <refsect1> @@ -15,7 +15,10 @@ <methodparam><type>resource</type><parameter>td</parameter></methodparam> </methodsynopsis> <para> - &warn.undocumented.func; + This function closes the specified encryption handle. + </para> + <para> + See <function>mcrypt_module_open</function> for an example. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-get-supported-key-sizes.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-get-supported-key-sizes.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-get-supported-key-sizes.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-get-supported-key-sizes.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-get-supported-key-sizes.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-module-get-supported-key-sizes"> <refnamediv> @@ -14,12 +14,15 @@ <methodparam choice="opt"><type>string</type><parameter>lib_dir</parameter></methodparam> </methodsynopsis> <para> - Returns an array with the key sizes supported by the specified - algorithm. If it returns an empty array then all key sizes - between 1 and <function>mcrypt_module_get_algo_key_size</function> - are supported by the algorithm. The optional - <parameter>lib_dir</parameter> parameter can contain the - location where the mode module is on the system. + Returns an array with the key sizes supported by the specified algorithm. + If it returns an empty array then all key sizes between 1 and + <function>mcrypt_module_get_algo_key_size</function> are supported by the + algorithm. The optional <parameter>lib_dir</parameter> parameter can + contain the location where the mode module is on the system. + </para> + <para> + See also <function>mcrypt_enc_get_supported_key_sizes</function> which is + used on open encryption modules. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm-mode.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm-mode.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm-mode.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm-mode.xml:1.2 Wed Apr 17 02:40:13 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm-mode.xml Sun May 12 17:00:19 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-module-is-block-algorithm-mode"> <refnamediv> @@ -14,10 +14,11 @@ <methodparam choice="opt"><type>string</type><parameter>lib_dir</parameter></methodparam> </methodsynopsis> <para> - This function returns &true; if the mode is for use with block algorithms, - otherwise it returns 0. (eg. 0 for stream, and 1 for cbc, cfb, ofb). - The optional <parameter>lib_dir</parameter> parameter can contain - the location where the mode module is on the system. + This function returns &true; if the mode is for use with block + algorithms, otherwise it returns &false;. (eg. &false; for stream, and + &true; for cbc, cfb, ofb). The optional <parameter>lib_dir</parameter> + parameter can contain the location where the mode module is on the + system. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm.xml:1.2 Wed Apr 17 02:40:14 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-algorithm.xml Sun May 12 17:00:20 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-module-is-block-algorithm"> <refnamediv> @@ -15,9 +15,9 @@ </methodsynopsis> <para> This function returns &true; if the specified algorithm is a block - algorithm, or &false; is it is a stream algorithm. - The optional <parameter>lib_dir</parameter> parameter can contain - the location where the algorithm module is on the system. + algorithm, or &false; is it is a stream algorithm. The optional + <parameter>lib_dir</parameter> parameter can contain the location where + the algorithm module is on the system. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-mode.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-mode.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-mode.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-mode.xml:1.2 Wed Apr 17 02:40:14 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-is-block-mode.xml Sun May 12 17:00:20 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-module-is-block-mode"> <refnamediv> @@ -15,9 +15,10 @@ </methodsynopsis> <para> This function returns &true; if the mode outputs blocks of bytes or - &false; if it outputs just bytes. (eg. 1 for cbc and ecb, and 0 for cfb - and stream). The optional <parameter>lib_dir</parameter> parameter - can contain the location where the mode module is on the system. + &false; if it outputs just bytes. (eg. &true; for cbc and ecb, and + &false; for cfb and stream). The optional <parameter>lib_dir</parameter> + parameter can contain the location where the mode module is on the + system. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-open.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-open.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-open.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-open.xml:1.2 Wed Apr 17 02:40:14 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-open.xml Sun May 12 17:00:20 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-module-open"> <refnamediv> @@ -16,24 +16,21 @@ <methodparam><type>string</type><parameter>mode_directory</parameter></methodparam> </methodsynopsis> <para> - This function opens the module of the algorithm and the mode - to be used. The name of the algorithm is specified in algorithm, - eg "twofish" or is one of the MCRYPT_ciphername constants. - The library is closed by calling - <function>mcrypt_module_close</function>, but there is no need - to call that function if <function>mcrypt_generic_end</function> - is called. Normally it returns an encryption descriptor, or - &false; on error. + This function opens the module of the algorithm and the mode to be used. + The name of the algorithm is specified in algorithm, eg. "twofish" or is + one of the MCRYPT_ciphername constants. The module is closed by calling + <function>mcrypt_module_close</function>. Normally it returns an + encryption descriptor, or &false; on error. </para> <para> The <parameter>algorithm_directory</parameter> and - <parameter>mode_directory</parameter> are used to locate the - encryption modules. When you supply a directory name, it is used. - When you set one of these to the empty string (""), the value set - by the <parameter>mcrypt.algorithms_dir</parameter> or - <parameter>mcrypt.modes_dir</parameter> ini-directive is used. - When these are not set, the default directory are used that are - compiled in into libmcrypt (usally /usr/local/lib/libmcrypt). + <parameter>mode_directory</parameter> are used to locate the encryption + modules. When you supply a directory name, it is used. When you set one + of these to the empty string (""), the value set by the + <parameter>mcrypt.algorithms_dir</parameter> or + <parameter>mcrypt.modes_dir</parameter> ini-directive is used. When + these are not set, the default directories that are used are the ones + that were compiled in into libmcrypt (usally /usr/local/lib/libmcrypt). </para> <para> <example> @@ -41,16 +38,75 @@ <programlisting role="php"> <![CDATA[ <?php -$td = mcrypt_module_open (MCRYPT_DES, "", MCRYPT_MODE_ECB, "/usr/lib/mcrypt-modes"); + $td = mcrypt_module_open (MCRYPT_DES, '', MCRYPT_MODE_ECB, '/usr/lib/mcrypt-modes'); + $td = mcrypt_module_open ('rijndael-256', '', 'ofb', ''); ?> ]]> </programlisting> - <para> - The above example will try to open the DES cipher - from the default directory and the EBC mode from the directory - <filename>/usr/lib/mcrypt-modes</filename>. - </para> </example> + </para> + <para> + The first line in the example above will try to open the DES cipher from + the default directory and the EBC mode from the directory + <filename>/usr/lib/mcrypt-modes</filename>. The second example uses + strings as name for the cipher an dmode, this only works when the + extension is linked against libmcrypt 2.4.x or 2.5.x. + </para> + <para> + <example> + <title>Using <function>mcrypt_module_open</function> in encryption</title> + <programlisting role="php"> +<![CDATA[ +<?php + /* Open the cipher */ + $td = mcrypt_module_open ('rijndael-256', '', 'ofb', ''); + + /* Create the IV and determine the keysize length */ + $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM); + $ks = mcrypt_enc_get_key_size ($td); + + /* Create key */ + $key = substr (md5 ('very secret key'), 0, $ks); + + /* Intialize encryption */ + mcrypt_generic_init ($td, $key, $iv); + + /* Encrypt data */ + $encrypted = mcrypt_generic ($td, 'This is very important data'); + + /* Terminate encryption handler */ + mcrypt_generic_deinit ($td); + + /* Initialize encryption module for decryption */ + mcrypt_generic_init ($td, $key, $iv); + + /* Decrypt encrypted string */ + $decrypted = mdecrypt_generic ($td, $encrypted); + + /* Terminate decryption handle and close module */ + mcrypt_generic_deinit ($td); + mcrypt_module_close ($td); + + /* Show string */ + echo trim ($decrypted)."\n"; +?> +]]> + </programlisting> + </example> + </para> + <para> + The first line in the example above will try to open the DES cipher from + the default directory and the EBC mode from the directory + <filename>/usr/lib/mcrypt-modes</filename>. The second example uses + strings as name for the cipher an dmode, this only works when the + extension is linked against libmcrypt 2.4.x or 2.5.x. + </para> + <para> + See also <function>mcrypt_module_close</function>, + <function>mcrypt_generic</function>, + <function>mdecrypt_generic</function>, + <function>mcrypt_generic_init</function> and + <function>mcrypt_generic_deinit</function>. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-module-self-test.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-module-self-test.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-module-self-test.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-module-self-test.xml:1.2 Wed Apr 17 02:40:14 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-module-self-test.xml Sun May 12 17:00:20 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-module-self-test"> <refnamediv> @@ -14,13 +14,13 @@ <methodparam choice="opt"><type>string</type><parameter>lib_dir</parameter></methodparam> </methodsynopsis> <para> - This function runs the self test on the algorithm specified. - The optional <parameter>lib_dir</parameter> parameter can contain - the location of where the algorithm module is on the system. + This function runs the self test on the algorithm specified. The + optional <parameter>lib_dir</parameter> parameter can contain the + location of where the algorithm module is on the system. </para> <para> - The function returns &true; if the self test succeeds, or &false; when - if fails. + The function returns &true; if the self test succeeds, or &false; when if + fails. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mcrypt-ofb.xml diff -u phpdoc/en/reference/mcrypt/functions/mcrypt-ofb.xml:1.2 phpdoc/en/reference/mcrypt/functions/mcrypt-ofb.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mcrypt-ofb.xml:1.2 Wed Apr 17 02:40:14 2002 +++ phpdoc/en/reference/mcrypt/functions/mcrypt-ofb.xml Sun May 12 17:00:20 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mcrypt-ofb"> <refnamediv> @@ -26,36 +26,12 @@ </methodsynopsis> <para> The first prototype is when linked against libmcrypt 2.2.x, the - second when linked against libmcrypt 2.4.x. + second when linked against libmcrypt 2.4.x or higher. </para> <para> - <function>mcrypt_ofb</function> encrypts or decrypts (depending - on <parameter>mode</parameter>) the <parameter>data</parameter> - with <parameter>cipher</parameter> and <parameter>key</parameter> - in OFB cipher mode and returns the resulting string. - </para> - <para> - <parameter>Cipher</parameter> is one of the MCRYPT_ciphername - constants. - </para> - <para> - <parameter>Key</parameter> is the key supplied to the - algorithm. It must be kept secret. - </para> - <para> - <parameter>Data</parameter> is the data which shall be - encrypted/decrypted. - </para> - <para> - <parameter>Mode</parameter> is MCRYPT_ENCRYPT or MCRYPT_DECRYPT. - </para> - <para> - <parameter>IV</parameter> is the initialization vector. - </para> - <para> - See also: <function>mcrypt_cbc</function>, - <function>mcrypt_cfb</function>, and - <function>mcrypt_ecb</function>. + This function should not be used anymore, see + <function>mcrypt_generic</function> and + <function>mdecrypt_generic</function> for replacements. </para> </refsect1> </refentry> Index: phpdoc/en/reference/mcrypt/functions/mdecrypt-generic.xml diff -u phpdoc/en/reference/mcrypt/functions/mdecrypt-generic.xml:1.2 phpdoc/en/reference/mcrypt/functions/mdecrypt-generic.xml:1.3 --- phpdoc/en/reference/mcrypt/functions/mdecrypt-generic.xml:1.2 Wed Apr 17 02:40:14 2002 +++ phpdoc/en/reference/mcrypt/functions/mdecrypt-generic.xml Sun May 12 17:00:20 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.7 --> <refentry id="function.mdecrypt-generic"> <refnamediv> @@ -14,9 +14,9 @@ <methodparam><type>string</type><parameter>data</parameter></methodparam> </methodsynopsis> <para> - This function decrypts data. Note that the length of the - returned string can in fact be longer then the unencrypted - string, due to the padding of the data. + This function decrypts data. Note that the length of the returned string + can in fact be longer then the unencrypted string, due to the padding of + the data. </para> <para> <example> @@ -24,27 +24,60 @@ <programlisting role="php"> <![CDATA[ <?php -$iv_size = mcrypt_enc_get_iv_size ($td)); -$iv = @mcrypt_create_iv ($iv_size, MCRYPT_RAND); + /* Data */ + $key = 'this is a very long key, even too long for the cipher'; + $plain_text = 'very important data'; + + /* Open module, and create IV */ + $td = mcrypt_module_open ('des', '', 'ecb', ''); + $key = substr ($key, 0, mcrypt_enc_get_key_size ($td)); + $iv_size = mcrypt_enc_get_iv_size ($td); + $iv = mcrypt_create_iv ($iv_size, MCRYPT_RAND); -if (@mcrypt_generic_init ($td, $key, $iv) != -1) -{ - $c_t = mcrypt_generic ($td, $plain_text); - @mcrypt_generic_init ($td, $key, $iv); - $p_t = mdecrypt_generic ($td, $c_t); -} -if (strncmp ($p_t, $plain_text, strlen($plain_text)) == 0) - echo "ok"; -else - echo "error"; + /* Initialize encryption handle */ + if (mcrypt_generic_init ($td, $key, $iv) != -1) { + + /* Encrypt data */ + $c_t = mcrypt_generic ($td, $plain_text); + mcrypt_generic_deinit ($td); + + /* Reinitialize buffers for decryption */ + mcrypt_generic_init ($td, $key, $iv); + $p_t = mdecrypt_generic ($td, $c_t); + + /* Clean up */ + mcrypt_generic_deinit ($td); + mcrypt_module_close ($td); + } + + if (strncmp ($p_t, $plain_text, strlen($plain_text)) == 0) { + echo "ok\n"; + } else { + echo "error\n"; + } ?> ]]> </programlisting> - <para> - The above example shows how to check if the data before the - encryption is the same as the data after the decryption. - </para> </example> + </para> + <para> + The above example shows how to check if the data before the encryption is + the same as the data after the decryption. It is very important to + reinitialize the encryption buffer with + <function>mcrypt_generic_init</function> before you try to decrypt the + data. + </para> + <para> + The decryption handle should alwayws be initialized with + <function>mcrypt_generic_init</function> with a key and an IV before + calling this function. Where the encryption is done, you should free the + encryption buffers by calling <function>mcrypt_generic_deinit</function>. + See <function>mcrypt_module_open</function> for an example. + </para> + <para> + See also <function>mcrypt_generic</function>, + <function>mcrypt_generic_init</function> and + <function>mcrypt_generic_deinit</function>. </para> </refsect1> </refentry>