diff options
author | friendica <info@friendica.com> | 2013-07-24 17:07:45 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2013-07-24 17:07:45 -0700 |
commit | f92266d8040dd4d2e0aa08760d2ab5a8d9a1dfb3 (patch) | |
tree | 7fbcbc611bbcadc347700b466ced0628a41367fb | |
parent | 30da63287888a754c864fa80b3803a13f68c0575 (diff) | |
download | volse-hubzilla-f92266d8040dd4d2e0aa08760d2ab5a8d9a1dfb3.tar.gz volse-hubzilla-f92266d8040dd4d2e0aa08760d2ab5a8d9a1dfb3.tar.bz2 volse-hubzilla-f92266d8040dd4d2e0aa08760d2ab5a8d9a1dfb3.zip |
recover padding functions which are still used
-rw-r--r-- | include/crypto.php | 15 |
1 files changed, 15 insertions, 0 deletions
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, |