From f92266d8040dd4d2e0aa08760d2ab5a8d9a1dfb3 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 24 Jul 2013 17:07:45 -0700 Subject: recover padding functions which are still used --- include/crypto.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/crypto.php') diff --git a/include/crypto.php b/include/crypto.php index dc3580f88..1a62d60af 100644 --- a/include/crypto.php +++ b/include/crypto.php @@ -18,6 +18,21 @@ function rsa_verify($data,$sig,$key,$alg = 'sha256') { } + +function pkcs5_pad ($text, $blocksize) +{ + $pad = $blocksize - (strlen($text) % $blocksize); + return $text . str_repeat(chr($pad), $pad); +} + +function pkcs5_unpad($text) +{ + $pad = ord($text{strlen($text)-1}); + if ($pad > strlen($text)) return false; + if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return false; + return substr($text, 0, -1 * $pad); +} + function AES256CBC_encrypt($data,$key,$iv) { return mcrypt_encrypt( MCRYPT_RIJNDAEL_128, -- cgit v1.2.3