User tests: Successful: Unsuccessful:
Pull Request for Issue # .
Strip zero padding from plaintext response in OpenSSL decrypt, otherwise encrypting / decrypting is not symmetrical, unless the plain text was exactly the same as the OpenSSL block length. So encoding a plain text string, then decoding it, the decoded result will (most likely) not be "==" or "===" the plain text.
NOTE - the rtrim() is exactly what the com_users UserModel does when fetching the OTP ...
... which I wish I'd known before spending an hour or so banging my head on this one. And seems to me like the rtrim() should just go in decrypt, and not be something that has to be applied to the returned value.
Insert this code at the bottom of ./index.php
$key = \JFactory::getConfig()->get('secret');
$aes = new Joomla\CMS\Encrypt\Aes($key, 256);
$plaintext = "this is a test, this is only a test, do not adjust your set";
$encrypted = $aes->encryptString($plaintext);
$decrypted = $aes->decryptString($encrypted);
if ($plaintext === $decrypted) {
echo "YAY!";
}
else
{
echo "WTAF?!?";
var_dump($plaintext, $decrypted);
}
... then load the page.
Expect result is "YAY!", my decrypted result === my plain text.
Actual result is "WTAF?!?". My decrypted result was not === my plain text, because it got zero padded.
Apply the PR, and YAY!
None?
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Title |
|
I have tested this item
Labels |
Added:
?
|
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-07-21 09:17:10 |
Closed_By | ⇒ | laoneo |
Thanks.
Changed Title to "[4.0] ".
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19182.