diff --git a/include/crypto.php b/include/crypto.php index 6b27e832b..999b48be4 100644 --- a/include/crypto.php +++ b/include/crypto.php @@ -74,7 +74,7 @@ function DerToRsa($Der) //Encode: $Der = base64_encode($Der); //Split lines: - $lines = str_split($Der, 65); + $lines = str_split($Der, 64); $body = implode("\n", $lines); //Get title: $title = 'RSA PUBLIC KEY'; @@ -184,3 +184,43 @@ function salmon_key($pubkey) { } + +if(! function_exists('aes_decrypt')) { +function aes_decrypt($val,$ky) +{ + $key="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + for($a=0;$a=0 and ord(substr($dec, strlen($dec)-1,1))<=16)? chr(ord( substr($dec,strlen($dec)-1,1))):null)); +}} + + +if(! function_exists('aes_encrypt')) { +function aes_encrypt($val,$ky) +{ + $key="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + for($a=0;$a strlen($text)) return false; + if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return false; + return substr($text, 0, -1 * $pad); +} diff --git a/include/diaspora.php b/include/diaspora.php index 2e8ff6892..a52c82913 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -141,6 +141,7 @@ function diaspora_decode($importer,$xml) { $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $outer_key, $ciphertext, MCRYPT_MODE_CBC, $outer_iv); + $decrypted = pkcs5_unpad($decrypted); /** diff --git a/include/items.php b/include/items.php index 39a61c4ad..b84b71ba8 100644 --- a/include/items.php +++ b/include/items.php @@ -1,8 +1,9 @@ =0 and ord(substr($dec, strlen($dec)-1,1))<=16)? chr(ord( substr($dec,strlen($dec)-1,1))):null)); -}} - - -if(! function_exists('aes_encrypt')) { -function aes_encrypt($val,$ky) -{ - $key="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; - for($a=0;$a strlen($text)) return false; - if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return false; - return substr($text, 0, -1 * $pad); -} - function base64url_encode($s, $strip_padding = false) { diff --git a/include/zotfns.php b/include/zotfns.php index b695b6fcb..b23fce82a 100644 --- a/include/zotfns.php +++ b/include/zotfns.php @@ -2,6 +2,8 @@ require_once('include/salmon.php'); +require_once('include/crypto.php'); + function zot_get($url,$args) { $argstr = '';