X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fcrypto.php;h=f5163a9dacbeb2bb8ccf8b3be23ff6de27a62546;hb=40790844920f8afe6b9c3bd33536091633c26bf9;hp=a20606db540a5313b67b7dcb67e147df74e33a62;hpb=d8bd4fbb3e38bf0ff9c7b61dba58e20c0d097d75;p=friendica.git diff --git a/include/crypto.php b/include/crypto.php index a20606db54..f5163a9dac 100644 --- a/include/crypto.php +++ b/include/crypto.php @@ -187,6 +187,7 @@ function salmon_key($pubkey) { if(! function_exists('aes_decrypt')) { +// DEPRECATED IN 3.4.1 function aes_decrypt($val,$ky) { $key="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; @@ -200,6 +201,7 @@ function aes_decrypt($val,$ky) if(! function_exists('aes_encrypt')) { +// DEPRECATED IN 3.4.1 function aes_encrypt($val,$ky) { $key="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; @@ -211,7 +213,6 @@ function aes_encrypt($val,$ky) return mcrypt_encrypt($enc, $key, $val, $mode, mcrypt_create_iv( mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM)); }} - function pkcs5_pad ($text, $blocksize) { $pad = $blocksize - (strlen($text) % $blocksize); @@ -225,3 +226,38 @@ function pkcs5_unpad($text) if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return false; return substr($text, 0, -1 * $pad); } + + +function new_keypair($bits) { + + $openssl_options = array( + 'digest_alg' => 'sha1', + 'private_key_bits' => $bits, + 'encrypt_key' => false + ); + + $conf = get_config('system','openssl_conf_file'); + if($conf) + $openssl_options['config'] = $conf; + + $result = openssl_pkey_new($openssl_options); + + if(empty($result)) { + logger('new_keypair: failed'); + return false; + } + + // Get private key + + $response = array('prvkey' => '', 'pubkey' => ''); + + openssl_pkey_export($result, $response['prvkey']); + + // Get public key + $pkey = openssl_pkey_get_details($result); + $response['pubkey'] = $pkey["key"]; + + return $response; + +} +