Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mcrypt_encrypt] PHP5.4 Despite producing warning error, mcrypt still produce a result for mcrypt_encrypt, phpseclib_mcrypt_encrypt does not. #6

Closed
evaisse opened this issue Apr 24, 2017 · 2 comments

Comments

@evaisse
Copy link

evaisse commented Apr 24, 2017

Despite producing warning error, mcrypt still produce a result for mcrypt_encrypt on php5.4, phpseclib_mcrypt_encrypt does not.

In short the following code does not produce the same result :

<?php
$input = ""; // empty string 
$iv = str_repeat('a', mcrypt_get_iv_size(MCRYPT_3DES, MCRYPT_MODE_CBC));
$key = "someKeyThatDoesNot"; // empty 
mcrypt_encrypt(MCRYPT_3DES, $key, $input, MCRYPT_MODE_CBC, $iv);
phpseclib_mcrypt_encrypt(MCRYPT_3DES, $key, $input, MCRYPT_MODE_CBC, $iv);

Results here : http://sandbox.onlinephpfunctions.com/code/931a527873bfcaca5a1837993cb180c7b6843716

@terrafrost
Copy link
Member

Just saw this lol. I'll try to take a look at it later today.

Thanks!

@terrafrost
Copy link
Member

terrafrost commented May 6, 2017

Quoting https://github.com/phpseclib/mcrypt_compat/blob/master/lib/mcrypt.php#L889,

// PHP 5.6 made mcrypt_encrypt() a lot less tolerant of bad input but it neglected to change
// anything about mcrypt_generic(). and despite the changes insufficiently long plaintext
// is still accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants