<?xml version="1.0"?><phpdoc><class name="Crypt_Xtea" extends="PEAR" undoc="false" access="public" package="Crypt_Xtea"><file>/tmp/pear-apidoc/Xtea.php</file><doc><author email="jeroen@derks.it">Jeroen Derks</author><description>  Class that implements the xTEA encryption algorithm.&amp;lt;br /&amp;gt;   This enables you to encrypt data without requiring mcrypt.    From the C source:   -----------------------------------------   The Tiny Encryption Algorithm (TEA) by   David Wheeler and Roger Needham of the   Cambridge Computer Laboratory.    Placed in the Public Domain by   David Wheeler and Roger Needham.    **** ANSI C VERSION (New Variant) ****    Notes:    TEA is a Feistel cipher with XOR and   and addition as the non-linear mixing   functions.    Takes 64 bits of data in v[0] and v[1].   Returns 64 bits of data in w[0] and w[1].   Takes 128 bits of key in k[0] - k[3].    TEA can be operated in any of the modes   of DES. Cipher Block Chaining is, for example,   simple to implement.    n is the number of iterations. 32 is ample,   16 is sufficient, as few as eight may be OK.   The algorithm achieves good dispersion after   six iterations. The iteration count can be   made variable if required.    Note this is optimised for 32-bit CPUs with   fast shift capabilities. It can very easily   be ported to assembly language on most CPUs.    delta is chosen to be the real part of (the   golden ratio Sqrt(5/4) - 1/2 ~ 0.618034   multiplied by 2^32).    This version has been amended to foil two   weaknesses identified by David A. Wagner   (daw@cs.berkeley.edu): 1) effective key   length of old-variant TEA was 126 not 128   bits 2) a related key attack was possible   although impractical.    void encipher(unsigned long *const v,unsigned long *const w,   const unsigned long *const k)   {    register unsigned long       y=v[0],z=v[1],sum=0,delta=0x9E3779B9,n=32;     while(n--&amp;gt;0)       {         y+= (z&amp;lt;&amp;lt;4 ^ z&amp;gt;&amp;gt;5) + z ^ sum + k[sum&amp;3];       sum += delta;       z+= (y&amp;lt;&amp;lt;4 ^ y&amp;gt;&amp;gt;5) + y ^ sum + k[sum&amp;gt;&amp;gt;11 &amp; 3];       }     w[0]=y; w[1]=z;   }    void decipher(unsigned long *const v,unsigned long *const w,   const unsigned long *const k)   {    register unsigned long       y=v[0],z=v[1],sum=0xC6EF3720,                                 delta=0x9E3779B9,n=32;     # sum = delta&amp;lt;&amp;lt;5, in general sum = delta * n         while(n--&amp;gt;0)           {             z-= (y&amp;lt;&amp;lt;4 ^ y&amp;gt;&amp;gt;5) + y ^ sum + k[sum&amp;gt;&amp;gt;11 &amp; 3];           sum -= delta;             y-= (z&amp;lt;&amp;lt;4 ^ z&amp;gt;&amp;gt;5) + z ^ sum + k[sum&amp;3];           }     w[0]=y; w[1]=z;   }    -----------------------------------------</description><shortdescription>Class that implements the xTEA encryption algorithm.</shortdescription><version>$Revision: 1.13 $</version></doc><function name="Crypt_Xtea" undoc="false" access="public"><doc><author email="jeroen@derks.it">Jeroen Derks</author><see type="functions">setIter()</see><return type="void"/><description/><shortdescription>Constructor, sets the number of iterations.</shortdescription></doc></function><function name="setIter" undoc="false" access="public"><doc><author email="jeroen@derks.it">Jeroen Derks</author><see type="variables">$n_iter</see><see type="functions">getIter()</see><parameter name="$n_iter" type="integer">Number of iterations to use.</parameter><return type="void"/><description/><shortdescription>Set the number of iterations to use.</shortdescription></doc></function><function name="getIter" undoc="false" access="public"><doc><author email="jeroen@derks.it">Jeroen Derks</author><see type="variables">$n_iter</see><see type="functions">setIter()</see><return name="" type="integer">Number of iterations to use.</return><description/><shortdescription>Get the number of iterations to use.</shortdescription></doc></function><function name="encrypt" undoc="false" access="public"><doc><author email="jeroen@derks.it">Jeroen Derks</author><see type="functions">decrypt()</see><see type="functions">_encipherLong()</see><see type="functions">_resize()</see><see type="functions">_str2long()</see><parameter name="$data" type="string">Data to encrypt.</parameter><parameter name="$key" type="string">Key to encrypt data with (binary string).</parameter><return name="" type="string">Binary encrypted character string.</return><description/><shortdescription>Encrypt a string using a specific key.</shortdescription></doc></function><function name="decrypt" undoc="false" access="public"><doc><author email="jeroen@derks.it">Jeroen Derks</author><see type="functions">_encipherLong()</see><see type="functions">encrypt()</see><see type="functions">_resize()</see><see type="functions">_str2long()</see><parameter name="$enc_data" type="string">Encrypted data to decrypt.</parameter><parameter name="$key" type="string">Key to decrypt encrypted data with (binary string).</parameter><return name="" type="string">Binary decrypted character string.</return><description/><shortdescription>Decrypt an encrypted string using a specific key.</shortdescription></doc></function><function name="_encipherLong" undoc="false" access="private"><doc><author email="jeroen@derks.it">Jeroen Derks</author><see type="variables">$n_iter</see><see type="functions">_add()</see><see type="functions">_rshift()</see><see type="functions">_decipherLong()</see><parameter name="$y" type="integer">32 bits of data.</parameter><parameter name="$z" type="integer">32 bits of data.</parameter><parameter name="&amp;$w" type="array">Placeholder for enciphered 64 bits (in w[0] and w[1]).</parameter><parameter name="&amp;$k" type="array">Key 128 bits (in k[0]-k[3]).</parameter><return type="void"/><description/><shortdescription>Encipher a single long (32-bit) value.</shortdescription></doc></function><function name="_decipherLong" undoc="false" access="private"><doc><author email="jeroen@derks.it">Jeroen Derks</author><see type="variables">$n_iter</see><see type="functions">_add()</see><see type="functions">_rshift()</see><see type="functions">_decipherLong()</see><parameter name="$y" type="integer">32 bits of enciphered data.</parameter><parameter name="$z" type="integer">32 bits of enciphered data.</parameter><parameter name="&amp;$w" type="array">Placeholder for deciphered 64 bits (in w[0] and w[1]).</parameter><parameter name="&amp;$k" type="array">Key 128 bits (in k[0]-k[3]).</parameter><return type="void"/><description/><shortdescription>Decipher a single long (32-bit) value.</shortdescription></doc></function><function name="_resize" undoc="false" access="private"><doc><author email="jeroen@derks.it">Jeroen Derks</author><parameter name="&amp;$data" type="string">Data string to resize to specified size.</parameter><parameter name="$size" type="integer">Size in bytes to align data to.</parameter><parameter name="$nonull" default="false" type="boolean">Set to true if padded bytes should not be zero.</parameter><return name="" type="integer">Length of supplied data string.</return><description/><shortdescription>Resize data string to a multiple of specified size.</shortdescription></doc></function><function name="_hex2bin" undoc="false" access="private"><doc><author email="jeroen@derks.it">Jeroen Derks</author><parameter name="$str" type="string">Hexadecimal string to convert to binary string.</parameter><return name="" type="string">Binary string.</return><description/><shortdescription>Convert a hexadecimal string to a binary string (e.g. convert &amp;quot;616263&amp;quot; to &amp;quot;abc&amp;quot;).</shortdescription></doc></function><function name="_str2long" undoc="false" access="private"><doc><author email="jeroen@derks.it">Jeroen Derks</author><parameter name="$start" type="integer">Index into $data_long for output.</parameter><parameter name="&amp;$data" type="string">Input string.</parameter><parameter name="&amp;$data_long" type="array">Output array of long.</parameter><return name="" type="integer">Index from which to optionally continue.</return><description/><shortdescription>Convert string to array of long.</shortdescription></doc></function><function name="_long2str" undoc="false" access="private"><doc><author email="jeroen@derks.it">Jeroen Derks</author><parameter name="$l" type="long">Long to convert to character string.</parameter><return name="" type="string">Character string.</return><description/><shortdescription>Convert long to character string.</shortdescription></doc></function><function name="_rshift" undoc="false" access="private"><doc><author email="jeroen@derks.it">Jeroen Derks</author><parameter name="$integer" undoc="true"/><parameter name="$n" undoc="true"/><return type="void"/><description/><shortdescription>Handle proper unsigned right shift, dealing with PHP&amp;apos;s signed shift.</shortdescription><since>2004/Sep/06</since></doc></function><function name="_add" undoc="false" access="private"><doc><author email="jeroen@derks.it">Jeroen Derks</author><parameter name="$i1" undoc="true"/><parameter name="$i2" undoc="true"/><return type="void"/><description/><shortdescription>Handle proper unsigned add, dealing with PHP&amp;apos;s signed add.</shortdescription><since>2004/Sep/06</since></doc></function><variable name="$n_iter" access="private" type="integer"><doc><see type="functions">setIter()</see><see type="functions">getIter()</see><description/><shortdescription>Number of iterations.</shortdescription></doc></variable></class></phpdoc>
