summaryrefslogtreecommitdiff
path: root/inc/blowfish.php
diff options
context:
space:
mode:
authorfurun <furun@arcor.de>2009-07-25 14:01:52 +0200
committerfurun <furun@arcor.de>2009-07-25 14:01:52 +0200
commitc3edf42be2b4f0310676bca64e6763ba89347075 (patch)
tree8329a397d07c32f84f65f2678170c47188fe0c7c /inc/blowfish.php
parentc078fc55b5ede3d19df62e132b40811e06cc08b7 (diff)
downloadrpg-c3edf42be2b4f0310676bca64e6763ba89347075.tar.gz
rpg-c3edf42be2b4f0310676bca64e6763ba89347075.tar.bz2
make blowfish library binary safe by adding a protection char before trimming FS#1713
Ignore-this: a3921b5eabb463ec0ba78623acfdedb8 darcs-hash:20090725120152-c0bf4-75f73dc36c914623a093f0dab48649c7d9c51fa7.gz
Diffstat (limited to 'inc/blowfish.php')
-rw-r--r--inc/blowfish.php15
1 files changed, 7 insertions, 8 deletions
diff --git a/inc/blowfish.php b/inc/blowfish.php
index b81991b25..42e3a589a 100644
--- a/inc/blowfish.php
+++ b/inc/blowfish.php
@@ -478,17 +478,18 @@ class Horde_Cipher_blowfish
*
* @author lem9
*/
-function PMA_blowfish_encrypt($data, $secret)
+function PMA_blowfish_encrypt($data, $secret)
{
$pma_cipher = new Horde_Cipher_blowfish;
$encrypt = '';
-
+
+ $data .= '_'; // triming fixed for DokuWiki FS#1690 FS#1713
$mod = strlen($data) % 8;
-
+
if ($mod > 0) {
$data .= str_repeat("\0", 8 - $mod);
}
-
+
foreach (str_split($data, 8) as $chunk) {
$encrypt .= $pma_cipher->encryptBlock($chunk, $secret);
}
@@ -512,11 +513,9 @@ function PMA_blowfish_decrypt($encdata, $secret)
$pma_cipher = new Horde_Cipher_blowfish;
$decrypt = '';
$data = base64_decode($encdata);
-
+
foreach (str_split($data, 8) as $chunk) {
$decrypt .= $pma_cipher->decryptBlock($chunk, $secret);
}
- return trim($decrypt,"\0"); // triming fixed for DokuWiki FS#1690
+ return substr(rtrim($decrypt, "\0"), 0, -1); // triming fixed for DokuWiki FS#1690 FS#1713
}
-
-?>