get rid of special "short salmon key" for statusnet

This commit is contained in:
friendica 2012-07-11 16:54:18 -07:00
parent 71afdf3d9c
commit 3f414aec63
7 changed files with 15 additions and 34 deletions

View file

@ -155,7 +155,7 @@ function delivery_run($argv, $argc){
}
$r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
`user`.`timezone`, `user`.`nickname`,
`user`.`page-flags`, `user`.`prvnets`
FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",

View file

@ -537,7 +537,7 @@ function fetch_xrd_links($url) {
$xrd_timeout = intval(get_config('system','xrd_timeout'));
$redirects = 0;
$xml = fetch_url($url,false,$redirects,(($xrd_timeout) ? $xrd_timeout : 20));
$xml = fetch_url($url,false,$redirects,(($xrd_timeout) ? $xrd_timeout : 30));
logger('fetch_xrd_links: ' . $xml, LOGGER_DATA);
@ -547,11 +547,9 @@ function fetch_xrd_links($url) {
// fix diaspora's bad xml
$xml = str_replace(array('href="','"/>'),array('href="','"/>'),$xml);
$h = parse_xml_string($xml);
if(! $h)
return array();
$arr = xml2array($xml);
$arr = convert_xml_element_to_array($h);
logger('fetch_xrd_links: ' . print_r($arr,true), LOGGER_DATA);
$links = array();

View file

@ -153,7 +153,7 @@ function notifier_run($argv, $argc){
}
$r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
`user`.`timezone`, `user`.`nickname`,
`user`.`page-flags`, `user`.`prvnets`
FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",

View file

@ -74,7 +74,7 @@ function slapper($owner,$url,$slap) {
return;
if(! $owner['sprvkey']) {
if(! $owner['prvkey']) {
logger(sprintf("slapper: user '%s' (%d) does not have a salmon private key. Send failed.",
$owner['username'],$owner['uid']));
return;
@ -103,17 +103,17 @@ EOT;
$data_type = 'application/atom+xml';
$encoding = 'base64url';
$algorithm = 'RSA-SHA256';
$keyhash = base64url_encode(hash('sha256',salmon_key($owner['spubkey'])),true);
$keyhash = base64url_encode(hash('sha256',salmon_key($owner['pubkey'])),true);
// precomputed base64url encoding of data_type, encoding, algorithm concatenated with periods
$precomputed = '.YXBwbGljYXRpb24vYXRvbSt4bWw=.YmFzZTY0dXJs.UlNBLVNIQTI1Ng==';
$signature = base64url_encode(rsa_sign(str_replace('=','',$data . $precomputed),$owner['sprvkey']));
$signature = base64url_encode(rsa_sign(str_replace('=','',$data . $precomputed),$owner['prvkey']));
$signature2 = base64url_encode(rsa_sign($data . $precomputed,$owner['sprvkey']));
$signature2 = base64url_encode(rsa_sign($data . $precomputed,$owner['prvkey']));
$signature3 = base64url_encode(rsa_sign($data,$owner['sprvkey']));
$signature3 = base64url_encode(rsa_sign($data,$owner['prvkey']));
$salmon_tpl = get_markup_template('magicsig.tpl');

View file

@ -162,24 +162,9 @@ function create_user($arr) {
$prvkey = $keys['prvkey'];
$pubkey = $keys['pubkey'];
/**
*
* Create another keypair for signing/verifying
* salmon protocol messages. We have to use a slightly
* less robust key because this won't be using openssl
* but the phpseclib. Since it is PHP interpreted code
* it is not nearly as efficient, and the larger keys
* will take several minutes each to process.
*
*/
$sres = new_keypair(512);
$sprvkey = $sres['prvkey'];
$spubkey = $sres['pubkey'];
$r = q("INSERT INTO `user` ( `guid`, `username`, `password`, `email`, `openid`, `nickname`,
`pubkey`, `prvkey`, `spubkey`, `sprvkey`, `register_date`, `verified`, `blocked`, `timezone`, `service_class` )
VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 'UTC', '%s' )",
`pubkey`, `prvkey`, `register_date`, `verified`, `blocked`, `timezone`, `service_class` )
VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 'UTC', '%s' )",
dbesc(generate_user_guid()),
dbesc($username),
dbesc($new_password_encoded),
@ -188,8 +173,6 @@ function create_user($arr) {
dbesc($nickname),
dbesc($pubkey),
dbesc($prvkey),
dbesc($spubkey),
dbesc($sprvkey),
dbesc(datetime_convert()),
intval($verified),
intval($blocked),

View file

@ -8,14 +8,14 @@ function modexp_init(&$a) {
killme();
$nick = $a->argv[1];
$r = q("SELECT `spubkey` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
$r = q("SELECT `pubkey` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
dbesc($nick)
);
if(! count($r))
killme();
$lines = explode("\n",$r[0]['spubkey']);
$lines = explode("\n",$r[0]['pubkey']);
unset($lines[0]);
unset($lines[count($lines)]);
$x = base64_decode(implode('',$lines));

View file

@ -22,7 +22,7 @@ function xrd_init(&$a) {
if(! count($r))
killme();
$salmon_key = salmon_key($r[0]['spubkey']);
$salmon_key = salmon_key($r[0]['pubkey']);
header('Access-Control-Allow-Origin: *');
header("Content-type: text/xml");