+ $params = array();
+
+ // Per the protocol document, we will verify both ends by encrypting the dfrn_id with our
+ // site private key (person on the other end can decrypt it with our site public key).
+ // Then encrypt our profile URL with the other person's site public key. They can decrypt
+ // it with their site private key. If the decryption on the other end fails for either
+ // item, it indicates tampering or key failure on at least one site and we will not be
+ // able to provide a secure communication pathway.
+
+ // If other site is willing to accept full encryption, (aes_allow is 1 AND we have php5.3
+ // or later) then we encrypt the personal public key we send them using AES-256-CBC and a
+ // random key which is encrypted with their site public key.
+
+ $src_aes_key = random_string();
+
+ $result = '';
+ openssl_private_encrypt($dfrn_id,$result,$user[0]['prvkey']);
+
+ $params['dfrn_id'] = bin2hex($result);
+ $params['public_key'] = $public_key;
+
+
+ $my_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
+
+ openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
+ $params['source_url'] = bin2hex($params['source_url']);
+
+ if($aes_allow && function_exists('openssl_encrypt')) {
+ openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey);
+ $params['aes_key'] = bin2hex($params['aes_key']);
+ $params['public_key'] = bin2hex(openssl_encrypt($public_key,'AES-256-CBC',$src_aes_key));