]> git.mxchange.org Git - friendica.git/commitdiff
inline salmon magic keys
authorMike Macgirvin <mike@macgirvin.com>
Tue, 12 Oct 2010 11:07:03 +0000 (04:07 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Tue, 12 Oct 2010 11:07:03 +0000 (04:07 -0700)
include/salmon.php [new file with mode: 0644]
mod/modexp.php
mod/xrd.php
view/xrd_person.tpl

diff --git a/include/salmon.php b/include/salmon.php
new file mode 100644 (file)
index 0000000..7198f07
--- /dev/null
@@ -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 ;
+}
index d424b4c39d75f90652fdfb3be4837306ff113066..715ffe30c85f0c6d6da304aca511450329421b5f 100644 (file)
@@ -8,14 +8,14 @@ function modexp_init(&$a) {
                killme();
 
        $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)
        );
 
        if(! count($r))
                killme();
 
-       $lines = explode("\n",$r[0]['pubkey']);
+       $lines = explode("\n",$r[0]['spubkey']);
        unset($lines[0]);
        unset($lines[count($lines)]);
        $x = base64_decode(implode('',$lines));
@@ -30,4 +30,5 @@ function modexp_init(&$a) {
 
        killme();
 
-}
\ No newline at end of file
+}
+
index 06b2442b233594e597c4a0d2b7674c7caab72ce3..53985e10c1faf51a68dad545f58ac40be9b18fc0 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+require_once('salmon.php');
 
 function xrd_content(&$a) {
 
@@ -16,6 +17,11 @@ function xrd_content(&$a) {
        if(! count($r))
                killme();
 
+       $salmon_key = salmon_key($r[0]['spubkey']);
+
+
+
+
        $tpl = load_view_file('view/xrd_person.tpl');
 
        $o = replace_macros($tpl, array(
@@ -23,10 +29,10 @@ function xrd_content(&$a) {
                '$profile_url' => $a->get_baseurl() . '/profile/' . $r[0]['nickname'],
                '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'],
                '$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;
        killme();
 
-}
\ No newline at end of file
+}
index ba9bc64db1e049c4e956e8fd1af84615607315ec..d7ce13efabdacb1c4f21b4a9e518db0b025ef5f6 100644 (file)
@@ -15,8 +15,6 @@
     <Link rel='http://webfinger.net/rel/avatar'
           href='$photo' />
     <Link rel="salmon" href="$salmon" />
-       <Link rel="magic-public-key" 
-               type="application/magic-public-key"
-               href="$modexp" />
+    <Link rel="magic-public-key" href="$modexp" />
  
 </XRD>