inline salmon magic keys

This commit is contained in:
Mike Macgirvin 2010-10-12 04:07:03 -07:00
parent cc64742e23
commit 013d2604f8
4 changed files with 31 additions and 8 deletions

18
include/salmon.php Normal file
View file

@ -0,0 +1,18 @@
<?php
require_once('library/asn1.php');
function salmon_key($pubkey) {
$lines = explode("\n",$pubkey);
unset($lines[0]);
unset($lines[count($lines)]);
$x = base64_decode(implode('',$lines));
$r = ASN_BASE::parseASNString($x);
$m = $r[0]->asnData[1]->asnData[0]->asnData[0]->asnData;
$e = $r[0]->asnData[1]->asnData[0]->asnData[1]->asnData;
return 'RSA' . '.' . $m . '.' . $e ;
}

View file

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

View file

@ -1,5 +1,6 @@
<?php <?php
require_once('salmon.php');
function xrd_content(&$a) { function xrd_content(&$a) {
@ -16,6 +17,11 @@ function xrd_content(&$a) {
if(! count($r)) if(! count($r))
killme(); killme();
$salmon_key = salmon_key($r[0]['spubkey']);
$tpl = load_view_file('view/xrd_person.tpl'); $tpl = load_view_file('view/xrd_person.tpl');
$o = replace_macros($tpl, array( $o = replace_macros($tpl, array(
@ -23,10 +29,10 @@ function xrd_content(&$a) {
'$profile_url' => $a->get_baseurl() . '/profile/' . $r[0]['nickname'], '$profile_url' => $a->get_baseurl() . '/profile/' . $r[0]['nickname'],
'$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'], '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'],
'$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention', '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention',
'$modexp' => $a->get_baseurl() . '/modexp/' . $r[0]['nickname'] '$modexp' => 'data:application/magic-public-key,' . $salmon_key
)); ));
echo $o; echo $o;
killme(); killme();
} }

View file

@ -15,8 +15,6 @@
<Link rel='http://webfinger.net/rel/avatar' <Link rel='http://webfinger.net/rel/avatar'
href='$photo' /> href='$photo' />
<Link rel="salmon" href="$salmon" /> <Link rel="salmon" href="$salmon" />
<Link rel="magic-public-key" <Link rel="magic-public-key" href="$modexp" />
type="application/magic-public-key"
href="$modexp" />
</XRD> </XRD>