Crypto to src
move Crypto to src and Friendica\Util namespace
This commit is contained in:
parent
6d6d83012c
commit
9e6bf79380
15 changed files with 317 additions and 230 deletions
|
@ -29,6 +29,7 @@ use Friendica\Model\Group;
|
|||
use Friendica\Model\User;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Util\Crypto;
|
||||
|
||||
require_once 'include/enotify.php';
|
||||
|
||||
|
@ -162,9 +163,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
|
|||
* worried about key leakage than anybody cracking it.
|
||||
*
|
||||
*/
|
||||
require_once 'include/crypto.php';
|
||||
|
||||
$res = new_keypair(4096);
|
||||
$res = Crypto::newKeypair(4096);
|
||||
|
||||
|
||||
$private_key = $res['prvkey'];
|
||||
|
|
|
@ -8,8 +8,6 @@ use Friendica\Core\System;
|
|||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
require_once "include/crypto.php";
|
||||
|
||||
function fetch_init(App $a)
|
||||
{
|
||||
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file mod/hostxrd.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Util\Crypto;
|
||||
|
||||
require_once('include/crypto.php');
|
||||
|
||||
function hostxrd_init(App $a) {
|
||||
function hostxrd_init(App $a)
|
||||
{
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header("Content-type: text/xml");
|
||||
$pubkey = Config::get('system','site_pubkey');
|
||||
$pubkey = Config::get('system', 'site_pubkey');
|
||||
|
||||
if(! $pubkey) {
|
||||
$res = new_keypair(1024);
|
||||
if (! $pubkey) {
|
||||
$res = Crypto::newKeypair(1024);
|
||||
|
||||
Config::set('system','site_prvkey', $res['prvkey']);
|
||||
Config::set('system','site_pubkey', $res['pubkey']);
|
||||
|
@ -23,8 +25,8 @@ function hostxrd_init(App $a) {
|
|||
'$zhost' => $a->get_hostname(),
|
||||
'$zroot' => System::baseUrl(),
|
||||
'$domain' => System::baseUrl(),
|
||||
'$bigkey' => salmon_key(Config::get('system','site_pubkey')),
|
||||
));
|
||||
exit();
|
||||
'$bigkey' => Crypto::salmonKey(Config::get('system', 'site_pubkey')))
|
||||
);
|
||||
|
||||
exit();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ use Friendica\Protocol\Diaspora;
|
|||
use Friendica\Protocol\Email;
|
||||
use Friendica\Util\Emailer;
|
||||
|
||||
require_once 'include/crypto.php';
|
||||
require_once 'include/enotify.php';
|
||||
require_once 'include/tags.php';
|
||||
require_once 'include/files.php';
|
||||
|
|
|
@ -9,8 +9,6 @@ use Friendica\Core\Config;
|
|||
use Friendica\Database\DBM;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
|
||||
require_once 'include/crypto.php';
|
||||
|
||||
/**
|
||||
* @param object $a App
|
||||
* @return void
|
||||
|
|
|
@ -7,8 +7,8 @@ use Friendica\Core\PConfig;
|
|||
use Friendica\Database\DBM;
|
||||
use Friendica\Protocol\OStatus;
|
||||
use Friendica\Protocol\Salmon;
|
||||
use Friendica\Util\Crypto;
|
||||
|
||||
require_once 'include/crypto.php';
|
||||
require_once 'include/items.php';
|
||||
require_once 'include/follow.php';
|
||||
|
||||
|
@ -117,23 +117,23 @@ function salmon_post(App $a) {
|
|||
|
||||
logger('mod-salmon: key details: ' . print_r($key_info,true), LOGGER_DEBUG);
|
||||
|
||||
$pubkey = metopem($m,$e);
|
||||
$pubkey = Crypto::meToPem($m, $e);
|
||||
|
||||
// We should have everything we need now. Let's see if it verifies.
|
||||
|
||||
// Try GNU Social format
|
||||
$verify = rsa_verify($signed_data, $signature, $pubkey);
|
||||
$verify = Crypto::rsaVerify($signed_data, $signature, $pubkey);
|
||||
$mode = 1;
|
||||
|
||||
if (! $verify) {
|
||||
logger('mod-salmon: message did not verify using protocol. Trying compliant format.');
|
||||
$verify = rsa_verify($compliant_format, $signature, $pubkey);
|
||||
$verify = Crypto::rsaVerify($compliant_format, $signature, $pubkey);
|
||||
$mode = 2;
|
||||
}
|
||||
|
||||
if (! $verify) {
|
||||
logger('mod-salmon: message did not verify using padding. Trying old statusnet format.');
|
||||
$verify = rsa_verify($stnet_signed_data, $signature, $pubkey);
|
||||
$verify = Crypto::rsaVerify($stnet_signed_data, $signature, $pubkey);
|
||||
$mode = 3;
|
||||
}
|
||||
|
||||
|
|
24
mod/xrd.php
24
mod/xrd.php
|
@ -1,12 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file mod/xrd.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Util\Crypto;
|
||||
|
||||
require_once('include/crypto.php');
|
||||
|
||||
function xrd_init(App $a) {
|
||||
function xrd_init(App $a)
|
||||
{
|
||||
if ($a->argv[0] == 'xrd') {
|
||||
$uri = urldecode(notags(trim($_GET['uri'])));
|
||||
if ($_SERVER['HTTP_ACCEPT'] == 'application/jrd+json') {
|
||||
|
@ -54,8 +56,9 @@ function xrd_init(App $a) {
|
|||
}
|
||||
}
|
||||
|
||||
function xrd_json($a, $uri, $alias, $profile_url, $r) {
|
||||
$salmon_key = salmon_key($r['spubkey']);
|
||||
function xrd_json($a, $uri, $alias, $profile_url, $r)
|
||||
{
|
||||
$salmon_key = Crypto::salmonKey($r['spubkey']);
|
||||
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header("Content-type: application/json; charset=utf-8");
|
||||
|
@ -79,8 +82,9 @@ function xrd_json($a, $uri, $alias, $profile_url, $r) {
|
|||
killme();
|
||||
}
|
||||
|
||||
function xrd_xml($a, $uri, $alias, $profile_url, $r) {
|
||||
$salmon_key = salmon_key($r['spubkey']);
|
||||
function xrd_xml($a, $uri, $alias, $profile_url, $r)
|
||||
{
|
||||
$salmon_key = Crypto::salmonKey($r['spubkey']);
|
||||
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header("Content-type: text/xml");
|
||||
|
@ -100,8 +104,8 @@ function xrd_xml($a, $uri, $alias, $profile_url, $r) {
|
|||
'$salmon' => System::baseUrl() . '/salmon/' . $r['nickname'],
|
||||
'$salmen' => System::baseUrl() . '/salmon/' . $r['nickname'] . '/mention',
|
||||
'$subscribe' => System::baseUrl() . '/follow?url={uri}',
|
||||
'$modexp' => 'data:application/magic-public-key,' . $salmon_key,
|
||||
));
|
||||
'$modexp' => 'data:application/magic-public-key,' . $salmon_key)
|
||||
);
|
||||
|
||||
$arr = array('user' => $r, 'xml' => $o);
|
||||
call_hooks('personal_xrd', $arr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue