Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, this time I focused better and here's one possible problem/solution:</p> <p>Can you post this file too: <code>/var/www/html/myproject/cake/libs/log/file_log.php</code> as it seems that error happens here and not in AES.php:</p> <p><code>Fatal error: Class declarations may not be nested in /var/www/html/myproject/cake/libs/log/file_log.php on line 30</code></p> <p>I think that <b>Notice</b> and <b>Fatal Error</b> are two different things that should not be mixed together. There is one notice about too big integer value (which is converted to float) and other fatal error about nesting classes inside each other.</p> <h2>How Aes and AesCtr should used:</h2> <p>Both Aes and AesCtr are fully static classes so ther's no point to instantiate them:</p> <p>Change: </p> <pre><code>$aes = new AesCtr(); $decrypted = $aes-&gt;decrypt($encrypted, "mykey", 128); </code></pre> <p>To: </p> <pre><code>$decrypted = AesCtr::decrypt($encrypted, "mykey", 128); </code></pre> <p>Yes you should drop <code>$aes = new AesCtr();</code> as it is not needed when calling only static functions.</p> <h2>Here's about notice, AES.php line 230:</h2> <p>In AES.php at line 230 there is hex number <code>0x100000000</code> which is not valid signed 32-bit integer (in fact, it requires at least 33 bits even if unsigned), some PHP versions will throw an error or notice about it (older mostly). I am using PHP 5.3 and it will not notice anything even with <code>error_reporting(E_ALL);</code></p> <p>Signed integer maximum value is <code>2147483647</code> or in hex <code>0x7FFFFFFF</code> and AES.php tries to use value of <code>4294967296</code> which is converted to floating point.</p> <p>And, as <a href="http://www.php.net/manual/en/language.types.integer.php" rel="noreferrer">language.types.integer.php</a> says: <code>There is no integer division operator in PHP.</code> so that value should be converted to float anyway.</p> <p>I think that problem is, as stated in error message <code>Hex number is too big: 0x100000000</code>, that php tries to use that hex value as integer but it is too big so it is converted to float first.</p> <h3>Some tests:</h3> <pre class="lang-php prettyprint-override"><code>var_dump(0x100000000); var_dump((int)0x100000000); </code></pre> <p>Output in 32bit system:</p> <pre><code>float(4294967296) int(0) </code></pre> <p>And same with 64bit system:</p> <pre><code>int(4294967296) int(4294967296) </code></pre> <h2>How to fix it then?</h2> <p>Here's solution which may or may not work:</p> <p>Simply replace <code>0x100000000</code> with <code>4294967296.0</code> so that line 230 will be like this: </p> <pre><code>for ($c=0; $c&lt;4; $c++) $counterBlock[15-$c-4] = self::urs($b/4294967296.0, $c*8); </code></pre> <p>Maybe you should also check what <code>urs()</code> tries to do and how it try to do that. However it should already expecting floating point values as arguments, see <a href="http://www.php.net/manual/en/language.types.integer.php" rel="noreferrer">integer</a> division.</p> <h3>Update:</h3> <p>Checked that urs() seems to expect int as first arg, however it gets that from <code>(x/y)</code> operation which in PHP returns float if there is fractions and int otherwise.</p> <p>To make it int again is simple type conversion using <code>(int)(x/y)</code>, there is no drawbacks (or very little) compared to old way, this is only to convert it back.</p> <p>Originally, before modifications, there was same possibility and propability of conversion to float as there is now <i>(<code>urs()</code> doc says that first arg should be int)</i>. </p> <pre><code>for ($c=0; $c&lt;4; $c++) $counterBlock[15-$c-4] = self::urs((int)($b/4294967296.0), $c*8); </code></pre> <h2>Update: file_log.php</h2> <p>I think that there is nothing wrong with <code>file_log.php</code>, it declares <code>class FileLog</code> which is properly implemented and closed as far as i can see.</p> <p>Other thing about <code>file_log.php</code> is that it seems that it is cakephp's internal library and loaded by cakephp framework. And I don't know anything about cakephp...</p> <p>However, you really should test your code without <code>AES.php</code> or maybe try including <code>AES.php</code> some other way like this way to <b>test if <code>App::import()</code> does not work correctly</b>: </p> <pre><code>/* Remember to take into account that filenames are propably * case sensitive at server, but maybe case insensitive at * your workstation (if developing under windows). */ // If needed, change vendors/AES/AES.php to correct path: require_once 'vendors/AES/AES.php'; $decrypted = AesCtr::decrypt($encrypted, "mykey", 128); </code></pre> <p><b>or maybe (from cakephp manual):</b> </p> <pre><code>// Vendor not vendor and AES/AES not aes/AES or aes/aes just to be sure... App::import('Vendor', 'AES/AES'); $decrypted = AesCtr::decrypt($encrypted, "mykey", 128); </code></pre> <p><b>or maybe drop it completely out:</b> </p> <pre><code>$decrypted = 'dummytest'; </code></pre> <p><b>or maybe include without using it at all:</b> </p> <pre><code>App::import('vendor', 'aes', array('file' =&gt; 'AES/AES.php')); $decrypted = 'dummytest'; </code></pre> <p><b>instead of:</b> </p> <pre><code>App::import('vendor', 'aes', array('file' =&gt; 'AES/AES.php')); $decrypted = AesCtr::decrypt($encrypted, "mykey", 128); </code></pre> <p>This way problem is narrowed down, if same error still happens to pop up then problem is somewhere else but if error disappears after this test, then we know that error is either in App::import() or propably somewhere in cakephp framework.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload